diff options
| author | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-05-21 14:45:57 -0400 |
|---|---|---|
| committer | Jack Huey <31162821+jackh726@users.noreply.github.com> | 2022-05-22 15:21:27 -0400 |
| commit | 99daba2a4a17c733f4edf781fde6fa8cb30975a0 (patch) | |
| tree | 9f88a7588d0b8b3c87a441c7e2cc874f7d42616d /src/test | |
| parent | 8220be5240e644a368559388e0de5e1e412a3e61 (diff) | |
| download | rust-99daba2a4a17c733f4edf781fde6fa8cb30975a0.tar.gz rust-99daba2a4a17c733f4edf781fde6fa8cb30975a0.zip | |
Use revisions for NLL in object-lifetime
Diffstat (limited to 'src/test')
15 files changed, 67 insertions, 35 deletions
diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr index 5af4c5bdfae..c402d1fefad 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr @@ -1,26 +1,26 @@ error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:10 + --> $DIR/object-lifetime-default-elision.rs:58:10 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that reference does not outlive borrowed content - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:13 + --> $DIR/object-lifetime-default-elision.rs:58:13 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the types are compatible - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ @@ -28,28 +28,28 @@ LL | ss found `&dyn SomeTrait` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:10 + --> $DIR/object-lifetime-default-elision.rs:58:10 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54:13 + --> $DIR/object-lifetime-default-elision.rs:58:13 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the types are compatible - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | ss | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr index 61e96f59fed..49bbadf7224 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-elision.rs:71:5 + --> $DIR/object-lifetime-default-elision.rs:75:5 | LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs index dc42edfba2c..16b4df7bad5 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test various cases where the old rules under lifetime elision // yield slightly different results than the new rules. @@ -69,8 +73,9 @@ fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { // which fails to type check. ss - //~^ ERROR cannot infer - //~| ERROR cannot infer + //[base]~^ ERROR cannot infer + //[base]~| ERROR cannot infer + //[nll]~^^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr index 1708700f77a..5a8cba175e9 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr @@ -1,5 +1,5 @@ error[E0759]: `ss` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | --------------- this data with an anonymous lifetime `'_`... @@ -8,7 +8,7 @@ LL | ss.r | ^^^^ ...is used and required to live as long as `'static` here | note: `'static` lifetime requirement introduced by the return type - --> $DIR/object-lifetime-default-from-box-error.rs:14:37 + --> $DIR/object-lifetime-default-from-box-error.rs:18:37 | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | ^^^^^^^^^^^^^ `'static` requirement introduced here @@ -21,7 +21,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> { | ++++ error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:12 + --> $DIR/object-lifetime-default-from-box-error.rs:38:12 | LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr index 43695a7511d..7907813f267 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | -- has type `&mut SomeStruct<'1>` @@ -13,13 +13,13 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> { | ++++ error[E0507]: cannot move out of `ss.r` which is behind a mutable reference - --> $DIR/object-lifetime-default-from-box-error.rs:18:5 + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 | LL | ss.r | ^^^^ move occurs because `ss.r` has type `Box<dyn SomeTrait>`, which does not implement the `Copy` trait error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:5 + --> $DIR/object-lifetime-default-from-box-error.rs:38:5 | LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs index 4a2665d8e16..1cb9834913c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test various cases where the defaults should lead to errors being // reported. @@ -15,7 +19,10 @@ fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { // `Box<SomeTrait>` defaults to a `'static` bound, so this return // is illegal. - ss.r //~ ERROR E0759 + ss.r + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot move out of } fn store(ss: &mut SomeStruct, b: Box<dyn SomeTrait>) { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr index e7fab9ecefc..7e88aa32357 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:12 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:12 | LL | ss.t = t; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | ss.t = t; = note: expected reference `&'a Box<(dyn Test + 'static)>` found reference `&'a Box<(dyn Test + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:14:6 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:18:6 | LL | fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr index 7d6f9f39d13..a07cc0718f1 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:5 + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:5 | LL | fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs index bf9e0beb57c..8cdd64be193 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that the lifetime from the enclosing `&` is "inherited" // through the `Box` struct. @@ -12,7 +16,9 @@ struct SomeStruct<'a> { } fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types + ss.t = t; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr index 1649841c186..b97a7d22549 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:12 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:12 | LL | ss.t = t; | ^ lifetime mismatch @@ -7,7 +7,7 @@ LL | ss.t = t; = note: expected reference `&'a MyBox<(dyn Test + 'static)>` found reference `&'a MyBox<(dyn Test + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:19:6 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:23:6 | LL | fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr index 2bc8e097859..63d51b5c28c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:5 + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:5 | LL | fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs index dc0b86903c9..2d9a148a389 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test that the lifetime from the enclosing `&` is "inherited" // through the `MyBox` struct. @@ -17,7 +21,9 @@ struct MyBox<T:?Sized> { } fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types + ss.t = t; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr index 4c5fb452ebe..6a72fab307b 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/object-lifetime-default-mybox.rs:27:5 + --> $DIR/object-lifetime-default-mybox.rs:31:5 | LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, | ------------------------ this parameter and the return type are declared with different lifetimes... @@ -11,7 +11,7 @@ LL | a | ^ ...but data from `a` is returned here error[E0308]: mismatched types - --> $DIR/object-lifetime-default-mybox.rs:31:11 + --> $DIR/object-lifetime-default-mybox.rs:37:11 | LL | load0(ss) | ^^ lifetime mismatch @@ -19,7 +19,7 @@ LL | load0(ss) = note: expected reference `&MyBox<(dyn SomeTrait + 'static)>` found reference `&MyBox<(dyn SomeTrait + 'a)>` note: the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-mybox.rs:30:10 + --> $DIR/object-lifetime-default-mybox.rs:36:10 | LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { | ^^ diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index af20c5e5fc0..aa454cb9931 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/object-lifetime-default-mybox.rs:27:5 + --> $DIR/object-lifetime-default-mybox.rs:31:5 | LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | a = help: consider adding the following bound: `'a: 'b` error[E0521]: borrowed data escapes outside of function - --> $DIR/object-lifetime-default-mybox.rs:31:5 + --> $DIR/object-lifetime-default-mybox.rs:37:5 | LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { | -- -- `ss` is a reference that is only valid in the function body diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs index eb27fe90f47..874556dafeb 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs @@ -1,3 +1,7 @@ +// ignore-compare-mode-nll +// revisions: base nll +// [nll]compile-flags: -Zborrowck=mir + // Test a "pass-through" object-lifetime-default that produces errors. #![allow(dead_code)] @@ -24,11 +28,15 @@ fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, b: &'b MyBox<dyn SomeTrait>) -> &'b MyBox<dyn SomeTrait> { - a //~ ERROR lifetime mismatch + a + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { - load0(ss) //~ ERROR mismatched types + load0(ss) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes outside of function } fn main() { |
