Skip to content

Commit 12af36a

Browse files
committed
Update tests for new spans for nll errors involving closures
1 parent 5639e21 commit 12af36a

22 files changed

+184
-130
lines changed

src/test/ui/borrowck/borrowck-closures-two-mut.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
7777
--> $DIR/borrowck-closures-two-mut.rs:24:24
7878
|
7979
LL | let c1 = to_fn_mut(|| x = 4);
80-
| -- - previous borrow occurs due to use of `x` in closure
80+
| -- - first borrow occurs due to use of `x` in closure
8181
| |
8282
| first mutable borrow occurs here
8383
LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
84-
| ^^ - borrow occurs due to use of `x` in closure
84+
| ^^ - second borrow occurs due to use of `x` in closure
8585
| |
8686
| second mutable borrow occurs here
8787
LL | //~| ERROR cannot borrow `x` as mutable more than once
@@ -92,11 +92,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
9292
--> $DIR/borrowck-closures-two-mut.rs:36:24
9393
|
9494
LL | let c1 = to_fn_mut(|| set(&mut x));
95-
| -- - previous borrow occurs due to use of `x` in closure
95+
| -- - first borrow occurs due to use of `x` in closure
9696
| |
9797
| first mutable borrow occurs here
9898
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
99-
| ^^ - borrow occurs due to use of `x` in closure
99+
| ^^ - second borrow occurs due to use of `x` in closure
100100
| |
101101
| second mutable borrow occurs here
102102
LL | //~| ERROR cannot borrow `x` as mutable more than once
@@ -107,11 +107,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
107107
--> $DIR/borrowck-closures-two-mut.rs:44:24
108108
|
109109
LL | let c1 = to_fn_mut(|| x = 5);
110-
| -- - previous borrow occurs due to use of `x` in closure
110+
| -- - first borrow occurs due to use of `x` in closure
111111
| |
112112
| first mutable borrow occurs here
113113
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
114-
| ^^ - borrow occurs due to use of `x` in closure
114+
| ^^ - second borrow occurs due to use of `x` in closure
115115
| |
116116
| second mutable borrow occurs here
117117
LL | //~| ERROR cannot borrow `x` as mutable more than once
@@ -122,11 +122,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
122122
--> $DIR/borrowck-closures-two-mut.rs:52:24
123123
|
124124
LL | let c1 = to_fn_mut(|| x = 5);
125-
| -- - previous borrow occurs due to use of `x` in closure
125+
| -- - first borrow occurs due to use of `x` in closure
126126
| |
127127
| first mutable borrow occurs here
128128
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
129-
| ^^ - borrow occurs due to use of `x` in closure
129+
| ^^ - second borrow occurs due to use of `x` in closure
130130
| |
131131
| second mutable borrow occurs here
132132
...
@@ -137,11 +137,11 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir)
137137
--> $DIR/borrowck-closures-two-mut.rs:65:24
138138
|
139139
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
140-
| -- - previous borrow occurs due to use of `x` in closure
140+
| -- - first borrow occurs due to use of `x` in closure
141141
| |
142142
| first mutable borrow occurs here
143143
LL | let c2 = to_fn_mut(|| set(&mut *x.f));
144-
| ^^ - borrow occurs due to use of `x` in closure
144+
| ^^ - second borrow occurs due to use of `x` in closure
145145
| |
146146
| second mutable borrow occurs here
147147
...

src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error[E0597]: `books` does not live long enough
2-
--> $DIR/borrowck-escaping-closure-error-1.rs:23:11
2+
--> $DIR/borrowck-escaping-closure-error-1.rs:23:14
33
|
44
LL | spawn(|| books.push(4));
5-
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
5+
| -- ^^^^^ borrowed value does not live long enough
6+
| |
7+
| value captured here
68
LL | //~^ ERROR E0373
79
LL | }
810
| - `books` dropped here while still borrowed

src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error[E0597]: `books` does not live long enough
2-
--> $DIR/borrowck-escaping-closure-error-2.rs:21:14
2+
--> $DIR/borrowck-escaping-closure-error-2.rs:21:17
33
|
44
LL | Box::new(|| books.push(4))
5-
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
5+
| -- ^^^^^ borrowed value does not live long enough
6+
| |
7+
| value captured here
68
LL | //~^ ERROR E0373
79
LL | }
810
| - `books` dropped here while still borrowed

src/test/ui/error-codes/E0504.nll.stderr

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
error[E0505]: cannot move out of `fancy_num` because it is borrowed
22
--> $DIR/E0504.rs:19:13
33
|
4-
LL | let fancy_ref = &fancy_num;
5-
| ---------- borrow of `fancy_num` occurs here
4+
LL | let fancy_ref = &fancy_num;
5+
| ---------- borrow of `fancy_num` occurs here
66
LL |
7-
LL | let x = move || {
8-
| _____________^
9-
LL | | println!("child function: {}", fancy_num.num); //~ ERROR E0504
10-
LL | | };
11-
| |_____^ move out of `fancy_num` occurs here
7+
LL | let x = move || {
8+
| ^^^^^^^ move out of `fancy_num` occurs here
9+
LL | println!("child function: {}", fancy_num.num); //~ ERROR E0504
10+
| --------- move occurs due to use in closure
1211
...
13-
LL | println!("main function: {}", fancy_ref.num);
14-
| ------------- borrow later used here
12+
LL | println!("main function: {}", fancy_ref.num);
13+
| ------------- borrow later used here
1514

1615
error: aborting due to previous error
1716

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let mut test = |foo: &Foo| {
55
| ----------- mutable borrow occurs here
66
LL | println!("access {}", foo.x);
77
LL | ptr = box Foo { x: ptr.x + 1 };
8-
| --- previous borrow occurs due to use of `ptr` in closure
8+
| --- first borrow occurs due to use of `ptr` in closure
99
...
1010
LL | test(&*ptr);
1111
| -----^^^^^-

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0505]: cannot move out of `v` because it is borrowed
22
--> $DIR/issue-11873.rs:14:14
33
|
44
LL | let mut f = || v.push(2);
5-
| ------------ borrow of `v` occurs here
5+
| -- - borrow occurs due to use in closure
6+
| |
7+
| borrow of `v` occurs here
68
LL | let _w = v; //~ ERROR: cannot move out of `v`
79
| ^ move out of `v` occurs here
810
LL |

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ error[E0499]: cannot borrow `y` as mutable more than once at a time
22
--> $DIR/issue-18783.rs:17:21
33
|
44
LL | c.push(Box::new(|| y = 0));
5-
| -- - previous borrow occurs due to use of `y` in closure
5+
| -- - first borrow occurs due to use of `y` in closure
66
| |
77
| first mutable borrow occurs here
88
LL | c.push(Box::new(|| y = 0));
9-
| ^^ - borrow occurs due to use of `y` in closure
9+
| ^^ - second borrow occurs due to use of `y` in closure
1010
| |
1111
| second mutable borrow occurs here
1212
LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time
@@ -17,11 +17,11 @@ error[E0499]: cannot borrow `y` as mutable more than once at a time
1717
--> $DIR/issue-18783.rs:26:29
1818
|
1919
LL | Push::push(&c, Box::new(|| y = 0));
20-
| -- - previous borrow occurs due to use of `y` in closure
20+
| -- - first borrow occurs due to use of `y` in closure
2121
| |
2222
| first mutable borrow occurs here
2323
LL | Push::push(&c, Box::new(|| y = 0));
24-
| ^^ - borrow occurs due to use of `y` in closure
24+
| ^^ - second borrow occurs due to use of `y` in closure
2525
| |
2626
| second mutable borrow occurs here
2727
LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0382]: use of moved value: `x`
22
--> $DIR/issue-24357.rs:16:12
33
|
44
LL | let f = move || { let y = x; };
5-
| ---------------------- value moved here
5+
| ------- - variable moved due to use in closure
6+
| |
7+
| value moved into closure here
68
LL | //~^ NOTE value moved (into closure) here
79
LL | let z = x;
810
| ^ value used here after move

src/test/ui/issue-27282-move-match-input-into-guard.stderr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
error[E0505]: cannot move out of `b` because it is borrowed
2-
--> $DIR/issue-27282-move-match-input-into-guard.rs:26:16
2+
--> $DIR/issue-27282-move-match-input-into-guard.rs:26:17
33
|
44
LL | match b {
55
| - borrow of `b` occurs here
66
LL | &mut false => {},
77
LL | _ if { (|| { let bar = b; *bar = false; })();
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move out of `b` occurs here
8+
| ^^ - move occurs due to use in closure
9+
| |
10+
| move out of `b` occurs here
911
...
1012
LL | &mut true => { println!("You might think we should get here"); },
1113
| --------- borrow later used here
@@ -14,7 +16,9 @@ error[E0382]: use of moved value: `*b`
1416
--> $DIR/issue-27282-move-match-input-into-guard.rs:29:14
1517
|
1618
LL | _ if { (|| { let bar = b; *bar = false; })();
17-
| ----------------------------------- value moved here
19+
| -- - variable moved due to use in closure
20+
| |
21+
| value moved into closure here
1822
...
1923
LL | &mut true => { println!("You might think we should get here"); },
2024
| ^^^^ value used here after move

src/test/ui/issue-27282-mutate-before-diverging-arm-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | match x {
55
| - borrow occurs here
66
...
77
LL | (|| { *x = None; drop(force_fn_once); })();
8-
| ^^ - borrow occurs due to use of `x` in closure
8+
| ^^ - second borrow occurs due to use of `x` in closure
99
| |
1010
| closure construction occurs here
1111
...

0 commit comments

Comments
 (0)