-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#51025: improve test robustness so that they work under NLL too.
- Loading branch information
Showing
70 changed files
with
725 additions
and
362 deletions.
There are no files selected for viewing
48 changes: 37 additions & 11 deletions
48
src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.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 |
---|---|---|
@@ -1,14 +1,40 @@ | ||
error: compilation successful | ||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:12:1 | ||
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable | ||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:17:13 | ||
| | ||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 | ||
LL | | // Original borrow ends at end of function | ||
LL | | let mut x = 1; | ||
LL | | let y = &mut x; | ||
... | | ||
LL | | //~^ immutable borrow occurs here | ||
LL | | } | ||
| |_^ | ||
LL | let y = &mut x; | ||
| ------ mutable borrow occurs here | ||
LL | //~^ mutable borrow occurs here | ||
LL | let z = &x; //~ ERROR cannot borrow | ||
| ^^ immutable borrow occurs here | ||
... | ||
LL | y.use_mut(); | ||
| - borrow later used here | ||
|
||
error: aborting due to previous error | ||
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable | ||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:30:21 | ||
| | ||
LL | let y = &x; | ||
| -- immutable borrow occurs here | ||
LL | //~^ immutable borrow occurs here | ||
LL | let z = &mut x; //~ ERROR cannot borrow | ||
| ^^^^^^ mutable borrow occurs here | ||
... | ||
LL | y.use_ref(); | ||
| - borrow later used here | ||
|
||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:45:17 | ||
| | ||
LL | let y = &mut x; | ||
| ------ first mutable borrow occurs here | ||
LL | //~^ first mutable borrow occurs here | ||
LL | let z = &mut x; //~ ERROR cannot borrow | ||
| ^^^^^^ second mutable borrow occurs here | ||
... | ||
LL | y.use_mut(); | ||
| - borrow later used here | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors occurred: E0499, E0502. | ||
For more information about an error, try `rustc --explain E0499`. |
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 |
---|---|---|
@@ -1,14 +1,24 @@ | ||
error: compilation successful | ||
--> $DIR/mut-borrow-outside-loop.rs:13:1 | ||
error[E0499]: cannot borrow `void` as mutable more than once at a time | ||
--> $DIR/mut-borrow-outside-loop.rs:17:18 | ||
| | ||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 | ||
LL | | let mut void = (); | ||
LL | | | ||
LL | | let first = &mut void; | ||
... | | ||
LL | | } | ||
LL | | } | ||
| |_^ | ||
LL | let first = &mut void; | ||
| --------- first mutable borrow occurs here | ||
LL | let second = &mut void; //~ ERROR cannot borrow | ||
| ^^^^^^^^^ second mutable borrow occurs here | ||
LL | first.use_mut(); | ||
| ----- borrow later used here | ||
|
||
error: aborting due to previous error | ||
error[E0499]: cannot borrow `inner_void` as mutable more than once at a time | ||
--> $DIR/mut-borrow-outside-loop.rs:25:28 | ||
| | ||
LL | let inner_first = &mut inner_void; | ||
| --------------- first mutable borrow occurs here | ||
LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow | ||
| ^^^^^^^^^^^^^^^ second mutable borrow occurs here | ||
LL | inner_second.use_mut(); | ||
LL | inner_first.use_mut(); | ||
| ----------- borrow later used here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0499`. |
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
error: compilation successful | ||
--> $DIR/issue-11715.rs:97:1 | ||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/issue-11715.rs:100:13 | ||
| | ||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 | ||
LL | | let mut x = "foo"; | ||
LL | | let y = &mut x; | ||
LL | | let z = &mut x; //~ ERROR cannot borrow | ||
LL | | } | ||
| |_^ | ||
LL | let y = &mut x; | ||
| ------ first mutable borrow occurs here | ||
LL | let z = &mut x; //~ ERROR cannot borrow | ||
| ^^^^^^ second mutable borrow occurs here | ||
LL | z.use_mut(); | ||
LL | y.use_mut(); | ||
| - borrow later used here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0499`. |
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
21 changes: 11 additions & 10 deletions
21
src/test/ui/dropck/dropck-eyepatch-extern-crate.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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
error: compilation successful | ||
--> $DIR/dropck-eyepatch-extern-crate.rs:27:1 | ||
error[E0597]: `c_shortest` does not live long enough | ||
--> $DIR/dropck-eyepatch-extern-crate.rs:47:19 | ||
| | ||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855 | ||
LL | | use std::cell::Cell; | ||
LL | | let c_long; | ||
LL | | let (c, mut dt, mut dr, mut pt, mut pr, st, sr) | ||
... | | ||
LL | | println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); | ||
LL | | } | ||
| |_^ | ||
LL | dt = Dt("dt", &c_shortest); | ||
| ^^^^^^^^^^^ borrowed value does not live long enough | ||
... | ||
LL | } | ||
| - | ||
| | | ||
| borrowed value only lives until here | ||
| borrow later used here, when `dt` is dropped | ||
|
||
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
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
Oops, something went wrong.