From 99daba2a4a17c733f4edf781fde6fa8cb30975a0 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Sat, 21 May 2022 14:45:57 -0400 Subject: Use revisions for NLL in object-lifetime --- .../object-lifetime-default-elision.base.stderr | 61 ++++++++++++++++++++++ .../object-lifetime-default-elision.nll.stderr | 2 +- .../object-lifetime-default-elision.rs | 9 +++- .../object-lifetime-default-elision.stderr | 61 ---------------------- ...ect-lifetime-default-from-box-error.base.stderr | 35 +++++++++++++ ...ject-lifetime-default-from-box-error.nll.stderr | 6 +-- .../object-lifetime-default-from-box-error.rs | 9 +++- .../object-lifetime-default-from-box-error.stderr | 35 ------------- ...ifetime-default-from-rptr-box-error.base.stderr | 18 +++++++ ...lifetime-default-from-rptr-box-error.nll.stderr | 2 +- .../object-lifetime-default-from-rptr-box-error.rs | 8 ++- ...ect-lifetime-default-from-rptr-box-error.stderr | 18 ------- ...time-default-from-rptr-struct-error.base.stderr | 18 +++++++ ...etime-default-from-rptr-struct-error.nll.stderr | 2 +- ...ject-lifetime-default-from-rptr-struct-error.rs | 8 ++- ...-lifetime-default-from-rptr-struct-error.stderr | 18 ------- .../object-lifetime-default-mybox.base.stderr | 31 +++++++++++ .../object-lifetime-default-mybox.nll.stderr | 4 +- .../object-lifetime-default-mybox.rs | 12 ++++- .../object-lifetime-default-mybox.stderr | 31 ----------- 20 files changed, 210 insertions(+), 178 deletions(-) create mode 100644 src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr delete mode 100644 src/test/ui/object-lifetime/object-lifetime-default-elision.stderr create mode 100644 src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr delete mode 100644 src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr create mode 100644 src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr delete mode 100644 src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr create mode 100644 src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr delete mode 100644 src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr create mode 100644 src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr delete mode 100644 src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr (limited to 'src/test') diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr new file mode 100644 index 00000000000..c402d1fefad --- /dev/null +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.base.stderr @@ -0,0 +1,61 @@ +error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements + --> $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: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:75:5 + | +LL | ss + | ^^ +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $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:75:5 + | +LL | ss + | ^^ + = note: expected `&'b (dyn SomeTrait + 'b)` + found `&dyn SomeTrait` + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $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: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:75:5 + | +LL | ss + | ^^ +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $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:75:5 + | +LL | ss + | ^^ + = note: expected `&'b (dyn SomeTrait + 'b)` + found `&dyn SomeTrait` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0495`. 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-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr deleted file mode 100644 index 5af4c5bdfae..00000000000 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr +++ /dev/null @@ -1,61 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 - | -LL | ss - | ^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54: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 - | -LL | ss - | ^^ -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54: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 - | -LL | ss - | ^^ - = note: expected `&'b (dyn SomeTrait + 'b)` - found `&dyn SomeTrait` - -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/object-lifetime-default-elision.rs:71:5 - | -LL | ss - | ^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54: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 - | -LL | ss - | ^^ -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/object-lifetime-default-elision.rs:54: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 - | -LL | ss - | ^^ - = note: expected `&'b (dyn SomeTrait + 'b)` - found `&dyn SomeTrait` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr new file mode 100644 index 00000000000..5a8cba175e9 --- /dev/null +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.base.stderr @@ -0,0 +1,35 @@ +error[E0759]: `ss` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/object-lifetime-default-from-box-error.rs:22:5 + | +LL | fn load(ss: &mut SomeStruct) -> Box { + | --------------- this data with an anonymous lifetime `'_`... +... +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:18:37 + | +LL | fn load(ss: &mut SomeStruct) -> Box { + | ^^^^^^^^^^^^^ `'static` requirement introduced here +... +LL | ss.r + | ---- because of this returned expression +help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound + | +LL | fn load(ss: &mut SomeStruct) -> Box { + | ++++ + +error[E0621]: explicit lifetime required in the type of `ss` + --> $DIR/object-lifetime-default-from-box-error.rs:38:12 + | +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { + | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` +... +LL | ss.r = b; + | ^ lifetime `'b` required + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0621, E0759. +For more information about an error, try `rustc --explain E0621`. 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 { | -- has type `&mut SomeStruct<'1>` @@ -13,13 +13,13 @@ LL | fn load(ss: &mut SomeStruct) -> Box { | ++++ 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`, 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) { | --------------- 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 { // `Box` 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) { 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.stderr deleted file mode 100644 index 1708700f77a..00000000000 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ /dev/null @@ -1,35 +0,0 @@ -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 - | -LL | fn load(ss: &mut SomeStruct) -> Box { - | --------------- this data with an anonymous lifetime `'_`... -... -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 - | -LL | fn load(ss: &mut SomeStruct) -> Box { - | ^^^^^^^^^^^^^ `'static` requirement introduced here -... -LL | ss.r - | ---- because of this returned expression -help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound - | -LL | fn load(ss: &mut SomeStruct) -> Box { - | ++++ - -error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:31:12 - | -LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { - | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` -... -LL | ss.r = b; - | ^ lifetime `'b` required - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0621, E0759. -For more information about an error, try `rustc --explain E0621`. diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr new file mode 100644 index 00000000000..7e88aa32357 --- /dev/null +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.base.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:19:12 + | +LL | ss.t = t; + | ^ lifetime mismatch + | + = 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:18:6 + | +LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. 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, 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, 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-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr deleted file mode 100644 index e7fab9ecefc..00000000000 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:12 - | -LL | ss.t = t; - | ^ lifetime mismatch - | - = 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 - | -LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr new file mode 100644 index 00000000000..b97a7d22549 --- /dev/null +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.base.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:24:12 + | +LL | ss.t = t; + | ^ lifetime mismatch + | + = 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:23:6 + | +LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. 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, 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 { } fn c<'a>(t: &'a MyBox, 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.stderr deleted file mode 100644 index 1649841c186..00000000000 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:12 - | -LL | ss.t = t; - | ^ lifetime mismatch - | - = 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 - | -LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr new file mode 100644 index 00000000000..6a72fab307b --- /dev/null +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.base.stderr @@ -0,0 +1,31 @@ +error[E0623]: lifetime mismatch + --> $DIR/object-lifetime-default-mybox.rs:31:5 + | +LL | fn load1<'a,'b>(a: &'a MyBox, + | ------------------------ this parameter and the return type are declared with different lifetimes... +LL | b: &'b MyBox) +LL | -> &'b MyBox + | ------------------------ +LL | { +LL | a + | ^ ...but data from `a` is returned here + +error[E0308]: mismatched types + --> $DIR/object-lifetime-default-mybox.rs:37:11 + | +LL | load0(ss) + | ^^ lifetime mismatch + | + = 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:36:10 + | +LL | fn load2<'a>(ss: &MyBox) -> MyBox { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. 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, | -- -- 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) -> MyBox { | -- -- `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, b: &'b MyBox) -> &'b MyBox { - a //~ ERROR lifetime mismatch + a + //[base]~^ ERROR lifetime mismatch + //[nll]~^^ ERROR lifetime may not live long enough } fn load2<'a>(ss: &MyBox) -> MyBox { - load0(ss) //~ ERROR mismatched types + load0(ss) + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR borrowed data escapes outside of function } 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.stderr deleted file mode 100644 index 4c5fb452ebe..00000000000 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/object-lifetime-default-mybox.rs:27:5 - | -LL | fn load1<'a,'b>(a: &'a MyBox, - | ------------------------ this parameter and the return type are declared with different lifetimes... -LL | b: &'b MyBox) -LL | -> &'b MyBox - | ------------------------ -LL | { -LL | a - | ^ ...but data from `a` is returned here - -error[E0308]: mismatched types - --> $DIR/object-lifetime-default-mybox.rs:31:11 - | -LL | load0(ss) - | ^^ lifetime mismatch - | - = 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 - | -LL | fn load2<'a>(ss: &MyBox) -> MyBox { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0308, E0623. -For more information about an error, try `rustc --explain E0308`. -- cgit 1.4.1-3-g733a5