forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#37405 - mikhail-m1:dnlle, r=jonathandturner
Improve "Doesn't live long enough" error case with different lifetime scope issue rust-lang#36537 part of rust-lang#35233 r? @jonathandturner
- Loading branch information
Showing
29 changed files
with
309 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: borrowed value does not live long enough | ||
--> $DIR/borrowck-ref-into-rvalue.rs:18:5 | ||
| | ||
14 | Some(ref m) => { //~ ERROR borrowed value does not live long enough | ||
| ----- borrow occurs here | ||
... | ||
18 | } | ||
| ^ borrowed value dropped here while still borrowed | ||
19 | println!("{}", *msg); | ||
20 | } | ||
| - borrowed value needs to live until here | ||
| | ||
= note: consider using a `let` binding to increase its lifetime | ||
|
||
error: aborting due to previous error | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: `*a` does not live long enough | ||
--> $DIR/destructor-restrictions.rs:19:5 | ||
| | ||
18 | *a.borrow() + 1 //~ ERROR `*a` does not live long enough | ||
| - borrow occurs here | ||
19 | }; | ||
| ^- borrowed value needs to live until here | ||
| | | ||
| `*a` dropped here while still borrowed | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: `b` does not live long enough | ||
--> $DIR/mut-ptr-cant-outlive-ref.rs:19:5 | ||
| | ||
18 | p = &*b; //~ ERROR `b` does not live long enough | ||
| - borrow occurs here | ||
19 | } | ||
| ^ `b` dropped here while still borrowed | ||
20 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error: `a` does not live long enough | ||
--> $DIR/range-2.rs:20:5 | ||
| | ||
17 | &a..&b | ||
| - borrow occurs here | ||
... | ||
20 | }; | ||
| ^ `a` dropped here while still borrowed | ||
21 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: `b` does not live long enough | ||
--> $DIR/range-2.rs:20:5 | ||
| | ||
17 | &a..&b | ||
| - borrow occurs here | ||
... | ||
20 | }; | ||
| ^ `b` dropped here while still borrowed | ||
21 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to 2 previous errors | ||
|
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: `c` does not live long enough | ||
--> $DIR/regionck-unboxed-closure-lifetimes.rs:19:5 | ||
| | ||
17 | let c_ref = &c; //~ ERROR `c` does not live long enough | ||
| - borrow occurs here | ||
18 | f = move |a: isize, b: isize| { a + b + *c_ref }; | ||
19 | } | ||
| ^ `c` dropped here while still borrowed | ||
20 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
src/test/ui/span/regions-close-over-type-parameter-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: `tmp0` does not live long enough | ||
--> $DIR/regions-close-over-type-parameter-2.rs:35:5 | ||
| | ||
33 | let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough | ||
| ---- borrow occurs here | ||
34 | repeater3(tmp1) | ||
35 | }; | ||
| ^- borrowed value needs to live until here | ||
| | | ||
| `tmp0` dropped here while still borrowed | ||
|
||
error: aborting due to previous error | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: `x` does not live long enough | ||
--> $DIR/regions-escape-loop-via-variable.rs:22:5 | ||
| | ||
21 | p = &x; //~ ERROR `x` does not live long enough | ||
| - borrow occurs here | ||
22 | } | ||
| ^ `x` dropped here while still borrowed | ||
23 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
error: `z` does not live long enough | ||
--> $DIR/regions-escape-loop-via-vec.rs:26:5 | ||
| | ||
22 | _y.push(&mut z); //~ ERROR `z` does not live long enough | ||
| - borrow occurs here | ||
... | ||
26 | } | ||
| ^ `z` dropped here while still borrowed | ||
27 | //~^ NOTE borrowed value only lives until here | ||
28 | } | ||
| - borrowed value needs to live until here | ||
|
||
error[E0503]: cannot use `x` because it was mutably borrowed | ||
--> $DIR/regions-escape-loop-via-vec.rs:18:11 | ||
| | ||
14 | let mut _y = vec![&mut x]; | ||
| - borrow of `x` occurs here | ||
... | ||
18 | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed | ||
| ^ use of borrowed `x` | ||
|
||
error[E0503]: cannot use `x` because it was mutably borrowed | ||
--> $DIR/regions-escape-loop-via-vec.rs:20:13 | ||
| | ||
14 | let mut _y = vec![&mut x]; | ||
| - borrow of `x` occurs here | ||
... | ||
20 | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed | ||
| ^^^^^ use of borrowed `x` | ||
|
||
error[E0506]: cannot assign to `x` because it is borrowed | ||
--> $DIR/regions-escape-loop-via-vec.rs:24:9 | ||
| | ||
14 | let mut _y = vec![&mut x]; | ||
| - borrow of `x` occurs here | ||
... | ||
24 | x += 1; //~ ERROR cannot assign | ||
| ^^^^^^ assignment to borrowed `x` occurs here | ||
|
||
error: aborting due to 4 previous errors | ||
|
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: `*x` does not live long enough | ||
--> $DIR/regions-infer-borrow-scope-within-loop.rs:28:5 | ||
| | ||
24 | y = borrow(&*x); //~ ERROR `*x` does not live long enough | ||
| -- borrow occurs here | ||
... | ||
28 | } | ||
| ^ `*x` dropped here while still borrowed | ||
29 | assert!(*y != 0); | ||
30 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
src/test/ui/span/send-is-not-static-ensures-scoping.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
error: `x` does not live long enough | ||
--> $DIR/send-is-not-static-ensures-scoping.rs:32:5 | ||
| | ||
26 | let y = &x; //~ ERROR `x` does not live long enough | ||
| - borrow occurs here | ||
... | ||
32 | }; | ||
| ^ `x` dropped here while still borrowed | ||
... | ||
35 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: `y` does not live long enough | ||
--> $DIR/send-is-not-static-ensures-scoping.rs:29:22 | ||
| | ||
28 | scoped(|| { | ||
| -- capture occurs here | ||
29 | let _z = y; | ||
| ^ does not live long enough | ||
... | ||
32 | }; | ||
| - borrowed value only lives until here | ||
... | ||
35 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to 2 previous errors | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
error: `x` does not live long enough | ||
--> $DIR/send-is-not-static-std-sync-2.rs:22:5 | ||
| | ||
21 | Mutex::new(&x) //~ ERROR does not live long enough | ||
| - borrow occurs here | ||
22 | }; | ||
| ^ `x` dropped here while still borrowed | ||
... | ||
25 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: `x` does not live long enough | ||
--> $DIR/send-is-not-static-std-sync-2.rs:31:5 | ||
| | ||
30 | RwLock::new(&x) //~ ERROR does not live long enough | ||
| - borrow occurs here | ||
31 | }; | ||
| ^ `x` dropped here while still borrowed | ||
32 | let _dangling = *lock.read().unwrap(); | ||
33 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: `x` does not live long enough | ||
--> $DIR/send-is-not-static-std-sync-2.rs:41:5 | ||
| | ||
39 | let _ = tx.send(&x); //~ ERROR does not live long enough | ||
| - borrow occurs here | ||
40 | (tx, rx) | ||
41 | }; | ||
| ^ `x` dropped here while still borrowed | ||
... | ||
44 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to 3 previous errors | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
error: `z` does not live long enough | ||
--> $DIR/send-is-not-static-std-sync.rs:27:5 | ||
| | ||
26 | *lock.lock().unwrap() = &z; //~ ERROR does not live long enough | ||
| - borrow occurs here | ||
27 | } | ||
| ^ `z` dropped here while still borrowed | ||
28 | } | ||
| - borrowed value needs to live until here | ||
|
||
error[E0505]: cannot move out of `y` because it is borrowed | ||
--> $DIR/send-is-not-static-std-sync.rs:23:10 | ||
| | ||
22 | *lock.lock().unwrap() = &*y; | ||
| -- borrow of `*y` occurs here | ||
23 | drop(y); //~ ERROR cannot move out | ||
| ^ move out of `y` occurs here | ||
|
||
error: `z` does not live long enough | ||
--> $DIR/send-is-not-static-std-sync.rs:39:5 | ||
| | ||
38 | *lock.write().unwrap() = &z; //~ ERROR does not live long enough | ||
| - borrow occurs here | ||
39 | } | ||
| ^ `z` dropped here while still borrowed | ||
40 | } | ||
| - borrowed value needs to live until here | ||
|
||
error[E0505]: cannot move out of `y` because it is borrowed | ||
--> $DIR/send-is-not-static-std-sync.rs:35:10 | ||
| | ||
34 | *lock.write().unwrap() = &*y; | ||
| -- borrow of `*y` occurs here | ||
35 | drop(y); //~ ERROR cannot move out | ||
| ^ move out of `y` occurs here | ||
|
||
error: `z` does not live long enough | ||
--> $DIR/send-is-not-static-std-sync.rs:53:5 | ||
| | ||
52 | tx.send(&z).unwrap(); //~ ERROR does not live long enough | ||
| - borrow occurs here | ||
53 | } | ||
| ^ `z` dropped here while still borrowed | ||
54 | } | ||
| - borrowed value needs to live until here | ||
|
||
error[E0505]: cannot move out of `y` because it is borrowed | ||
--> $DIR/send-is-not-static-std-sync.rs:49:10 | ||
| | ||
48 | tx.send(&*y); | ||
| -- borrow of `*y` occurs here | ||
49 | drop(y); //~ ERROR cannot move out | ||
| ^ move out of `y` occurs here | ||
|
||
error: aborting due to 6 previous errors | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: `pointer` does not live long enough | ||
--> $DIR/wf-method-late-bound-regions.rs:31:5 | ||
| | ||
30 | f2.xmute(&pointer) //~ ERROR `pointer` does not live long enough | ||
| ------- borrow occurs here | ||
31 | }; | ||
| ^ `pointer` dropped here while still borrowed | ||
32 | println!("{}", dangling); | ||
33 | } | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|