diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index 49952d81cbb0b..963c14c48c829 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -9,7 +9,7 @@ // except according to those terms. use infer::{self, InferCtxt, SubregionOrigin}; -use ty::Region; +use ty::{self, Region}; use ty::error::TypeError; use errors::DiagnosticBuilder; @@ -262,7 +262,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { "the type `{}` does not fulfill the required \ lifetime", self.ty_to_string(ty)); - self.tcx.note_and_explain_region(&mut err, "type must outlive ", sub, ""); + match *sub { + ty::ReStatic => { + self.tcx.note_and_explain_region(&mut err, "type must satisfy ", sub, "") + } + _ => { + self.tcx.note_and_explain_region(&mut err, "type must outlive ", sub, "") + } + } err } infer::RelateRegionParamBound(span) => { diff --git a/src/test/ui/static-lifetime.rs b/src/test/ui/static-lifetime.rs new file mode 100644 index 0000000000000..7b1887b2d1a29 --- /dev/null +++ b/src/test/ui/static-lifetime.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Arbitrary: Sized + 'static {} + +impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {} + +fn main() { +} \ No newline at end of file diff --git a/src/test/ui/static-lifetime.stderr b/src/test/ui/static-lifetime.stderr new file mode 100644 index 0000000000000..f73dff4f73d0e --- /dev/null +++ b/src/test/ui/static-lifetime.stderr @@ -0,0 +1,10 @@ +error[E0477]: the type `std::borrow::Cow<'a, A>` does not fulfill the required lifetime + --> $DIR/static-lifetime.rs:13:20 + | +13 | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {} + | ^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error: aborting due to previous error +