From 65c4e391ee0536142b76e78258550e7ba2f71a0a Mon Sep 17 00:00:00 2001 From: mcarton Date: Sun, 5 Jun 2016 18:07:12 +0200 Subject: [PATCH 1/6] Fix wrong tests and improve some other --- tests/compile-fail/formatting.rs | 16 ++++++++++++---- tests/compile-fail/let_return.rs | 4 ++-- tests/compile-fail/mut_mut.rs | 4 +++- tests/compile-fail/needless_borrow.rs | 2 +- tests/compile-fail/no_effect.rs | 4 ++-- tests/compile-fail/swap.rs | 8 ++++---- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/compile-fail/formatting.rs b/tests/compile-fail/formatting.rs index 14a23111ec7..2436f64d216 100644 --- a/tests/compile-fail/formatting.rs +++ b/tests/compile-fail/formatting.rs @@ -11,24 +11,32 @@ fn foo() -> bool { true } fn main() { // weird `else if` formatting: if foo() { - } if foo() { //~ERROR this looks like an `else if` but the `else` is missing + } if foo() { + //~^ ERROR this looks like an `else if` but the `else` is missing + //~| NOTE add the missing `else` or } let _ = { if foo() { - } if foo() { //~ERROR this looks like an `else if` but the `else` is missing + } if foo() { + //~^ ERROR this looks like an `else if` but the `else` is missing + //~| NOTE add the missing `else` or } else { } }; if foo() { - } else //~ERROR this is an `else if` but the formatting might hide it + } else + //~^ ERROR this is an `else if` but the formatting might hide it + //~| NOTE remove the `else` or if foo() { // the span of the above error should continue here } if foo() { - } //~ERROR this is an `else if` but the formatting might hide it + } + //~^ ERROR this is an `else if` but the formatting might hide it + //~| NOTE remove the `else` or else if foo() { // the span of the above error should continue here } diff --git a/tests/compile-fail/let_return.rs b/tests/compile-fail/let_return.rs index 33d2d6a823a..477786813db 100644 --- a/tests/compile-fail/let_return.rs +++ b/tests/compile-fail/let_return.rs @@ -6,13 +6,13 @@ fn test() -> i32 { let _y = 0; // no warning - let x = 5; //~NOTE + let x = 5; //~NOTE this expression can be directly returned x //~ERROR returning the result of a let binding } fn test_inner() -> i32 { if true { - let x = 5; + let x = 5; //~NOTE this expression can be directly returned x //~ERROR returning the result of a let binding } else { 0 diff --git a/tests/compile-fail/mut_mut.rs b/tests/compile-fail/mut_mut.rs index 8d9bceb0d0d..92344110d2c 100644 --- a/tests/compile-fail/mut_mut.rs +++ b/tests/compile-fail/mut_mut.rs @@ -38,5 +38,7 @@ fn main() { ***y + **x; } - let mut z = mut_ptr!(&mut 3u32); //~ NOTE in this expansion of mut_ptr! + let mut z = mut_ptr!(&mut 3u32); + //~^ NOTE in this expansion of mut_ptr! + //~| NOTE in this expansion of mut_ptr! } diff --git a/tests/compile-fail/needless_borrow.rs b/tests/compile-fail/needless_borrow.rs index 602e1e0859b..88099297b98 100644 --- a/tests/compile-fail/needless_borrow.rs +++ b/tests/compile-fail/needless_borrow.rs @@ -10,7 +10,7 @@ fn x(y: &i32) -> i32 { fn main() { let a = 5; let b = x(&a); - let c = x(&&a); //~ ERROR: needless_borrow + let c = x(&&a); //~ ERROR: this expression borrows a reference that is immediately dereferenced by the compiler let s = &String::from("hi"); let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not let g_val = g(&Vec::new()); // should not error, because `&Vec` derefs to `&[T]` diff --git a/tests/compile-fail/no_effect.rs b/tests/compile-fail/no_effect.rs index c1d9b175428..76c7fa54c01 100644 --- a/tests/compile-fail/no_effect.rs +++ b/tests/compile-fail/no_effect.rs @@ -62,7 +62,7 @@ fn main() { //~|SUGGESTION get_number(); Struct { ..get_struct() }; //~ERROR statement can be reduced //~^HELP replace it with - //~|SUGGESTION get_number(); + //~|SUGGESTION get_struct(); Enum::Tuple(get_number()); //~ERROR statement can be reduced //~^HELP replace it with //~|SUGGESTION get_number(); @@ -74,7 +74,7 @@ fn main() { //~|SUGGESTION 5;get_number(); *&get_number(); //~ERROR statement can be reduced //~^HELP replace it with - //~|SUGGESTION &get_number(); + //~|SUGGESTION get_number(); &get_number(); //~ERROR statement can be reduced //~^HELP replace it with //~|SUGGESTION get_number(); diff --git a/tests/compile-fail/swap.rs b/tests/compile-fail/swap.rs index c4135467556..c8ff2b610d0 100644 --- a/tests/compile-fail/swap.rs +++ b/tests/compile-fail/swap.rs @@ -57,12 +57,12 @@ fn main() { //~| SUGGESTION std::mem::swap(&mut a, &mut b); //~| NOTE or maybe you should use `std::mem::replace`? - let t = a; + ; let t = a; a = b; b = t; //~^^^ ERROR this looks like you are swapping `a` and `b` manually //~| HELP try - //~| SUGGESTION std::mem::swap(&mut a, &mut b); + //~| SUGGESTION ; std::mem::swap(&mut a, &mut b); //~| NOTE or maybe you should use `std::mem::replace`? let mut c = Foo(42); @@ -74,11 +74,11 @@ fn main() { //~| SUGGESTION std::mem::swap(&mut c.0, &mut a); //~| NOTE or maybe you should use `std::mem::replace`? - let t = c.0; + ; let t = c.0; c.0 = a; a = t; //~^^^ ERROR this looks like you are swapping `c.0` and `a` manually //~| HELP try - //~| SUGGESTION std::mem::swap(&mut c.0, &mut a); + //~| SUGGESTION ; std::mem::swap(&mut c.0, &mut a); //~| NOTE or maybe you should use `std::mem::replace`? } From 5b09501d6169b56cba665bf45e379fdc3b5ca42c Mon Sep 17 00:00:00 2001 From: mcarton Date: Tue, 7 Jun 2016 17:49:13 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Fix=20typo=20in=20`REVERSE=5FRANGE=5FLOOP`?= =?UTF-8?q?=E2=80=99s=20suggestion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clippy_lints/src/loops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 3d3c9ab47a4..664ff21994e 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -450,7 +450,7 @@ fn check_for_loop_reverse_range(cx: &LateContext, arg: &Expr, expr: &Expr) { "consider using the following if \ you are attempting to iterate \ over this range in reverse", - format!("({}..{}).rev()` ", end_snippet, start_snippet)); + format!("({}..{}).rev()", end_snippet, start_snippet)); }); } else if eq && limits != ast::RangeLimits::Closed { // if they are equal, it's also problematic - this loop From 3df32cc723cc156e0ed5b507220039a52e0cbfde Mon Sep 17 00:00:00 2001 From: mcarton Date: Tue, 7 Jun 2016 17:58:52 +0200 Subject: [PATCH 3/6] =?UTF-8?q?Fix=20span=20in=20`REVERSE=5FRANGE=5FLOOP`?= =?UTF-8?q?=E2=80=99s=20suggestion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clippy_lints/src/loops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 664ff21994e..e635b34e1de 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -446,7 +446,7 @@ fn check_for_loop_reverse_range(cx: &LateContext, arg: &Expr, expr: &Expr) { expr.span, "this range is empty so this for loop will never run", |db| { - db.span_suggestion(expr.span, + db.span_suggestion(arg.span, "consider using the following if \ you are attempting to iterate \ over this range in reverse", From dd3fd41a037c32098815adab6f6734202f1510c8 Mon Sep 17 00:00:00 2001 From: mcarton Date: Tue, 7 Jun 2016 18:32:26 +0200 Subject: [PATCH 4/6] Use `span_suggestion` for `WHILE_LET_ON_ITERATOR` --- clippy_lints/src/loops.rs | 10 +++- .../absurd-extreme-comparisons.rs | 56 ++++++++++++++----- tests/compile-fail/booleans.rs | 24 +++++--- tests/compile-fail/collapsible_if.rs | 10 +++- tests/compile-fail/for_loop.rs | 10 +++- tests/compile-fail/matches.rs | 27 +++++++-- tests/compile-fail/mut_mut.rs | 1 - 7 files changed, 102 insertions(+), 36 deletions(-) diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index e635b34e1de..5dcea35e5a7 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -290,11 +290,15 @@ impl LateLintPass for LoopsPass { !is_iterator_used_after_while_let(cx, iter_expr) { let iterator = snippet(cx, method_args[0].span, "_"); let loop_var = snippet(cx, pat_args[0].span, "_"); - span_help_and_lint(cx, + span_lint_and_then(cx, WHILE_LET_ON_ITERATOR, expr.span, "this loop could be written as a `for` loop", - &format!("try\nfor {} in {} {{...}}", loop_var, iterator)); + |db| { + db.span_suggestion(expr.span, + "try", + format!("for {} in {} {{ .. }}", loop_var, iterator)); + }); } } } @@ -598,7 +602,7 @@ fn check_for_loop_over_map_kv(cx: &LateContext, pat: &Pat, arg: &Expr, body: &Ex |db| { db.span_suggestion(expr.span, "use the corresponding method", - format!("for {} in {}.{}() {{...}}", + format!("for {} in {}.{}() {{ .. }}", snippet(cx, *pat_span, ".."), snippet(cx, arg_span, ".."), kind)); diff --git a/tests/compile-fail/absurd-extreme-comparisons.rs b/tests/compile-fail/absurd-extreme-comparisons.rs index f1e4a692800..627cd888aac 100644 --- a/tests/compile-fail/absurd-extreme-comparisons.rs +++ b/tests/compile-fail/absurd-extreme-comparisons.rs @@ -8,15 +8,33 @@ fn main() { let u: u32 = 42; - u <= 0; //~ERROR this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - u <= Z; //~ERROR this comparison involving - u < Z; //~ERROR this comparison involving - Z >= u; //~ERROR this comparison involving - Z > u; //~ERROR this comparison involving - u > std::u32::MAX; //~ERROR this comparison involving - u >= std::u32::MAX; //~ERROR this comparison involving - std::u32::MAX < u; //~ERROR this comparison involving - std::u32::MAX <= u; //~ERROR this comparison involving + u <= 0; + //~^ ERROR this comparison involving the minimum or maximum element for this type contains a case that is always true or always false + //~| HELP using u == 0 instead + u <= Z; + //~^ ERROR this comparison involving + //~| HELP using u == Z instead + u < Z; + //~^ ERROR this comparison involving + //~| HELP comparison is always false + Z >= u; + //~^ ERROR this comparison involving + //~| HELP using Z == u instead + Z > u; + //~^ ERROR this comparison involving + //~| HELP comparison is always false + u > std::u32::MAX; + //~^ ERROR this comparison involving + //~| HELP comparison is always false + u >= std::u32::MAX; + //~^ ERROR this comparison involving + //~| HELP using u == std::u32::MAX instead + std::u32::MAX < u; + //~^ ERROR this comparison involving + //~| HELP comparison is always false + std::u32::MAX <= u; + //~^ ERROR this comparison involving + //~| HELP using std::u32::MAX == u instead 1-1 > u; //~^ ERROR this comparison involving @@ -29,13 +47,23 @@ fn main() { //~| HELP because 12 - 2*6 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 12 - 2*6 instead let i: i8 = 0; - i < -127 - 1; //~ERROR this comparison involving - std::i8::MAX >= i; //~ERROR this comparison involving - 3-7 < std::i32::MIN; //~ERROR this comparison involving + i < -127 - 1; + //~^ ERROR this comparison involving + //~| HELP comparison is always false + std::i8::MAX >= i; + //~^ ERROR this comparison involving + //~| HELP comparison is always true + 3-7 < std::i32::MIN; + //~^ ERROR this comparison involving + //~| HELP comparison is always false let b = false; - b >= true; //~ERROR this comparison involving - false > b; //~ERROR this comparison involving + b >= true; + //~^ ERROR this comparison involving + //~| HELP using b == true instead + false > b; + //~^ ERROR this comparison involving + //~| HELP comparison is always false u > 0; // ok diff --git a/tests/compile-fail/booleans.rs b/tests/compile-fail/booleans.rs index fc220d1ac22..193edebf3c4 100644 --- a/tests/compile-fail/booleans.rs +++ b/tests/compile-fail/booleans.rs @@ -52,29 +52,37 @@ fn equality_stuff() { let c: i32 = unimplemented!(); let d: i32 = unimplemented!(); let e: i32 = unimplemented!(); - let _ = a == b && a != b; //~ ERROR this boolean expression contains a logic bug + let _ = a == b && a != b; + //~^ ERROR this boolean expression contains a logic bug //~| HELP this expression can be optimized out //~| HELP it would look like the following //~| SUGGESTION let _ = false; - let _ = a == b && c == 5 && a == b; //~ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = a == b && c == 5; - let _ = a == b && c == 5 && b == a; //~ ERROR this boolean expression can be simplified + let _ = a == b && c == 5 && a == b; + //~^ ERROR this boolean expression can be simplified //~| HELP try //~| SUGGESTION let _ = a == b && c == 5; //~| HELP try //~| SUGGESTION let _ = !(c != 5 || a != b); - let _ = a < b && a >= b; //~ ERROR this boolean expression contains a logic bug + let _ = a == b && c == 5 && b == a; + //~^ ERROR this boolean expression can be simplified + //~| HELP try + //~| SUGGESTION let _ = a == b && c == 5; + //~| HELP try + //~| SUGGESTION let _ = !(c != 5 || a != b); + let _ = a < b && a >= b; + //~^ ERROR this boolean expression contains a logic bug //~| HELP this expression can be optimized out //~| HELP it would look like the following //~| SUGGESTION let _ = false; - let _ = a > b && a <= b; //~ ERROR this boolean expression contains a logic bug + let _ = a > b && a <= b; + //~^ ERROR this boolean expression contains a logic bug //~| HELP this expression can be optimized out //~| HELP it would look like the following //~| SUGGESTION let _ = false; let _ = a > b && a == b; - let _ = a != b || !(a != b || c == d); //~ ERROR this boolean expression can be simplified + let _ = a != b || !(a != b || c == d); + //~^ ERROR this boolean expression can be simplified //~| HELP try //~| SUGGESTION let _ = c != d || a != b; //~| HELP try diff --git a/tests/compile-fail/collapsible_if.rs b/tests/compile-fail/collapsible_if.rs index 3bf4128347a..34c55499612 100644 --- a/tests/compile-fail/collapsible_if.rs +++ b/tests/compile-fail/collapsible_if.rs @@ -5,13 +5,19 @@ fn main() { let x = "hello"; let y = "world"; - if x == "hello" { //~ERROR this if statement can be collapsed + if x == "hello" { + //~^ ERROR this if statement can be collapsed + //~| HELP try + //~| SUGGESTION if x == "hello" && y == "world" { if y == "world" { println!("Hello world!"); } } - if x == "hello" || x == "world" { //~ERROR this if statement can be collapsed + if x == "hello" || x == "world" { + //~^ ERROR this if statement can be collapsed + //~| HELP try + //~| SUGGESTION if (x == "hello" || x == "world") && (y == "world" || y == "hello") { if y == "world" || y == "hello" { println!("Hello world!"); } diff --git a/tests/compile-fail/for_loop.rs b/tests/compile-fail/for_loop.rs index 2f164d1e569..d35beb617e0 100644 --- a/tests/compile-fail/for_loop.rs +++ b/tests/compile-fail/for_loop.rs @@ -200,11 +200,17 @@ fn main() { } // testing that the empty range lint folds constants - for i in 10..5+4 { //~ERROR this range is empty so this for loop will never run + for i in 10..5+4 { + //~^ ERROR this range is empty so this for loop will never run + //~| HELP if you are attempting to iterate over this range in reverse + //~| SUGGESTION for i in (5+4..10).rev() { println!("{}", i); } - for i in (5+2)..(3-1) { //~ERROR this range is empty so this for loop will never run + for i in (5+2)..(3-1) { + //~^ ERROR this range is empty so this for loop will never run + //~| HELP if you are attempting to iterate over this range in reverse + //~| SUGGESTION for i in ((3-1)..(5+2)).rev() { println!("{}", i); } diff --git a/tests/compile-fail/matches.rs b/tests/compile-fail/matches.rs index affa7e4e86e..650b5917fdc 100644 --- a/tests/compile-fail/matches.rs +++ b/tests/compile-fail/matches.rs @@ -100,28 +100,43 @@ fn single_match_know_enum() { fn match_bool() { let test: bool = true; - match test { //~ ERROR you seem to be trying to match on a boolean expression + match test { + //~^ ERROR you seem to be trying to match on a boolean expression + //~| HELP try + //~| SUGGESTION if test { 0 } else { 42 }; true => 0, false => 42, }; let option = 1; - match option == 1 { //~ ERROR you seem to be trying to match on a boolean expression + match option == 1 { + //~^ ERROR you seem to be trying to match on a boolean expression + //~| HELP try + //~| SUGGESTION if option == 1 { 1 } else { 0 }; true => 1, false => 0, }; - match test { //~ ERROR you seem to be trying to match on a boolean expression + match test { + //~^ ERROR you seem to be trying to match on a boolean expression + //~| HELP try + //~^^ SUGGESTION if !test { println!("Noooo!"); }; true => (), false => { println!("Noooo!"); } }; - match test { //~ ERROR you seem to be trying to match on a boolean expression + match test { + //~^ ERROR you seem to be trying to match on a boolean expression + //~| HELP try + //~^^ SUGGESTION if !test { println!("Noooo!"); }; false => { println!("Noooo!"); } _ => (), }; - match test { //~ ERROR you seem to be trying to match on a boolean expression + match test { + //~^ ERROR you seem to be trying to match on a boolean expression + //~| HELP try + //~| SUGGESTION if test { println!("Yes!"); } else { println!("Noooo!"); }; false => { println!("Noooo!"); } true => { println!("Yes!"); } }; @@ -216,7 +231,7 @@ fn overlapping() { 11 ... 50 => println!("0 ... 10"), _ => (), } - + if let None = Some(42) { // nothing } else if let None = Some(42) { diff --git a/tests/compile-fail/mut_mut.rs b/tests/compile-fail/mut_mut.rs index 92344110d2c..21c0dcee511 100644 --- a/tests/compile-fail/mut_mut.rs +++ b/tests/compile-fail/mut_mut.rs @@ -40,5 +40,4 @@ fn main() { let mut z = mut_ptr!(&mut 3u32); //~^ NOTE in this expansion of mut_ptr! - //~| NOTE in this expansion of mut_ptr! } From 1f419a29869eb4788a14e894219d732542cae295 Mon Sep 17 00:00:00 2001 From: mcarton Date: Tue, 7 Jun 2016 18:33:11 +0200 Subject: [PATCH 5/6] Add missing suggestions and help message to tests --- tests/compile-fail/methods.rs | 12 +++++++++--- tests/compile-fail/needless_return.rs | 25 ++++++++++++++++++++----- tests/compile-fail/strings.rs | 7 +++++-- tests/compile-fail/while_loop.rs | 20 ++++++++++++++++---- 4 files changed, 50 insertions(+), 14 deletions(-) diff --git a/tests/compile-fail/methods.rs b/tests/compile-fail/methods.rs index 78ffbb1a58a..89267462f5d 100644 --- a/tests/compile-fail/methods.rs +++ b/tests/compile-fail/methods.rs @@ -356,13 +356,19 @@ fn starts_with() { fn use_extend_from_slice() { let mut v : Vec<&'static str> = vec![]; - v.extend(&["Hello", "World"]); //~ERROR use of `extend` + v.extend(&["Hello", "World"]); + //~^ ERROR use of `extend` + //~| HELP try this + //~| SUGGESTION v.extend_from_slice(&["Hello", "World"]); v.extend(&vec!["Some", "more"]); - //~^ERROR use of `extend` + //~^ ERROR use of `extend` //~| HELP try this //~| SUGGESTION v.extend_from_slice(&vec!["Some", "more"]); - v.extend(vec!["And", "even", "more"].iter()); //~ERROR use of `extend` + v.extend(vec!["And", "even", "more"].iter()); + //~^ ERROR use of `extend` + //~| HELP try this + //FIXME: the suggestion if broken because of the macro let o : Option<&'static str> = None; v.extend(o); v.extend(Some("Bye")); diff --git a/tests/compile-fail/needless_return.rs b/tests/compile-fail/needless_return.rs index fe29d991661..80fed2818ef 100644 --- a/tests/compile-fail/needless_return.rs +++ b/tests/compile-fail/needless_return.rs @@ -23,26 +23,41 @@ fn test_no_semicolon() -> bool { fn test_if_block() -> bool { if true { - return true; //~ERROR unneeded return statement + return true; + //~^ ERROR unneeded return statement + //~| HELP remove `return` as shown + //~| SUGGESTION true } else { - return false; //~ERROR unneeded return statement + return false; + //~^ ERROR unneeded return statement + //~| HELP remove `return` as shown + //~| SUGGESTION false } } fn test_match(x: bool) -> bool { match x { true => { - return false; //~ERROR unneeded return statement + return false; + //~^ ERROR unneeded return statement + //~| HELP remove `return` as shown + //~| SUGGESTION false } false => { - return true; //~ERROR unneeded return statement + return true; + //~^ ERROR unneeded return statement + //~| HELP remove `return` as shown + //~| SUGGESTION true } } } fn test_closure() { let _ = || { - return true; //~ERROR unneeded return statement + return true; + //~^ ERROR unneeded return statement + //~| HELP remove `return` as shown + //~| SUGGESTION true }; } diff --git a/tests/compile-fail/strings.rs b/tests/compile-fail/strings.rs index 542b6db4abb..d08f8b891bc 100644 --- a/tests/compile-fail/strings.rs +++ b/tests/compile-fail/strings.rs @@ -63,8 +63,11 @@ fn main() { add_assign_only(); both(); - // the add is only caught for String + // the add is only caught for `String` let mut x = 1; - x = x + 1; //~ WARN assign_op_pattern + ; x = x + 1; + //~^ WARN assign_op_pattern + //~| HELP replace + //~| SUGGESTION ; x += 1; assert_eq!(2, x); } diff --git a/tests/compile-fail/while_loop.rs b/tests/compile-fail/while_loop.rs index 7c5582ba9bf..4c1090876b4 100644 --- a/tests/compile-fail/while_loop.rs +++ b/tests/compile-fail/while_loop.rs @@ -80,17 +80,26 @@ fn main() { } let mut iter = 1..20; - while let Option::Some(x) = iter.next() { //~ERROR this loop could be written as a `for` loop + while let Option::Some(x) = iter.next() { + //~^ ERROR this loop could be written as a `for` loop + //~| HELP try + //~| SUGGESTION for x in iter { println!("{}", x); } let mut iter = 1..20; - while let Some(x) = iter.next() { //~ERROR this loop could be written as a `for` loop + while let Some(x) = iter.next() { + //~^ ERROR this loop could be written as a `for` loop + //~| HELP try + //~| SUGGESTION for x in iter { println!("{}", x); } let mut iter = 1..20; - while let Some(_) = iter.next() {} //~ERROR this loop could be written as a `for` loop + while let Some(_) = iter.next() {} + //~^ ERROR this loop could be written as a `for` loop + //~| HELP try + //~| SUGGESTION for _ in iter { let mut iter = 1..20; while let None = iter.next() {} // this is fine (if nonsensical) @@ -130,7 +139,10 @@ fn main() { // cause this function to trigger it fn no_panic(slice: &[T]) { let mut iter = slice.iter(); - loop { //~ERROR + loop { + //~^ ERROR + //~| HELP try + //~| SUGGESTION while let Some(ele) = iter.next() { .. } let _ = match iter.next() { Some(ele) => ele, None => break From 35a22bc3f40e1f3c1c73ecf1a960cf0c71374e75 Mon Sep 17 00:00:00 2001 From: mcarton Date: Tue, 7 Jun 2016 18:33:29 +0200 Subject: [PATCH 6/6] Bump `compiletest_rs` to 0.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 81ef9a08bf7..0bfd05a0de4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ clippy_lints = { version = "0.0.74", path = "clippy_lints" } rustc-serialize = "0.3" [dev-dependencies] -compiletest_rs = "0.1.0" +compiletest_rs = "0.2.0" lazy_static = "0.1.15" regex = "0.1.56"