Skip to content

Commit 12af36a

Browse files
committedAug 3, 2018
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
...

‎src/test/ui/issue-27282-mutate-before-diverging-arm-2.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
...

‎src/test/ui/issue-4335.nll.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ LL | id(Box::new(|| *v))
55
| ^^ cannot move out of captured variable in an `FnMut` closure
66

77
error[E0597]: `v` does not live long enough
8-
--> $DIR/issue-4335.rs:16:17
8+
--> $DIR/issue-4335.rs:16:21
99
|
1010
LL | id(Box::new(|| *v))
11-
| ^^^^^ borrowed value does not live long enough
11+
| -- ^ borrowed value does not live long enough
12+
| |
13+
| value captured here
1214
...
1315
LL | }
1416
| - `v` dropped here while still borrowed

‎src/test/ui/issue-6801.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 `x` because it is borrowed
22
--> $DIR/issue-6801.rs:29:13
33
|
44
LL | let sq = || { *x * *x };
5-
| -------------- borrow of `x` occurs here
5+
| -- - borrow occurs due to use in closure
6+
| |
7+
| borrow of `x` occurs here
68
LL |
79
LL | twice(x); //~ ERROR: cannot move out of
810
| ^ move out of `x` occurs here

‎src/test/ui/nll/closure-captures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![allow(unused)]
1414
#![feature(nll)]
1515

16-
// Should have one error per assigment
16+
// Should have one error per assignment
1717

1818
fn one_closure(x: i32) {
1919
||

‎src/test/ui/nll/closure-requirements/escape-upvar-nested.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ fn test() {
2727
{
2828
let y = 22;
2929

30-
let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
31-
let mut closure1 = || p = &y;
30+
let mut closure = || {
31+
let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
3232
closure1();
3333
};
3434

‎src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
note: External requirements
22
--> $DIR/escape-upvar-nested.rs:31:32
33
|
4-
LL | let mut closure1 = || p = &y;
4+
LL | let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
55
| ^^^^^^^^^
66
|
77
= note: defining type: DefId(0/1:10 ~ escape_upvar_nested[317d]::test[0]::{{closure}}[0]::{{closure}}[0]) with closure substs [
@@ -16,9 +16,9 @@ LL | let mut closure1 = || p = &y;
1616
note: External requirements
1717
--> $DIR/escape-upvar-nested.rs:30:27
1818
|
19-
LL | let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
19+
LL | let mut closure = || {
2020
| ___________________________^
21-
LL | | let mut closure1 = || p = &y;
21+
LL | | let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
2222
LL | | closure1();
2323
LL | | };
2424
| |_________^
@@ -47,20 +47,18 @@ LL | | }
4747
= note: defining type: DefId(0/0:3 ~ escape_upvar_nested[317d]::test[0]) with substs []
4848

4949
error[E0597]: `y` does not live long enough
50-
--> $DIR/escape-upvar-nested.rs:30:27
50+
--> $DIR/escape-upvar-nested.rs:31:40
5151
|
52-
LL | let mut closure = || { //~ ERROR `y` does not live long enough [E0597]
53-
| ___________________________^
54-
LL | | let mut closure1 = || p = &y;
55-
LL | | closure1();
56-
LL | | };
57-
| |_________^ borrowed value does not live long enough
52+
LL | let mut closure = || {
53+
| -- value captured here
54+
LL | let mut closure1 = || p = &y; //~ ERROR `y` does not live long enough [E0597]
55+
| ^ borrowed value does not live long enough
5856
...
59-
LL | }
60-
| - `y` dropped here while still borrowed
57+
LL | }
58+
| - `y` dropped here while still borrowed
6159
LL |
62-
LL | deref(p);
63-
| - borrow later used here
60+
LL | deref(p);
61+
| - borrow later used here
6462

6563
error: aborting due to previous error
6664

‎src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ LL | | }
2828
= note: defining type: DefId(0/0:3 ~ escape_upvar_ref[317d]::test[0]) with substs []
2929

3030
error[E0597]: `y` does not live long enough
31-
--> $DIR/escape-upvar-ref.rs:33:27
31+
--> $DIR/escape-upvar-ref.rs:33:35
3232
|
3333
LL | let mut closure = || p = &y;
34-
| ^^^^^^^^^ borrowed value does not live long enough
34+
| -- ^ borrowed value does not live long enough
35+
| |
36+
| value captured here
3537
...
3638
LL | }
3739
| - `y` dropped here while still borrowed

‎src/test/ui/nll/issue-51268.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | self.thing.bar(|| {
88
| ||
99
LL | || //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502]
1010
LL | || &self.number;
11-
| || ---- previous borrow occurs due to use of `self` in closure
11+
| || ---- first borrow occurs due to use of `self` in closure
1212
LL | || });
1313
| || ^
1414
| ||__________|

0 commit comments

Comments
 (0)
Please sign in to comment.