Dedup suggestions

This commit is contained in:
ashtneoi 2018-08-13 03:17:53 -07:00
parent 40b5118c8a
commit 20ae08bda6
3 changed files with 654 additions and 105 deletions

View file

@ -10,13 +10,16 @@
#![feature(nll)]
#[derive(Clone)]
enum Either {
One(X),
Two(X),
}
#[derive(Clone)]
struct X(Y);
#[derive(Clone)]
struct Y;
pub fn main() {
@ -338,4 +341,118 @@ pub fn main() {
//~| SUGGESTION Either::One(_t)
Either::Two(_t) => (),
}
// --------
let &(X(_t), X(_u)) = &(x.clone(), x.clone());
//~^ ERROR cannot move
//~| HELP consider removing the `&`
//~| SUGGESTION (X(_t), X(_u))
if let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
//~^ ERROR cannot move
//~| HELP consider removing the `&`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
while let &(Either::One(_t), Either::Two(_u)) = &(e.clone(), e.clone()) { }
//~^ ERROR cannot move
//~| HELP consider removing the `&`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
match &(e.clone(), e.clone()) {
//~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&(Either::Two(_t), Either::One(_u)) => (),
//~^ HELP consider removing the `&`
//~| SUGGESTION (Either::Two(_t), Either::One(_u))
_ => (),
}
match &(e.clone(), e.clone()) {
//~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u))
//~^ HELP consider removing the `&`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
| &(Either::Two(_t), Either::One(_u)) => (),
// FIXME: would really like a suggestion here too
_ => (),
}
match &(e.clone(), e.clone()) {
//~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&(Either::Two(ref _t), Either::One(ref _u)) => (),
_ => (),
}
match &(e.clone(), e.clone()) {
//~^ ERROR cannot move
&(Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
(Either::Two(_t), Either::One(_u)) => (),
_ => (),
}
fn f3(&(X(_t), X(_u)): &(X, X)) { }
//~^ ERROR cannot move
//~| HELP consider removing the `&`
//~| SUGGESTION (X(_t), X(_u))
let &mut (X(_t), X(_u)) = &mut (xm.clone(), xm.clone());
//~^ ERROR cannot move
//~| HELP consider removing the `&mut`
//~| SUGGESTION (X(_t), X(_u))
if let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
//~^ ERROR cannot move
//~| HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
while let &mut (Either::One(_t), Either::Two(_u)) = &mut (em.clone(), em.clone()) { }
//~^ ERROR cannot move
//~| HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&mut (Either::Two(_t), Either::One(_u)) => (),
//~^ HELP consider removing the `&mut`
//~| SUGGESTION (Either::Two(_t), Either::One(_u))
_ => (),
}
match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u))
//~^ HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
| &mut (Either::Two(_t), Either::One(_u)) => (),
// FIXME: would really like a suggestion here too
_ => (),
}
match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&mut (Either::Two(ref _t), Either::One(ref _u)) => (),
_ => (),
}
match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
&mut (Either::Two(ref mut _t), Either::One(ref mut _u)) => (),
_ => (),
}
match &mut (em.clone(), em.clone()) {
//~^ ERROR cannot move
&mut (Either::One(_t), Either::Two(_u)) => (),
//~^ HELP consider removing the `&mut`
//~| SUGGESTION (Either::One(_t), Either::Two(_u))
(Either::Two(_t), Either::One(_u)) => (),
_ => (),
}
fn f4(&mut (X(_t), X(_u)): &mut (X, X)) { }
//~^ ERROR cannot move
//~| HELP consider removing the `&mut`
//~| SUGGESTION (X(_t), X(_u))
}

File diff suppressed because it is too large Load diff