// Whether or not in-band lifetimes are being collected. This is used to
// indicate whether or not we're in a place where new lifetimes will result
// in in-band lifetime definitions, such a function or an impl header.
- // This will always be false unless the `in_band_lifetimes` feature is
- // enabled.
+ // This will always be false unless the `in_band_lifetimes` or
+ // `impl_header_lifetime_elision` feature is enabled.
is_collecting_in_band_lifetimes: bool,
// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
assert!(self.lifetimes_to_define.is_empty());
let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode;
- self.is_collecting_in_band_lifetimes = self.sess.features_untracked().in_band_lifetimes;
- if self.is_collecting_in_band_lifetimes {
+ if self.sess.features_untracked().impl_header_lifetime_elision {
self.anonymous_lifetime_mode = anonymous_lifetime_mode;
+ self.is_collecting_in_band_lifetimes = true;
+ } else if self.sess.features_untracked().in_band_lifetimes {
+ self.is_collecting_in_band_lifetimes = true;
}
let (in_band_ty_params, res) = f(self);
return;
}
+ if !self.sess.features_untracked().in_band_lifetimes {
+ return;
+ }
+
if self.in_scope_lifetimes.contains(&ident.modern()) {
return;
}
Self { tcx, error: None, regions: Some((span, sub, sup)), tables }
}
+ pub fn try_report_from_nll(&self) -> Option<ErrorReported> {
+ // Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
+ // the nice region errors are required when running under the MIR borrow checker.
+ self.try_report_named_anon_conflict()
+ }
+
pub fn try_report(&self) -> Option<ErrorReported> {
self.try_report_named_anon_conflict()
.or_else(|| self.try_report_anon_anon_conflict())
#![feature(step_trait)]
#![feature(integer_atomics)]
#![feature(test)]
+#![cfg_attr(not(stage0), feature(impl_header_lifetime_elision))]
#![feature(in_band_lifetimes)]
#![feature(macro_at_most_once_rep)]
#![feature(crate_in_paths)]
if let (Some(f), Some(o)) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) {
let tables = infcx.tcx.typeck_tables_of(mir_def_id);
let nice = NiceRegionError::new_from_span(infcx.tcx, span, o, f, Some(tables));
- if let Some(_error_reported) = nice.try_report() {
+ if let Some(_error_reported) = nice.try_report_from_nll() {
return;
}
}
(active, crate_in_paths, "1.23.0", Some(45477), Some(Edition::Edition2018)),
// In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`)
- (active, in_band_lifetimes, "1.23.0", Some(44524), Some(Edition::Edition2018)),
+ (active, in_band_lifetimes, "1.23.0", Some(44524), None),
// generic associated types (RFC 1598)
(active, generic_associated_types, "1.23.0", Some(44265), None),
(active, alloc_error_handler, "1.29.0", Some(51540), None),
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),
+
+ // impl<I:Iterator> Iterator for &mut Iterator
+ // impl Debug for Foo<'_>
+ (active, impl_header_lifetime_elision, "1.30.0", Some(15872), Some(Edition::Edition2018)),
);
declare_features! (
fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
foo(x, y)
- //~^ ERROR lifetime mismatch [E0623]
+ //~^ ERROR unsatisfied lifetime constraints
//~| WARNING not reporting region error due to nll
}
fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) {
Foo { x, y };
- //~^ ERROR lifetime mismatch [E0623]
+ //~^ ERROR unsatisfied lifetime constraints
//~| WARNING not reporting region error due to nll
}
--- /dev/null
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(warnings)]
+
+// Make sure this related feature didn't accidentally enable this
+#![feature(in_band_lifetimes)]
+
+trait MyTrait<'a> { }
+
+impl MyTrait<'a> for &u32 { }
+//~^ ERROR missing lifetime specifier
+
+struct MyStruct;
+trait MarkerTrait {}
+
+impl MarkerTrait for &'_ MyStruct { }
+//~^ ERROR missing lifetime specifier
+
+fn main() {}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/feature-gate-impl_header_lifetime_elision-with-in_band.rs:18:22
+ |
+LL | impl MyTrait<'a> for &u32 { }
+ | ^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/feature-gate-impl_header_lifetime_elision-with-in_band.rs:24:23
+ |
+LL | impl MarkerTrait for &'_ MyStruct { }
+ | ^^ expected lifetime parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0106`.
--- /dev/null
+// Copyright 2017 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(warnings)]
+
+trait MyTrait<'a> { }
+
+impl<'a> MyTrait<'a> for &u32 { }
+//~^ ERROR missing lifetime specifier
+
+impl<'a> MyTrait<'_> for &'a f32 { }
+//~^ ERROR missing lifetime specifier
+
+fn main() {}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/feature-gate-impl_header_lifetime_elision.rs:15:26
+ |
+LL | impl<'a> MyTrait<'a> for &u32 { }
+ | ^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/feature-gate-impl_header_lifetime_elision.rs:18:18
+ |
+LL | impl<'a> MyTrait<'_> for &'a f32 { }
+ | ^^ expected lifetime parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0106`.
+++ /dev/null
-// Copyright 2017 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(warnings)]
-
-trait MyTrait<'a> { }
-
-impl<'a> MyTrait<'a> for &u32 { }
-//~^ ERROR missing lifetime specifier
-
-impl<'a> MyTrait<'_> for &'a f32 { }
-//~^ ERROR missing lifetime specifier
-
-fn main() {}
+++ /dev/null
-error[E0106]: missing lifetime specifier
- --> $DIR/feature-gate-in_band_lifetimes-impl.rs:15:26
- |
-LL | impl<'a> MyTrait<'a> for &u32 { }
- | ^ expected lifetime parameter
-
-error[E0106]: missing lifetime specifier
- --> $DIR/feature-gate-in_band_lifetimes-impl.rs:18:18
- |
-LL | impl<'a> MyTrait<'_> for &'a f32 { }
- | ^^ expected lifetime parameter
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0106`.
#![allow(warnings)]
+// Make sure this related feature didn't accidentally enable this
+#![feature(impl_header_lifetime_elision)]
+
fn foo(x: &'x u8) -> &'x u8 { x }
//~^ ERROR use of undeclared lifetime name
//~^^ ERROR use of undeclared lifetime name
error[E0261]: use of undeclared lifetime name `'x`
- --> $DIR/feature-gate-in_band_lifetimes.rs:13:12
+ --> $DIR/feature-gate-in_band_lifetimes.rs:16:12
|
LL | fn foo(x: &'x u8) -> &'x u8 { x }
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'x`
- --> $DIR/feature-gate-in_band_lifetimes.rs:13:23
+ --> $DIR/feature-gate-in_band_lifetimes.rs:16:23
|
LL | fn foo(x: &'x u8) -> &'x u8 { x }
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:25:12
+ --> $DIR/feature-gate-in_band_lifetimes.rs:28:12
|
LL | impl<'a> X<'b> {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:27:27
+ --> $DIR/feature-gate-in_band_lifetimes.rs:30:27
|
LL | fn inner_2(&self) -> &'b u8 {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:33:8
+ --> $DIR/feature-gate-in_band_lifetimes.rs:36:8
|
LL | impl X<'b> {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:35:27
+ --> $DIR/feature-gate-in_band_lifetimes.rs:38:27
|
LL | fn inner_3(&self) -> &'b u8 {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a`
- --> $DIR/feature-gate-in_band_lifetimes.rs:43:9
+ --> $DIR/feature-gate-in_band_lifetimes.rs:46:9
|
LL | impl Y<&'a u8> {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a`
- --> $DIR/feature-gate-in_band_lifetimes.rs:45:25
+ --> $DIR/feature-gate-in_band_lifetimes.rs:48:25
|
LL | fn inner(&self) -> &'a u8 {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:53:27
+ --> $DIR/feature-gate-in_band_lifetimes.rs:56:27
|
LL | fn any_lifetime() -> &'b u8;
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:55:27
+ --> $DIR/feature-gate-in_band_lifetimes.rs:58:27
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:55:40
+ --> $DIR/feature-gate-in_band_lifetimes.rs:58:40
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a`
- --> $DIR/feature-gate-in_band_lifetimes.rs:60:14
+ --> $DIR/feature-gate-in_band_lifetimes.rs:63:14
|
LL | impl MyTrait<'a> for Y<&'a u8> {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a`
- --> $DIR/feature-gate-in_band_lifetimes.rs:60:25
+ --> $DIR/feature-gate-in_band_lifetimes.rs:63:25
|
LL | impl MyTrait<'a> for Y<&'a u8> {
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a`
- --> $DIR/feature-gate-in_band_lifetimes.rs:63:31
+ --> $DIR/feature-gate-in_band_lifetimes.rs:66:31
|
LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:65:27
+ --> $DIR/feature-gate-in_band_lifetimes.rs:68:27
|
LL | fn any_lifetime() -> &'b u8 { &0 }
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:67:27
+ --> $DIR/feature-gate-in_band_lifetimes.rs:70:27
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
- --> $DIR/feature-gate-in_band_lifetimes.rs:67:40
+ --> $DIR/feature-gate-in_band_lifetimes.rs:70:40
|
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
| ^^ undeclared lifetime
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that we do not yet support elision in associated types, even
+// when there is just one name we could take from the impl header.
+
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+trait MyTrait {
+ type Output;
+}
+
+impl MyTrait for &i32 {
+ type Output = &i32;
+ //~^ ERROR missing lifetime specifier
+}
+
+impl MyTrait for &u32 {
+ type Output = &'_ i32;
+ //~^ ERROR missing lifetime specifier
+}
+
+// This is what you have to do:
+impl<'a> MyTrait for &'a f32 {
+ type Output = &'a f32;
+}
+
+fn main() { }
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/assoc-type.rs:23:19
+ |
+LL | type Output = &i32;
+ | ^ expected lifetime parameter
+
+error[E0106]: missing lifetime specifier
+ --> $DIR/assoc-type.rs:28:20
+ |
+LL | type Output = &'_ i32;
+ | ^^ expected lifetime parameter
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0106`.
--- /dev/null
+warning: not reporting region error due to nll
+ --> $DIR/dyn-trait.rs:32:16
+ |
+LL | static_val(x); //~ ERROR cannot infer
+ | ^
+
+error: borrowed data escapes outside of function
+ --> $DIR/dyn-trait.rs:32:5
+ |
+LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
+ | - `x` is a reference that is only valid in the function body
+LL | static_val(x); //~ ERROR cannot infer
+ | ^^^^^^^^^^^^^ `x` escapes the function body here
+
+error: aborting due to previous error
+
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
+// 'b> MyTrait<'a> for &'b i32`.
+
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+use std::fmt::Debug;
+
+// Equivalent to `Box<dyn Debug + 'static>`:
+trait StaticTrait { }
+impl StaticTrait for Box<dyn Debug> { }
+
+// Equivalent to `Box<dyn Debug + 'static>`:
+trait NotStaticTrait { }
+impl NotStaticTrait for Box<dyn Debug + '_> { }
+
+fn static_val<T: StaticTrait>(_: T) {
+}
+
+fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
+ static_val(x); //~ ERROR cannot infer
+}
+
+fn not_static_val<T: NotStaticTrait>(_: T) {
+}
+
+fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
+ not_static_val(x); // OK
+}
+
+fn main() {
+}
--- /dev/null
+error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
+ --> $DIR/dyn-trait.rs:32:16
+ |
+LL | static_val(x); //~ ERROR cannot infer
+ | ^
+ |
+note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:26...
+ --> $DIR/dyn-trait.rs:31:26
+ |
+LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
+ | ^^
+ = note: ...so that the expression is assignable:
+ expected std::boxed::Box<dyn std::fmt::Debug>
+ found std::boxed::Box<(dyn std::fmt::Debug + 'a)>
+ = note: but, the lifetime must be valid for the static lifetime...
+ = note: ...so that the types are compatible:
+ expected StaticTrait
+ found StaticTrait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0495`.
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+trait MyTrait { }
+
+struct Foo<'a> { x: &'a u32 }
+
+impl MyTrait for Foo {
+ //~^ ERROR missing lifetime specifier
+}
+
+fn main() {}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/path-elided.rs:18:18
+ |
+LL | impl MyTrait for Foo {
+ | ^^^ expected lifetime parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0106`.
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that `impl MyTrait for Foo<'_>` works.
+
+// run-pass
+
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+trait MyTrait { }
+
+struct Foo<'a> { x: &'a u32 }
+
+impl MyTrait for Foo<'_> {
+}
+
+fn impls_my_trait<T: MyTrait>() { }
+
+fn impls_my_trait_val<T: MyTrait>(_: T) {
+ impls_my_trait::<T>();
+}
+
+fn random_where_clause()
+where for<'a> Foo<'a>: MyTrait { }
+
+fn main() {
+ let x = 22;
+ let f = Foo { x: &x };
+
+ // This type is `Foo<'x>` for a local lifetime `'x`; so the impl
+ // must apply to any lifetime to apply to this.
+ impls_my_trait_val(f);
+
+ impls_my_trait::<Foo<'static>>();
+
+ random_where_clause();
+}
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that `impl MyTrait for &i32` works and is equivalent to any lifetime.
+
+// run-pass
+
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+trait MyTrait { }
+
+impl MyTrait for &i32 {
+}
+
+fn impls_my_trait<T: MyTrait>() { }
+
+fn impls_my_trait_val<T: MyTrait>(_: T) {
+ impls_my_trait::<T>();
+}
+
+fn random_where_clause()
+where for<'a> &'a i32: MyTrait { }
+
+fn main() {
+ let x = 22;
+ let f = &x;
+
+ impls_my_trait_val(f);
+
+ impls_my_trait::<&'static i32>();
+
+ random_where_clause();
+}
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+trait MyTrait<'a> { }
+
+impl MyTrait for u32 {
+ //~^ ERROR missing lifetime specifier
+}
+
+fn main() {}
--- /dev/null
+error[E0106]: missing lifetime specifier
+ --> $DIR/trait-elided.rs:16:6
+ |
+LL | impl MyTrait for u32 {
+ | ^^^^^^^ expected lifetime parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0106`.
--- /dev/null
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
+// 'b> MyTrait<'a> for &'b i32`.
+//
+// run-pass
+
+#![allow(warnings)]
+
+#![feature(impl_header_lifetime_elision)]
+
+trait MyTrait<'a> { }
+
+// This is equivalent to `MyTrait<'a> for &'b i32`, which is proven by
+// the code below.
+impl MyTrait<'_> for &i32 {
+}
+
+// When called, T will be `&'x i32` for some `'x`, so since we can
+// prove that `&'x i32: for<'a> MyTrait<'a>, then we know that the
+// lifetime parameter above is disconnected.
+fn impls_my_trait<T: for<'a> MyTrait<'a>>() { }
+
+fn impls_my_trait_val<T: for<'a> MyTrait<'a>>(_: T) {
+ impls_my_trait::<T>();
+}
+
+fn random_where_clause()
+where for<'a, 'b> &'a i32: MyTrait<'b> { }
+
+fn main() {
+ let x = 22;
+ let f = &x;
+ impls_my_trait_val(f);
+
+ impls_my_trait::<&'static i32>();
+
+ random_where_clause();
+}
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that we do not yet support elision in associated types, even
-// when there is just one name we could take from the impl header.
-
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-trait MyTrait {
- type Output;
-}
-
-impl MyTrait for &i32 {
- type Output = &i32;
- //~^ ERROR missing lifetime specifier
-}
-
-impl MyTrait for &u32 {
- type Output = &'_ i32;
- //~^ ERROR missing lifetime specifier
-}
-
-// This is what you have to do:
-impl MyTrait for &'a f32 {
- type Output = &'a f32;
-}
-
-fn main() { }
+++ /dev/null
-error[E0106]: missing lifetime specifier
- --> $DIR/assoc-type.rs:23:19
- |
-LL | type Output = &i32;
- | ^ expected lifetime parameter
-
-error[E0106]: missing lifetime specifier
- --> $DIR/assoc-type.rs:28:20
- |
-LL | type Output = &'_ i32;
- | ^^ expected lifetime parameter
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0106`.
+++ /dev/null
-warning: not reporting region error due to nll
- --> $DIR/dyn-trait.rs:32:16
- |
-LL | static_val(x); //~ ERROR cannot infer
- | ^
-
-error: borrowed data escapes outside of function
- --> $DIR/dyn-trait.rs:32:5
- |
-LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
- | - `x` is a reference that is only valid in the function body
-LL | static_val(x); //~ ERROR cannot infer
- | ^^^^^^^^^^^^^ `x` escapes the function body here
-
-error: aborting due to previous error
-
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
-// 'b> MyTrait<'a> for &'b i32`.
-
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-use std::fmt::Debug;
-
-// Equivalent to `Box<dyn Debug + 'static>`:
-trait StaticTrait { }
-impl StaticTrait for Box<dyn Debug> { }
-
-// Equivalent to `Box<dyn Debug + 'static>`:
-trait NotStaticTrait { }
-impl NotStaticTrait for Box<dyn Debug + '_> { }
-
-fn static_val<T: StaticTrait>(_: T) {
-}
-
-fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
- static_val(x); //~ ERROR cannot infer
-}
-
-fn not_static_val<T: NotStaticTrait>(_: T) {
-}
-
-fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
- not_static_val(x); // OK
-}
-
-fn main() {
-}
+++ /dev/null
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
- --> $DIR/dyn-trait.rs:32:16
- |
-LL | static_val(x); //~ ERROR cannot infer
- | ^
- |
-note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:26...
- --> $DIR/dyn-trait.rs:31:26
- |
-LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
- | ^^
- = note: ...so that the expression is assignable:
- expected std::boxed::Box<dyn std::fmt::Debug>
- found std::boxed::Box<(dyn std::fmt::Debug + 'a)>
- = note: but, the lifetime must be valid for the static lifetime...
- = note: ...so that the types are compatible:
- expected StaticTrait
- found StaticTrait
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0495`.
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-trait MyTrait { }
-
-struct Foo<'a> { x: &'a u32 }
-
-impl MyTrait for Foo {
- //~^ ERROR missing lifetime specifier
-}
-
-fn main() {}
+++ /dev/null
-error[E0106]: missing lifetime specifier
- --> $DIR/path-elided.rs:18:18
- |
-LL | impl MyTrait for Foo {
- | ^^^ expected lifetime parameter
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0106`.
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that `impl MyTrait for Foo<'_>` works.
-
-// run-pass
-
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-trait MyTrait { }
-
-struct Foo<'a> { x: &'a u32 }
-
-impl MyTrait for Foo<'_> {
-}
-
-fn impls_my_trait<T: MyTrait>() { }
-
-fn impls_my_trait_val<T: MyTrait>(_: T) {
- impls_my_trait::<T>();
-}
-
-fn random_where_clause()
-where for<'a> Foo<'a>: MyTrait { }
-
-fn main() {
- let x = 22;
- let f = Foo { x: &x };
-
- // This type is `Foo<'x>` for a local lifetime `'x`; so the impl
- // must apply to any lifetime to apply to this.
- impls_my_trait_val(f);
-
- impls_my_trait::<Foo<'static>>();
-
- random_where_clause();
-}
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that `impl MyTrait for &i32` works and is equivalent to any lifetime.
-
-// run-pass
-
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-trait MyTrait { }
-
-impl MyTrait for &i32 {
-}
-
-fn impls_my_trait<T: MyTrait>() { }
-
-fn impls_my_trait_val<T: MyTrait>(_: T) {
- impls_my_trait::<T>();
-}
-
-fn random_where_clause()
-where for<'a> &'a i32: MyTrait { }
-
-fn main() {
- let x = 22;
- let f = &x;
-
- impls_my_trait_val(f);
-
- impls_my_trait::<&'static i32>();
-
- random_where_clause();
-}
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-trait MyTrait<'a> { }
-
-impl MyTrait for u32 {
- //~^ ERROR missing lifetime specifier
-}
-
-fn main() {}
+++ /dev/null
-error[E0106]: missing lifetime specifier
- --> $DIR/trait-elided.rs:16:6
- |
-LL | impl MyTrait for u32 {
- | ^^^^^^^ expected lifetime parameter
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0106`.
+++ /dev/null
-// Copyright 2018 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
-// 'b> MyTrait<'a> for &'b i32`.
-//
-// run-pass
-
-#![allow(warnings)]
-
-#![feature(in_band_lifetimes)]
-
-trait MyTrait<'a> { }
-
-// This is equivalent to `MyTrait<'a> for &'b i32`, which is proven by
-// the code below.
-impl MyTrait<'_> for &i32 {
-}
-
-// When called, T will be `&'x i32` for some `'x`, so since we can
-// prove that `&'x i32: for<'a> MyTrait<'a>, then we know that the
-// lifetime parameter above is disconnected.
-fn impls_my_trait<T: for<'a> MyTrait<'a>>() { }
-
-fn impls_my_trait_val<T: for<'a> MyTrait<'a>>(_: T) {
- impls_my_trait::<T>();
-}
-
-fn random_where_clause()
-where for<'a, 'b> &'a i32: MyTrait<'b> { }
-
-fn main() {
- let x = 22;
- let f = &x;
- impls_my_trait_val(f);
-
- impls_my_trait::<&'static i32>();
-
- random_where_clause();
-}
| |
| consider changing the type of `y` to `&'a u32`
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/mismatched.rs:16:46
|
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
- | ------- ------- ^ ...but data from `y` is returned here
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | -- -- ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+ | | |
+ | | lifetime `'b` defined here
+ | lifetime `'a` defined here
error: aborting due to 2 previous errors
-Some errors occurred: E0621, E0623.
-For more information about an error, try `rustc --explain E0621`.
+For more information about this error, try `rustc --explain E0621`.
LL | if x > y { x } else { y } //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:21:12
|
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
- | ---- -------
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | -- - let's call the lifetime of this reference `'1`
+ | |
+ | lifetime `'a` defined here
LL |
LL | if x > y { x } else { y } //~ ERROR lifetime mismatch
- | ^^^^^ ...but data from `x` is returned here
+ | ^^^^^ requires that `'1` must outlive `'a`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:18:5
|
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
- | ------- ----
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | -- - let's call the lifetime of this reference `'1`
+ | |
+ | lifetime `'a` defined here
LL |
LL | x //~ ERROR lifetime mismatch
- | ^ ...but data from `x` is returned here
+ | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | if true { x } else { self } //~ ERROR lifetime mismatch
| ^^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex1-return-one-existing-name-self-is-anon.rs:18:9
|
LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
- | ----- -------
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | -- - let's call the lifetime of this reference `'1`
+ | |
+ | lifetime `'a` defined here
LL |
LL | if true { x } else { self } //~ ERROR lifetime mismatch
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `self` is returned here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'1` must outlive `'a`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex2b-push-no-existing-names.rs:16:5
|
LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
- | -------- -------- these two types are declared with different lifetimes...
+ | -------- -------- lifetime `'1` appears in this type
+ | |
+ | lifetime `'2` appears in this type
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | let z = Ref { data: y.data };
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex2c-push-inference-variable.rs:17:5
|
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
- | ------------ ------------ these two types are declared with different lifetimes...
+ | -- -- lifetime `'c` defined here
+ | |
+ | lifetime `'b` defined here
LL | let z = Ref { data: y.data };
LL | x.push(z); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'c` must outlive `'b`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | let b = Ref { data: y.data };
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex2d-push-inference-variable-2.rs:18:5
|
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
- | ------------ ------------ these two types are declared with different lifetimes...
+ | -- -- lifetime `'c` defined here
+ | |
+ | lifetime `'b` defined here
...
LL | a.push(b);
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'c` must outlive `'b`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | let b = Ref { data: y.data };
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex2e-push-inference-variable-3.rs:18:5
|
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
- | ------------ ------------ these two types are declared with different lifetimes...
+ | -- -- lifetime `'c` defined here
+ | |
+ | lifetime `'b` defined here
...
LL | Vec::push(a, b);
- | ^^^^^^^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^^^^^^^ argument requires that `'c` must outlive `'b`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | *v = x; //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-2.rs:12:5
|
LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
- | --- --- these two types are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | *v = x; //~ ERROR lifetime mismatch
- | ^^^^^^ ...but data from `x` flows here
+ | ^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | z.push((x,y)); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-3.rs:12:5
|
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
- | --- --- these two types are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | z.push((x,y)); //~ ERROR lifetime mismatch
- | ^^^^^^^^^^^^^ ...but data flows into `z` here
+ | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-3.rs:12:5
|
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
- | --- --- these two types are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | z.push((x,y)); //~ ERROR lifetime mismatch
- | ^^^^^^^^^^^^^ ...but data flows into `z` here
+ | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0623`.
LL | x.b = y.b; //~ ERROR lifetime mismatch
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:16:5
|
LL | fn foo(mut x: Ref, y: Ref) {
- | --- --- these two types are declared with different lifetimes...
+ | --- --- lifetime `'1` appears in this type
+ | |
+ | lifetime `'2` appears in this type
LL | x.b = y.b; //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.a = x.b; //~ ERROR lifetime mismatch
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:16:5
|
LL | fn foo(mut x: Ref) {
| ---
| |
- | this type is declared with multiple lifetimes...
+ | lifetime `'1` appears in this type
+ | lifetime `'2` appears in this type
LL | x.a = x.b; //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data with one lifetime flows into the other here
+ | ^^^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.a = x.b; //~ ERROR lifetime mismatch
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:5
|
LL | fn foo(mut x: Ref) {
| ---
| |
- | this type is declared with multiple lifetimes...
+ | lifetime `'1` appears in this type
+ | lifetime `'2` appears in this type
LL | x.a = x.b; //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data with one lifetime flows into the other here
+ | ^^^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:18:5
|
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>)
- | ------- ------- these two types are declared with different lifetimes...
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
...
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'b` must outlive `'a`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:15:5
|
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
- | ------- ------- these two types are declared with different lifetimes...
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'b` must outlive `'a`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-both-are-structs.rs:15:5
|
LL | fn foo(mut x: Vec<Ref>, y: Ref) {
- | --- --- these two types are declared with different lifetimes...
+ | --- --- lifetime `'1` appears in this type
+ | |
+ | lifetime `'2` appears in this type
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-latebound-regions.rs:12:5
|
LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
- | ------ ------ these two types are declared with different lifetimes...
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'b` must outlive `'a`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | y = x.b; //~ ERROR lifetime mismatch
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:14:5
|
LL | fn foo(mut x: Ref, y: &u32) {
- | --- ----
+ | --- - let's call the lifetime of this reference `'2`
| |
- | these two types are declared with different lifetimes...
+ | lifetime `'1` appears in this type
LL | y = x.b; //~ ERROR lifetime mismatch
- | ^^^^^^^ ...but data from `x` flows into `y` here
+ | ^^^^^^^ requires that `'1` must outlive `'2`
error[E0384]: cannot assign to immutable argument `y`
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:14:5
error: aborting due to 2 previous errors
-Some errors occurred: E0384, E0623.
-For more information about an error, try `rustc --explain E0384`.
+For more information about this error, try `rustc --explain E0384`.
LL | y.b = x; //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:14:5
|
LL | fn foo(mut y: Ref, x: &u32) {
- | --- ---- these two types are declared with different lifetimes...
+ | --- - let's call the lifetime of this reference `'1`
+ | |
+ | lifetime `'2` appears in this type
LL | y.b = x; //~ ERROR lifetime mismatch
- | ^^^^^^^ ...but data from `x` flows into `y` here
+ | ^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | y.b = x; //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:14:5
|
LL | fn foo(mut y: Ref, x: &u32) {
- | --- ---- these two types are declared with different lifetimes...
+ | --- - let's call the lifetime of this reference `'1`
+ | |
+ | lifetime `'2` appears in this type
LL | y.b = x; //~ ERROR lifetime mismatch
- | ^^^^^^^ ...but data from `x` flows into `y` here
+ | ^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x.b = y; //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-one-is-struct.rs:17:5
|
LL | fn foo(mut x: Ref, y: &u32) {
- | --- ---- these two types are declared with different lifetimes...
+ | --- - let's call the lifetime of this reference `'1`
+ | |
+ | lifetime `'2` appears in this type
LL | x.b = y; //~ ERROR lifetime mismatch
- | ^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | x //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:17:5
|
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
- | ---- ----
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | x //~ ERROR lifetime mismatch
- | ^ ...but data from `x` is returned here
+ | ^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | if true { x } else { self } //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-self-is-anon.rs:17:9
|
LL | fn foo<'a>(&self, x: &Foo) -> &Foo {
- | ---- ----
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | if true { x } else { self } //~ ERROR lifetime mismatch
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `x` is returned here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | y.push(z); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3
|
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
- | --- --- these two types are declared with different lifetimes...
+ | - help: consider changing this to be mutable: `mut y`
LL | y.push(z); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `z` flows into `y` here
+ | ^ cannot borrow as mutable
-error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3
|
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
- | - help: consider changing this to be mutable: `mut y`
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | y.push(z); //~ ERROR lifetime mismatch
- | ^ cannot borrow as mutable
+ | ^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to 2 previous errors
-Some errors occurred: E0596, E0623.
-For more information about an error, try `rustc --explain E0596`.
+For more information about this error, try `rustc --explain E0596`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-using-impl-items.rs:15:9
|
LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
- | --- --- these two types are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
LL | y.push(z); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3
|
LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
- | --- --- these two types are declared with different lifetimes...
+ | - help: consider changing this to be mutable: `mut y`
LL | y.push(z); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `z` flows into `y` here
+ | ^ cannot borrow as mutable
-error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3
|
LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
- | - help: consider changing this to be mutable: `mut y`
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | y.push(z); //~ ERROR lifetime mismatch
- | ^ cannot borrow as mutable
+ | ^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to 2 previous errors
-Some errors occurred: E0596, E0623.
-For more information about an error, try `rustc --explain E0596`.
+For more information about this error, try `rustc --explain E0596`.
LL | x.push(y); //~ ERROR lifetime mismatch
| ^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/ex3-both-anon-regions.rs:12:5
|
LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
- | --- --- these two types are declared with different lifetimes...
+ | - - let's call the lifetime of this reference `'1`
+ | |
+ | let's call the lifetime of this reference `'2`
LL | x.push(y); //~ ERROR lifetime mismatch
- | ^^^^^^^^^ ...but data from `y` flows into `x` here
+ | ^^^^^^^^^ argument requires that `'1` must outlive `'2`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
#[rustc_regions]
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
- //~^ ERROR lifetime mismatch
+ //~^ ERROR unsatisfied lifetime constraints
// Only works if 'x: 'y:
demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
|
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
| _______________________________________________^
-LL | | //~^ ERROR lifetime mismatch
+LL | | //~^ ERROR unsatisfied lifetime constraints
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
= note: number of external vids: 5
= note: where '_#1r: '_#2r
-error[E0623]: lifetime mismatch
- --> $DIR/propagate-approximated-ref.rs:53:5
- |
-LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
- | ------- -------
- | |
- | these two types are declared with different lifetimes...
-LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
-LL | | //~^ ERROR lifetime mismatch
-LL | |
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
-LL | | });
- | |______^ ...but data from `cell_a` flows into `cell_b` here
-
note: No external requirements
--> $DIR/propagate-approximated-ref.rs:52:1
|
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
-LL | | //~^ ERROR lifetime mismatch
+LL | | //~^ ERROR unsatisfied lifetime constraints
LL | |
... |
LL | | });
|
= note: defining type: DefId(0/0:6 ~ propagate_approximated_ref[317d]::supply[0]) with substs []
+error: unsatisfied lifetime constraints
+ --> $DIR/propagate-approximated-ref.rs:53:5
+ |
+LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
+LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
+LL | | //~^ ERROR unsatisfied lifetime constraints
+LL | |
+LL | | // Only works if 'x: 'y:
+LL | | demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
+LL | | });
+ | |______^ argument requires that `'a` must outlive `'b`
+
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
#[rustc_regions]
fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
- //~^ ERROR lifetime mismatch
+ //~^ ERROR unsatisfied lifetime constraints
// Only works if 'x: 'y:
demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
|
LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
| _____________________________________________^
-LL | | //~^ ERROR lifetime mismatch
+LL | | //~^ ERROR unsatisfied lifetime constraints
LL | |
LL | | // Only works if 'x: 'y:
LL | | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
= note: number of external vids: 5
= note: where '_#1r: '_#2r
-error[E0623]: lifetime mismatch
- --> $DIR/propagate-approximated-val.rs:46:5
- |
-LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
- | ------- -------
- | |
- | these two types are declared with different lifetimes...
-LL | / establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
-LL | | //~^ ERROR lifetime mismatch
-LL | |
-LL | | // Only works if 'x: 'y:
-LL | | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
-LL | | });
- | |______^ ...but data from `cell_a` flows into `cell_b` here
-
note: No external requirements
--> $DIR/propagate-approximated-val.rs:45:1
|
LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
LL | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
-LL | | //~^ ERROR lifetime mismatch
+LL | | //~^ ERROR unsatisfied lifetime constraints
LL | |
... |
LL | | });
|
= note: defining type: DefId(0/0:6 ~ propagate_approximated_val[317d]::test[0]) with substs []
+error: unsatisfied lifetime constraints
+ --> $DIR/propagate-approximated-val.rs:46:5
+ |
+LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
+LL | / establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
+LL | | //~^ ERROR unsatisfied lifetime constraints
+LL | |
+LL | | // Only works if 'x: 'y:
+LL | | demand_y(outlives1, outlives2, x.get()) //~ WARNING not reporting region error due to nll
+LL | | });
+ | |______^ argument requires that `'a` must outlive `'b`
+
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
&*x
//~^ WARN not reporting region error due to nll
- //~| ERROR lifetime mismatch
+ //~| ERROR unsatisfied lifetime constraints
}
fn main() { }
LL | &*x
| ^^^
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
|
LL | fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> &'b u32 {
- | ------- -------
- | |
- | this parameter and the return type are declared with different lifetimes...
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
LL | &*x
- | ^^^ ...but data from `x` is returned here
+ | ^^^ requires that `'a` must outlive `'b`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.
}
fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b {
- let x = move || { //~ ERROR lifetime mismatch
+ let x = move || { //~ ERROR unsatisfied lifetime constraints
let value: &'a u32 = value;
data.push(value);
};
-error[E0623]: lifetime mismatch
+error: unsatisfied lifetime constraints
--> $DIR/issue-52113.rs:43:9
|
LL | fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b {
- | -------------------- ------- these two types are declared with different lifetimes...
-LL | let x = move || { //~ ERROR lifetime mismatch
- | ^ ...but data from `value` flows into `data` here
+ | -- -- lifetime `'b` defined here
+ | |
+ | lifetime `'a` defined here
+LL | let x = move || { //~ ERROR unsatisfied lifetime constraints
+ | ^ requires that `'a` must outlive `'b`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0623`.