|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -// revisions: lexical nll |
12 |
| -#![cfg_attr(nll, feature(nll))] |
| 11 | + |
| 12 | + |
13 | 13 |
|
14 | 14 | // Exercise the unused_mut attribute in some positive and negative cases
|
15 | 15 |
|
|
21 | 21 |
|
22 | 22 | fn main() {
|
23 | 23 | // negative cases
|
24 |
| - let mut a = 3; //[lexical]~ ERROR: variable does not need to be mutable |
25 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
26 |
| - let mut a = 2; //[lexical]~ ERROR: variable does not need to be mutable |
27 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
28 |
| - let mut b = 3; //[lexical]~ ERROR: variable does not need to be mutable |
29 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
30 |
| - let mut a = vec![3]; //[lexical]~ ERROR: variable does not need to be mutable |
31 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
32 |
| - let (mut a, b) = (1, 2); //[lexical]~ ERROR: variable does not need to be mutable |
33 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
34 |
| - let mut a; //[lexical]~ ERROR: variable does not need to be mutable |
35 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 24 | + let mut a = 3; //~ ERROR: variable does not need to be mutable |
| 25 | + |
| 26 | + let mut a = 2; //~ ERROR: variable does not need to be mutable |
| 27 | + |
| 28 | + let mut b = 3; //~ ERROR: variable does not need to be mutable |
| 29 | + |
| 30 | + let mut a = vec![3]; //~ ERROR: variable does not need to be mutable |
| 31 | + |
| 32 | + let (mut a, b) = (1, 2); //~ ERROR: variable does not need to be mutable |
| 33 | + |
| 34 | + let mut a; //~ ERROR: variable does not need to be mutable |
| 35 | + |
36 | 36 | a = 3;
|
37 | 37 |
|
38 |
| - let mut b; //[lexical]~ ERROR: variable does not need to be mutable |
39 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 38 | + let mut b; //~ ERROR: variable does not need to be mutable |
| 39 | + |
40 | 40 | if true {
|
41 | 41 | b = 3;
|
42 | 42 | } else {
|
43 | 43 | b = 4;
|
44 | 44 | }
|
45 | 45 |
|
46 | 46 | match 30 {
|
47 |
| - mut x => {} //[lexical]~ ERROR: variable does not need to be mutable |
48 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 47 | + mut x => {} //~ ERROR: variable does not need to be mutable |
| 48 | + |
49 | 49 | }
|
50 | 50 | match (30, 2) {
|
51 |
| - (mut x, 1) | //[lexical]~ ERROR: variable does not need to be mutable |
52 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 51 | + (mut x, 1) | //~ ERROR: variable does not need to be mutable |
| 52 | + |
53 | 53 | (mut x, 2) |
|
54 | 54 | (mut x, 3) => {
|
55 | 55 | }
|
56 | 56 | _ => {}
|
57 | 57 | }
|
58 | 58 |
|
59 |
| - let x = |mut y: isize| 10; //[lexical]~ ERROR: variable does not need to be mutable |
60 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
61 |
| - fn what(mut foo: isize) {} //[lexical]~ ERROR: variable does not need to be mutable |
62 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 59 | + let x = |mut y: isize| 10; //~ ERROR: variable does not need to be mutable |
| 60 | + |
| 61 | + fn what(mut foo: isize) {} //~ ERROR: variable does not need to be mutable |
| 62 | + |
| 63 | + |
| 64 | + let mut a = &mut 5; //~ ERROR: variable does not need to be mutable |
63 | 65 |
|
64 |
| - let mut a = &mut 5; //[lexical]~ ERROR: variable does not need to be mutable |
65 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
66 | 66 | *a = 4;
|
67 | 67 |
|
68 | 68 | let mut a = 5;
|
69 |
| - let mut b = (&mut a,); //[lexical]~ ERROR: variable does not need to be mutable |
70 |
| - *b.0 = 4; //[nll]~^ ERROR: variable does not need to be mutable |
| 69 | + let mut b = (&mut a,); //~ ERROR: variable does not need to be mutable |
| 70 | + *b.0 = 4; |
| 71 | + |
| 72 | + let mut x = &mut 1; //~ ERROR: variable does not need to be mutable |
71 | 73 |
|
72 |
| - let mut x = &mut 1; //[lexical]~ ERROR: variable does not need to be mutable |
73 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
74 | 74 | let mut f = || {
|
75 | 75 | *x += 1;
|
76 | 76 | };
|
77 | 77 | f();
|
78 | 78 |
|
79 | 79 | fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] {
|
80 |
| - &mut arg[..] //[lexical]~^ ERROR: variable does not need to be mutable |
81 |
| - //[nll]~^^ ERROR: variable does not need to be mutable |
| 80 | + &mut arg[..] //~^ ERROR: variable does not need to be mutable |
| 81 | + |
82 | 82 | }
|
83 | 83 |
|
84 |
| - let mut v : &mut Vec<()> = &mut vec![]; //[lexical]~ ERROR: variable does not need to be mutable |
85 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 84 | + let mut v : &mut Vec<()> = &mut vec![]; //~ ERROR: variable does not need to be mutable |
| 85 | + |
86 | 86 | v.push(());
|
87 | 87 |
|
88 | 88 | // positive cases
|
@@ -140,6 +140,6 @@ fn foo(mut a: isize) {
|
140 | 140 | fn bar() {
|
141 | 141 | #[allow(unused_mut)]
|
142 | 142 | let mut a = 3;
|
143 |
| - let mut b = vec![2]; //[lexical]~ ERROR: variable does not need to be mutable |
144 |
| - //[nll]~^ ERROR: variable does not need to be mutable |
| 143 | + let mut b = vec![2]; //~ ERROR: variable does not need to be mutable |
| 144 | + |
145 | 145 | }
|
0 commit comments