Skip to content

Commit 0023dd9

Browse files
committed
Split tests more and bless them again
1 parent f335fb0 commit 0023dd9

File tree

5 files changed

+653
-602
lines changed

5 files changed

+653
-602
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(nll)]
12+
13+
#[derive(Clone)]
14+
enum Either {
15+
One(X),
16+
Two(X),
17+
}
18+
19+
#[derive(Clone)]
20+
struct X(Y);
21+
22+
#[derive(Clone)]
23+
struct Y;
24+
25+
26+
pub fn main() {
27+
let e = Either::One(X(Y));
28+
let mut em = Either::One(X(Y));
29+
30+
let r = &e;
31+
let rm = &mut Either::One(X(Y));
32+
33+
let x = X(Y);
34+
let mut xm = X(Y);
35+
36+
let s = &x;
37+
let sm = &mut X(Y);
38+
39+
let ve = vec![Either::One(X(Y))];
40+
41+
let vr = &ve;
42+
let vrm = &mut vec![Either::One(X(Y))];
43+
44+
let vx = vec![X(Y)];
45+
46+
let vs = &vx;
47+
let vsm = &mut vec![X(Y)];
48+
49+
// -------- test for duplicate suggestions --------
50+
51+
let &(X(_t), X(_u)) = &(x.clone(), x.clone());
52+
//~^ ERROR cannot move
53+
//~| HELP consider removing the `&`
54+
//~| SUGGESTION (X(_t), X(_u))
55+
if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
56+
//~^ ERROR cannot move
57+
//~| HELP consider removing the `&`
58+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
59+
while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
60+
//~^ ERROR cannot move
61+
//~| HELP consider removing the `&`
62+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
63+
match &(e.clone(), e.clone()) {
64+
//~^ ERROR cannot move
65+
&(Either::One(_t), Either::Two(_u)) => (),
66+
//~^ HELP consider removing the `&`
67+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
68+
&(Either::Two(_t), Either::One(_u)) => (),
69+
//~^ HELP consider removing the `&`
70+
//~| SUGGESTION (Either::Two(_t), Either::One(_u))
71+
_ => (),
72+
}
73+
match &(e.clone(), e.clone()) {
74+
//~^ ERROR cannot move
75+
&(Either::One(_t), Either::Two(_u))
76+
//~^ HELP consider removing the `&`
77+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
78+
| &(Either::Two(_t), Either::One(_u)) => (),
79+
// FIXME: would really like a suggestion here too
80+
_ => (),
81+
}
82+
match &(e.clone(), e.clone()) {
83+
//~^ ERROR cannot move
84+
&(Either::One(_t), Either::Two(_u)) => (),
85+
//~^ HELP consider removing the `&`
86+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
87+
&(Either::Two(ref _t), Either::One(ref _u)) => (),
88+
_ => (),
89+
}
90+
match &(e.clone(), e.clone()) {
91+
//~^ ERROR cannot move
92+
&(Either::One(_t), Either::Two(_u)) => (),
93+
//~^ HELP consider removing the `&`
94+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
95+
(Either::Two(_t), Either::One(_u)) => (),
96+
_ => (),
97+
}
98+
fn f5(&(X(_t), X(_u)): &(X, X)) { }
99+
//~^ ERROR cannot move
100+
//~| HELP consider removing the `&`
101+
//~| SUGGESTION (X(_t), X(_u))
102+
103+
let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
104+
//~^ ERROR cannot move
105+
//~| HELP consider removing the `&mut`
106+
//~| SUGGESTION (X(_t), X(_u))
107+
if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
108+
//~^ ERROR cannot move
109+
//~| HELP consider removing the `&mut`
110+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
111+
while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
112+
//~^ ERROR cannot move
113+
//~| HELP consider removing the `&mut`
114+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
115+
match &mut (em.clone(), em.clone()) {
116+
//~^ ERROR cannot move
117+
&mut (Either::One(_t), Either::Two(_u)) => (),
118+
//~^ HELP consider removing the `&mut`
119+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
120+
&mut (Either::Two(_t), Either::One(_u)) => (),
121+
//~^ HELP consider removing the `&mut`
122+
//~| SUGGESTION (Either::Two(_t), Either::One(_u))
123+
_ => (),
124+
}
125+
match &mut (em.clone(), em.clone()) {
126+
//~^ ERROR cannot move
127+
&mut (Either::One(_t), Either::Two(_u))
128+
//~^ HELP consider removing the `&mut`
129+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
130+
| &mut (Either::Two(_t), Either::One(_u)) => (),
131+
// FIXME: would really like a suggestion here too
132+
_ => (),
133+
}
134+
match &mut (em.clone(), em.clone()) {
135+
//~^ ERROR cannot move
136+
&mut (Either::One(_t), Either::Two(_u)) => (),
137+
//~^ HELP consider removing the `&mut`
138+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
139+
&mut (Either::Two(ref _t), Either::One(ref _u)) => (),
140+
_ => (),
141+
}
142+
match &mut (em.clone(), em.clone()) {
143+
//~^ ERROR cannot move
144+
&mut (Either::One(_t), Either::Two(_u)) => (),
145+
//~^ HELP consider removing the `&mut`
146+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
147+
&mut (Either::Two(ref mut _t), Either::One(ref mut _u)) => (),
148+
_ => (),
149+
}
150+
match &mut (em.clone(), em.clone()) {
151+
//~^ ERROR cannot move
152+
&mut (Either::One(_t), Either::Two(_u)) => (),
153+
//~^ HELP consider removing the `&mut`
154+
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
155+
(Either::Two(_t), Either::One(_u)) => (),
156+
_ => (),
157+
}
158+
fn f6(&mut (X(_t), X(_u)): &mut (X, X)) { }
159+
//~^ ERROR cannot move
160+
//~| HELP consider removing the `&mut`
161+
//~| SUGGESTION (X(_t), X(_u))
162+
}

0 commit comments

Comments
 (0)