Skip to content

Commit a5e855b

Browse files
committed
Update test for issue 17780 since diagnostic message have changed
The test was also renamed to be more descriptive.
1 parent d7d0057 commit a5e855b

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/test/compile-fail/issue-17780.rs renamed to src/test/compile-fail/borrow-immutable-upvar-mutation.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,32 @@
1010

1111
#![feature(unboxed_closures, overloaded_calls)]
1212

13+
// Tests that we can't assign to or mutably borrow upvars from `Fn`
14+
// closures (issue #17780)
15+
1316
fn set(x: &mut uint) { *x = 5; }
1417

1518
fn main() {
1619
// By-ref captures
1720
{
1821
let mut x = 0u;
19-
let _f = |&:| x = 42;
20-
//~^ ERROR cannot assign to data in a free
21-
// variable from an immutable unboxed closure
22+
let _f = |&:| x = 42; //~ ERROR cannot assign
2223

2324
let mut y = 0u;
24-
let _g = |&:| set(&mut y);
25-
//~^ ERROR cannot borrow data mutably in a free
26-
// variable from an immutable unboxed closure
25+
let _g = |&:| set(&mut y); //~ ERROR cannot borrow
2726

2827
let mut z = 0u;
29-
let _h = |&mut:| { set(&mut z); |&:| z = 42; };
30-
//~^ ERROR cannot assign to data in a
31-
// free variable from an immutable unboxed closure
28+
let _h = |&mut:| { set(&mut z); |&:| z = 42; }; //~ ERROR cannot assign
3229
}
3330
// By-value captures
3431
{
3532
let mut x = 0u;
36-
let _f = move |&:| x = 42;
37-
//~^ ERROR cannot assign to data in a free
38-
// variable from an immutable unboxed closure
33+
let _f = move |&:| x = 42; //~ ERROR cannot assign
3934

4035
let mut y = 0u;
41-
let _g = move |&:| set(&mut y);
42-
//~^ ERROR cannot borrow data mutably in a free
43-
// variable from an immutable unboxed closure
36+
let _g = move |&:| set(&mut y); //~ ERROR cannot borrow
4437

4538
let mut z = 0u;
46-
let _h = move |&mut:| { set(&mut z); move |&:| z = 42; };
47-
//~^ ERROR cannot assign to data in a free
48-
// variable from an immutable unboxed closure
39+
let _h = move |&mut:| { set(&mut z); move |&:| z = 42; }; //~ ERROR cannot assign
4940
}
5041
}

0 commit comments

Comments
 (0)