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#53407 - pnkfelix:partial-53351-make-more-po…
…rted-compile-fail-tests-more-robust-wrt-nll, r=nikomatsakis make more ported compile fail tests more robust w.r.t. NLL This is similar to PR rust-lang#53369, except it covers a disjoint (and much smaller) set of tests that I needed to look at more carefully before being 100% certain they were the same kind of issue.
- Loading branch information
Showing
14 changed files
with
236 additions
and
23 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
src/test/ui/borrowck/borrowck-closures-two-mut-fail.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,75 @@ | ||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/borrowck-closures-two-mut-fail.rs:26:24 | ||
| | ||
LL | let c1 = to_fn_mut(|| x = 4); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| first mutable borrow occurs here | ||
LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| second mutable borrow occurs here | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/borrowck-closures-two-mut-fail.rs:37:24 | ||
| | ||
LL | let c1 = to_fn_mut(|| set(&mut x)); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| first mutable borrow occurs here | ||
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| second mutable borrow occurs here | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/borrowck-closures-two-mut-fail.rs:44:24 | ||
| | ||
LL | let c1 = to_fn_mut(|| x = 5); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| first mutable borrow occurs here | ||
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| second mutable borrow occurs here | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/borrowck-closures-two-mut-fail.rs:51:24 | ||
| | ||
LL | let c1 = to_fn_mut(|| x = 5); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| first mutable borrow occurs here | ||
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| second mutable borrow occurs here | ||
LL | //~^ ERROR cannot borrow `x` as mutable more than once | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0499]: cannot borrow `x` as mutable more than once at a time | ||
--> $DIR/borrowck-closures-two-mut-fail.rs:63:24 | ||
| | ||
LL | let c1 = to_fn_mut(|| set(&mut *x.f)); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| first mutable borrow occurs here | ||
LL | let c2 = to_fn_mut(|| set(&mut *x.f)); | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| second mutable borrow occurs here | ||
LL | //~^ ERROR cannot borrow `x` as mutable more than once | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error: aborting due to 5 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
error[E0500]: closure requires unique access to `x` but it is already borrowed | ||
--> $DIR/borrowck-closures-unique.rs:36:14 | ||
| | ||
LL | let c1 = || get(x); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| borrow occurs here | ||
LL | let c2 = || set(x); //~ ERROR closure requires unique access to `x` | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| closure construction occurs here | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0500]: closure requires unique access to `x` but it is already borrowed | ||
--> $DIR/borrowck-closures-unique.rs:42:14 | ||
| | ||
LL | let c1 = || get(x); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| borrow occurs here | ||
LL | let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x` | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| closure construction occurs here | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0524]: two closures require unique access to `x` at the same time | ||
--> $DIR/borrowck-closures-unique.rs:48:14 | ||
| | ||
LL | let c1 = || set(x); | ||
| -- - first borrow occurs due to use of `x` in closure | ||
| | | ||
| first closure is constructed here | ||
LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time | ||
| ^^ - second borrow occurs due to use of `x` in closure | ||
| | | ||
| second closure is constructed here | ||
LL | c1; | ||
| -- borrow later used here | ||
|
||
error[E0594]: cannot assign to `x`, as it is not declared as mutable | ||
--> $DIR/borrowck-closures-unique.rs:57:38 | ||
| | ||
LL | fn e(x: &'static mut isize) { | ||
| - help: consider changing this to be mutable: `mut x` | ||
LL | let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument | ||
| ^^^^^ cannot assign | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors occurred: E0500, E0524, E0594. | ||
For more information about an error, try `rustc --explain E0500`. |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable | ||
--> $DIR/hashmap-lifetimes.rs:18:5 | ||
| | ||
LL | let mut it = my_stuff.iter(); | ||
| -------- immutable borrow occurs here | ||
LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow | ||
| ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here | ||
LL | it; | ||
| -- borrow later used here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0502`. |
Oops, something went wrong.