Skip to content

Commit 2bd5993

Browse files
committed
Auto merge of #54343 - blitzerr:master, r=nikomatsakis
First shot at #54015 Closes #54015
2 parents 1c5e9c6 + 671e77d commit 2bd5993

20 files changed

+345
-249
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

+288-225
Large diffs are not rendered by default.

src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ impl<'tcx> BorrowExplanation<'tcx> {
4646
},
4747
BorrowExplanation::UsedLaterInLoop(is_in_closure, var_or_use_span) => {
4848
let message = if is_in_closure {
49-
"borrow captured here by closure in later iteration of loop"
49+
"borrow captured here by closure, in later iteration of loop"
5050
} else {
51-
"borrow used here in later iteration of loop"
51+
"borrow used here, in later iteration of loop"
5252
};
5353
err.span_label(var_or_use_span, message);
5454
},

src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | for &x in &vector {
55
| -------
66
| |
77
| immutable borrow occurs here
8-
| borrow used here in later iteration of loop
8+
| borrow used here, in later iteration of loop
99
LL | let cap = vector.capacity();
1010
LL | vector.extend(repeat(0)); //~ ERROR cannot borrow
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
@@ -17,7 +17,7 @@ LL | for &x in &vector {
1717
| -------
1818
| |
1919
| immutable borrow occurs here
20-
| borrow used here in later iteration of loop
20+
| borrow used here, in later iteration of loop
2121
...
2222
LL | vector[1] = 5; //~ ERROR cannot borrow
2323
| ^^^^^^ mutable borrow occurs here

src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ LL | borrow(&*v); //~ ERROR cannot borrow
88
| ^^^ immutable borrow occurs here
99
LL | }
1010
LL | *x = box 5;
11-
| -- borrow used here in later iteration of loop
11+
| -- borrow used here, in later iteration of loop
1212

1313
error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable
1414
--> $DIR/borrowck-lend-flow-loop.rs:109:16
1515
|
1616
LL | **x += 1;
17-
| -------- borrow used here in later iteration of loop
17+
| -------- borrow used here, in later iteration of loop
1818
LL | borrow(&*v); //~ ERROR cannot borrow
1919
| ^^^ immutable borrow occurs here
2020
LL | if cond2 {

src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time
44
LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
55
| ---- ^^^^^^ second mutable borrow occurs here
66
| |
7-
| borrow used here in later iteration of loop
7+
| borrow used here, in later iteration of loop
88
...
99
LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
1010
| ------ first mutable borrow occurs here
@@ -13,7 +13,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time
1313
--> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30
1414
|
1515
LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
16-
| ---- borrow used here in later iteration of loop
16+
| ---- borrow used here, in later iteration of loop
1717
LL | //[mir]~^ ERROR [E0499]
1818
LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
1919
| ^^^^^^ second mutable borrow occurs here

src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time
44
LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
55
| ---- ^^^^^^ second mutable borrow occurs here
66
| |
7-
| borrow used here in later iteration of loop
7+
| borrow used here, in later iteration of loop
88
...
99
LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
1010
| ------ first mutable borrow occurs here
@@ -13,7 +13,7 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time
1313
--> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30
1414
|
1515
LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
16-
| ---- borrow used here in later iteration of loop
16+
| ---- borrow used here, in later iteration of loop
1717
LL | //[mir]~^ ERROR [E0499]
1818
LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499]
1919
| ^^^^^^ second mutable borrow occurs here

src/test/ui/borrowck/issue-41962.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ error[E0382]: use of moved value (Mir)
2020
--> $DIR/issue-41962.rs:17:21
2121
|
2222
LL | if let Some(thing) = maybe {
23-
| ^^^^^ value moved here in previous iteration of loop
23+
| ^^^^^ value moved here, in previous iteration of loop
2424
|
2525
= note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
2626

src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow
1717
| ^^^^^^^^^^^^^^^ second mutable borrow occurs here
1818
LL | inner_second.use_mut();
1919
LL | inner_first.use_mut();
20-
| ----------- borrow used here in later iteration of loop
20+
| ----------- borrow used here, in later iteration of loop
2121

2222
error: aborting due to 2 previous errors
2323

src/test/ui/issues/issue-12041.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0382]: use of moved value: `tx`
22
--> $DIR/issue-12041.rs:18:22
33
|
44
LL | let tx = tx;
5-
| ^^ value moved here in previous iteration of loop
5+
| ^^ value moved here, in previous iteration of loop
66
|
77
= note: move occurs because `tx` has type `std::sync::mpsc::Sender<i32>`, which does not implement the `Copy` trait
88

src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let v: Vec<&str> = line.split_whitespace().collect();
55
| ^^^^ borrowed value does not live long enough
66
LL | //~^ ERROR `line` does not live long enough
77
LL | println!("accumulator before add_assign {:?}", acc.map);
8-
| ------- borrow used here in later iteration of loop
8+
| ------- borrow used here, in later iteration of loop
99
...
1010
LL | }
1111
| - `line` dropped here while still borrowed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0382]: use of moved value: `x`
2+
--> $DIR/liveness-move-call-arg.rs:19:14
3+
|
4+
LL | take(x); //~ ERROR use of moved value: `x`
5+
| ^ value moved here, in previous iteration of loop
6+
|
7+
= note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0382`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0382]: use of moved value: `y`
2+
--> $DIR/liveness-move-in-loop.rs:21:25
3+
|
4+
LL | x = y; //~ ERROR use of moved value
5+
| ^ value moved here, in previous iteration of loop
6+
|
7+
= note: move occurs because `y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0382`.

src/test/ui/liveness/liveness-move-in-while.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `y`
44
LL | println!("{}", y); //~ ERROR use of moved value: `y`
55
| ^ value borrowed here after move
66
LL | while true { while true { while true { x = y; x.clone(); } } }
7-
| - value moved here
7+
| - value moved here, in previous iteration of loop
88
|
99
= note: move occurs because `y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
1010

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0382]: use of moved value: `x`
2+
--> $DIR/move-in-guard-2.rs:20:24
3+
|
4+
LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x`
5+
| ^ value moved here, in previous iteration of loop
6+
|
7+
= note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0382`.

src/test/ui/nll/closures-in-loops.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: use of moved value: `x`
44
LL | || x; //~ ERROR
55
| ^^ - use occurs due to use in closure
66
| |
7-
| value moved into closure here in previous iteration of loop
7+
| value moved into closure here, in previous iteration of loop
88
|
99
= note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
1010

src/test/ui/nll/issue-53807.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0382]: use of moved value
22
--> $DIR/issue-53807.rs:14:21
33
|
44
LL | if let Some(thing) = maybe {
5-
| ^^^^^ value moved here in previous iteration of loop
5+
| ^^^^^ value moved here, in previous iteration of loop
66
|
77
= note: move occurs because value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
88

src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | foo.mutate();
77
| ^^^^^^^^^^^^ mutable borrow occurs here
88
LL | //~^ ERROR cannot borrow `foo` as mutable
99
LL | println!("foo={:?}", *string);
10-
| ------- borrow used here in later iteration of loop
10+
| ------- borrow used here, in later iteration of loop
1111

1212
error: aborting due to previous error
1313

src/test/ui/span/regions-escape-loop-via-variable.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0597]: `x` does not live long enough
22
--> $DIR/regions-escape-loop-via-variable.rs:21:13
33
|
44
LL | let x = 1 + *p;
5-
| -- borrow used here in later iteration of loop
5+
| -- borrow used here, in later iteration of loop
66
LL | p = &x;
77
| ^^ borrowed value does not live long enough
88
LL | }

src/test/ui/span/regions-escape-loop-via-vec.nll.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
77
| ^ use of borrowed `x`
88
LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
99
LL | _y.push(&mut z);
10-
| -- borrow used here in later iteration of loop
10+
| -- borrow used here, in later iteration of loop
1111

1212
error[E0503]: cannot use `x` because it was mutably borrowed
1313
--> $DIR/regions-escape-loop-via-vec.rs:16:21
@@ -18,15 +18,15 @@ LL | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed
1818
LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed
1919
| ^ use of borrowed `x`
2020
LL | _y.push(&mut z);
21-
| -- borrow used here in later iteration of loop
21+
| -- borrow used here, in later iteration of loop
2222

2323
error[E0597]: `z` does not live long enough
2424
--> $DIR/regions-escape-loop-via-vec.rs:17:17
2525
|
2626
LL | _y.push(&mut z);
2727
| -- ^^^^^^ borrowed value does not live long enough
2828
| |
29-
| borrow used here in later iteration of loop
29+
| borrow used here, in later iteration of loop
3030
...
3131
LL | }
3232
| - `z` dropped here while still borrowed
@@ -38,7 +38,7 @@ LL | let mut _y = vec![&mut x];
3838
| ------ borrow of `x` occurs here
3939
...
4040
LL | _y.push(&mut z);
41-
| -- borrow used here in later iteration of loop
41+
| -- borrow used here, in later iteration of loop
4242
LL | //~^ ERROR `z` does not live long enough
4343
LL | x += 1; //~ ERROR cannot assign
4444
| ^^^^^^ use of borrowed `x`

src/test/ui/vec/vec-mut-iter-borrow.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | for x in &mut xs {
55
| -------
66
| |
77
| first mutable borrow occurs here
8-
| borrow used here in later iteration of loop
8+
| borrow used here, in later iteration of loop
99
LL | xs.push(1) //~ ERROR cannot borrow `xs`
1010
| ^^ second mutable borrow occurs here
1111

0 commit comments

Comments
 (0)