bless polonius output of test ui/nll/outlives-suggestion-simple.rs
The polonius output has one more error which should be displayed in the regular case, but error reporting in the regular case stopped at the first error. Admittedly it would be nice to combine suggestions for the same source lifetime so that `'a: 'b` and `'a: 'c` are not bothsuggested, but instead a single `'a: 'b + 'c` is.
This commit is contained in:
parent
67b04d5f64
commit
695640816a
1 changed files with 121 additions and 0 deletions
121
src/test/ui/nll/outlives-suggestion-simple.polonius.stderr
Normal file
121
src/test/ui/nll/outlives-suggestion-simple.polonius.stderr
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:6:5
|
||||
|
|
||||
LL | fn foo1<'a, 'b>(x: &'a usize) -> &'b usize {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
LL | x
|
||||
| ^ returning this value requires that `'a` must outlive `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:10:5
|
||||
|
|
||||
LL | fn foo2<'a>(x: &'a usize) -> &'static usize {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | x
|
||||
| ^ returning this value requires that `'a` must outlive `'static`
|
||||
|
|
||||
= help: consider replacing `'a` with `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:14:5
|
||||
|
|
||||
LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
LL | (x, y)
|
||||
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:14:5
|
||||
|
|
||||
LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
LL | (x, y)
|
||||
| ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
help: `'a` and `'b` must be the same: replace one with the other
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:22:5
|
||||
|
|
||||
LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
...
|
||||
LL | (x, x)
|
||||
| ^^^^^^ returning this value requires that `'a` must outlive `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:22:5
|
||||
|
|
||||
LL | fn foo4<'a, 'b, 'c>(x: &'a usize) -> (&'b usize, &'c usize) {
|
||||
| -- -- lifetime `'c` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
...
|
||||
LL | (x, x)
|
||||
| ^^^^^^ returning this value requires that `'a` must outlive `'c`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'c`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:31:9
|
||||
|
|
||||
LL | pub fn foo<'a>(x: &'a usize) -> Self {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | Foo { x }
|
||||
| ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
|
||||
|
|
||||
= help: consider replacing `'a` with `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:41:9
|
||||
|
|
||||
LL | impl<'a> Bar<'a> {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | pub fn get<'b>(&self) -> &'b usize {
|
||||
| -- lifetime `'b` defined here
|
||||
LL | self.x
|
||||
| ^^^^^^ returning this value requires that `'a` must outlive `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/outlives-suggestion-simple.rs:52:9
|
||||
|
|
||||
LL | impl<'a> Baz<'a> {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | fn get<'b>(&'b self) -> &'a i32 {
|
||||
| -- lifetime `'b` defined here
|
||||
LL | self.x
|
||||
| ^^^^^^ returning this value requires that `'b` must outlive `'a`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/outlives-suggestion-simple.rs:73:9
|
||||
|
|
||||
LL | fn get_bar(&self) -> Bar2 {
|
||||
| -----
|
||||
| |
|
||||
| `self` is declared here, outside of the function body
|
||||
| `self` is a reference that is only valid in the function body
|
||||
LL | Bar2::new(&self)
|
||||
| ^^^^^^^^^^^^^^^^ `self` escapes the function body here
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue