-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #37554 - mikhail-m1:dnlle, r=jonathandturner
Improve "Doesn't live long enough" error case with temporary variable issue #36279 part of #35233 r? @jonathandturner
- Loading branch information
Showing
9 changed files
with
63 additions
and
24 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
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
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
fn main() { | ||
let v = vec![ | ||
&3 | ||
//~^ ERROR borrowed value does not live long enough | ||
]; | ||
|
||
for &&x in &v { | ||
|
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,15 @@ | ||
error: borrowed value does not live long enough | ||
--> $DIR/issue-15480.rs:14:6 | ||
| | ||
13 | &3 | ||
| - temporary value created here | ||
14 | ]; | ||
| ^ temporary value dropped here while still borrowed | ||
... | ||
19 | } | ||
| - temporary value needs to live until here | ||
| | ||
= note: consider using a `let` binding to increase its lifetime | ||
|
||
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
13 changes: 13 additions & 0 deletions
13
src/test/ui/span/regions-close-over-borrowed-ref-in-obj.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: borrowed value does not live long enough | ||
--> $DIR/regions-close-over-borrowed-ref-in-obj.rs:22:5 | ||
| | ||
20 | let ss: &isize = &1; | ||
| - temporary value created here | ||
21 | blah = box ss as Box<Foo>; | ||
22 | } | ||
| ^ temporary value dropped here while still borrowed | ||
23 | } | ||
| - temporary value needs to live until here | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: borrowed value does not live long enough | ||
--> $DIR/slice-borrow.rs:18:5 | ||
| | ||
16 | let x: &[isize] = &[1, 2, 3, 4, 5]; | ||
| --------------- temporary value created here | ||
17 | y = &x[1..]; | ||
18 | } | ||
| ^ temporary value dropped here while still borrowed | ||
19 | } | ||
| - temporary value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|