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.
Regression test for issue rust-lang#54382
(I opted to rely on compare-mode=nll rather than opt into `#![feature(nll)]`, mostly to make it easy to observe the interesting differences between the AST-borrwock diagnostic and the NLL one.)
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.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,18 @@ | ||
error[E0597]: `_thing1` does not live long enough | ||
--> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:29 | ||
| | ||
LL | D("other").next(&_thing1) | ||
| ----------------^^^^^^^^- | ||
| | | | ||
| | borrowed value does not live long enough | ||
| a temporary with access to the borrow is created here ... | ||
LL | } | ||
LL | } | ||
| - `_thing1` dropped here while still borrowed | ||
LL | | ||
LL | ; | ||
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
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 @@ | ||
fn main() { | ||
{ | ||
let mut _thing1 = D(Box::new("thing1")); | ||
{ | ||
let _thing2 = D("thing2"); | ||
side_effects(); | ||
D("other").next(&_thing1) | ||
} | ||
} | ||
|
||
; | ||
} | ||
|
||
#[derive(Debug)] | ||
struct D<T: std::fmt::Debug>(T); | ||
|
||
impl<T: std::fmt::Debug> Drop for D<T> { | ||
fn drop(&mut self) { | ||
println!("dropping {:?})", self); | ||
} | ||
} | ||
|
||
impl<T: std::fmt::Debug> D<T> { | ||
fn next<U: std::fmt::Debug>(&self, _other: U) -> D<U> { D(_other) } | ||
fn end(&self) { } | ||
} | ||
|
||
fn side_effects() { } |
15 changes: 15 additions & 0 deletions
15
src/test/ui/nll/issue-54382-use-span-of-tail-of-block.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,15 @@ | ||
error[E0597]: `_thing1` does not live long enough | ||
--> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:30 | ||
| | ||
LL | D("other").next(&_thing1) | ||
| ^^^^^^^ borrowed value does not live long enough | ||
LL | } | ||
LL | } | ||
| - `_thing1` dropped here while still borrowed | ||
LL | | ||
LL | ; | ||
| - borrowed value needs to live until here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |