mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Use revisions for NLL in lifetimes
This commit is contained in:
parent
fe91cfd684
commit
383fbeec63
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187-2.rs:8:5
|
||||
--> $DIR/issue-79187-2.rs:12:5
|
||||
|
|
||||
LL | take_foo(|a| a);
|
||||
| ^^^^^^^^ lifetime mismatch
|
||||
@ -7,18 +7,18 @@ LL | take_foo(|a| a);
|
||||
= note: expected type `for<'r> Fn<(&'r i32,)>`
|
||||
found type `Fn<(&i32,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-79187-2.rs:8:14
|
||||
--> $DIR/issue-79187-2.rs:12:14
|
||||
|
|
||||
LL | take_foo(|a| a);
|
||||
| ^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187-2.rs:5:21
|
||||
--> $DIR/issue-79187-2.rs:9:21
|
||||
|
|
||||
LL | fn take_foo(_: impl Foo) {}
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187-2.rs:9:5
|
||||
--> $DIR/issue-79187-2.rs:16:5
|
||||
|
|
||||
LL | take_foo(|a: &i32| a);
|
||||
| ^^^^^^^^ lifetime mismatch
|
||||
@ -26,18 +26,18 @@ LL | take_foo(|a: &i32| a);
|
||||
= note: expected reference `&i32`
|
||||
found reference `&i32`
|
||||
note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements
|
||||
--> $DIR/issue-79187-2.rs:9:14
|
||||
--> $DIR/issue-79187-2.rs:16:14
|
||||
|
|
||||
LL | take_foo(|a: &i32| a);
|
||||
| ^^^^^^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187-2.rs:5:21
|
||||
--> $DIR/issue-79187-2.rs:9:21
|
||||
|
|
||||
LL | fn take_foo(_: impl Foo) {}
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187-2.rs:10:5
|
||||
--> $DIR/issue-79187-2.rs:20:5
|
||||
|
|
||||
LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
| ^^^^^^^^ lifetime mismatch
|
||||
@ -45,12 +45,12 @@ LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
= note: expected reference `&i32`
|
||||
found reference `&i32`
|
||||
note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements
|
||||
--> $DIR/issue-79187-2.rs:10:14
|
||||
--> $DIR/issue-79187-2.rs:20:14
|
||||
|
|
||||
LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187-2.rs:5:21
|
||||
--> $DIR/issue-79187-2.rs:9:21
|
||||
|
|
||||
LL | fn take_foo(_: impl Foo) {}
|
||||
| ^^^
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-79187-2.rs:9:24
|
||||
--> $DIR/issue-79187-2.rs:16:24
|
||||
|
|
||||
LL | take_foo(|a: &i32| a);
|
||||
| - - ^ returning this value requires that `'1` must outlive `'2`
|
||||
@ -8,7 +8,7 @@ LL | take_foo(|a: &i32| a);
|
||||
| let's call the lifetime of this reference `'1`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-79187-2.rs:10:34
|
||||
--> $DIR/issue-79187-2.rs:20:34
|
||||
|
|
||||
LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
| - - ^ returning this value requires that `'1` must outlive `'2`
|
||||
@ -17,7 +17,7 @@ LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
| let's call the lifetime of this reference `'1`
|
||||
|
||||
error: implementation of `FnOnce` is not general enough
|
||||
--> $DIR/issue-79187-2.rs:8:5
|
||||
--> $DIR/issue-79187-2.rs:12:5
|
||||
|
|
||||
LL | take_foo(|a| a);
|
||||
| ^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
|
||||
@ -26,7 +26,7 @@ LL | take_foo(|a| a);
|
||||
= note: ...but it actually implements `FnOnce<(&'2 i32,)>`, for some specific lifetime `'2`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187-2.rs:8:5
|
||||
--> $DIR/issue-79187-2.rs:12:5
|
||||
|
|
||||
LL | take_foo(|a| a);
|
||||
| ^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -34,18 +34,18 @@ LL | take_foo(|a| a);
|
||||
= note: expected type `for<'r> Fn<(&'r i32,)>`
|
||||
found type `Fn<(&i32,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-79187-2.rs:8:14
|
||||
--> $DIR/issue-79187-2.rs:12:14
|
||||
|
|
||||
LL | take_foo(|a| a);
|
||||
| ^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187-2.rs:5:21
|
||||
--> $DIR/issue-79187-2.rs:9:21
|
||||
|
|
||||
LL | fn take_foo(_: impl Foo) {}
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187-2.rs:9:5
|
||||
--> $DIR/issue-79187-2.rs:16:5
|
||||
|
|
||||
LL | take_foo(|a: &i32| a);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -53,13 +53,13 @@ LL | take_foo(|a: &i32| a);
|
||||
= note: expected reference `&i32`
|
||||
found reference `&i32`
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187-2.rs:5:21
|
||||
--> $DIR/issue-79187-2.rs:9:21
|
||||
|
|
||||
LL | fn take_foo(_: impl Foo) {}
|
||||
| ^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187-2.rs:10:5
|
||||
--> $DIR/issue-79187-2.rs:20:5
|
||||
|
|
||||
LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -67,7 +67,7 @@ LL | take_foo(|a: &i32| -> &i32 { a });
|
||||
= note: expected reference `&i32`
|
||||
found reference `&i32`
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187-2.rs:5:21
|
||||
--> $DIR/issue-79187-2.rs:9:21
|
||||
|
|
||||
LL | fn take_foo(_: impl Foo) {}
|
||||
| ^^^
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo {}
|
||||
|
||||
impl<F> Foo for F where F: Fn(&i32) -> &i32 {}
|
||||
@ -5,9 +9,18 @@ impl<F> Foo for F where F: Fn(&i32) -> &i32 {}
|
||||
fn take_foo(_: impl Foo) {}
|
||||
|
||||
fn main() {
|
||||
take_foo(|a| a); //~ ERROR mismatched types
|
||||
take_foo(|a: &i32| a); //~ ERROR mismatched types
|
||||
take_foo(|a: &i32| -> &i32 { a }); //~ ERROR mismatched types
|
||||
take_foo(|a| a);
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR implementation of `FnOnce` is not general enough
|
||||
//[nll]~| ERROR mismatched types
|
||||
take_foo(|a: &i32| a);
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR mismatched types
|
||||
take_foo(|a: &i32| -> &i32 { a });
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR mismatched types
|
||||
|
||||
// OK
|
||||
take_foo(identity(|a| a));
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: implementation of `FnOnce` is not general enough
|
||||
--> $DIR/issue-79187.rs:5:5
|
||||
--> $DIR/issue-79187.rs:9:5
|
||||
|
|
||||
LL | thing(f);
|
||||
| ^^^^^ implementation of `FnOnce` is not general enough
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-79187.rs:5:5
|
||||
--> $DIR/issue-79187.rs:9:5
|
||||
|
|
||||
LL | thing(f);
|
||||
| ^^^^^^^^ one type is more general than the other
|
||||
@ -7,18 +7,18 @@ LL | thing(f);
|
||||
= note: expected type `for<'r> FnOnce<(&'r u32,)>`
|
||||
found type `FnOnce<(&u32,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-79187.rs:4:13
|
||||
--> $DIR/issue-79187.rs:8:13
|
||||
|
|
||||
LL | let f = |_| ();
|
||||
| ^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-79187.rs:1:18
|
||||
--> $DIR/issue-79187.rs:5:18
|
||||
|
|
||||
LL | fn thing(x: impl FnOnce(&u32)) {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: implementation of `FnOnce` is not general enough
|
||||
--> $DIR/issue-79187.rs:5:5
|
||||
--> $DIR/issue-79187.rs:9:5
|
||||
|
|
||||
LL | thing(f);
|
||||
| ^^^^^^^^ implementation of `FnOnce` is not general enough
|
||||
|
@ -1,6 +1,12 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn thing(x: impl FnOnce(&u32)) {}
|
||||
|
||||
fn main() {
|
||||
let f = |_| ();
|
||||
thing(f); //~ERROR implementation of `FnOnce` is not general enough
|
||||
thing(f);
|
||||
//[nll]~^ ERROR mismatched types
|
||||
//~^^ ERROR implementation of `FnOnce` is not general enough
|
||||
}
|
||||
|
15
src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed
Normal file
15
src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.fixed
Normal file
@ -0,0 +1,15 @@
|
||||
// FIXME(nll): On NLL stabilization, this should be replace
|
||||
// `issue-90170-elision-mismatch.rs`. Compiletest has
|
||||
// problems with rustfix and revisions.
|
||||
// ignore-compare-mode-nll
|
||||
// compile-flags: -Zborrowck=mir
|
||||
|
||||
// run-rustfix
|
||||
|
||||
pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough
|
||||
|
||||
pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough
|
||||
|
||||
pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime may not live long enough
|
||||
|
||||
fn main() {}
|
15
src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs
Normal file
15
src/test/ui/lifetimes/issue-90170-elision-mismatch-nll.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// FIXME(nll): On NLL stabilization, this should be replace
|
||||
// `issue-90170-elision-mismatch.rs`. Compiletest has
|
||||
// problems with rustfix and revisions.
|
||||
// ignore-compare-mode-nll
|
||||
// compile-flags: -Zborrowck=mir
|
||||
|
||||
// run-rustfix
|
||||
|
||||
pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
|
||||
|
||||
pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
|
||||
|
||||
pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime may not live long enough
|
||||
|
||||
fn main() {}
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:3:40
|
||||
--> $DIR/issue-90170-elision-mismatch-nll.rs:9:40
|
||||
|
|
||||
LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
|
||||
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||
@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||
| ++++ ++ ++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:5:44
|
||||
--> $DIR/issue-90170-elision-mismatch-nll.rs:11:44
|
||||
|
|
||||
LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
|
||||
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
||||
@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||
| ++++ ~~ ++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:7:63
|
||||
--> $DIR/issue-90170-elision-mismatch-nll.rs:13:63
|
||||
|
|
||||
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
|
||||
| - - ^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
@ -1,3 +1,8 @@
|
||||
// FIXME(nll): On NLL stabilization, this should be replaced by
|
||||
// `issue-90170-elision-mismatch-nll.rs`. Compiletest has
|
||||
// problems with rustfix and revisions.
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
// run-rustfix
|
||||
|
||||
pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } //~ ERROR lifetime mismatch
|
||||
|
@ -1,3 +1,8 @@
|
||||
// FIXME(nll): On NLL stabilization, this should be replaced by
|
||||
// `issue-90170-elision-mismatch-nll.rs`. Compiletest has
|
||||
// problems with rustfix and revisions.
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
// run-rustfix
|
||||
|
||||
pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } //~ ERROR lifetime mismatch
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:3:47
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:8:47
|
||||
|
|
||||
LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); }
|
||||
| --- --- ^ ...but data from `y` flows into `x` here
|
||||
@ -13,7 +13,7 @@ LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||
| ++++ ++ ++
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:5:51
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:10:51
|
||||
|
|
||||
LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); }
|
||||
| ------ --- ^ ...but data from `y` flows into `x` here
|
||||
@ -27,7 +27,7 @@ LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); }
|
||||
| ++++ ~~ ++
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:7:70
|
||||
--> $DIR/issue-90170-elision-mismatch.rs:12:70
|
||||
|
|
||||
LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); }
|
||||
| --- --- ^ ...but data from `y` flows into `x` here
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0759]: `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
|
||||
--> $DIR/issue-90600-expected-return-static-indirect.rs:11:32
|
||||
|
|
||||
LL | fn inner(mut foo: &[u8]) {
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
@ -1,9 +1,9 @@
|
||||
error[E0597]: `foo` does not live long enough
|
||||
--> $DIR/issue-90600-expected-return-static-indirect.rs:7:32
|
||||
--> $DIR/issue-90600-expected-return-static-indirect.rs:11:32
|
||||
|
|
||||
LL | let refcell = RefCell::new(&mut foo);
|
||||
| ^^^^^^^^ borrowed value does not live long enough
|
||||
LL |
|
||||
...
|
||||
LL | let read = &refcell as &RefCell<dyn Read>;
|
||||
| -------- cast requires that `foo` is borrowed for `'static`
|
||||
...
|
||||
@ -11,7 +11,7 @@ LL | }
|
||||
| - `foo` dropped here while still borrowed
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-90600-expected-return-static-indirect.rs:9:16
|
||||
--> $DIR/issue-90600-expected-return-static-indirect.rs:14:16
|
||||
|
|
||||
LL | fn inner(mut foo: &[u8]) {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::io::Read;
|
||||
|
||||
@ -5,8 +9,10 @@ fn main() {}
|
||||
|
||||
fn inner(mut foo: &[u8]) {
|
||||
let refcell = RefCell::new(&mut foo);
|
||||
//~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[base]~^ ERROR `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[nll]~^^ ERROR `foo` does not live long enough
|
||||
let read = &refcell as &RefCell<dyn Read>;
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
|
||||
read_thing(read);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:34:13
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:38:13
|
||||
|
|
||||
LL | ref_obj(x)
|
||||
| ^ lifetime mismatch
|
||||
@ -7,14 +7,14 @@ LL | ref_obj(x)
|
||||
= note: expected reference `&Box<(dyn Fn() + 'static)>`
|
||||
found reference `&Box<(dyn Fn() + 'a)>`
|
||||
note: the lifetime `'a` as defined here...
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:32:10
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:36:10
|
||||
|
|
||||
LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
| ^^
|
||||
= note: ...does not necessarily outlive the static lifetime
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:39:18
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:45:18
|
||||
|
|
||||
LL | lib::ref_obj(x)
|
||||
| ^ lifetime mismatch
|
||||
@ -22,7 +22,7 @@ LL | lib::ref_obj(x)
|
||||
= note: expected reference `&Box<(dyn Fn() + 'static)>`
|
||||
found reference `&Box<(dyn Fn() + 'a)>`
|
||||
note: the lifetime `'a` as defined here...
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:37:12
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:43:12
|
||||
|
|
||||
LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
| ^^
|
@ -1,5 +1,5 @@
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:34:5
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:38:5
|
||||
|
|
||||
LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
| -- - `x` is a reference that is only valid in the function body
|
||||
@ -13,7 +13,7 @@ LL | ref_obj(x)
|
||||
| argument requires that `'a` must outlive `'static`
|
||||
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:39:5
|
||||
--> $DIR/lifetime-bound-will-change-warning.rs:45:5
|
||||
|
|
||||
LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
| -- - `x` is a reference that is only valid in the function body
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
// aux-build:lifetime_bound_will_change_warning_lib.rs
|
||||
|
||||
// Test that various corner cases cause an error. These are tests
|
||||
@ -31,12 +35,16 @@ fn test1cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
|
||||
fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
// but ref_obj will not, so warn.
|
||||
ref_obj(x) //~ ERROR mismatched types
|
||||
ref_obj(x)
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR borrowed data escapes
|
||||
}
|
||||
|
||||
fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
|
||||
// same as test2, but cross crate
|
||||
lib::ref_obj(x) //~ ERROR mismatched types
|
||||
lib::ref_obj(x)
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR borrowed data escapes
|
||||
}
|
||||
|
||||
fn test3<'a>(x: &'a Box<dyn Fn() + 'static>) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:11:20
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:15:20
|
||||
|
|
||||
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
|
||||
| ---- -------
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:11:20
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:15:20
|
||||
|
|
||||
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
|
||||
| -- - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo {
|
||||
|
||||
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
|
||||
@ -8,7 +12,9 @@ impl Foo for () {
|
||||
|
||||
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
|
||||
|
||||
if x > y { x } else { y } //~ ERROR lifetime mismatch
|
||||
if x > y { x } else { y }
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5
|
||||
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:12:5
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
|
||||
| ------- ----
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:8:5
|
||||
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:12:5
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
|
||||
| -- - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Foo {
|
||||
field: i32
|
||||
}
|
||||
@ -5,7 +9,9 @@ struct Foo {
|
||||
impl Foo {
|
||||
fn foo<'a>(&self, x: &'a i32) -> &i32 {
|
||||
|
||||
x //~ ERROR lifetime mismatch
|
||||
x
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex1-return-one-existing-name-self-is-anon.rs:8:30
|
||||
--> $DIR/ex1-return-one-existing-name-self-is-anon.rs:12:30
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
|
||||
| ----- -------
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex1-return-one-existing-name-self-is-anon.rs:8:30
|
||||
--> $DIR/ex1-return-one-existing-name-self-is-anon.rs:12:30
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
|
||||
| -- - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Foo {
|
||||
field: i32,
|
||||
}
|
||||
@ -5,7 +9,9 @@ struct Foo {
|
||||
impl Foo {
|
||||
fn foo<'a>(&self, x: &'a Foo) -> &'a Foo {
|
||||
|
||||
if true { x } else { self } //~ ERROR lifetime mismatch
|
||||
if true { x } else { self }
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/ex2a-push-one-existing-name-2.rs:6:12
|
||||
--> $DIR/ex2a-push-one-existing-name-2.rs:10:12
|
||||
|
|
||||
LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
|
||||
| -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/ex2a-push-one-existing-name-2.rs:6:5
|
||||
--> $DIR/ex2a-push-one-existing-name-2.rs:10:5
|
||||
|
|
||||
LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
|
||||
| -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, T: 'a> {
|
||||
data: &'a T
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:12
|
||||
--> $DIR/ex2a-push-one-existing-name-early-bound.rs:12:12
|
||||
|
|
||||
LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T)
|
||||
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:5
|
||||
--> $DIR/ex2a-push-one-existing-name-early-bound.rs:12:5
|
||||
|
|
||||
LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T)
|
||||
| -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo<'a> {}
|
||||
impl<'a, T> Foo<'a> for T {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/ex2a-push-one-existing-name.rs:6:12
|
||||
--> $DIR/ex2a-push-one-existing-name.rs:10:12
|
||||
|
|
||||
LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
|
||||
| -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>`
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/ex2a-push-one-existing-name.rs:6:5
|
||||
--> $DIR/ex2a-push-one-existing-name.rs:10:5
|
||||
|
|
||||
LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
|
||||
| -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, T: 'a> {
|
||||
data: &'a T
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex2b-push-no-existing-names.rs:6:12
|
||||
--> $DIR/ex2b-push-no-existing-names.rs:10:12
|
||||
|
|
||||
LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
|
||||
| -------- -------- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex2b-push-no-existing-names.rs:6:5
|
||||
--> $DIR/ex2b-push-no-existing-names.rs:10:5
|
||||
|
|
||||
LL | fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
|
||||
| - - has type `Ref<'1, i32>`
|
||||
|
@ -1,9 +1,15 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, T: 'a> {
|
||||
data: &'a T
|
||||
}
|
||||
|
||||
fn foo(x: &mut Vec<Ref<i32>>, y: Ref<i32>) {
|
||||
x.push(y); //~ ERROR lifetime mismatch
|
||||
x.push(y);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex2c-push-inference-variable.rs:7:12
|
||||
--> $DIR/ex2c-push-inference-variable.rs:11:12
|
||||
|
|
||||
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...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex2c-push-inference-variable.rs:7:5
|
||||
--> $DIR/ex2c-push-inference-variable.rs:11:5
|
||||
|
|
||||
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
|
||||
| -- -- lifetime `'c` defined here
|
||||
|
@ -1,10 +1,16 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, T: 'a> {
|
||||
data: &'a T
|
||||
}
|
||||
|
||||
fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
|
||||
let z = Ref { data: y.data };
|
||||
x.push(z); //~ ERROR lifetime mismatch
|
||||
x.push(z);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex2d-push-inference-variable-2.rs:6:33
|
||||
--> $DIR/ex2d-push-inference-variable-2.rs:10:33
|
||||
|
|
||||
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...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex2d-push-inference-variable-2.rs:8:5
|
||||
--> $DIR/ex2d-push-inference-variable-2.rs:13:5
|
||||
|
|
||||
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
|
||||
| -- -- lifetime `'c` defined here
|
||||
|
@ -1,11 +1,17 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, T: 'a> {
|
||||
data: &'a T
|
||||
}
|
||||
|
||||
fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
|
||||
let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch
|
||||
let a: &mut Vec<Ref<i32>> = x;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
let b = Ref { data: y.data };
|
||||
a.push(b);
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex2e-push-inference-variable-3.rs:6:33
|
||||
--> $DIR/ex2e-push-inference-variable-3.rs:10:33
|
||||
|
|
||||
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...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex2e-push-inference-variable-3.rs:8:5
|
||||
--> $DIR/ex2e-push-inference-variable-3.rs:13:5
|
||||
|
|
||||
LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
|
||||
| -- -- lifetime `'c` defined here
|
||||
|
@ -1,11 +1,17 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, T: 'a> {
|
||||
data: &'a T
|
||||
}
|
||||
|
||||
fn foo<'a, 'b, 'c>(x: &'a mut Vec<Ref<'b, i32>>, y: Ref<'c, i32>) {
|
||||
let a: &mut Vec<Ref<i32>> = x; //~ ERROR lifetime mismatch
|
||||
let a: &mut Vec<Ref<i32>> = x;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
let b = Ref { data: y.data };
|
||||
Vec::push(a, b);
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-2.rs:2:10
|
||||
--> $DIR/ex3-both-anon-regions-2.rs:6:10
|
||||
|
|
||||
LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-2.rs:2:5
|
||||
--> $DIR/ex3-both-anon-regions-2.rs:6:5
|
||||
|
|
||||
LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,5 +1,11 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
|
||||
*v = x; //~ ERROR lifetime mismatch
|
||||
*v = x;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:2:13
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:6:13
|
||||
|
|
||||
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
||||
@ -13,7 +13,7 @@ LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) {
|
||||
| ++++ ++ ++
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:2:15
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:6:15
|
||||
|
|
||||
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:2:5
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:6:5
|
||||
|
|
||||
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
@ -14,7 +14,7 @@ LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) {
|
||||
| ++++ ++ ++
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:2:5
|
||||
--> $DIR/ex3-both-anon-regions-3.rs:6:5
|
||||
|
|
||||
LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||
| - - let's call the lifetime of this reference `'3`
|
||||
|
@ -1,6 +1,13 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) {
|
||||
z.push((x,y)); //~ ERROR lifetime mismatch
|
||||
//~^ ERROR lifetime mismatch
|
||||
z.push((x,y));
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[base]~| ERROR lifetime mismatch
|
||||
//[nll]~^^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:11
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:11:11
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: Ref) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:7:5
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:11:5
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: Ref) {
|
||||
| ----- - has type `Ref<'_, '1>`
|
||||
|
@ -1,10 +1,16 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, 'b> {
|
||||
a: &'a u32,
|
||||
b: &'b u32,
|
||||
}
|
||||
|
||||
fn foo(mut x: Ref, y: Ref) {
|
||||
x.b = y.b; //~ ERROR lifetime mismatch
|
||||
x.b = y.b;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:11
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:11:11
|
||||
|
|
||||
LL | fn foo(mut x: Ref) {
|
||||
| --- this type is declared with multiple lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:5
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:11:5
|
||||
|
|
||||
LL | fn foo(mut x: Ref) {
|
||||
| -----
|
||||
|
@ -1,10 +1,16 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, 'b> {
|
||||
a: &'a u32,
|
||||
b: &'b u32,
|
||||
}
|
||||
|
||||
fn foo(mut x: Ref) {
|
||||
x.a = x.b; //~ ERROR lifetime mismatch
|
||||
x.a = x.b;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:9:12
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:13:12
|
||||
|
|
||||
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>)
|
||||
| ------- ------- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:9:5
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:13:5
|
||||
|
|
||||
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>)
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a> {
|
||||
x: &'a u32,
|
||||
}
|
||||
@ -6,7 +10,9 @@ fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>)
|
||||
where &'a (): Sized,
|
||||
&'b u32: Sized
|
||||
{
|
||||
x.push(y); //~ ERROR lifetime mismatch
|
||||
x.push(y);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:6:12
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:10:12
|
||||
|
|
||||
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
|
||||
| ------- ------- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:6:5
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:10:5
|
||||
|
|
||||
LL | fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,9 +1,15 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a> {
|
||||
x: &'a u32,
|
||||
}
|
||||
|
||||
fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
|
||||
x.push(y); //~ ERROR lifetime mismatch
|
||||
x.push(y);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs.rs:6:12
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs.rs:10:12
|
||||
|
|
||||
LL | fn foo(mut x: Vec<Ref>, y: Ref) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs.rs:6:5
|
||||
--> $DIR/ex3-both-anon-regions-both-are-structs.rs:10:5
|
||||
|
|
||||
LL | fn foo(mut x: Vec<Ref>, y: Ref) {
|
||||
| ----- - has type `Ref<'1>`
|
||||
|
@ -1,9 +1,15 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a> {
|
||||
x: &'a u32,
|
||||
}
|
||||
|
||||
fn foo(mut x: Vec<Ref>, y: Ref) {
|
||||
x.push(y); //~ ERROR lifetime mismatch
|
||||
x.push(y);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-latebound-regions.rs:2:12
|
||||
--> $DIR/ex3-both-anon-regions-latebound-regions.rs:6:12
|
||||
|
|
||||
LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
|
||||
| ------ ------ these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-latebound-regions.rs:2:5
|
||||
--> $DIR/ex3-both-anon-regions-latebound-regions.rs:6:5
|
||||
|
|
||||
LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,5 +1,11 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) {
|
||||
x.push(y); //~ ERROR lifetime mismatch
|
||||
x.push(y);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:9
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:9
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: &u32) {
|
||||
| --- ----
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:5
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: &u32) {
|
||||
| ----- - let's call the lifetime of this reference `'2`
|
||||
@ -9,7 +9,7 @@ LL | y = x.b;
|
||||
| ^^^^^^^ assignment requires that `'1` must outlive `'2`
|
||||
|
||||
error[E0384]: cannot assign to immutable argument `y`
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:4:5
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:8:5
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: &u32) {
|
||||
| - help: consider making this binding mutable: `mut y`
|
||||
|
@ -1,7 +1,14 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 }
|
||||
|
||||
fn foo(mut x: Ref, y: &u32) {
|
||||
y = x.b; //~ ERROR lifetime mismatch
|
||||
y = x.b;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR cannot assign to immutable argument
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:4:11
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:8:11
|
||||
|
|
||||
LL | fn foo(mut y: Ref, x: &u32) {
|
||||
| --- ---- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:4:5
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:8:5
|
||||
|
|
||||
LL | fn foo(mut y: Ref, x: &u32) {
|
||||
| ----- - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,7 +1,13 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 }
|
||||
|
||||
fn foo(mut y: Ref, x: &u32) {
|
||||
y.b = x; //~ ERROR lifetime mismatch
|
||||
y.b = x;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:4:11
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:8:11
|
||||
|
|
||||
LL | fn foo(mut y: Ref, x: &u32) {
|
||||
| --- ---- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:4:5
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:8:5
|
||||
|
|
||||
LL | fn foo(mut y: Ref, x: &u32) {
|
||||
| ----- - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,7 +1,13 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, 'b> { a: &'a u32, b: &'b u32 }
|
||||
|
||||
fn foo(mut y: Ref, x: &u32) {
|
||||
y.b = x; //~ ERROR lifetime mismatch
|
||||
y.b = x;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct.rs:7:11
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct.rs:11:11
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: &u32) {
|
||||
| --- ---- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct.rs:7:5
|
||||
--> $DIR/ex3-both-anon-regions-one-is-struct.rs:11:5
|
||||
|
|
||||
LL | fn foo(mut x: Ref, y: &u32) {
|
||||
| ----- - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,10 +1,16 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Ref<'a, 'b> {
|
||||
a: &'a u32,
|
||||
b: &'b u32,
|
||||
}
|
||||
|
||||
fn foo(mut x: Ref, y: &u32) {
|
||||
x.b = y; //~ ERROR lifetime mismatch
|
||||
x.b = y;
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5
|
||||
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:11:5
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
|
||||
| ---- ----
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:7:5
|
||||
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:11:5
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,10 +1,16 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Foo {
|
||||
field: i32
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn foo<'a>(&self, x: &i32) -> &i32 {
|
||||
x //~ ERROR lifetime mismatch
|
||||
x
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19
|
||||
--> $DIR/ex3-both-anon-regions-self-is-anon.rs:11:19
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &Foo) -> &Foo {
|
||||
| ---- ----
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-self-is-anon.rs:7:19
|
||||
--> $DIR/ex3-both-anon-regions-self-is-anon.rs:11:19
|
||||
|
|
||||
LL | fn foo<'a>(&self, x: &Foo) -> &Foo {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,10 +1,16 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Foo {
|
||||
field: i32,
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn foo<'a>(&self, x: &Foo) -> &Foo {
|
||||
if true { x } else { self } //~ ERROR lifetime mismatch
|
||||
if true { x } else { self }
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:10
|
||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:10
|
||||
|
|
||||
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3
|
||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:3
|
||||
|
|
||||
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
@ -14,7 +14,7 @@ LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) {
|
||||
| ++++ ++ ++
|
||||
|
||||
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3
|
||||
--> $DIR/ex3-both-anon-regions-using-fn-items.rs:6:3
|
||||
|
|
||||
LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
|
||||
| - help: consider changing this to be mutable: `mut y`
|
||||
|
@ -1,5 +1,12 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
|
||||
y.push(z); //~ ERROR lifetime mismatch
|
||||
y.push(z);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-using-impl-items.rs:6:16
|
||||
--> $DIR/ex3-both-anon-regions-using-impl-items.rs:10:16
|
||||
|
|
||||
LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-using-impl-items.rs:6:9
|
||||
--> $DIR/ex3-both-anon-regions-using-impl-items.rs:10:9
|
||||
|
|
||||
LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,9 +1,15 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo {
|
||||
fn foo<'a>(x: &mut Vec<&u8>, y: &u8);
|
||||
}
|
||||
impl Foo for () {
|
||||
fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||
x.push(y); //~ ERROR lifetime mismatch
|
||||
x.push(y);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
}
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:10
|
||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:10
|
||||
|
|
||||
LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3
|
||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:3
|
||||
|
|
||||
LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
@ -14,7 +14,7 @@ LL | fn foo<'a>(x:Box<dyn Fn(&'a u8, &'a u8)> , y: Vec<&u8>, z: &u8) {
|
||||
| ++++ ++ ++
|
||||
|
||||
error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable
|
||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3
|
||||
--> $DIR/ex3-both-anon-regions-using-trait-objects.rs:6:3
|
||||
|
|
||||
LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
|
||||
| - help: consider changing this to be mutable: `mut y`
|
||||
|
@ -1,5 +1,12 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) {
|
||||
y.push(z); //~ ERROR lifetime mismatch
|
||||
y.push(z);
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ex3-both-anon-regions.rs:2:12
|
||||
--> $DIR/ex3-both-anon-regions.rs:6:12
|
||||
|
|
||||
LL | fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||
| --- --- these two types are declared with different lifetimes...
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user