From e18a250139200d40390e46797bb93564108b2d6f Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 12:38:17 +0100 Subject: [PATCH 01/55] clean tests/ui/absurd-extreme-comparisons.rs Cleaning the empty lines for clarity. --- tests/ui/absurd-extreme-comparisons.rs | 41 ------------ tests/ui/absurd-extreme-comparisons.stderr | 72 +++++++++++----------- 2 files changed, 36 insertions(+), 77 deletions(-) diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index 3482237bd0b..4bd1aa35dc9 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -6,68 +6,27 @@ fn main() { const Z: u32 = 0; - let u: u32 = 42; - u <= 0; - - u <= Z; - - u < Z; - - Z >= u; - - Z > u; - - u > std::u32::MAX; - - u >= std::u32::MAX; - - std::u32::MAX < u; - - std::u32::MAX <= u; - - - 1-1 > u; - - u >= !0; - - u <= 12 - 2*6; - - - let i: i8 = 0; i < -127 - 1; - - std::i8::MAX >= i; - - 3-7 < std::i32::MIN; - - - let b = false; b >= true; - - false > b; - - - u > 0; // ok - // this is handled by unit_cmp () < {}; } diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 834bcf03fe1..25fabf0aafd 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,7 +1,7 @@ error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:12:5 + --> $DIR/absurd-extreme-comparisons.rs:10:5 | -12 | u <= 0; +10 | u <= 0; | ^^^^^^ | note: lint level defined here @@ -12,137 +12,137 @@ note: lint level defined here = help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:15:5 + --> $DIR/absurd-extreme-comparisons.rs:11:5 | -15 | u <= Z; +11 | u <= Z; | ^^^^^^ | = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:18:5 + --> $DIR/absurd-extreme-comparisons.rs:12:5 | -18 | u < Z; +12 | u < Z; | ^^^^^ | = help: because Z is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:21:5 + --> $DIR/absurd-extreme-comparisons.rs:13:5 | -21 | Z >= u; +13 | Z >= u; | ^^^^^^ | = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:24:5 + --> $DIR/absurd-extreme-comparisons.rs:14:5 | -24 | Z > u; +14 | Z > u; | ^^^^^ | = help: because Z is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:27:5 + --> $DIR/absurd-extreme-comparisons.rs:15:5 | -27 | u > std::u32::MAX; +15 | u > std::u32::MAX; | ^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:30:5 + --> $DIR/absurd-extreme-comparisons.rs:16:5 | -30 | u >= std::u32::MAX; +16 | u >= std::u32::MAX; | ^^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:33:5 + --> $DIR/absurd-extreme-comparisons.rs:17:5 | -33 | std::u32::MAX < u; +17 | std::u32::MAX < u; | ^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:36:5 + --> $DIR/absurd-extreme-comparisons.rs:18:5 | -36 | std::u32::MAX <= u; +18 | std::u32::MAX <= u; | ^^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:40:5 + --> $DIR/absurd-extreme-comparisons.rs:19:5 | -40 | 1-1 > u; +19 | 1-1 > u; | ^^^^^^^ | = help: because 1-1 is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:43:5 + --> $DIR/absurd-extreme-comparisons.rs:20:5 | -43 | u >= !0; +20 | u >= !0; | ^^^^^^^ | = help: because !0 is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == !0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:46:5 + --> $DIR/absurd-extreme-comparisons.rs:21:5 | -46 | u <= 12 - 2*6; +21 | u <= 12 - 2*6; | ^^^^^^^^^^^^^ | = 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 error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:51:5 + --> $DIR/absurd-extreme-comparisons.rs:23:5 | -51 | i < -127 - 1; +23 | i < -127 - 1; | ^^^^^^^^^^^^ | = help: because -127 - 1 is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:54:5 + --> $DIR/absurd-extreme-comparisons.rs:24:5 | -54 | std::i8::MAX >= i; +24 | std::i8::MAX >= i; | ^^^^^^^^^^^^^^^^^ | = help: because std::i8::MAX is the maximum value for this type, this comparison is always true error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:57:5 + --> $DIR/absurd-extreme-comparisons.rs:25:5 | -57 | 3-7 < std::i32::MIN; +25 | 3-7 < std::i32::MIN; | ^^^^^^^^^^^^^^^^^^^ | = help: because std::i32::MIN is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:62:5 + --> $DIR/absurd-extreme-comparisons.rs:27:5 | -62 | b >= true; +27 | b >= true; | ^^^^^^^^^ | = help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:65:5 + --> $DIR/absurd-extreme-comparisons.rs:28:5 | -65 | false > b; +28 | false > b; | ^^^^^^^^^ | = help: because false is the minimum value for this type, this comparison is always false warning: <-comparison of unit values detected. This will always be false - --> $DIR/absurd-extreme-comparisons.rs:72:5 + --> $DIR/absurd-extreme-comparisons.rs:31:5 | -72 | () < {}; +31 | () < {}; | ^^^^^^^ | = note: #[warn(unit_cmp)] on by default From ac4ce0b2fec685125fe13f4ec824869fcecd14ed Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 14:52:44 +0100 Subject: [PATCH 02/55] clean tests/ui/assign_ops2 Cleaning the empty lines for clarity. --- tests/ui/assign_ops2.rs | 16 ---------- tests/ui/assign_ops2.stderr | 58 ++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index 3071cce161c..be68d2716bd 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -6,29 +6,13 @@ fn main() { let mut a = 5; a += a + 1; - - a += 1 + a; - - a -= a - 1; - - a *= a * 99; - - a *= 42 * a; - - a /= a / 2; - - a %= a % 5; - - a &= a & 1; - - a -= 1 - a; a /= 5 / a; a %= 42 % a; diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index adab959f6ee..6fbfac71c15 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -10,46 +10,46 @@ note: lint level defined here 5 | #[deny(misrefactored_assign_op)] | ^^^^^^^^^^^^^^^^^^^^^^^ +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:9:5 + | +9 | a += 1 + a; + | ^^^^^^^^^^ help: replace it with `a += 1` + +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:10:5 + | +10 | a -= a - 1; + | ^^^^^^^^^^ help: replace it with `a -= 1` + error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:11:5 | -11 | a += 1 + a; - | ^^^^^^^^^^ help: replace it with `a += 1` +11 | a *= a * 99; + | ^^^^^^^^^^^ help: replace it with `a *= 99` + +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:12:5 + | +12 | a *= 42 * a; + | ^^^^^^^^^^^ help: replace it with `a *= 42` + +error: variable appears on both sides of an assignment operation + --> $DIR/assign_ops2.rs:13:5 + | +13 | a /= a / 2; + | ^^^^^^^^^^ help: replace it with `a /= 2` error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:14:5 | -14 | a -= a - 1; - | ^^^^^^^^^^ help: replace it with `a -= 1` - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:17:5 - | -17 | a *= a * 99; - | ^^^^^^^^^^^ help: replace it with `a *= 99` - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:20:5 - | -20 | a *= 42 * a; - | ^^^^^^^^^^^ help: replace it with `a *= 42` - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:23:5 - | -23 | a /= a / 2; - | ^^^^^^^^^^ help: replace it with `a /= 2` - -error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:26:5 - | -26 | a %= a % 5; +14 | a %= a % 5; | ^^^^^^^^^^ help: replace it with `a %= 5` error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:29:5 + --> $DIR/assign_ops2.rs:15:5 | -29 | a &= a & 1; +15 | a &= a & 1; | ^^^^^^^^^^ help: replace it with `a &= 1` error: aborting due to 8 previous errors From 0c9d9d9f6cf3230013d70b60a4d15c04534adcb2 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 15:03:45 +0100 Subject: [PATCH 03/55] clean tests/ui/blacklisted_name.rs Cleaning the empty lines for clarity. --- tests/ui/blacklisted_name.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/ui/blacklisted_name.rs b/tests/ui/blacklisted_name.rs index 16b4240fac2..c1abbf1bb9d 100644 --- a/tests/ui/blacklisted_name.rs +++ b/tests/ui/blacklisted_name.rs @@ -18,9 +18,6 @@ fn main() { match (42, Some(1337), Some(0)) { (foo, Some(bar), baz @ Some(_)) => (), - - - _ => (), } } From cc923b5d0e62647c054fbed16b4d4813ca4aa93a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 15:40:40 +0100 Subject: [PATCH 04/55] clean tests/ui/block_in_if_condition.rs Cleaning the empty lines for clarity. --- tests/ui/block_in_if_condition.rs | 3 --- tests/ui/block_in_if_condition.stderr | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/ui/block_in_if_condition.rs b/tests/ui/block_in_if_condition.rs index feb28e37797..64832771715 100644 --- a/tests/ui/block_in_if_condition.rs +++ b/tests/ui/block_in_if_condition.rs @@ -56,13 +56,10 @@ fn pred_test() { // inside a closure that the condition is using. same principle applies. add some extra // expressions to make sure linter isn't confused by them. if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) { - } if predicate(|x| { let target = 3; x == target }, v) { - } - } fn condition_is_normal() -> i32 { diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index 403ad7efe8d..fb7f1179863 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -45,15 +45,15 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:62:22 + --> $DIR/block_in_if_condition.rs:61:22 | -62 | if predicate(|x| { let target = 3; x == target }, v) { +61 | if predicate(|x| { let target = 3; x == target }, v) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: this boolean expression can be simplified - --> $DIR/block_in_if_condition.rs:70:8 + --> $DIR/block_in_if_condition.rs:67:8 | -70 | if true && x == 3 { +67 | if true && x == 3 { | ^^^^^^^^^^^^^^ help: try `x == 3` | note: lint level defined here From 5865c2aacd73041a6a6d73c05483c24e57719769 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 15:48:58 +0100 Subject: [PATCH 05/55] clean tests/ui/bool_comparison.rs Cleaning the empty lines for clarity. --- tests/ui/bool_comparison.rs | 12 ------------ tests/ui/bool_comparison.stderr | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index 3991d04bd2c..606cbdc91ff 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -5,19 +5,7 @@ fn main() { let x = true; if x == true { "yes" } else { "no" }; - - - if x == false { "yes" } else { "no" }; - - - if true == x { "yes" } else { "no" }; - - - if false == x { "yes" } else { "no" }; - - - } diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 341f0734430..6cefb2f2223 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -11,21 +11,21 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:11:8 - | -11 | if x == false { "yes" } else { "no" }; - | ^^^^^^^^^^ help: try simplifying it as shown: `!x` + --> $DIR/bool_comparison.rs:8:8 + | +8 | if x == false { "yes" } else { "no" }; + | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:15:8 - | -15 | if true == x { "yes" } else { "no" }; - | ^^^^^^^^^ help: try simplifying it as shown: `x` + --> $DIR/bool_comparison.rs:9:8 + | +9 | if true == x { "yes" } else { "no" }; + | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:19:8 + --> $DIR/bool_comparison.rs:10:8 | -19 | if false == x { "yes" } else { "no" }; +10 | if false == x { "yes" } else { "no" }; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: aborting due to 4 previous errors From 34e4c0f9e35e8f18bfe7adac2f01634ed00ad1a9 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 16:07:54 +0100 Subject: [PATCH 06/55] clean tests/ui/booleans.rs Cleaning the empty lines for clarity. --- tests/ui/booleans.rs | 50 --------------------- tests/ui/booleans.stderr | 94 ++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 97 deletions(-) diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index fc1791f7f55..6acb66d9c40 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -10,39 +10,17 @@ fn main() { let d: bool = unimplemented!(); let e: bool = unimplemented!(); let _ = a && b || a; - - - let _ = !(a && b); let _ = !true; - - let _ = !false; - - let _ = !!a; - - - let _ = false && a; - - - - let _ = false || a; - - - // don't lint on cfgs let _ = cfg!(you_shall_not_not_pass) && a; - let _ = a || !b || !c || !d || !e; - let _ = !(a && b || c); - let _ = !(!a && b); - - } #[allow(unused, many_single_char_names)] @@ -53,38 +31,10 @@ fn equality_stuff() { let d: i32 = unimplemented!(); let e: i32 = unimplemented!(); let _ = a == b && a != b; - - - - let _ = a == b && c == 5 && a == b; - - - - - let _ = a == b && c == 5 && b == a; - - - - - let _ = a < b && a >= b; - - - - let _ = a > b && a <= b; - - - - let _ = a > b && a == b; - let _ = a != b || !(a != b || c == d); - - - - - } diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index dd8190d1011..27e1d882a7b 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -16,9 +16,9 @@ help: this expression can be optimized out by applying boolean operations to the | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:17:13 + --> $DIR/booleans.rs:14:13 | -17 | let _ = !true; +14 | let _ = !true; | ^^^^^ help: try `false` | note: lint level defined here @@ -28,93 +28,93 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:20:13 + --> $DIR/booleans.rs:15:13 | -20 | let _ = !false; +15 | let _ = !false; | ^^^^^^ help: try `true` +error: this boolean expression can be simplified + --> $DIR/booleans.rs:16:13 + | +16 | let _ = !!a; + | ^^^ help: try `a` + +error: this boolean expression contains a logic bug + --> $DIR/booleans.rs:17:13 + | +17 | let _ = false && a; + | ^^^^^^^^^^ help: it would look like the following `false` + | +help: this expression can be optimized out by applying boolean operations to the outer expression + --> $DIR/booleans.rs:17:22 + | +17 | let _ = false && a; + | ^ + +error: this boolean expression can be simplified + --> $DIR/booleans.rs:18:13 + | +18 | let _ = false || a; + | ^^^^^^^^^^ help: try `a` + error: this boolean expression can be simplified --> $DIR/booleans.rs:23:13 | -23 | let _ = !!a; - | ^^^ help: try `a` - -error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:27:13 - | -27 | let _ = false && a; - | ^^^^^^^^^^ help: it would look like the following `false` - | -help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:27:22 - | -27 | let _ = false && a; - | ^ - -error: this boolean expression can be simplified - --> $DIR/booleans.rs:32:13 - | -32 | let _ = false || a; - | ^^^^^^^^^^ help: try `a` - -error: this boolean expression can be simplified - --> $DIR/booleans.rs:43:13 - | -43 | let _ = !(!a && b); +23 | let _ = !(!a && b); | ^^^^^^^^^^ help: try `!b || a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:55:13 + --> $DIR/booleans.rs:33:13 | -55 | let _ = a == b && a != b; +33 | let _ = a == b && a != b; | ^^^^^^^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:55:13 + --> $DIR/booleans.rs:33:13 | -55 | let _ = a == b && a != b; +33 | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:60:13 + --> $DIR/booleans.rs:34:13 | -60 | let _ = a == b && c == 5 && a == b; +34 | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `a == b && c == 5` error: this boolean expression can be simplified - --> $DIR/booleans.rs:66:13 + --> $DIR/booleans.rs:35:13 | -66 | let _ = a == b && c == 5 && b == a; +35 | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `a == b && c == 5` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:72:13 + --> $DIR/booleans.rs:36:13 | -72 | let _ = a < b && a >= b; +36 | let _ = a < b && a >= b; | ^^^^^^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:72:13 + --> $DIR/booleans.rs:36:13 | -72 | let _ = a < b && a >= b; +36 | let _ = a < b && a >= b; | ^^^^^ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:77:13 + --> $DIR/booleans.rs:37:13 | -77 | let _ = a > b && a <= b; +37 | let _ = a > b && a <= b; | ^^^^^^^^^^^^^^^ help: it would look like the following `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:77:13 + --> $DIR/booleans.rs:37:13 | -77 | let _ = a > b && a <= b; +37 | let _ = a > b && a <= b; | ^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:84:13 + --> $DIR/booleans.rs:39:13 | -84 | let _ = a != b || !(a != b || c == d); +39 | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `c != d || a != b` error: aborting due to 13 previous errors From 17284baceeb24dd8e8e7cefa36df1fcf4a6196b4 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 10 May 2017 16:25:40 +0100 Subject: [PATCH 07/55] clean tests/ui/cast.rs Cleaning the empty lines for clarity. --- tests/ui/cast.rs | 13 ---- tests/ui/cast.stderr | 156 +++++++++++++++++++++---------------------- 2 files changed, 78 insertions(+), 91 deletions(-) diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index d63e0b10278..19c98481873 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -13,30 +13,23 @@ fn main() { 1u64 as f64; 1i32 as f64; // Should not trigger the lint 1u32 as f64; // Should not trigger the lint - // Test cast_possible_truncation 1f32 as i32; 1f32 as u32; - 1f64 as f32; 1i32 as i8; 1i32 as u8; - 1f64 as isize; 1f64 as usize; - - // Test cast_possible_wrap 1u8 as i8; 1u16 as i16; 1u32 as i32; 1u64 as i64; 1usize as isize; - // Test cast_sign_loss 1i32 as u32; 1isize as usize; - // Extra checks for *size // Casting from *size 1isize as i8; @@ -46,28 +39,22 @@ fn main() { 1usize as f32; 1isize as i32; 1isize as u32; - 1usize as u32; 1usize as i32; - // Casting to *size 1i64 as isize; 1i64 as usize; - 1u64 as isize; - 1u64 as usize; 1u32 as isize; 1u32 as usize; // Should not trigger any lint 1i32 as isize; // Neither should this 1i32 as usize; - // Test cast_unnecessary 1i32 as i32; 1f32 as f32; false as bool; &1i32 as &i32; - // Should not trigger 1i32 as i64; let v = vec!(1); diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 7238daa2b41..e9fd694d121 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -41,9 +41,9 @@ error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f | ^^^^^^^^^^^ error: casting f32 to i32 may truncate the value - --> $DIR/cast.rs:18:5 + --> $DIR/cast.rs:17:5 | -18 | 1f32 as i32; +17 | 1f32 as i32; | ^^^^^^^^^^^ | note: lint level defined here @@ -53,15 +53,15 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^^^^ error: casting f32 to u32 may truncate the value - --> $DIR/cast.rs:19:5 + --> $DIR/cast.rs:18:5 | -19 | 1f32 as u32; +18 | 1f32 as u32; | ^^^^^^^^^^^ error: casting f32 to u32 may lose the sign of the value - --> $DIR/cast.rs:19:5 + --> $DIR/cast.rs:18:5 | -19 | 1f32 as u32; +18 | 1f32 as u32; | ^^^^^^^^^^^ | note: lint level defined here @@ -71,51 +71,51 @@ note: lint level defined here | ^^^^^^^^^^^^^^ error: casting f64 to f32 may truncate the value - --> $DIR/cast.rs:21:5 + --> $DIR/cast.rs:19:5 | -21 | 1f64 as f32; +19 | 1f64 as f32; | ^^^^^^^^^^^ error: casting i32 to i8 may truncate the value - --> $DIR/cast.rs:22:5 + --> $DIR/cast.rs:20:5 | -22 | 1i32 as i8; +20 | 1i32 as i8; | ^^^^^^^^^^ error: casting i32 to u8 may lose the sign of the value - --> $DIR/cast.rs:23:5 + --> $DIR/cast.rs:21:5 | -23 | 1i32 as u8; +21 | 1i32 as u8; | ^^^^^^^^^^ error: casting i32 to u8 may truncate the value - --> $DIR/cast.rs:23:5 + --> $DIR/cast.rs:21:5 | -23 | 1i32 as u8; +21 | 1i32 as u8; | ^^^^^^^^^^ error: casting f64 to isize may truncate the value - --> $DIR/cast.rs:25:5 + --> $DIR/cast.rs:22:5 | -25 | 1f64 as isize; +22 | 1f64 as isize; | ^^^^^^^^^^^^^ error: casting f64 to usize may truncate the value - --> $DIR/cast.rs:26:5 + --> $DIR/cast.rs:23:5 | -26 | 1f64 as usize; +23 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting f64 to usize may lose the sign of the value - --> $DIR/cast.rs:26:5 + --> $DIR/cast.rs:23:5 | -26 | 1f64 as usize; +23 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting u8 to i8 may wrap around the value - --> $DIR/cast.rs:30:5 + --> $DIR/cast.rs:25:5 | -30 | 1u8 as i8; +25 | 1u8 as i8; | ^^^^^^^^^ | note: lint level defined here @@ -125,175 +125,175 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^ error: casting u16 to i16 may wrap around the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:26:5 | -31 | 1u16 as i16; +26 | 1u16 as i16; | ^^^^^^^^^^^ error: casting u32 to i32 may wrap around the value - --> $DIR/cast.rs:32:5 + --> $DIR/cast.rs:27:5 | -32 | 1u32 as i32; +27 | 1u32 as i32; | ^^^^^^^^^^^ error: casting u64 to i64 may wrap around the value - --> $DIR/cast.rs:33:5 + --> $DIR/cast.rs:28:5 | -33 | 1u64 as i64; +28 | 1u64 as i64; | ^^^^^^^^^^^ error: casting usize to isize may wrap around the value - --> $DIR/cast.rs:34:5 + --> $DIR/cast.rs:29:5 | -34 | 1usize as isize; +29 | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting i32 to u32 may lose the sign of the value - --> $DIR/cast.rs:37:5 + --> $DIR/cast.rs:31:5 | -37 | 1i32 as u32; +31 | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value - --> $DIR/cast.rs:38:5 + --> $DIR/cast.rs:32:5 | -38 | 1isize as usize; +32 | 1isize as usize; | ^^^^^^^^^^^^^^^ error: casting isize to i8 may truncate the value - --> $DIR/cast.rs:42:5 + --> $DIR/cast.rs:35:5 | -42 | 1isize as i8; +35 | 1isize as i8; | ^^^^^^^^^^^^ error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast.rs:43:5 + --> $DIR/cast.rs:36:5 | -43 | 1isize as f64; +36 | 1isize as f64; | ^^^^^^^^^^^^^ error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast.rs:44:5 + --> $DIR/cast.rs:37:5 | -44 | 1usize as f64; +37 | 1usize as f64; | ^^^^^^^^^^^^^ error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:45:5 + --> $DIR/cast.rs:38:5 | -45 | 1isize as f32; +38 | 1isize as f32; | ^^^^^^^^^^^^^ error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:46:5 + --> $DIR/cast.rs:39:5 | -46 | 1usize as f32; +39 | 1usize as f32; | ^^^^^^^^^^^^^ error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:47:5 + --> $DIR/cast.rs:40:5 | -47 | 1isize as i32; +40 | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value - --> $DIR/cast.rs:48:5 + --> $DIR/cast.rs:41:5 | -48 | 1isize as u32; +41 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:48:5 + --> $DIR/cast.rs:41:5 | -48 | 1isize as u32; +41 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:50:5 + --> $DIR/cast.rs:42:5 | -50 | 1usize as u32; +42 | 1usize as u32; | ^^^^^^^^^^^^^ error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:51:5 + --> $DIR/cast.rs:43:5 | -51 | 1usize as i32; +43 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:51:5 + --> $DIR/cast.rs:43:5 | -51 | 1usize as i32; +43 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:54:5 + --> $DIR/cast.rs:45:5 | -54 | 1i64 as isize; +45 | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value - --> $DIR/cast.rs:55:5 + --> $DIR/cast.rs:46:5 | -55 | 1i64 as usize; +46 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:55:5 + --> $DIR/cast.rs:46:5 | -55 | 1i64 as usize; +46 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:57:5 + --> $DIR/cast.rs:47:5 | -57 | 1u64 as isize; +47 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:57:5 + --> $DIR/cast.rs:47:5 | -57 | 1u64 as isize; +47 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:59:5 + --> $DIR/cast.rs:48:5 | -59 | 1u64 as usize; +48 | 1u64 as usize; | ^^^^^^^^^^^^^ error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:60:5 + --> $DIR/cast.rs:49:5 | -60 | 1u32 as isize; +49 | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value - --> $DIR/cast.rs:63:5 + --> $DIR/cast.rs:52:5 | -63 | 1i32 as usize; +52 | 1i32 as usize; | ^^^^^^^^^^^^^ warning: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/cast.rs:66:5 + --> $DIR/cast.rs:54:5 | -66 | 1i32 as i32; +54 | 1i32 as i32; | ^^^^^^^^^^^ | = note: #[warn(unnecessary_cast)] on by default warning: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/cast.rs:67:5 + --> $DIR/cast.rs:55:5 | -67 | 1f32 as f32; +55 | 1f32 as f32; | ^^^^^^^^^^^ | = note: #[warn(unnecessary_cast)] on by default warning: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/cast.rs:68:5 + --> $DIR/cast.rs:56:5 | -68 | false as bool; +56 | false as bool; | ^^^^^^^^^^^^^ | = note: #[warn(unnecessary_cast)] on by default From ed713d67d69dc24a63ac6095221f2aa377965cf9 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 10:41:44 +0100 Subject: [PATCH 08/55] clean tests/ui/cmp_owned.rs Cleaning the empty lines for clarity. --- tests/ui/cmp_owned.rs | 2 -- tests/ui/cmp_owned.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/ui/cmp_owned.rs b/tests/ui/cmp_owned.rs index 30cd502a105..12dcc8262c2 100644 --- a/tests/ui/cmp_owned.rs +++ b/tests/ui/cmp_owned.rs @@ -7,9 +7,7 @@ fn main() { fn with_to_string(x : &str) { x != "foo".to_string(); - "foo".to_string() != x; - } let x = "oh"; diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index 231e2752c81..a476110be61 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -11,21 +11,21 @@ note: lint level defined here | ^^^^^^^^^ error: this creates an owned instance just for comparison. Consider using `"foo" != x` to compare without allocation - --> $DIR/cmp_owned.rs:11:9 + --> $DIR/cmp_owned.rs:10:9 | -11 | "foo".to_string() != x; +10 | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation - --> $DIR/cmp_owned.rs:19:10 + --> $DIR/cmp_owned.rs:17:10 | -19 | x != "foo".to_owned(); +17 | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation - --> $DIR/cmp_owned.rs:24:10 + --> $DIR/cmp_owned.rs:22:10 | -24 | x != String::from("foo"); +22 | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors From aa3d361bec0714753f00c77e8c188f809be2cc2c Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 11:00:31 +0100 Subject: [PATCH 09/55] clean tests/ui/collapsible_if.rs Cleaning the empty lines for clarity. --- tests/ui/collapsible_if.rs | 39 ------ tests/ui/collapsible_if.stderr | 222 +++++++++++++++------------------ 2 files changed, 103 insertions(+), 158 deletions(-) diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index 6034bba848e..b06f4fa793e 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -6,54 +6,36 @@ fn main() { let x = "hello"; let y = "world"; if x == "hello" { - - - if y == "world" { println!("Hello world!"); } } if x == "hello" || x == "world" { - - - if y == "world" || y == "hello" { println!("Hello world!"); } } if x == "hello" && x == "world" { - - - if y == "world" || y == "hello" { println!("Hello world!"); } } if x == "hello" || x == "world" { - - - if y == "world" && y == "hello" { println!("Hello world!"); } } if x == "hello" && x == "world" { - - - if y == "world" && y == "hello" { println!("Hello world!"); } } if 42 == 1337 { - - - if 'a' != 'A' { println!("world!") } @@ -63,9 +45,6 @@ fn main() { if x == "hello" { print!("Hello "); } else { - - - if y == "world" { println!("world!") } @@ -74,9 +53,6 @@ fn main() { if x == "hello" { print!("Hello "); } else { - - - if let Some(42) = Some(42) { println!("world!") } @@ -85,9 +61,6 @@ fn main() { if x == "hello" { print!("Hello "); } else { - - - if y == "world" { println!("world") } @@ -99,9 +72,6 @@ fn main() { if x == "hello" { print!("Hello "); } else { - - - if let Some(42) = Some(42) { println!("world") } @@ -113,9 +83,6 @@ fn main() { if let Some(42) = Some(42) { print!("Hello "); } else { - - - if let Some(42) = Some(42) { println!("world") } @@ -127,9 +94,6 @@ fn main() { if let Some(42) = Some(42) { print!("Hello "); } else { - - - if x == "hello" { println!("world") } @@ -141,9 +105,6 @@ fn main() { if let Some(42) = Some(42) { print!("Hello "); } else { - - - if let Some(42) = Some(42) { println!("world") } diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index e638727e902..5e643f68160 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -2,12 +2,10 @@ error: this if statement can be collapsed --> $DIR/collapsible_if.rs:8:5 | 8 | / if x == "hello" { -9 | | -10 | | -11 | | -... | -14 | | } -15 | | } +9 | | if y == "world" { +10 | | println!("Hello world!"); +11 | | } +12 | | } | |_____^ | note: lint level defined here @@ -21,15 +19,13 @@ help: try | } error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:17:5 + --> $DIR/collapsible_if.rs:14:5 | -17 | / if x == "hello" || x == "world" { -18 | | -19 | | -20 | | -... | -23 | | } -24 | | } +14 | / if x == "hello" || x == "world" { +15 | | if y == "world" || y == "hello" { +16 | | println!("Hello world!"); +17 | | } +18 | | } | |_____^ | help: try @@ -38,15 +34,13 @@ help: try | } error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:26:5 + --> $DIR/collapsible_if.rs:20:5 | -26 | / if x == "hello" && x == "world" { -27 | | -28 | | -29 | | -... | -32 | | } -33 | | } +20 | / if x == "hello" && x == "world" { +21 | | if y == "world" || y == "hello" { +22 | | println!("Hello world!"); +23 | | } +24 | | } | |_____^ | help: try @@ -55,15 +49,13 @@ help: try | } error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:35:5 + --> $DIR/collapsible_if.rs:26:5 | -35 | / if x == "hello" || x == "world" { -36 | | -37 | | -38 | | -... | -41 | | } -42 | | } +26 | / if x == "hello" || x == "world" { +27 | | if y == "world" && y == "hello" { +28 | | println!("Hello world!"); +29 | | } +30 | | } | |_____^ | help: try @@ -72,15 +64,13 @@ help: try | } error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:44:5 + --> $DIR/collapsible_if.rs:32:5 | -44 | / if x == "hello" && x == "world" { -45 | | -46 | | -47 | | -... | -50 | | } -51 | | } +32 | / if x == "hello" && x == "world" { +33 | | if y == "world" && y == "hello" { +34 | | println!("Hello world!"); +35 | | } +36 | | } | |_____^ | help: try @@ -89,15 +79,13 @@ help: try | } error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:53:5 + --> $DIR/collapsible_if.rs:38:5 | -53 | / if 42 == 1337 { -54 | | -55 | | -56 | | -... | -59 | | } -60 | | } +38 | / if 42 == 1337 { +39 | | if 'a' != 'A' { +40 | | println!("world!") +41 | | } +42 | | } | |_____^ | help: try @@ -106,16 +94,14 @@ help: try | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:65:12 + --> $DIR/collapsible_if.rs:47:12 | -65 | } else { +47 | } else { | ____________^ -66 | | -67 | | -68 | | -... | -71 | | } -72 | | } +48 | | if y == "world" { +49 | | println!("world!") +50 | | } +51 | | } | |_____^ | help: try @@ -124,16 +110,14 @@ help: try | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:76:12 + --> $DIR/collapsible_if.rs:55:12 | -76 | } else { +55 | } else { | ____________^ -77 | | -78 | | -79 | | -... | -82 | | } -83 | | } +56 | | if let Some(42) = Some(42) { +57 | | println!("world!") +58 | | } +59 | | } | |_____^ | help: try @@ -142,16 +126,16 @@ help: try | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:87:12 + --> $DIR/collapsible_if.rs:63:12 | -87 | } else { +63 | } else { | ____________^ -88 | | -89 | | -90 | | +64 | | if y == "world" { +65 | | println!("world") +66 | | } ... | -96 | | } -97 | | } +69 | | } +70 | | } | |_____^ | help: try @@ -163,58 +147,58 @@ help: try | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:101:12 - | -101 | } else { - | ____________^ -102 | | -103 | | -104 | | -... | -110 | | } -111 | | } - | |_____^ - | + --> $DIR/collapsible_if.rs:74:12 + | +74 | } else { + | ____________^ +75 | | if let Some(42) = Some(42) { +76 | | println!("world") +77 | | } +... | +80 | | } +81 | | } + | |_____^ + | help: try - | } else if let Some(42) = Some(42) { - | println!("world") - | } - | else { - | println!("!") - | } + | } else if let Some(42) = Some(42) { + | println!("world") + | } + | else { + | println!("!") + | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:115:12 - | -115 | } else { - | ____________^ -116 | | -117 | | -118 | | -... | -124 | | } -125 | | } - | |_____^ - | + --> $DIR/collapsible_if.rs:85:12 + | +85 | } else { + | ____________^ +86 | | if let Some(42) = Some(42) { +87 | | println!("world") +88 | | } +... | +91 | | } +92 | | } + | |_____^ + | help: try - | } else if let Some(42) = Some(42) { - | println!("world") - | } - | else { - | println!("!") - | } + | } else if let Some(42) = Some(42) { + | println!("world") + | } + | else { + | println!("!") + | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:129:12 + --> $DIR/collapsible_if.rs:96:12 | -129 | } else { +96 | } else { | ____________^ -130 | | -131 | | -132 | | +97 | | if x == "hello" { +98 | | println!("world") +99 | | } ... | -138 | | } -139 | | } +102 | | } +103 | | } | |_____^ | help: try @@ -226,16 +210,16 @@ help: try | } error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:143:12 + --> $DIR/collapsible_if.rs:107:12 | -143 | } else { +107 | } else { | ____________^ -144 | | -145 | | -146 | | +108 | | if let Some(42) = Some(42) { +109 | | println!("world") +110 | | } ... | -152 | | } -153 | | } +113 | | } +114 | | } | |_____^ | help: try From 5e45d09c4f78077695a05547fc7f90fa709105db Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 11:02:01 +0100 Subject: [PATCH 10/55] clean tests/ui/conf_french_blacklisted_name.rs Cleaning the empty lines for clarity. --- tests/ui/conf_french_blacklisted_name.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/ui/conf_french_blacklisted_name.rs b/tests/ui/conf_french_blacklisted_name.rs index 20cd6aba369..ccc53f0c07a 100644 --- a/tests/ui/conf_french_blacklisted_name.rs +++ b/tests/ui/conf_french_blacklisted_name.rs @@ -18,9 +18,6 @@ fn main() { match (42, Some(1337), Some(0)) { (toto, Some(tata), titi @ Some(_)) => (), - - - _ => (), } } From e2cce4809b60ea8c9d1f5fa4b5f7541874910aa6 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 11:07:08 +0100 Subject: [PATCH 11/55] clean tests/ui/copies.rs Cleaning the empty lines for clarity. --- tests/ui/conf_path_non_string.rs | 1 - tests/ui/copies.rs | 29 --- tests/ui/copies.stderr | 414 +++++++++++++++---------------- 3 files changed, 203 insertions(+), 241 deletions(-) diff --git a/tests/ui/conf_path_non_string.rs b/tests/ui/conf_path_non_string.rs index ba78ccce715..f6f40513be8 100644 --- a/tests/ui/conf_path_non_string.rs +++ b/tests/ui/conf_path_non_string.rs @@ -2,5 +2,4 @@ #![feature(plugin)] #![plugin(clippy(conf_file=42))] - fn main() {} diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index 15c14914176..8192593be1a 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -28,7 +28,6 @@ pub enum Abc { #[deny(match_same_arms)] fn if_same_then_else() -> Result<&'static str, ()> { if true { - Foo { bar: 42 }; 0..10; ..; @@ -78,8 +77,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match 42 { 42 => { - - foo(); let mut a = 42 + [23].len() as i32; if true { @@ -101,8 +98,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match Abc::A { Abc::A => 0, - - Abc::B => 1, _ => 0, }; @@ -112,7 +107,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } let _ = if true { - 42 } else { @@ -120,7 +114,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { }; if true { - for _ in &[42] { let foo: &Option<_> = &Some::(42); if true { @@ -142,7 +135,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - let bar = if true { 42 } @@ -166,7 +158,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - let _ = match 42 { 42 => 1, a if a > 0 => 2, @@ -187,7 +178,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - if let Some(a) = Some(42) {} } else { @@ -195,7 +185,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - if let (1, .., 3) = (1, 2, 3) {} } else { @@ -253,16 +242,12 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match 42 { 42 => foo(), - - 51 => foo(), _ => true, }; let _ = match Some(42) { Some(_) => 24, - - None => 24, }; @@ -285,37 +270,29 @@ fn if_same_then_else() -> Result<&'static str, ()> { match (Some(42), Some(42)) { (Some(a), None) => bar(a), - - (None, Some(a)) => bar(a), _ => (), } match (Some(42), Some(42)) { (Some(a), ..) => bar(a), - - (.., Some(a)) => bar(a), _ => (), } match (1, 2, 3) { (1, .., 3) => 42, - - (.., 3) => 42, _ => 0, }; let _ = if true { - 0.0 } else { 0.0 }; let _ = if true { - -0.0 } else { -0.0 @@ -336,7 +313,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { // Same NaNs let _ = if true { - std::f32::NAN } else { std::f32::NAN @@ -354,7 +330,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - try!(Ok("foo")); } else { @@ -362,7 +337,6 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - let foo = ""; return Ok(&foo[0..]); } @@ -383,19 +357,16 @@ fn ifs_same_cond() { let b = false; if b { - } else if b { } if a == 1 { - } else if a == 1 { } if 2*a == 1 { - } else if 2*a == 2 { } diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index 05c5e92a7fa..c9ad01f335e 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,11 +1,11 @@ warning: This else block is redundant. - --> $DIR/copies.rs:128:20 + --> $DIR/copies.rs:121:20 | -128 | } else { +121 | } else { | ____________________^ -129 | | continue; -130 | | } +122 | | continue; +123 | | } | |_____________^ | = note: #[warn(needless_continue)] on by default @@ -18,12 +18,12 @@ warning: This else block is redundant. warning: This else block is redundant. - --> $DIR/copies.rs:138:20 + --> $DIR/copies.rs:131:20 | -138 | } else { +131 | } else { | ____________________^ -139 | | continue; -140 | | } +132 | | continue; +133 | | } | |_____________^ | = note: #[warn(needless_continue)] on by default @@ -35,16 +35,16 @@ warning: This else block is redundant. error: this `if` has identical blocks - --> $DIR/copies.rs:40:10 + --> $DIR/copies.rs:39:10 | -40 | else { +39 | else { | __________^ -41 | | Foo { bar: 42 }; -42 | | 0..10; -43 | | ..; +40 | | Foo { bar: 42 }; +41 | | 0..10; +42 | | ..; ... | -47 | | foo(); -48 | | } +46 | | foo(); +47 | | } | |_____^ | note: lint level defined here @@ -57,25 +57,25 @@ note: same as this | 30 | if true { | _____________^ -31 | | -32 | | Foo { bar: 42 }; -33 | | 0..10; +31 | | Foo { bar: 42 }; +32 | | 0..10; +33 | | ..; ... | -38 | | foo(); -39 | | } +37 | | foo(); +38 | | } | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:91:14 + --> $DIR/copies.rs:88:14 | -91 | _ => { +88 | _ => { | ______________^ -92 | | foo(); -93 | | let mut a = 42 + [23].len() as i32; -94 | | if true { +89 | | foo(); +90 | | let mut a = 42 + [23].len() as i32; +91 | | if true { ... | -98 | | a -99 | | } +95 | | a +96 | | } | |_________^ | note: lint level defined here @@ -84,403 +84,395 @@ note: lint level defined here 28 | #[deny(match_same_arms)] | ^^^^^^^^^^^^^^^ note: same as this - --> $DIR/copies.rs:80:15 + --> $DIR/copies.rs:79:15 | -80 | 42 => { +79 | 42 => { | _______________^ -81 | | -82 | | -83 | | foo(); +80 | | foo(); +81 | | let mut a = 42 + [23].len() as i32; +82 | | if true { ... | -89 | | a -90 | | } +86 | | a +87 | | } | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:80:15 + --> $DIR/copies.rs:79:15 | -80 | 42 => { +79 | 42 => { | _______________^ -81 | | -82 | | -83 | | foo(); +80 | | foo(); +81 | | let mut a = 42 + [23].len() as i32; +82 | | if true { ... | -89 | | a -90 | | } +86 | | a +87 | | } | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:107:14 + --> $DIR/copies.rs:102:14 | -107 | _ => 0, +102 | _ => 0, | ^ | note: same as this - --> $DIR/copies.rs:103:19 + --> $DIR/copies.rs:100:19 | -103 | Abc::A => 0, +100 | Abc::A => 0, | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:103:19 + --> $DIR/copies.rs:100:19 | -103 | Abc::A => 0, +100 | Abc::A => 0, | ^ error: this `if` has identical blocks - --> $DIR/copies.rs:118:10 + --> $DIR/copies.rs:112:10 | -118 | else { +112 | else { | __________^ -119 | | 42 -120 | | }; +113 | | 42 +114 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:114:21 + --> $DIR/copies.rs:109:21 | -114 | let _ = if true { +109 | let _ = if true { | _____________________^ -115 | | -116 | | 42 -117 | | } +110 | | 42 +111 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:133:10 + --> $DIR/copies.rs:126:10 | -133 | else { +126 | else { | __________^ -134 | | for _ in &[42] { -135 | | let foo: &Option<_> = &Some::(42); -136 | | if true { +127 | | for _ in &[42] { +128 | | let foo: &Option<_> = &Some::(42); +129 | | if true { ... | -141 | | } -142 | | } +134 | | } +135 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:122:13 + --> $DIR/copies.rs:116:13 | -122 | if true { +116 | if true { | _____________^ -123 | | -124 | | for _ in &[42] { -125 | | let foo: &Option<_> = &Some::(42); +117 | | for _ in &[42] { +118 | | let foo: &Option<_> = &Some::(42); +119 | | if true { ... | -131 | | } -132 | | } +124 | | } +125 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:156:10 + --> $DIR/copies.rs:148:10 | -156 | else { +148 | else { | __________^ -157 | | let bar = if true { -158 | | 42 -159 | | } +149 | | let bar = if true { +150 | | 42 +151 | | } ... | -165 | | bar + 1; -166 | | } +157 | | bar + 1; +158 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:144:13 + --> $DIR/copies.rs:137:13 | -144 | if true { +137 | if true { | _____________^ -145 | | -146 | | let bar = if true { -147 | | 42 +138 | | let bar = if true { +139 | | 42 +140 | | } ... | -154 | | bar + 1; -155 | | } +146 | | bar + 1; +147 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:180:19 + --> $DIR/copies.rs:171:19 | -180 | else if foo() { +171 | else if foo() { | ___________________^ -181 | | let _ = match 42 { -182 | | 42 => 1, -183 | | a if a > 0 => 2, +172 | | let _ = match 42 { +173 | | 42 => 1, +174 | | a if a > 0 => 2, ... | -186 | | }; -187 | | } +177 | | }; +178 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:168:13 + --> $DIR/copies.rs:160:13 | -168 | if true { +160 | if true { | _____________^ -169 | | -170 | | let _ = match 42 { -171 | | 42 => 1, +161 | | let _ = match 42 { +162 | | 42 => 1, +163 | | a if a > 0 => 2, ... | -175 | | }; -176 | | } +166 | | }; +167 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:193:10 + --> $DIR/copies.rs:183:10 | -193 | else { +183 | else { | __________^ -194 | | if let Some(a) = Some(42) {} -195 | | } +184 | | if let Some(a) = Some(42) {} +185 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:189:13 + --> $DIR/copies.rs:180:13 | -189 | if true { +180 | if true { | _____________^ -190 | | -191 | | if let Some(a) = Some(42) {} +181 | | if let Some(a) = Some(42) {} +182 | | } + | |_____^ + +error: this `if` has identical blocks + --> $DIR/copies.rs:190:10 + | +190 | else { + | __________^ +191 | | if let (1, .., 3) = (1, 2, 3) {} 192 | | } | |_____^ - -error: this `if` has identical blocks - --> $DIR/copies.rs:201:10 - | -201 | else { - | __________^ -202 | | if let (1, .., 3) = (1, 2, 3) {} -203 | | } - | |_____^ | note: same as this - --> $DIR/copies.rs:197:13 + --> $DIR/copies.rs:187:13 | -197 | if true { +187 | if true { | _____________^ -198 | | -199 | | if let (1, .., 3) = (1, 2, 3) {} -200 | | } +188 | | if let (1, .., 3) = (1, 2, 3) {} +189 | | } | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:258:15 + --> $DIR/copies.rs:245:15 | -258 | 51 => foo(), +245 | 51 => foo(), | ^^^^^ | note: same as this - --> $DIR/copies.rs:255:15 + --> $DIR/copies.rs:244:15 | -255 | 42 => foo(), +244 | 42 => foo(), | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:255:15 + --> $DIR/copies.rs:244:15 | -255 | 42 => foo(), +244 | 42 => foo(), | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:266:17 + --> $DIR/copies.rs:251:17 | -266 | None => 24, +251 | None => 24, | ^^ | note: same as this - --> $DIR/copies.rs:263:20 + --> $DIR/copies.rs:250:20 | -263 | Some(_) => 24, +250 | Some(_) => 24, | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:263:20 + --> $DIR/copies.rs:250:20 | -263 | Some(_) => 24, +250 | Some(_) => 24, | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:290:28 + --> $DIR/copies.rs:273:28 | -290 | (None, Some(a)) => bar(a), +273 | (None, Some(a)) => bar(a), | ^^^^^^ | note: same as this - --> $DIR/copies.rs:287:28 + --> $DIR/copies.rs:272:28 | -287 | (Some(a), None) => bar(a), +272 | (Some(a), None) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:287:28 + --> $DIR/copies.rs:272:28 | -287 | (Some(a), None) => bar(a), +272 | (Some(a), None) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:298:26 + --> $DIR/copies.rs:279:26 | -298 | (.., Some(a)) => bar(a), +279 | (.., Some(a)) => bar(a), | ^^^^^^ | note: same as this - --> $DIR/copies.rs:295:26 + --> $DIR/copies.rs:278:26 | -295 | (Some(a), ..) => bar(a), +278 | (Some(a), ..) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:295:26 + --> $DIR/copies.rs:278:26 | -295 | (Some(a), ..) => bar(a), +278 | (Some(a), ..) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:306:20 + --> $DIR/copies.rs:285:20 | -306 | (.., 3) => 42, +285 | (.., 3) => 42, | ^^ | note: same as this - --> $DIR/copies.rs:303:23 + --> $DIR/copies.rs:284:23 | -303 | (1, .., 3) => 42, +284 | (1, .., 3) => 42, | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:303:23 + --> $DIR/copies.rs:284:23 | -303 | (1, .., 3) => 42, +284 | (1, .., 3) => 42, | ^^ error: this `if` has identical blocks - --> $DIR/copies.rs:313:12 + --> $DIR/copies.rs:291:12 | -313 | } else { +291 | } else { | ____________^ -314 | | 0.0 -315 | | }; +292 | | 0.0 +293 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:310:21 + --> $DIR/copies.rs:289:21 | -310 | let _ = if true { +289 | let _ = if true { | _____________________^ -311 | | -312 | | 0.0 -313 | | } else { +290 | | 0.0 +291 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:320:12 + --> $DIR/copies.rs:297:12 | -320 | } else { +297 | } else { | ____________^ -321 | | -0.0 -322 | | }; +298 | | -0.0 +299 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:317:21 + --> $DIR/copies.rs:295:21 | -317 | let _ = if true { +295 | let _ = if true { | _____________________^ -318 | | -319 | | -0.0 -320 | | } else { +296 | | -0.0 +297 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:341:12 + --> $DIR/copies.rs:317:12 | -341 | } else { +317 | } else { | ____________^ -342 | | std::f32::NAN -343 | | }; +318 | | std::f32::NAN +319 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:338:21 + --> $DIR/copies.rs:315:21 | -338 | let _ = if true { +315 | let _ = if true { | _____________________^ -339 | | -340 | | std::f32::NAN -341 | | } else { +316 | | std::f32::NAN +317 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:360:10 + --> $DIR/copies.rs:335:10 | -360 | else { +335 | else { | __________^ -361 | | try!(Ok("foo")); -362 | | } +336 | | try!(Ok("foo")); +337 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:356:13 + --> $DIR/copies.rs:332:13 | -356 | if true { +332 | if true { | _____________^ -357 | | -358 | | try!(Ok("foo")); -359 | | } +333 | | try!(Ok("foo")); +334 | | } | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:373:10 + --> $DIR/copies.rs:347:10 | -373 | else { +347 | else { | __________^ -374 | | let foo = ""; -375 | | return Ok(&foo[0..]); -376 | | } +348 | | let foo = ""; +349 | | return Ok(&foo[0..]); +350 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:364:13 + --> $DIR/copies.rs:339:13 | -364 | if true { +339 | if true { | _____________^ -365 | | -366 | | let foo = ""; -367 | | return Ok(&foo[0..]); -368 | | } +340 | | let foo = ""; +341 | | return Ok(&foo[0..]); +342 | | } | |_____^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:388:13 + --> $DIR/copies.rs:361:13 | -388 | else if b { +361 | else if b { | ^ | note: lint level defined here - --> $DIR/copies.rs:379:8 + --> $DIR/copies.rs:353:8 | -379 | #[deny(ifs_same_cond)] +353 | #[deny(ifs_same_cond)] | ^^^^^^^^^^^^^ note: same as this - --> $DIR/copies.rs:385:8 + --> $DIR/copies.rs:359:8 | -385 | if b { +359 | if b { | ^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:394:13 + --> $DIR/copies.rs:366:13 | -394 | else if a == 1 { +366 | else if a == 1 { | ^^^^^^ | note: same as this - --> $DIR/copies.rs:391:8 + --> $DIR/copies.rs:364:8 | -391 | if a == 1 { +364 | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:402:13 + --> $DIR/copies.rs:373:13 | -402 | else if 2*a == 1 { +373 | else if 2*a == 1 { | ^^^^^^^^ | note: same as this - --> $DIR/copies.rs:397:8 + --> $DIR/copies.rs:369:8 | -397 | if 2*a == 1 { +369 | if 2*a == 1 { | ^^^^^^^^ error: aborting due to 22 previous errors From e3aa07403348ed9471436909f93570e9104bf810 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 11:11:00 +0100 Subject: [PATCH 12/55] clean tests/ui/derive.rs Cleaning the empty lines for clarity. --- tests/ui/derive.rs | 5 --- tests/ui/derive.stderr | 69 ++++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index 7274c0fb7ad..50c1c1103c4 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -16,7 +16,6 @@ impl PartialEq for Foo { } #[derive(Hash)] - struct Bar; impl PartialEq for Bar { @@ -24,7 +23,6 @@ impl PartialEq for Bar { } #[derive(Hash)] - struct Baz; impl PartialEq for Baz { @@ -35,7 +33,6 @@ impl PartialEq for Baz { struct Bah; impl Hash for Bah { - fn hash(&self, _: &mut H) {} } @@ -43,7 +40,6 @@ impl Hash for Bah { struct Qux; impl Clone for Qux { - fn clone(&self) -> Self { Qux } } @@ -68,7 +64,6 @@ struct Lt<'a> { } impl<'a> Clone for Lt<'a> { - fn clone(&self) -> Self { unimplemented!() } } diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index 290ba68c5b3..25d59bdb7da 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -11,51 +11,49 @@ note: lint level defined here 6 | #![deny(warnings)] | ^^^^^^^^ note: `PartialEq` implemented here - --> $DIR/derive.rs:22:1 + --> $DIR/derive.rs:21:1 | -22 | / impl PartialEq for Bar { -23 | | fn eq(&self, _: &Bar) -> bool { true } -24 | | } +21 | / impl PartialEq for Bar { +22 | | fn eq(&self, _: &Bar) -> bool { true } +23 | | } | |_^ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derive.rs:26:10 + --> $DIR/derive.rs:25:10 | -26 | #[derive(Hash)] +25 | #[derive(Hash)] | ^^^^ | = note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)] note: `PartialEq` implemented here - --> $DIR/derive.rs:30:1 + --> $DIR/derive.rs:28:1 | -30 | / impl PartialEq for Baz { -31 | | fn eq(&self, _: &Baz) -> bool { true } -32 | | } +28 | / impl PartialEq for Baz { +29 | | fn eq(&self, _: &Baz) -> bool { true } +30 | | } | |_^ error: you are implementing `Hash` explicitly but have derived `PartialEq` - --> $DIR/derive.rs:37:1 + --> $DIR/derive.rs:35:1 | -37 | / impl Hash for Bah { -38 | | -39 | | fn hash(&self, _: &mut H) {} -40 | | } +35 | / impl Hash for Bah { +36 | | fn hash(&self, _: &mut H) {} +37 | | } | |_^ | = note: #[deny(derive_hash_xor_eq)] implied by #[deny(warnings)] note: `PartialEq` implemented here - --> $DIR/derive.rs:34:10 + --> $DIR/derive.rs:32:10 | -34 | #[derive(PartialEq)] +32 | #[derive(PartialEq)] | ^^^^^^^^^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:45:1 + --> $DIR/derive.rs:42:1 | -45 | / impl Clone for Qux { -46 | | -47 | | fn clone(&self) -> Self { Qux } -48 | | } +42 | / impl Clone for Qux { +43 | | fn clone(&self) -> Self { Qux } +44 | | } | |_^ | = note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)] @@ -65,31 +63,28 @@ note: lint level defined here 6 | #![deny(warnings)] | ^^^^^^^^ note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:45:1 + --> $DIR/derive.rs:42:1 | -45 | / impl Clone for Qux { -46 | | -47 | | fn clone(&self) -> Self { Qux } -48 | | } +42 | / impl Clone for Qux { +43 | | fn clone(&self) -> Self { Qux } +44 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:70:1 + --> $DIR/derive.rs:66:1 | -70 | / impl<'a> Clone for Lt<'a> { -71 | | -72 | | fn clone(&self) -> Self { unimplemented!() } -73 | | } +66 | / impl<'a> Clone for Lt<'a> { +67 | | fn clone(&self) -> Self { unimplemented!() } +68 | | } | |_^ | = note: #[deny(expl_impl_clone_on_copy)] implied by #[deny(warnings)] note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:70:1 + --> $DIR/derive.rs:66:1 | -70 | / impl<'a> Clone for Lt<'a> { -71 | | -72 | | fn clone(&self) -> Self { unimplemented!() } -73 | | } +66 | / impl<'a> Clone for Lt<'a> { +67 | | fn clone(&self) -> Self { unimplemented!() } +68 | | } | |_^ error: aborting due to 5 previous errors From 856d64d43e6bc732e149e63e6e0b952f3a7d8184 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 11:13:52 +0100 Subject: [PATCH 13/55] clean tests/ui/doc.rs Cleaning the empty lines for clarity. --- tests/ui/doc.rs | 30 -------- tests/ui/doc.stderr | 182 ++++++++++++++++++++++---------------------- 2 files changed, 91 insertions(+), 121 deletions(-) diff --git a/tests/ui/doc.rs b/tests/ui/doc.rs index 1e34b391915..b954e78999e 100644 --- a/tests/ui/doc.rs +++ b/tests/ui/doc.rs @@ -1,23 +1,16 @@ //! This file tests for the DOC_MARKDOWN lint - #![feature(plugin)] #![plugin(clippy)] #![deny(doc_markdown)] /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) - - /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun - /// which should be reported only once despite being __doubly bad__. /// Here be ::is::a::global:path. - /// That's not code ~NotInCodeBlock~. - /// be_sure_we_got_to_the_end_of_it - fn foo_bar() { } @@ -32,7 +25,6 @@ fn foo_bar() { /// _foo bar_ /// ~~~ /// be_sure_we_got_to_the_end_of_it - fn multiline_codeblock() { } @@ -40,7 +32,6 @@ fn multiline_codeblock() { /// multiline /// emphasis_. /// be_sure_we_got_to_the_end_of_it - fn test_emphasis() { } @@ -55,7 +46,6 @@ fn test_emphasis() { /// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb /// NaN /// be_sure_we_got_to_the_end_of_it - fn test_units() { } @@ -65,15 +55,11 @@ fn test_units() { /// `💣` /// `❤️` /// ß_foo - /// ℝ_foo - /// 💣_foo /// ❤️_foo /// foo_ß - /// foo_ℝ - /// foo_💣 /// foo_❤️ /// [ßdummy textß][foo_1ß] @@ -89,28 +75,23 @@ fn test_units() { /// [foo3_💣]: dummy text /// [foo4_❤️]: dummy text /// be_sure_we_got_to_the_end_of_it - fn test_unicode() { } /// This test has [a link_with_underscores][chunked-example] inside it. See #823. - /// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues) /// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link]. /// It can also be [inline_link2]. - /// /// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example /// [inline_link]: https://foobar /// [inline_link2]: https://foobar - /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and /// `multiline_ticks` functions. /// /// expression of the type `_ m c` (where `` /// is one of {`&`, '|'} and `` is one of {`!=`, `>=`, `>` , /// be_sure_we_got_to_the_end_of_it - fn main() { foo_bar(); multiline_codeblock(); @@ -124,9 +105,7 @@ fn main() { /// # CamelCaseThing /// /// Not a title #897 CamelCaseThing - /// be_sure_we_got_to_the_end_of_it - fn issue897() { } @@ -134,7 +113,6 @@ fn issue897() { /// I am confused by brackets? (foo `x_y`) /// I am confused by brackets? (`x_y` foo) /// be_sure_we_got_to_the_end_of_it - fn issue900() { } @@ -148,7 +126,6 @@ fn issue900() { /// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html /// [helper_types]: ../helper_types/index.html /// be_sure_we_got_to_the_end_of_it - fn issue883() { } @@ -167,9 +144,6 @@ That's in a code block: `PackedNode` And BarQuz too. be_sure_we_got_to_the_end_of_it */ - - - fn issue1073() { } @@ -181,9 +155,6 @@ That's in a code block: PackedNode And BarQuz too. be_sure_we_got_to_the_end_of_it */ - - - fn issue1073_alt() { } @@ -194,6 +165,5 @@ fn issue1073_alt() { /// StillDont /// ```` /// be_sure_we_got_to_the_end_of_it - fn four_quotes() { } diff --git a/tests/ui/doc.stderr b/tests/ui/doc.stderr index 90df4766fae..d267331fb68 100644 --- a/tests/ui/doc.stderr +++ b/tests/ui/doc.stderr @@ -5,45 +5,51 @@ error: you should put `DOC_MARKDOWN` between ticks in the documentation | ^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/doc.rs:7:9 + --> $DIR/doc.rs:6:9 | -7 | #![deny(doc_markdown)] +6 | #![deny(doc_markdown)] | ^^^^^^^^^^^^ error: you should put `foo_bar` between ticks in the documentation - --> $DIR/doc.rs:9:9 + --> $DIR/doc.rs:8:9 | -9 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) +8 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^ error: you should put `foo::bar` between ticks in the documentation - --> $DIR/doc.rs:9:51 + --> $DIR/doc.rs:8:51 | -9 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) +8 | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^^ error: you should put `Foo::some_fun` between ticks in the documentation - --> $DIR/doc.rs:12:84 - | -12 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun - | ^^^^^^^^^^^^^ + --> $DIR/doc.rs:9:84 + | +9 | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun + | ^^^^^^^^^^^^^ error: you should put `is::a::global:path` between ticks in the documentation - --> $DIR/doc.rs:15:13 + --> $DIR/doc.rs:11:13 | -15 | /// Here be ::is::a::global:path. +11 | /// Here be ::is::a::global:path. | ^^^^^^^^^^^^^^^^^^^^ error: you should put `NotInCodeBlock` between ticks in the documentation - --> $DIR/doc.rs:17:21 + --> $DIR/doc.rs:12:21 | -17 | /// That's not code ~NotInCodeBlock~. +12 | /// That's not code ~NotInCodeBlock~. | ^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:19:5 + --> $DIR/doc.rs:13:5 | -19 | /// be_sure_we_got_to_the_end_of_it +13 | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:27:5 + | +27 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation @@ -53,129 +59,123 @@ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the doc | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:42:5 + --> $DIR/doc.rs:48:5 | -42 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:57:5 - | -57 | /// be_sure_we_got_to_the_end_of_it +48 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `ß_foo` between ticks in the documentation - --> $DIR/doc.rs:67:5 + --> $DIR/doc.rs:57:5 | -67 | /// ß_foo +57 | /// ß_foo | ^^^^^ error: you should put `ℝ_foo` between ticks in the documentation - --> $DIR/doc.rs:69:5 + --> $DIR/doc.rs:58:5 | -69 | /// ℝ_foo +58 | /// ℝ_foo | ^^^^^ error: you should put `foo_ß` between ticks in the documentation - --> $DIR/doc.rs:73:5 + --> $DIR/doc.rs:61:5 | -73 | /// foo_ß +61 | /// foo_ß | ^^^^^ error: you should put `foo_ℝ` between ticks in the documentation - --> $DIR/doc.rs:75:5 + --> $DIR/doc.rs:62:5 | -75 | /// foo_ℝ +62 | /// foo_ℝ | ^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:91:5 + --> $DIR/doc.rs:77:5 | -91 | /// be_sure_we_got_to_the_end_of_it +77 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `link_with_underscores` between ticks in the documentation - --> $DIR/doc.rs:96:22 + --> $DIR/doc.rs:81:22 | -96 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. +81 | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. | ^^^^^^^^^^^^^^^^^^^^^ error: you should put `inline_link2` between ticks in the documentation - --> $DIR/doc.rs:100:21 - | -100 | /// It can also be [inline_link2]. - | ^^^^^^^^^^^^ + --> $DIR/doc.rs:84:21 + | +84 | /// It can also be [inline_link2]. + | ^^^^^^^^^^^^ error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:112:5 - | -112 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/doc.rs:94:5 + | +94 | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you should put `CamelCaseThing` between ticks in the documentation - --> $DIR/doc.rs:126:22 + --> $DIR/doc.rs:107:22 | -126 | /// Not a title #897 CamelCaseThing +107 | /// Not a title #897 CamelCaseThing | ^^^^^^^^^^^^^^ +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:108:5 + | +108 | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:115:5 + | +115 | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation --> $DIR/doc.rs:128:5 | 128 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:136:5 - | -136 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:150:5 - | -150 | /// be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: you should put `FooBar` between ticks in the documentation - --> $DIR/doc.rs:162:42 + --> $DIR/doc.rs:139:42 | -162 | /** E.g. serialization of an empty list: FooBar +139 | /** E.g. serialization of an empty list: FooBar | ^^^^^^ error: you should put `BarQuz` between ticks in the documentation + --> $DIR/doc.rs:144:5 + | +144 | And BarQuz too. + | ^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:145:1 + | +145 | be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put `FooBar` between ticks in the documentation + --> $DIR/doc.rs:150:42 + | +150 | /** E.g. serialization of an empty list: FooBar + | ^^^^^^ + +error: you should put `BarQuz` between ticks in the documentation + --> $DIR/doc.rs:155:5 + | +155 | And BarQuz too. + | ^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation + --> $DIR/doc.rs:156:1 + | +156 | be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation --> $DIR/doc.rs:167:5 | -167 | And BarQuz too. - | ^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:168:1 - | -168 | be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `FooBar` between ticks in the documentation - --> $DIR/doc.rs:176:42 - | -176 | /** E.g. serialization of an empty list: FooBar - | ^^^^^^ - -error: you should put `BarQuz` between ticks in the documentation - --> $DIR/doc.rs:181:5 - | -181 | And BarQuz too. - | ^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:182:1 - | -182 | be_sure_we_got_to_the_end_of_it - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation - --> $DIR/doc.rs:196:5 - | -196 | /// be_sure_we_got_to_the_end_of_it +167 | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 29 previous errors From 5013f491954b9db4db4219f16fe3445f3fcf27c1 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:03:39 +0100 Subject: [PATCH 14/55] clean tests/ui/entry.rs Cleaning the empty lines for clarity. --- tests/ui/empty_enum.rs | 1 - tests/ui/entry.rs | 21 --------------------- tests/ui/entry.stderr | 24 ++++++++++++------------ 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/tests/ui/empty_enum.rs b/tests/ui/empty_enum.rs index 9f32b7ede10..941f0e73c0a 100644 --- a/tests/ui/empty_enum.rs +++ b/tests/ui/empty_enum.rs @@ -6,6 +6,5 @@ enum Empty {} - fn main() { } diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index 090221ba7a8..c7ee1840904 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -11,51 +11,30 @@ fn foo() {} fn insert_if_absent0(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { m.insert(k, v); } - - - } fn insert_if_absent1(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { foo(); m.insert(k, v); } - - - } fn insert_if_absent2(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { m.insert(k, v) } else { None }; - - - } fn insert_if_present2(m: &mut HashMap, k: K, v: V) { if m.contains_key(&k) { None } else { m.insert(k, v) }; - - - } fn insert_if_absent3(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - - - } fn insert_if_present3(m: &mut HashMap, k: K, v: V) { if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; - - - } fn insert_in_btreemap(m: &mut BTreeMap, k: K, v: V) { if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - - - } fn insert_other_if_absent(m: &mut HashMap, k: K, o: K, v: V) { diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 84edc47a714..838eb887370 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -11,39 +11,39 @@ note: lint level defined here | ^^^^^^^^^ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:20:5 + --> $DIR/entry.rs:17:5 | -20 | if !m.contains_key(&k) { foo(); m.insert(k, v); } +17 | if !m.contains_key(&k) { foo(); m.insert(k, v); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:27:5 + --> $DIR/entry.rs:21:5 | -27 | if !m.contains_key(&k) { m.insert(k, v) } else { None }; +21 | if !m.contains_key(&k) { m.insert(k, v) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:34:5 + --> $DIR/entry.rs:25:5 | -34 | if m.contains_key(&k) { None } else { m.insert(k, v) }; +25 | if m.contains_key(&k) { None } else { m.insert(k, v) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:41:5 + --> $DIR/entry.rs:29:5 | -41 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; +29 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:48:5 + --> $DIR/entry.rs:33:5 | -48 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; +33 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `BTreeMap` - --> $DIR/entry.rs:55:5 + --> $DIR/entry.rs:37:5 | -55 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; +37 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `m.entry(k)` error: aborting due to 7 previous errors From 8fc00c57b6604f60599e18d18b0f1252d61df260 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:03:48 +0100 Subject: [PATCH 15/55] clean tests/ui/eq_op.rs Cleaning the empty lines for clarity. --- tests/ui/eq_op.rs | 8 ---- tests/ui/eq_op.stderr | 88 +++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 52 deletions(-) diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index cbe12b066c9..cb02947933b 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -21,9 +21,6 @@ fn main() { // unary and binary operators (-(2) < -(2)); ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); - - - (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; // various other things @@ -35,7 +32,6 @@ fn main() { 1 + 1 == 2; 1 - 1 == 0; - 1 - 1; 1 / 1; true && true; @@ -47,14 +43,10 @@ fn main() { let b: u32 = 0; a == b && b == a; - a != b && b != a; - a < b && b > a; - a <= b && b >= a; - let mut a = vec![1]; a == a; 2*a.len() == 2*a.len(); // ok, functions diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index ab51797fe82..3e96dd4f968 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -1,7 +1,7 @@ error: this boolean expression can be simplified - --> $DIR/eq_op.rs:41:5 + --> $DIR/eq_op.rs:37:5 | -41 | true && true; +37 | true && true; | ^^^^^^^^^^^^ help: try `true` | note: lint level defined here @@ -11,33 +11,33 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/eq_op.rs:43:5 + --> $DIR/eq_op.rs:39:5 | -43 | true || true; +39 | true || true; | ^^^^^^^^^^^^ help: try `true` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:49:5 + --> $DIR/eq_op.rs:45:5 | -49 | a == b && b == a; +45 | a == b && b == a; | ^^^^^^^^^^^^^^^^ help: try `a == b` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:51:5 + --> $DIR/eq_op.rs:46:5 | -51 | a != b && b != a; +46 | a != b && b != a; | ^^^^^^^^^^^^^^^^ help: try `a != b` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:53:5 + --> $DIR/eq_op.rs:47:5 | -53 | a < b && b > a; +47 | a < b && b > a; | ^^^^^^^^^^^^^^ help: try `a < b` error: this boolean expression can be simplified - --> $DIR/eq_op.rs:55:5 + --> $DIR/eq_op.rs:48:5 | -55 | a <= b && b >= a; +48 | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ help: try `a <= b` error: equal expressions as operands to `==` @@ -113,99 +113,99 @@ error: equal expressions as operands to `&` | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:27:5 + --> $DIR/eq_op.rs:24:5 | -27 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; +24 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:30:5 + --> $DIR/eq_op.rs:27:5 | -30 | ([1] != [1]); +27 | ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:31:5 + --> $DIR/eq_op.rs:28:5 | -31 | ((1, 2) != (1, 2)); +28 | ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:35:5 + --> $DIR/eq_op.rs:32:5 | -35 | 1 + 1 == 2; +32 | 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:36:5 + --> $DIR/eq_op.rs:33:5 | -36 | 1 - 1 == 0; +33 | 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:36:5 + --> $DIR/eq_op.rs:33:5 | -36 | 1 - 1 == 0; +33 | 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:39:5 + --> $DIR/eq_op.rs:35:5 | -39 | 1 - 1; +35 | 1 - 1; | ^^^^^ error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:40:5 + --> $DIR/eq_op.rs:36:5 | -40 | 1 / 1; +36 | 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:41:5 + --> $DIR/eq_op.rs:37:5 | -41 | true && true; +37 | true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` - --> $DIR/eq_op.rs:43:5 + --> $DIR/eq_op.rs:39:5 | -43 | true || true; +39 | true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:49:5 + --> $DIR/eq_op.rs:45:5 | -49 | a == b && b == a; +45 | a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:51:5 + --> $DIR/eq_op.rs:46:5 | -51 | a != b && b != a; +46 | a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:53:5 + --> $DIR/eq_op.rs:47:5 | -53 | a < b && b > a; +47 | a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:55:5 + --> $DIR/eq_op.rs:48:5 | -55 | a <= b && b >= a; +48 | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:59:5 + --> $DIR/eq_op.rs:51:5 | -59 | a == a; +51 | a == a; | ^^^^^^ warning: taken reference of right operand - --> $DIR/eq_op.rs:97:13 + --> $DIR/eq_op.rs:89:13 | -97 | let z = x & &y; +89 | let z = x & &y; | ^^^^-- | | | help: use the right value directly `y` From fbc6b26592381d3916cf59639af99a3b3645ea8e Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:06:12 +0100 Subject: [PATCH 16/55] clean tests/ui/eta.rs Cleaning the empty lines for clarity. --- tests/ui/eta.rs | 15 --------------- tests/ui/eta.stderr | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index d333b938a32..91e081f5ec6 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -5,20 +5,10 @@ fn main() { let a = Some(1u8).map(|a| foo(a)); - - - meta(|a| foo(a)); - - - let c = Some(1u8).map(|a| {1+2; foo}(a)); - - - let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted - unsafe { Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn } @@ -26,11 +16,7 @@ fn main() { // See #815 let e = Some(1u8).map(|a| divergent(a)); let e = Some(1u8).map(|a| generic(a)); - - - let e = Some(1u8).map(generic); - // See #515 let a: Option>> = Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref> { Box::new(v) }); @@ -41,7 +27,6 @@ fn meta(f: F) where F: Fn(u8) { } fn foo(_: u8) { - } fn foo2(_: u8) -> u8 { diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 355db4deae4..b218523ba5f 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -11,29 +11,29 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^ error: redundant closure found - --> $DIR/eta.rs:11:10 - | -11 | meta(|a| foo(a)); - | ^^^^^^^^^^ help: remove closure as shown: `foo` + --> $DIR/eta.rs:8:10 + | +8 | meta(|a| foo(a)); + | ^^^^^^^^^^ help: remove closure as shown: `foo` error: redundant closure found - --> $DIR/eta.rs:15:27 - | -15 | let c = Some(1u8).map(|a| {1+2; foo}(a)); - | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` + --> $DIR/eta.rs:9:27 + | +9 | let c = Some(1u8).map(|a| {1+2; foo}(a)); + | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` warning: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/eta.rs:20:21 + --> $DIR/eta.rs:11:21 | -20 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted +11 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^ | = note: #[warn(needless_borrow)] on by default error: redundant closure found - --> $DIR/eta.rs:28:27 + --> $DIR/eta.rs:18:27 | -28 | let e = Some(1u8).map(|a| generic(a)); +18 | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` error: aborting due to 4 previous errors From bc9cdf1d645c3462be505ff5f4c3e5349271f839 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:08:07 +0100 Subject: [PATCH 17/55] clean tests/ui/eval_order_dependence.rs Cleaning the empty lines for clarity. --- tests/ui/eval_order_dependence.rs | 2 -- tests/ui/eval_order_dependence.stderr | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/ui/eval_order_dependence.rs b/tests/ui/eval_order_dependence.rs index 851a199f929..1c25afed77a 100644 --- a/tests/ui/eval_order_dependence.rs +++ b/tests/ui/eval_order_dependence.rs @@ -7,7 +7,6 @@ fn main() { let mut x = 0; let a = { x = 1; 1 } + x; - // Example from iss#277 x += { x = 20; 2 }; @@ -16,7 +15,6 @@ fn main() { struct Foo { a: i32, b: i32 }; let base = Foo { a: 4, b: 5 }; let foo = Foo { a: x, .. { x = 6; base } }; - // ...inside a closure? let closure = || { let mut x = 0; diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index ba985dd907a..5e5ae53e184 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -16,39 +16,39 @@ note: whether read occurs before this write depends on evaluation order | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:12:5 + --> $DIR/eval_order_dependence.rs:11:5 | -12 | x += { x = 20; 2 }; +11 | x += { x = 20; 2 }; | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:12:12 + --> $DIR/eval_order_dependence.rs:11:12 | -12 | x += { x = 20; 2 }; +11 | x += { x = 20; 2 }; | ^^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:18:24 + --> $DIR/eval_order_dependence.rs:17:24 | -18 | let foo = Foo { a: x, .. { x = 6; base } }; +17 | let foo = Foo { a: x, .. { x = 6; base } }; | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:18:32 + --> $DIR/eval_order_dependence.rs:17:32 | -18 | let foo = Foo { a: x, .. { x = 6; base } }; +17 | let foo = Foo { a: x, .. { x = 6; base } }; | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:23:9 + --> $DIR/eval_order_dependence.rs:21:9 | -23 | x += { x = 20; 2 }; +21 | x += { x = 20; 2 }; | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:23:16 + --> $DIR/eval_order_dependence.rs:21:16 | -23 | x += { x = 20; 2 }; +21 | x += { x = 20; 2 }; | ^^^^^^ error: aborting due to 4 previous errors From faca269488948425e1e624a3c2abbad6fb694731 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:10:27 +0100 Subject: [PATCH 18/55] clean tests/ui/float.rs Cleaning the empty lines for clarity. --- tests/ui/float_cmp.rs | 27 ------------------- tests/ui/float_cmp.stderr | 56 +++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 024dd9c242c..d6a74193ae3 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -41,48 +41,21 @@ fn main() { ZERO + ZERO != 1.0; //no error, comparison with zero is ok ONE == 1f32; - - - ONE == 1.0 + 0.0; - - - - ONE + ONE == ZERO + ONE + ONE; - - - - ONE != 2.0; - - - ONE != 0.0; // no error, comparison with zero is ok twice(ONE) != ONE; - - - ONE as f64 != 2.0; - - - ONE as f64 != 0.0; // no error, comparison with zero is ok let x : f64 = 1.0; x == 1.0; - - - x != 0f64; // no error, comparison with zero is ok twice(x) != twice(ONE as f64); - - - - x < 0.0; // no errors, lower or greater comparisons need no fuzzyness x > 0.0; x <= 0.0; diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 1eff9cdecc4..082990334d1 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -16,87 +16,87 @@ note: std::f32::EPSILON and std::f64::EPSILON are available. | ^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:47:5 + --> $DIR/float_cmp.rs:44:5 | -47 | ONE == 1.0 + 0.0; +44 | ONE == 1.0 + 0.0; | ^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE - (1.0 + 0.0)).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:47:5 + --> $DIR/float_cmp.rs:44:5 | -47 | ONE == 1.0 + 0.0; +44 | ONE == 1.0 + 0.0; | ^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:52:5 + --> $DIR/float_cmp.rs:45:5 | -52 | ONE + ONE == ZERO + ONE + ONE; +45 | ONE + ONE == ZERO + ONE + ONE; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE + ONE - (ZERO + ONE + ONE)).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:52:5 + --> $DIR/float_cmp.rs:45:5 | -52 | ONE + ONE == ZERO + ONE + ONE; +45 | ONE + ONE == ZERO + ONE + ONE; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:57:5 + --> $DIR/float_cmp.rs:46:5 | -57 | ONE != 2.0; +46 | ONE != 2.0; | ^^^^^^^^^^ help: consider comparing them within some error `(ONE - 2.0).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:57:5 + --> $DIR/float_cmp.rs:46:5 | -57 | ONE != 2.0; +46 | ONE != 2.0; | ^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:62:5 + --> $DIR/float_cmp.rs:48:5 | -62 | twice(ONE) != ONE; +48 | twice(ONE) != ONE; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(twice(ONE) - ONE).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:62:5 + --> $DIR/float_cmp.rs:48:5 | -62 | twice(ONE) != ONE; +48 | twice(ONE) != ONE; | ^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:66:5 + --> $DIR/float_cmp.rs:49:5 | -66 | ONE as f64 != 2.0; +49 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(ONE as f64 - 2.0).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:66:5 + --> $DIR/float_cmp.rs:49:5 | -66 | ONE as f64 != 2.0; +49 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:74:5 + --> $DIR/float_cmp.rs:54:5 | -74 | x == 1.0; +54 | x == 1.0; | ^^^^^^^^ help: consider comparing them within some error `(x - 1.0).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:74:5 + --> $DIR/float_cmp.rs:54:5 | -74 | x == 1.0; +54 | x == 1.0; | ^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:80:5 + --> $DIR/float_cmp.rs:57:5 | -80 | twice(x) != twice(ONE as f64); +57 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error `(twice(x) - twice(ONE as f64)).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:80:5 + --> $DIR/float_cmp.rs:57:5 | -80 | twice(x) != twice(ONE as f64); +57 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors From 6d2329f2cbc967405e90f714b839cb7bda4fe3e7 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:15:10 +0100 Subject: [PATCH 19/55] clean tests/ui/for_loop.rs Cleaning the empty lines for clarity. --- tests/ui/for_loop.rs | 139 ------------ tests/ui/for_loop.stderr | 449 ++++++++++++++++----------------------- 2 files changed, 184 insertions(+), 404 deletions(-) diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index 76c8a82341d..556053fdbc5 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -14,45 +14,30 @@ fn for_loop_over_option_and_result() { let v = vec![0,1,2]; // check FOR_LOOP_OVER_OPTION lint - for x in option { - - println!("{}", x); } // check FOR_LOOP_OVER_RESULT lint - for x in result { - - println!("{}", x); } for x in option.ok_or("x not found") { - - println!("{}", x); } // make sure LOOP_OVER_NEXT lint takes precedence when next() is the last call in the chain - for x in v.iter().next() { - println!("{}", x); } // make sure we lint when next() is not the last call in the chain - for x in v.iter().next().and(Some(0)) { - - println!("{}", x); } for x in v.iter().next().ok_or("x not found") { - - println!("{}", x); } @@ -97,47 +82,26 @@ fn main() { let mut vec = vec![1, 2, 3, 4]; let vec2 = vec![1, 2, 3, 4]; for i in 0..vec.len() { - - - - println!("{}", vec[i]); } for i in 0..vec.len() { - let i = 42; // make a different `i` println!("{}", vec[i]); // ok, not the `i` of the for-loop } for i in 0..vec.len() { let _ = vec[i]; } - - - - // ICE #746 for j in 0..4 { - - - - println!("{:?}", STATIC[j]); } for j in 0..4 { - - - - println!("{:?}", CONST[j]); } for i in 0..vec.len() { - - - - println!("{} {}", vec[i], i); } for i in 0..vec.len() { // not an error, indexing more than one variable @@ -145,86 +109,46 @@ fn main() { } for i in 0..vec.len() { - - - - println!("{}", vec2[i]); } for i in 5..vec.len() { - - - - println!("{}", vec[i]); } for i in 0..MAX_LEN { - - - - println!("{}", vec[i]); } for i in 0...MAX_LEN { - - - - println!("{}", vec[i]); } for i in 5..10 { - - - - println!("{}", vec[i]); } for i in 5...10 { - - - - println!("{}", vec[i]); } for i in 5..vec.len() { - - - - println!("{} {}", vec[i], i); } for i in 5..10 { - - - - println!("{} {}", vec[i], i); } for i in 10..0 { - - - println!("{}", i); } for i in 10...0 { - - - println!("{}", i); } for i in MAX_LEN..0 { - - println!("{}", i); } @@ -250,16 +174,10 @@ fn main() { // testing that the empty range lint folds constants for i in 10..5+4 { - - - println!("{}", i); } for i in (5+2)..(3-1) { - - - println!("{}", i); } @@ -288,20 +206,11 @@ fn main() { for _v in vec.iter() { } - - - for _v in vec.iter_mut() { } - - - let out_vec = vec![1,2,3]; for _v in out_vec.into_iter() { } - - - let array = [1, 2, 3]; for _v in array.into_iter() {} @@ -310,61 +219,33 @@ fn main() { for _v in [1, 2, 3].iter() { } - - - for _v in (&mut [1, 2, 3]).iter() { } // no error for _v in [0; 32].iter() {} - - - for _v in [0; 33].iter() {} // no error let ll: LinkedList<()> = LinkedList::new(); for _v in ll.iter() { } - - - let vd: VecDeque<()> = VecDeque::new(); for _v in vd.iter() { } - - - let bh: BinaryHeap<()> = BinaryHeap::new(); for _v in bh.iter() { } - - - let hm: HashMap<(), ()> = HashMap::new(); for _v in hm.iter() { } - - - let bt: BTreeMap<(), ()> = BTreeMap::new(); for _v in bt.iter() { } - - - let hs: HashSet<()> = HashSet::new(); for _v in hs.iter() { } - - - let bs: BTreeSet<()> = BTreeSet::new(); for _v in bs.iter() { } - - - - for _v in vec.iter().next() { } let u = Unrelated(vec![]); @@ -442,19 +323,11 @@ fn main() { let m : HashMap = HashMap::new(); for (_, v) in &m { - - - - let _v = v; } let m : Rc> = Rc::new(HashMap::new()); for (_, v) in &*m { - - - - let _v = v; // Here the `*` is not actually necesarry, but the test tests that we don't suggest // `in *m.values()` as we used to @@ -462,29 +335,17 @@ fn main() { let mut m : HashMap = HashMap::new(); for (_, v) in &mut m { - - - - let _v = v; } let m: &mut HashMap = &mut HashMap::new(); for (_, v) in &mut *m { - - - - let _v = v; } let m : HashMap = HashMap::new(); let rm = &m; for (k, _value) in rm { - - - - let _k = k; } diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index ca93e4a38c6..fb5592a54e7 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -1,7 +1,7 @@ error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement. - --> $DIR/for_loop.rs:18:14 + --> $DIR/for_loop.rs:17:14 | -18 | for x in option { +17 | for x in option { | ^^^^^^ | = note: #[deny(for_loop_over_option)] implied by #[deny(clippy)] @@ -13,9 +13,9 @@ note: lint level defined here = help: consider replacing `for x in option` with `if let Some(x) = option` error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement. - --> $DIR/for_loop.rs:26:14 + --> $DIR/for_loop.rs:22:14 | -26 | for x in result { +22 | for x in result { | ^^^^^^ | = note: #[deny(for_loop_over_result)] implied by #[deny(clippy)] @@ -27,21 +27,20 @@ note: lint level defined here = help: consider replacing `for x in result` with `if let Ok(x) = result` error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement. - --> $DIR/for_loop.rs:32:14 + --> $DIR/for_loop.rs:26:14 | -32 | for x in option.ok_or("x not found") { +26 | for x in option.ok_or("x not found") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(for_loop_over_result)] implied by #[deny(clippy)] = help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want - --> $DIR/for_loop.rs:40:5 + --> $DIR/for_loop.rs:31:5 | -40 | / for x in v.iter().next() { -41 | | -42 | | println!("{}", x); -43 | | } +31 | / for x in v.iter().next() { +32 | | println!("{}", x); +33 | | } | |_____^ | = note: #[deny(iter_next_loop)] implied by #[deny(clippy)] @@ -52,522 +51,442 @@ note: lint level defined here | ^^^^^^ error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement. - --> $DIR/for_loop.rs:47:14 + --> $DIR/for_loop.rs:36:14 | -47 | for x in v.iter().next().and(Some(0)) { +36 | for x in v.iter().next().and(Some(0)) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(for_loop_over_option)] implied by #[deny(clippy)] = help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))` error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement. - --> $DIR/for_loop.rs:53:14 + --> $DIR/for_loop.rs:40:14 | -53 | for x in v.iter().next().ok_or("x not found") { +40 | for x in v.iter().next().ok_or("x not found") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(for_loop_over_result)] implied by #[deny(clippy)] = help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")` error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:99:5 - | -99 | / for i in 0..vec.len() { -100 | | -101 | | -102 | | -103 | | -104 | | println!("{}", vec[i]); -105 | | } - | |_____^ - | + --> $DIR/for_loop.rs:84:5 + | +84 | / for i in 0..vec.len() { +85 | | println!("{}", vec[i]); +86 | | } + | |_____^ + | note: lint level defined here - --> $DIR/for_loop.rs:90:8 - | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] - | ^^^^^^^^^^^^^^^^^^^ + --> $DIR/for_loop.rs:75:8 + | +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] + | ^^^^^^^^^^^^^^^^^^^ help: consider using an iterator - | for in &vec { + | for in &vec { warning: unused variable: `i` - --> $DIR/for_loop.rs:107:9 - | -107 | for i in 0..vec.len() { - | ^ - | - = note: #[warn(unused_variables)] on by default + --> $DIR/for_loop.rs:88:9 + | +88 | for i in 0..vec.len() { + | ^ + | + = note: #[warn(unused_variables)] on by default error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:113:5 - | -113 | for i in 0..vec.len() { let _ = vec[i]; } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | + --> $DIR/for_loop.rs:93:5 + | +93 | for i in 0..vec.len() { let _ = vec[i]; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | help: consider using an iterator - | for in &vec { let _ = vec[i]; } + | for in &vec { let _ = vec[i]; } error: the loop variable `j` is only used to index `STATIC`. - --> $DIR/for_loop.rs:120:5 - | -120 | / for j in 0..4 { -121 | | -122 | | -123 | | -124 | | -125 | | println!("{:?}", STATIC[j]); -126 | | } - | |_____^ - | + --> $DIR/for_loop.rs:96:5 + | +96 | / for j in 0..4 { +97 | | println!("{:?}", STATIC[j]); +98 | | } + | |_____^ + | help: consider using an iterator - | for in STATIC.iter().take(4) { + | for in STATIC.iter().take(4) { error: the loop variable `j` is only used to index `CONST`. - --> $DIR/for_loop.rs:128:5 + --> $DIR/for_loop.rs:100:5 | -128 | / for j in 0..4 { -129 | | -130 | | -131 | | -132 | | -133 | | println!("{:?}", CONST[j]); -134 | | } +100 | / for j in 0..4 { +101 | | println!("{:?}", CONST[j]); +102 | | } | |_____^ | help: consider using an iterator | for in CONST.iter().take(4) { error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:136:5 + --> $DIR/for_loop.rs:104:5 | -136 | / for i in 0..vec.len() { -137 | | -138 | | -139 | | -140 | | -141 | | println!("{} {}", vec[i], i); -142 | | } +104 | / for i in 0..vec.len() { +105 | | println!("{} {}", vec[i], i); +106 | | } | |_____^ | help: consider using an iterator | for (i, ) in vec.iter().enumerate() { error: the loop variable `i` is only used to index `vec2`. - --> $DIR/for_loop.rs:147:5 + --> $DIR/for_loop.rs:111:5 | -147 | / for i in 0..vec.len() { -148 | | -149 | | -150 | | -151 | | -152 | | println!("{}", vec2[i]); -153 | | } +111 | / for i in 0..vec.len() { +112 | | println!("{}", vec2[i]); +113 | | } | |_____^ | help: consider using an iterator | for in vec2.iter().take(vec.len()) { error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:155:5 + --> $DIR/for_loop.rs:115:5 | -155 | / for i in 5..vec.len() { -156 | | -157 | | -158 | | -159 | | -160 | | println!("{}", vec[i]); -161 | | } +115 | / for i in 5..vec.len() { +116 | | println!("{}", vec[i]); +117 | | } | |_____^ | help: consider using an iterator | for in vec.iter().skip(5) { error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:163:5 + --> $DIR/for_loop.rs:119:5 | -163 | / for i in 0..MAX_LEN { -164 | | -165 | | -166 | | -167 | | -168 | | println!("{}", vec[i]); -169 | | } +119 | / for i in 0..MAX_LEN { +120 | | println!("{}", vec[i]); +121 | | } | |_____^ | help: consider using an iterator | for in vec.iter().take(MAX_LEN) { error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:171:5 + --> $DIR/for_loop.rs:123:5 | -171 | / for i in 0...MAX_LEN { -172 | | -173 | | -174 | | -175 | | -176 | | println!("{}", vec[i]); -177 | | } +123 | / for i in 0...MAX_LEN { +124 | | println!("{}", vec[i]); +125 | | } | |_____^ | help: consider using an iterator | for in vec.iter().take(MAX_LEN + 1) { error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:179:5 + --> $DIR/for_loop.rs:127:5 | -179 | / for i in 5..10 { -180 | | -181 | | -182 | | -183 | | -184 | | println!("{}", vec[i]); -185 | | } +127 | / for i in 5..10 { +128 | | println!("{}", vec[i]); +129 | | } | |_____^ | help: consider using an iterator | for in vec.iter().take(10).skip(5) { error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:187:5 + --> $DIR/for_loop.rs:131:5 | -187 | / for i in 5...10 { -188 | | -189 | | -190 | | -191 | | -192 | | println!("{}", vec[i]); -193 | | } +131 | / for i in 5...10 { +132 | | println!("{}", vec[i]); +133 | | } | |_____^ | help: consider using an iterator | for in vec.iter().take(10 + 1).skip(5) { error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:195:5 + --> $DIR/for_loop.rs:135:5 | -195 | / for i in 5..vec.len() { -196 | | -197 | | -198 | | -199 | | -200 | | println!("{} {}", vec[i], i); -201 | | } +135 | / for i in 5..vec.len() { +136 | | println!("{} {}", vec[i], i); +137 | | } | |_____^ | help: consider using an iterator | for (i, ) in vec.iter().enumerate().skip(5) { error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:203:5 + --> $DIR/for_loop.rs:139:5 | -203 | / for i in 5..10 { -204 | | -205 | | -206 | | -207 | | -208 | | println!("{} {}", vec[i], i); -209 | | } +139 | / for i in 5..10 { +140 | | println!("{} {}", vec[i], i); +141 | | } | |_____^ | help: consider using an iterator | for (i, ) in vec.iter().enumerate().take(10).skip(5) { error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:211:5 + --> $DIR/for_loop.rs:143:5 | -211 | / for i in 10..0 { -212 | | -213 | | -214 | | -215 | | println!("{}", i); -216 | | } +143 | / for i in 10..0 { +144 | | println!("{}", i); +145 | | } | |_____^ | note: lint level defined here - --> $DIR/for_loop.rs:90:90 + --> $DIR/for_loop.rs:75:90 | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | for i in (0..10).rev() { error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:218:5 + --> $DIR/for_loop.rs:147:5 | -218 | / for i in 10...0 { -219 | | -220 | | -221 | | -222 | | println!("{}", i); -223 | | } +147 | / for i in 10...0 { +148 | | println!("{}", i); +149 | | } | |_____^ | help: consider using the following if you are attempting to iterate over this range in reverse | for i in (0...10).rev() { error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:225:5 + --> $DIR/for_loop.rs:151:5 | -225 | / for i in MAX_LEN..0 { -226 | | -227 | | -228 | | println!("{}", i); -229 | | } +151 | / for i in MAX_LEN..0 { +152 | | println!("{}", i); +153 | | } | |_____^ | help: consider using the following if you are attempting to iterate over this range in reverse | for i in (0..MAX_LEN).rev() { error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:231:5 + --> $DIR/for_loop.rs:155:5 | -231 | / for i in 5..5 { -232 | | println!("{}", i); -233 | | } +155 | / for i in 5..5 { +156 | | println!("{}", i); +157 | | } | |_____^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:252:5 + --> $DIR/for_loop.rs:176:5 | -252 | / for i in 10..5+4 { -253 | | -254 | | -255 | | -256 | | println!("{}", i); -257 | | } +176 | / for i in 10..5+4 { +177 | | println!("{}", i); +178 | | } | |_____^ | help: consider using the following if you are attempting to iterate over this range in reverse | for i in (5+4..10).rev() { error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:259:5 + --> $DIR/for_loop.rs:180:5 | -259 | / for i in (5+2)..(3-1) { -260 | | -261 | | -262 | | -263 | | println!("{}", i); -264 | | } +180 | / for i in (5+2)..(3-1) { +181 | | println!("{}", i); +182 | | } | |_____^ | help: consider using the following if you are attempting to iterate over this range in reverse | for i in ((3-1)..(5+2)).rev() { error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:266:5 + --> $DIR/for_loop.rs:184:5 | -266 | / for i in (5+2)..(8-1) { -267 | | println!("{}", i); -268 | | } +184 | / for i in (5+2)..(8-1) { +185 | | println!("{}", i); +186 | | } | |_____^ error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:289:15 + --> $DIR/for_loop.rs:207:15 | -289 | for _v in vec.iter() { } +207 | for _v in vec.iter() { } | ^^^^^^^^^^ help: to write this more concisely, try `&vec` | note: lint level defined here - --> $DIR/for_loop.rs:90:29 + --> $DIR/for_loop.rs:75:29 | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^^^^^ error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:294:15 + --> $DIR/for_loop.rs:209:15 | -294 | for _v in vec.iter_mut() { } +209 | for _v in vec.iter_mut() { } | ^^^^^^^^^^^^^^ help: to write this more concisely, try `&mut vec` error: it is more idiomatic to loop over containers instead of using explicit iteration methods` - --> $DIR/for_loop.rs:300:15 + --> $DIR/for_loop.rs:212:15 | -300 | for _v in out_vec.into_iter() { } +212 | for _v in out_vec.into_iter() { } | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `out_vec` | note: lint level defined here - --> $DIR/for_loop.rs:90:49 + --> $DIR/for_loop.rs:75:49 | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:306:15 + --> $DIR/for_loop.rs:215:15 | -306 | for _v in array.into_iter() {} +215 | for _v in array.into_iter() {} | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&array` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:311:15 + --> $DIR/for_loop.rs:220:15 | -311 | for _v in [1, 2, 3].iter() { } +220 | for _v in [1, 2, 3].iter() { } | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&[1, 2, 3]` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:318:15 + --> $DIR/for_loop.rs:224:15 | -318 | for _v in [0; 32].iter() {} +224 | for _v in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try `&[0; 32]` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:326:15 + --> $DIR/for_loop.rs:229:15 | -326 | for _v in ll.iter() { } +229 | for _v in ll.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&ll` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:332:15 + --> $DIR/for_loop.rs:232:15 | -332 | for _v in vd.iter() { } +232 | for _v in vd.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&vd` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:338:15 + --> $DIR/for_loop.rs:235:15 | -338 | for _v in bh.iter() { } +235 | for _v in bh.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&bh` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:344:15 + --> $DIR/for_loop.rs:238:15 | -344 | for _v in hm.iter() { } +238 | for _v in hm.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&hm` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:350:15 + --> $DIR/for_loop.rs:241:15 | -350 | for _v in bt.iter() { } +241 | for _v in bt.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&bt` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:356:15 + --> $DIR/for_loop.rs:244:15 | -356 | for _v in hs.iter() { } +244 | for _v in hs.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&hs` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:362:15 + --> $DIR/for_loop.rs:247:15 | -362 | for _v in bs.iter() { } +247 | for _v in bs.iter() { } | ^^^^^^^^^ help: to write this more concisely, try `&bs` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want - --> $DIR/for_loop.rs:368:5 + --> $DIR/for_loop.rs:249:5 | -368 | for _v in vec.iter().next() { } +249 | for _v in vec.iter().next() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/for_loop.rs:90:74 + --> $DIR/for_loop.rs:75:74 | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^ error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/for_loop.rs:375:5 + --> $DIR/for_loop.rs:256:5 | -375 | vec.iter().map(|x| out.push(x)).collect::>(); +256 | vec.iter().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/for_loop.rs:91:8 + --> $DIR/for_loop.rs:76:8 | -91 | #[deny(unused_collect)] +76 | #[deny(unused_collect)] | ^^^^^^^^^^^^^^ error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators - --> $DIR/for_loop.rs:380:5 + --> $DIR/for_loop.rs:261:5 | -380 | for _v in &vec { _index += 1 } +261 | for _v in &vec { _index += 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/for_loop.rs:90:110 + --> $DIR/for_loop.rs:75:110 | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^^^^^^^^^^^^ error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators - --> $DIR/for_loop.rs:384:5 + --> $DIR/for_loop.rs:265:5 | -384 | for _v in &vec { _index += 1 } +265 | for _v in &vec { _index += 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:444:5 + --> $DIR/for_loop.rs:325:5 | -444 | / for (_, v) in &m { -445 | | -446 | | -447 | | -448 | | -449 | | let _v = v; -450 | | } +325 | / for (_, v) in &m { +326 | | let _v = v; +327 | | } | |_____^ | note: lint level defined here - --> $DIR/for_loop.rs:90:133 + --> $DIR/for_loop.rs:75:133 | -90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] +75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)] | ^^^^^^^^^^ help: use the corresponding method | for v in m.values() { error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:453:5 + --> $DIR/for_loop.rs:330:5 | -453 | / for (_, v) in &*m { -454 | | -455 | | -456 | | -... | -460 | | // `in *m.values()` as we used to -461 | | } +330 | / for (_, v) in &*m { +331 | | let _v = v; +332 | | // Here the `*` is not actually necesarry, but the test tests that we don't suggest +333 | | // `in *m.values()` as we used to +334 | | } | |_____^ | help: use the corresponding method | for v in (*m).values() { error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:464:5 + --> $DIR/for_loop.rs:337:5 | -464 | / for (_, v) in &mut m { -465 | | -466 | | -467 | | -468 | | -469 | | let _v = v; -470 | | } +337 | / for (_, v) in &mut m { +338 | | let _v = v; +339 | | } | |_____^ | help: use the corresponding method | for v in m.values_mut() { error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:473:5 + --> $DIR/for_loop.rs:342:5 | -473 | / for (_, v) in &mut *m { -474 | | -475 | | -476 | | -477 | | -478 | | let _v = v; -479 | | } +342 | / for (_, v) in &mut *m { +343 | | let _v = v; +344 | | } | |_____^ | help: use the corresponding method | for v in (*m).values_mut() { error: you seem to want to iterate on a map's keys - --> $DIR/for_loop.rs:483:5 + --> $DIR/for_loop.rs:348:5 | -483 | / for (k, _value) in rm { -484 | | -485 | | -486 | | -487 | | -488 | | let _k = k; -489 | | } +348 | / for (k, _value) in rm { +349 | | let _k = k; +350 | | } | |_____^ | help: use the corresponding method From df5d12a3ecf8e903482c4b6ea427247b5fbe8a27 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:19:46 +0100 Subject: [PATCH 20/55] clean tests/ui/formatting.rs Cleaning the empty lines for clarity. --- tests/ui/formatting.rs | 22 ------------ tests/ui/formatting.stderr | 74 ++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 61 deletions(-) diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 03064bf5ae7..822e57d4541 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -13,8 +13,6 @@ fn main() { // weird `else if` formatting: if foo() { } if foo() { - - } let _ = { // if as the last expression @@ -22,8 +20,6 @@ fn main() { if foo() { } if foo() { - - } else { } @@ -32,8 +28,6 @@ fn main() { let _ = { // if in the middle of a block if foo() { } if foo() { - - } else { } @@ -43,15 +37,11 @@ fn main() { if foo() { } else - - if foo() { // the span of the above error should continue here } if foo() { } - - else if foo() { // the span of the above error should continue here } @@ -73,25 +63,17 @@ fn main() { if foo() { } - else if - foo() {} // weird op_eq formatting: let mut a = 42; a =- 35; - - a =* &191; - - let mut b = true; b =! false; - - // those are ok: a = -35; a = *&191; @@ -100,14 +82,10 @@ fn main() { // possible missing comma in an array let _ = &[ -1, -2, -3 // <= no comma here - - -4, -5, -6 ]; let _ = &[ -1, -2, -3 // <= no comma here - - *4, -5, -6 ]; diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index a96901e4fbc..d69c4dae730 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -13,54 +13,50 @@ note: lint level defined here = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:24:10 + --> $DIR/formatting.rs:22:10 | -24 | } if foo() { +22 | } if foo() { | ^ | = note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)] = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:34:10 + --> $DIR/formatting.rs:30:10 | -34 | } if foo() { +30 | } if foo() { | ^ | = note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)] = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:45:6 + --> $DIR/formatting.rs:39:6 | -45 | } else +39 | } else | ______^ -46 | | -47 | | -48 | | if foo() { // the span of the above error should continue here +40 | | if foo() { // the span of the above error should continue here | |____^ | = note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)] = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:52:6 + --> $DIR/formatting.rs:44:6 | -52 | } +44 | } | ______^ -53 | | -54 | | -55 | | else -56 | | if foo() { // the span of the above error should continue here +45 | | else +46 | | if foo() { // the span of the above error should continue here | |____^ | = note: #[deny(suspicious_else_formatting)] implied by #[deny(clippy)] = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:83:6 + --> $DIR/formatting.rs:71:6 | -83 | a =- 35; +71 | a =- 35; | ^^^^ | = note: #[deny(suspicious_assignment_formatting)] implied by #[deny(clippy)] @@ -72,45 +68,45 @@ note: lint level defined here = note: to remove this lint, use either `-=` or `= -` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:86:6 + --> $DIR/formatting.rs:72:6 | -86 | a =* &191; +72 | a =* &191; | ^^^^ | = note: #[deny(suspicious_assignment_formatting)] implied by #[deny(clippy)] = note: to remove this lint, use either `*=` or `= *` error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:91:6 + --> $DIR/formatting.rs:75:6 | -91 | b =! false; +75 | b =! false; | ^^^^ | = note: #[deny(suspicious_assignment_formatting)] implied by #[deny(clippy)] = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:102:19 - | -102 | -1, -2, -3 // <= no comma here - | ^ - | - = note: #[deny(possible_missing_comma)] implied by #[deny(clippy)] + --> $DIR/formatting.rs:84:19 + | +84 | -1, -2, -3 // <= no comma here + | ^ + | + = note: #[deny(possible_missing_comma)] implied by #[deny(clippy)] note: lint level defined here - --> $DIR/formatting.rs:4:9 - | -4 | #![deny(clippy)] - | ^^^^^^ - = note: to remove this lint, add a comma or write the expr in a single line + --> $DIR/formatting.rs:4:9 + | +4 | #![deny(clippy)] + | ^^^^^^ + = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:108:19 - | -108 | -1, -2, -3 // <= no comma here - | ^ - | - = note: #[deny(possible_missing_comma)] implied by #[deny(clippy)] - = note: to remove this lint, add a comma or write the expr in a single line + --> $DIR/formatting.rs:88:19 + | +88 | -1, -2, -3 // <= no comma here + | ^ + | + = note: #[deny(possible_missing_comma)] implied by #[deny(clippy)] + = note: to remove this lint, add a comma or write the expr in a single line error: aborting due to 10 previous errors From 2389f9e94c4ac493fef3701ac197a61e091c1db0 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:29:21 +0100 Subject: [PATCH 21/55] clean tests/ui/functions.rs Cleaning the empty lines for clarity. --- tests/ui/functions.rs | 12 ---------- tests/ui/functions.stderr | 47 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/tests/ui/functions.rs b/tests/ui/functions.rs index bb09be575fd..7f2330b60cc 100644 --- a/tests/ui/functions.rs +++ b/tests/ui/functions.rs @@ -9,7 +9,6 @@ fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {} fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { - } // don't lint extern fns @@ -19,7 +18,6 @@ pub trait Foo { fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool); fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); - fn ptr(p: *const u8); } @@ -28,7 +26,6 @@ pub struct Bar; impl Bar { fn good_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {} fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} - } // ok, we don’t want to warn implementations @@ -38,11 +35,8 @@ impl Foo for Bar { fn ptr(p: *const u8) { println!("{}", unsafe { *p }); - println!("{:?}", unsafe { p.as_ref() }); - unsafe { std::ptr::read(p) }; - } } @@ -54,11 +48,8 @@ fn private(p: *const u8) { pub fn public(p: *const u8) { println!("{}", unsafe { *p }); - println!("{:?}", unsafe { p.as_ref() }); - unsafe { std::ptr::read(p) }; - } impl Bar { @@ -68,11 +59,8 @@ impl Bar { pub fn public(self, p: *const u8) { println!("{}", unsafe { *p }); - println!("{:?}", unsafe { p.as_ref() }); - unsafe { std::ptr::read(p) }; - } pub fn public_ok(self, p: *const u8) { diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 6e674ffb7b2..0abf8f2f0a8 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -2,8 +2,7 @@ error: this function has too many arguments (8/7) --> $DIR/functions.rs:11:1 | 11 | / fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { -12 | | -13 | | } +12 | | } | |_^ | = note: #[deny(too_many_arguments)] implied by #[deny(clippy)] @@ -14,25 +13,25 @@ note: lint level defined here | ^^^^^^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:20:5 + --> $DIR/functions.rs:19:5 | -20 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); +19 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(too_many_arguments)] implied by #[deny(clippy)] error: this function has too many arguments (8/7) - --> $DIR/functions.rs:30:5 + --> $DIR/functions.rs:28:5 | -30 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} +28 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(too_many_arguments)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:40:34 + --> $DIR/functions.rs:37:34 | -40 | println!("{}", unsafe { *p }); +37 | println!("{}", unsafe { *p }); | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] @@ -43,65 +42,65 @@ note: lint level defined here | ^^^^^^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:42:35 + --> $DIR/functions.rs:38:35 | -42 | println!("{:?}", unsafe { p.as_ref() }); +38 | println!("{:?}", unsafe { p.as_ref() }); | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:44:33 + --> $DIR/functions.rs:39:33 | -44 | unsafe { std::ptr::read(p) }; +39 | unsafe { std::ptr::read(p) }; | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:56:30 + --> $DIR/functions.rs:50:30 | -56 | println!("{}", unsafe { *p }); +50 | println!("{}", unsafe { *p }); | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:58:31 + --> $DIR/functions.rs:51:31 | -58 | println!("{:?}", unsafe { p.as_ref() }); +51 | println!("{:?}", unsafe { p.as_ref() }); | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:60:29 + --> $DIR/functions.rs:52:29 | -60 | unsafe { std::ptr::read(p) }; +52 | unsafe { std::ptr::read(p) }; | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:70:34 + --> $DIR/functions.rs:61:34 | -70 | println!("{}", unsafe { *p }); +61 | println!("{}", unsafe { *p }); | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:72:35 + --> $DIR/functions.rs:62:35 | -72 | println!("{:?}", unsafe { p.as_ref() }); +62 | println!("{:?}", unsafe { p.as_ref() }); | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:74:33 + --> $DIR/functions.rs:63:33 | -74 | unsafe { std::ptr::read(p) }; +63 | unsafe { std::ptr::read(p) }; | ^ | = note: #[deny(not_unsafe_ptr_arg_deref)] implied by #[deny(clippy)] From 3ca67910a8a8bebf8a6fc20bec802c087214d3b3 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:31:44 +0100 Subject: [PATCH 22/55] clean tests/ui/if_let_redundant_pattern_matching.rs Cleaning the empty lines for clarity. --- tests/ui/if_let_redundant_pattern_matching.rs | 18 ------------------ .../if_let_redundant_pattern_matching.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/tests/ui/if_let_redundant_pattern_matching.rs b/tests/ui/if_let_redundant_pattern_matching.rs index c48518304e2..8ba2e1c5ff7 100644 --- a/tests/ui/if_let_redundant_pattern_matching.rs +++ b/tests/ui/if_let_redundant_pattern_matching.rs @@ -8,46 +8,28 @@ fn main() { if let Ok(_) = Ok::(42) {} - - - if let Err(_) = Err::(42) { - - - } if let None = None::<()> { - - - } if let Some(_) = Some(42) { - - - } if Ok::(42).is_ok() { - } if Err::(42).is_err() { - } if None::.is_none() { - } if Some(42).is_some() { - } if let Ok(x) = Ok::(42) { println!("{}", x); } } - - diff --git a/tests/ui/if_let_redundant_pattern_matching.stderr b/tests/ui/if_let_redundant_pattern_matching.stderr index 198a1974065..a5dddf05ec4 100644 --- a/tests/ui/if_let_redundant_pattern_matching.stderr +++ b/tests/ui/if_let_redundant_pattern_matching.stderr @@ -12,25 +12,25 @@ note: lint level defined here | ^^^^^^ error: redundant pattern matching, consider using `is_err()` - --> $DIR/if_let_redundant_pattern_matching.rs:14:12 + --> $DIR/if_let_redundant_pattern_matching.rs:11:12 | -14 | if let Err(_) = Err::(42) { +11 | if let Err(_) = Err::(42) { | -------^^^^^^---------------------- help: try this `if Err::(42).is_err()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] error: redundant pattern matching, consider using `is_none()` - --> $DIR/if_let_redundant_pattern_matching.rs:20:12 + --> $DIR/if_let_redundant_pattern_matching.rs:14:12 | -20 | if let None = None::<()> { +14 | if let None = None::<()> { | -------^^^^------------- help: try this `if None::<()>.is_none()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] error: redundant pattern matching, consider using `is_some()` - --> $DIR/if_let_redundant_pattern_matching.rs:26:12 + --> $DIR/if_let_redundant_pattern_matching.rs:17:12 | -26 | if let Some(_) = Some(42) { +17 | if let Some(_) = Some(42) { | -------^^^^^^^----------- help: try this `if Some(42).is_some()` | = note: #[deny(if_let_redundant_pattern_matching)] implied by #[deny(clippy)] From 7b2766af4ac8e1776d7a08d9977b7a2b3e088c6a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:35:29 +0100 Subject: [PATCH 23/55] clean tests/ui/len_zero.rs Cleaning the empty lines for clarity. --- tests/ui/len_zero.rs | 18 ------------------ tests/ui/len_zero.stderr | 38 +++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index d8f923bcaa9..4940ef4684f 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -128,16 +128,10 @@ impl HasWrongIsEmpty { fn main() { let x = [1, 2]; if x.len() == 0 { - - - println!("This should not happen!"); } if "".len() == 0 { - - - } let y = One; @@ -152,30 +146,18 @@ fn main() { let has_is_empty = HasIsEmpty; if has_is_empty.len() == 0 { - - - println!("Or this!"); } if has_is_empty.len() != 0 { - - - println!("Or this!"); } if has_is_empty.len() > 0 { - - - println!("Or this!"); } assert!(!has_is_empty.is_empty()); let with_is_empty: &WithIsEmpty = &Wither; if with_is_empty.len() == 0 { - - - println!("Or this!"); } assert!(!with_is_empty.is_empty()); diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index 27fa35e6c03..891f1741aa7 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -59,39 +59,39 @@ note: lint level defined here | ^^^^^^^^ error: length comparison to zero - --> $DIR/len_zero.rs:137:8 + --> $DIR/len_zero.rs:134:8 | -137 | if "".len() == 0 { +134 | if "".len() == 0 { | ^^^^^^^^^^^^^ help: using `is_empty` is more concise: `"".is_empty()` +error: length comparison to zero + --> $DIR/len_zero.rs:148:8 + | +148 | if has_is_empty.len() == 0 { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` + +error: length comparison to zero + --> $DIR/len_zero.rs:151:8 + | +151 | if has_is_empty.len() != 0 { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` + error: length comparison to zero --> $DIR/len_zero.rs:154:8 | -154 | if has_is_empty.len() == 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `has_is_empty.is_empty()` +154 | if has_is_empty.len() > 0 { + | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` error: length comparison to zero --> $DIR/len_zero.rs:160:8 | -160 | if has_is_empty.len() != 0 { - | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` - -error: length comparison to zero - --> $DIR/len_zero.rs:166:8 - | -166 | if has_is_empty.len() > 0 { - | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `!has_is_empty.is_empty()` - -error: length comparison to zero - --> $DIR/len_zero.rs:175:8 - | -175 | if with_is_empty.len() == 0 { +160 | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is more concise: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:190:8 + --> $DIR/len_zero.rs:172:8 | -190 | if b.len() != 0 { +172 | if b.len() != 0 { | ^^^^^^^^^^^^ help: using `is_empty` is more concise: `!b.is_empty()` error: aborting due to 11 previous errors From 2df0161973ee47095b4082c6869760fa489b556b Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:37:32 +0100 Subject: [PATCH 24/55] clean tests/ui/let_if_seq.rs Cleaning the empty lines for clarity. --- tests/ui/let_if_seq.rs | 14 ----------- tests/ui/let_if_seq.stderr | 51 ++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index 9e221cc5bc2..2e9edea006e 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -55,17 +55,11 @@ fn main() { issue985_alt(); let mut foo = 0; - - - if f() { foo = 42; } let mut bar = 0; - - - if f() { f(); bar = 42; @@ -75,10 +69,6 @@ fn main() { } let quz; - - - - if f() { quz = 42; } else { @@ -87,7 +77,6 @@ fn main() { // `toto` is used several times let mut toto; - if f() { toto = 42; } else { @@ -109,9 +98,6 @@ fn main() { // baz needs to be mut let mut baz = 0; - - - if f() { baz = 42; } diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index c080c54d057..ea3c820dd8c 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -2,12 +2,9 @@ error: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:57:5 | 57 | / let mut foo = 0; -58 | | -59 | | -60 | | -61 | | if f() { -62 | | foo = 42; -63 | | } +58 | | if f() { +59 | | foo = 42; +60 | | } | |_____^ help: it is more idiomatic to write `let foo = if f() { 42 } else { 0 };` | note: lint level defined here @@ -18,41 +15,37 @@ note: lint level defined here = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:65:5 + --> $DIR/let_if_seq.rs:62:5 | -65 | / let mut bar = 0; -66 | | -67 | | -68 | | +62 | / let mut bar = 0; +63 | | if f() { +64 | | f(); +65 | | bar = 42; ... | -74 | | f(); -75 | | } +68 | | f(); +69 | | } | |_____^ help: it is more idiomatic to write `let bar = if f() { ..; 42 } else { ..; 0 };` | = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:77:5 + --> $DIR/let_if_seq.rs:71:5 | -77 | / let quz; -78 | | -79 | | -80 | | -... | -85 | | quz = 0; -86 | | } +71 | / let quz; +72 | | if f() { +73 | | quz = 42; +74 | | } else { +75 | | quz = 0; +76 | | } | |_____^ help: it is more idiomatic to write `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:111:5 + --> $DIR/let_if_seq.rs:100:5 | -111 | / let mut baz = 0; -112 | | -113 | | -114 | | -115 | | if f() { -116 | | baz = 42; -117 | | } +100 | / let mut baz = 0; +101 | | if f() { +102 | | baz = 42; +103 | | } | |_____^ help: it is more idiomatic to write `let baz = if f() { 42 } else { 0 };` | = note: you might not need `mut` at all From cf9370f670a360df0ea838cab5ce8750be1df7b0 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:41:35 +0100 Subject: [PATCH 25/55] clean tests/ui/lifetimes.rs Cleaning the empty lines for clarity. --- tests/ui/lifetimes.rs | 8 ----- tests/ui/lifetimes.stderr | 66 +++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 41 deletions(-) diff --git a/tests/ui/lifetimes.rs b/tests/ui/lifetimes.rs index ea8a483924f..e10fd590e6c 100644 --- a/tests/ui/lifetimes.rs +++ b/tests/ui/lifetimes.rs @@ -6,10 +6,8 @@ fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } - fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } - fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) { } // no error, same lifetime on two params fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) { } // no error, static involved @@ -18,7 +16,6 @@ fn mut_and_static_input(_x: &mut u8, _y: &'static str) { } fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } - fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { x } // no error, multiple input refs fn multiple_in_and_out_2<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { x } // no error, multiple input refs @@ -31,18 +28,15 @@ fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 { x.unwrap() } // n fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } - // where clause, but without lifetimes fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> where T: Copy { Ok(x) } - type Ref<'r> = &'r u8; fn lifetime_param_1<'a>(_x: Ref<'a>, _y: &'a u8) { } // no error, same lifetime on two params fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } - fn lifetime_param_3<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) { } // no error, bounded lifetime fn lifetime_param_4<'a, 'b>(_x: Ref<'a>, _y: &'b u8) where 'b: 'a { } // no error, bounded lifetime @@ -66,12 +60,10 @@ struct X { impl X { fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } - fn self_and_in_out<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { &self.x } // no error, multiple input refs fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } - fn self_and_same_in<'s>(&'s self, _x: &'s u8) { } // no error, same lifetimes on two params } diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index 15306dfcc11..f80335af563 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -11,83 +11,83 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:10:1 - | -10 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/lifetimes.rs:9:1 + | +9 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:19:1 + --> $DIR/lifetimes.rs:17:1 | -19 | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } +17 | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: explicit lifetimes given in parameter types where they could be elided + --> $DIR/lifetimes.rs:29:1 + | +29 | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:32:1 | -32 | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:36:1 - | -36 | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> where T: Copy { Ok(x) } +32 | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> where T: Copy { Ok(x) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:43:1 + --> $DIR/lifetimes.rs:38:1 | -43 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } +38 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:58:1 + --> $DIR/lifetimes.rs:52:1 | -58 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> -59 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> -60 | | { unreachable!() } +52 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> +53 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> +54 | | { unreachable!() } | |__________________^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:67:5 + --> $DIR/lifetimes.rs:61:5 | -67 | fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } +61 | fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:72:5 + --> $DIR/lifetimes.rs:65:5 | -72 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } +65 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:89:1 + --> $DIR/lifetimes.rs:81:1 | -89 | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } +81 | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:109:1 + --> $DIR/lifetimes.rs:101:1 | -109 | fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } +101 | fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:113:1 + --> $DIR/lifetimes.rs:105:1 | -113 | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } +105 | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:124:1 + --> $DIR/lifetimes.rs:116:1 | -124 | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } +116 | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided - --> $DIR/lifetimes.rs:128:1 + --> $DIR/lifetimes.rs:120:1 | -128 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } +120 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors From a5e66fa34b256b0f805e6fd0bc8092547667dc64 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:43:13 +0100 Subject: [PATCH 26/55] clean tests/ui/literals.rs Cleaning the empty lines for clarity. --- tests/ui/lint_pass.rs | 3 --- tests/ui/literals.rs | 5 ----- 2 files changed, 8 deletions(-) diff --git a/tests/ui/lint_pass.rs b/tests/ui/lint_pass.rs index 5b65a5c3a26..3dbd672fc5a 100644 --- a/tests/ui/lint_pass.rs +++ b/tests/ui/lint_pass.rs @@ -11,7 +11,6 @@ use rustc::lint::{LintPass, LintArray}; declare_lint! { GOOD_LINT, Warn, "good lint" } declare_lint! { MISSING_LINT, Warn, "missing lint" } - pub struct Pass; impl LintPass for Pass { @@ -23,5 +22,3 @@ impl LintPass for Pass { fn main() { let _ = MISSING_LINT; } - - diff --git a/tests/ui/literals.rs b/tests/ui/literals.rs index e4cee81d53f..527a96b755e 100644 --- a/tests/ui/literals.rs +++ b/tests/ui/literals.rs @@ -28,11 +28,6 @@ fn main() { let ok10 = 0_i64; let fail8 = 0123; - - - - - let ok11 = 0o123; let ok12 = 0b101010; } From 86d5ffae8a23c0057989463b86d5e95102a457f6 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 12:45:55 +0100 Subject: [PATCH 27/55] clean tests/ui/matches.rs Cleaning the empty lines for clarity. --- tests/ui/matches.rs | 52 -------- tests/ui/matches.stderr | 285 +++++++++++++++++----------------------- 2 files changed, 117 insertions(+), 220 deletions(-) diff --git a/tests/ui/matches.rs b/tests/ui/matches.rs index 46a99293a35..e45b0c97f2f 100644 --- a/tests/ui/matches.rs +++ b/tests/ui/matches.rs @@ -24,9 +24,6 @@ fn dummy() { fn unwrap_addr() -> Option<&'static ExprNode> { match ExprNode::Butterflies { - - - ExprNode::ExprAddrOf => Some(&NODE), _ => { let x = 5; None }, } @@ -36,18 +33,12 @@ fn single_match(){ let x = Some(1u8); match x { - - - Some(y) => { println!("{:?}", y); } _ => () }; let z = (1u8,1u8); match z { - - - (2...3, 7...9) => dummy(), _ => {} }; @@ -70,17 +61,11 @@ fn single_match_know_enum() { let y : Result<_, i8> = Ok(1i8); match x { - - - Some(y) => dummy(), None => () }; match y { - - - Ok(y) => dummy(), Err(..) => () }; @@ -88,9 +73,6 @@ fn single_match_know_enum() { let c = Cow::Borrowed(""); match c { - - - Cow::Borrowed(..) => dummy(), Cow::Owned(..) => (), }; @@ -112,51 +94,32 @@ fn match_bool() { let test: bool = true; match test { - - - true => 0, false => 42, }; let option = 1; match option == 1 { - - - true => 1, false => 0, }; match test { - - - true => (), false => { println!("Noooo!"); } }; match test { - - - false => { println!("Noooo!"); } _ => (), }; match test && test { - - - - false => { println!("Noooo!"); } _ => (), }; match test { - - - false => { println!("Noooo!"); } true => { println!("Yes!"); } }; @@ -173,9 +136,6 @@ fn ref_pats() { { let v = &Some(0); match v { - - - &Some(v) => println!("{:?}", v), &None => println!("none"), } @@ -186,18 +146,12 @@ fn ref_pats() { } let tup =& (1, 2); match tup { - - - &(v, 1) => println!("{}", v), _ => println!("none"), } // special case: using & both in expr and pats let w = Some(0); match &w { - - - &Some(v) => println!("{:?}", v), &None => println!("none"), } @@ -209,17 +163,11 @@ fn ref_pats() { let a = &Some(0); if let &None = a { - - - println!("none"); } let b = Some(0); if let &None = &b { - - - println!("none"); } } diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 47c323cbfeb..a1013aa5011 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -2,12 +2,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co --> $DIR/matches.rs:26:5 | 26 | / match ExprNode::Butterflies { -27 | | -28 | | -29 | | -30 | | ExprNode::ExprAddrOf => Some(&NODE), -31 | | _ => { let x = 5; None }, -32 | | } +27 | | ExprNode::ExprAddrOf => Some(&NODE), +28 | | _ => { let x = 5; None }, +29 | | } | |_____^ help: try this `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }` | note: lint level defined here @@ -17,15 +14,12 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/matches.rs:38:5 + --> $DIR/matches.rs:35:5 | -38 | / match x { -39 | | -40 | | -41 | | -42 | | Some(y) => { println!("{:?}", y); } -43 | | _ => () -44 | | }; +35 | / match x { +36 | | Some(y) => { println!("{:?}", y); } +37 | | _ => () +38 | | }; | |_____^ help: try this `if let Some(y) = x { println!("{:?}", y); }` | = note: #[deny(single_match)] implied by #[deny(clippy)] @@ -36,140 +30,113 @@ note: lint level defined here | ^^^^^^ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/matches.rs:47:5 + --> $DIR/matches.rs:41:5 | -47 | / match z { -48 | | -49 | | -50 | | -51 | | (2...3, 7...9) => dummy(), -52 | | _ => {} -53 | | }; +41 | / match z { +42 | | (2...3, 7...9) => dummy(), +43 | | _ => {} +44 | | }; | |_____^ help: try this `if let (2...3, 7...9) = z { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/matches.rs:72:5 + --> $DIR/matches.rs:63:5 | -72 | / match x { -73 | | -74 | | -75 | | -76 | | Some(y) => dummy(), -77 | | None => () -78 | | }; +63 | / match x { +64 | | Some(y) => dummy(), +65 | | None => () +66 | | }; | |_____^ help: try this `if let Some(y) = x { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/matches.rs:80:5 + --> $DIR/matches.rs:68:5 | -80 | / match y { -81 | | -82 | | -83 | | -84 | | Ok(y) => dummy(), -85 | | Err(..) => () -86 | | }; +68 | / match y { +69 | | Ok(y) => dummy(), +70 | | Err(..) => () +71 | | }; | |_____^ help: try this `if let Ok(y) = y { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/matches.rs:90:5 + --> $DIR/matches.rs:75:5 | -90 | / match c { -91 | | -92 | | -93 | | -94 | | Cow::Borrowed(..) => dummy(), -95 | | Cow::Owned(..) => (), -96 | | }; +75 | / match c { +76 | | Cow::Borrowed(..) => dummy(), +77 | | Cow::Owned(..) => (), +78 | | }; | |_____^ help: try this `if let Cow::Borrowed(..) = c { dummy() }` | = note: #[deny(single_match)] implied by #[deny(clippy)] error: you seem to be trying to match on a boolean expression - --> $DIR/matches.rs:114:5 - | -114 | / match test { -115 | | -116 | | -117 | | -118 | | true => 0, -119 | | false => 42, -120 | | }; - | |_____^ help: consider using an if/else expression `if test { 0 } else { 42 }` - | - = note: #[deny(match_bool)] implied by #[deny(clippy)] + --> $DIR/matches.rs:96:5 + | +96 | / match test { +97 | | true => 0, +98 | | false => 42, +99 | | }; + | |_____^ help: consider using an if/else expression `if test { 0 } else { 42 }` + | + = note: #[deny(match_bool)] implied by #[deny(clippy)] note: lint level defined here - --> $DIR/matches.rs:5:9 - | -5 | #![deny(clippy)] - | ^^^^^^ + --> $DIR/matches.rs:5:9 + | +5 | #![deny(clippy)] + | ^^^^^^ error: you seem to be trying to match on a boolean expression - --> $DIR/matches.rs:123:5 + --> $DIR/matches.rs:102:5 | -123 | / match option == 1 { -124 | | -125 | | -126 | | -127 | | true => 1, -128 | | false => 0, -129 | | }; +102 | / match option == 1 { +103 | | true => 1, +104 | | false => 0, +105 | | }; | |_____^ help: consider using an if/else expression `if option == 1 { 1 } else { 0 }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] error: you seem to be trying to match on a boolean expression - --> $DIR/matches.rs:131:5 + --> $DIR/matches.rs:107:5 | -131 | / match test { -132 | | -133 | | -134 | | -135 | | true => (), -136 | | false => { println!("Noooo!"); } -137 | | }; +107 | / match test { +108 | | true => (), +109 | | false => { println!("Noooo!"); } +110 | | }; | |_____^ help: consider using an if/else expression `if !test { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] error: you seem to be trying to match on a boolean expression - --> $DIR/matches.rs:139:5 + --> $DIR/matches.rs:112:5 | -139 | / match test { -140 | | -141 | | -142 | | -143 | | false => { println!("Noooo!"); } -144 | | _ => (), -145 | | }; +112 | / match test { +113 | | false => { println!("Noooo!"); } +114 | | _ => (), +115 | | }; | |_____^ help: consider using an if/else expression `if !test { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] error: you seem to be trying to match on a boolean expression - --> $DIR/matches.rs:147:5 + --> $DIR/matches.rs:117:5 | -147 | / match test && test { -148 | | -149 | | -150 | | -... | -153 | | _ => (), -154 | | }; +117 | / match test && test { +118 | | false => { println!("Noooo!"); } +119 | | _ => (), +120 | | }; | |_____^ help: consider using an if/else expression `if !(test && test) { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] error: equal expressions as operands to `&&` - --> $DIR/matches.rs:147:11 + --> $DIR/matches.rs:117:11 | -147 | match test && test { +117 | match test && test { | ^^^^^^^^^^^^ | = note: #[deny(eq_op)] implied by #[deny(clippy)] @@ -180,29 +147,23 @@ note: lint level defined here | ^^^^^^ error: you seem to be trying to match on a boolean expression - --> $DIR/matches.rs:156:5 + --> $DIR/matches.rs:122:5 | -156 | / match test { -157 | | -158 | | -159 | | -160 | | false => { println!("Noooo!"); } -161 | | true => { println!("Yes!"); } -162 | | }; +122 | / match test { +123 | | false => { println!("Noooo!"); } +124 | | true => { println!("Yes!"); } +125 | | }; | |_____^ help: consider using an if/else expression `if test { println!("Yes!"); } else { println!("Noooo!"); }` | = note: #[deny(match_bool)] implied by #[deny(clippy)] error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:175:9 + --> $DIR/matches.rs:138:9 | -175 | / match v { -176 | | -177 | | -178 | | -179 | | &Some(v) => println!("{:?}", v), -180 | | &None => println!("none"), -181 | | } +138 | / match v { +139 | | &Some(v) => println!("{:?}", v), +140 | | &None => println!("none"), +141 | | } | |_________^ | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] @@ -215,15 +176,12 @@ help: instead of prefixing all patterns with `&`, you can dereference the expres | match *v { .. } error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:188:5 + --> $DIR/matches.rs:148:5 | -188 | / match tup { -189 | | -190 | | -191 | | -192 | | &(v, 1) => println!("{}", v), -193 | | _ => println!("none"), -194 | | } +148 | / match tup { +149 | | &(v, 1) => println!("{}", v), +150 | | _ => println!("none"), +151 | | } | |_____^ | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] @@ -231,28 +189,22 @@ help: instead of prefixing all patterns with `&`, you can dereference the expres | match *tup { .. } error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:197:5 + --> $DIR/matches.rs:154:5 | -197 | / match &w { -198 | | -199 | | -200 | | -201 | | &Some(v) => println!("{:?}", v), -202 | | &None => println!("none"), -203 | | } +154 | / match &w { +155 | | &Some(v) => println!("{:?}", v), +156 | | &None => println!("none"), +157 | | } | |_____^ help: try `match w { .. }` | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:211:5 + --> $DIR/matches.rs:165:5 | -211 | / if let &None = a { -212 | | -213 | | -214 | | -215 | | println!("none"); -216 | | } +165 | / if let &None = a { +166 | | println!("none"); +167 | | } | |_____^ | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] @@ -260,22 +212,19 @@ help: instead of prefixing all patterns with `&`, you can dereference the expres | if let .. = *a { .. } error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:219:5 + --> $DIR/matches.rs:170:5 | -219 | / if let &None = &b { -220 | | -221 | | -222 | | -223 | | println!("none"); -224 | | } +170 | / if let &None = &b { +171 | | println!("none"); +172 | | } | |_____^ help: try `if let .. = b { .. }` | = note: #[deny(match_ref_pats)] implied by #[deny(clippy)] error: some ranges overlap - --> $DIR/matches.rs:231:9 + --> $DIR/matches.rs:179:9 | -231 | 0 ... 10 => println!("0 ... 10"), +179 | 0 ... 10 => println!("0 ... 10"), | ^^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] @@ -285,67 +234,67 @@ note: lint level defined here 5 | #![deny(clippy)] | ^^^^^^ note: overlaps with this - --> $DIR/matches.rs:232:9 + --> $DIR/matches.rs:180:9 | -232 | 0 ... 11 => println!("0 ... 11"), +180 | 0 ... 11 => println!("0 ... 11"), | ^^^^^^^^ error: some ranges overlap - --> $DIR/matches.rs:237:9 + --> $DIR/matches.rs:185:9 | -237 | 0 ... 5 => println!("0 ... 5"), +185 | 0 ... 5 => println!("0 ... 5"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this - --> $DIR/matches.rs:239:9 + --> $DIR/matches.rs:187:9 | -239 | FOO ... 11 => println!("0 ... 11"), +187 | FOO ... 11 => println!("0 ... 11"), | ^^^^^^^^^^ error: some ranges overlap - --> $DIR/matches.rs:245:9 + --> $DIR/matches.rs:193:9 | -245 | 0 ... 5 => println!("0 ... 5"), +193 | 0 ... 5 => println!("0 ... 5"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this - --> $DIR/matches.rs:244:9 + --> $DIR/matches.rs:192:9 | -244 | 2 => println!("2"), +192 | 2 => println!("2"), | ^ error: some ranges overlap - --> $DIR/matches.rs:251:9 + --> $DIR/matches.rs:199:9 | -251 | 0 ... 2 => println!("0 ... 2"), +199 | 0 ... 2 => println!("0 ... 2"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this - --> $DIR/matches.rs:250:9 + --> $DIR/matches.rs:198:9 | -250 | 2 => println!("2"), +198 | 2 => println!("2"), | ^ error: some ranges overlap - --> $DIR/matches.rs:274:9 + --> $DIR/matches.rs:222:9 | -274 | 0 .. 11 => println!("0 .. 11"), +222 | 0 .. 11 => println!("0 .. 11"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this - --> $DIR/matches.rs:275:9 + --> $DIR/matches.rs:223:9 | -275 | 0 ... 11 => println!("0 ... 11"), +223 | 0 ... 11 => println!("0 ... 11"), | ^^^^^^^^ error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:292:9 + --> $DIR/matches.rs:240:9 | -292 | Err(_) => panic!("err") +240 | Err(_) => panic!("err") | ^^^^^^ | = note: #[deny(match_wild_err_arm)] implied by #[deny(clippy)] @@ -357,18 +306,18 @@ note: lint level defined here = note: to remove this warning, match each error seperately or use unreachable macro error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:298:9 + --> $DIR/matches.rs:246:9 | -298 | Err(_) => {panic!()} +246 | Err(_) => {panic!()} | ^^^^^^ | = note: #[deny(match_wild_err_arm)] implied by #[deny(clippy)] = note: to remove this warning, match each error seperately or use unreachable macro error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:304:9 + --> $DIR/matches.rs:252:9 | -304 | Err(_) => {panic!();} +252 | Err(_) => {panic!();} | ^^^^^^ | = note: #[deny(match_wild_err_arm)] implied by #[deny(clippy)] From 409eea2b516d11133d97465dbf0bc3d1cfd42c80 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:30:44 +0100 Subject: [PATCH 28/55] clean tests/ui/mem_forget.rs Cleaning the empty lines for clarity. --- tests/ui/mem_forget.rs | 3 --- tests/ui/mem_forget.stderr | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/ui/mem_forget.rs b/tests/ui/mem_forget.rs index e553afcf05f..82212414cf3 100644 --- a/tests/ui/mem_forget.rs +++ b/tests/ui/mem_forget.rs @@ -17,14 +17,11 @@ fn main() { let six: Arc = Arc::new(6); memstuff::forget(six); - let seven: Rc = Rc::new(7); std::mem::forget(seven); - let eight: Vec = vec![8]; forgetSomething(eight); - std::mem::forget(7); } diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 21cb65f82eb..306032c49c3 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -11,15 +11,15 @@ note: lint level defined here | ^^^^^^^^^^ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:22:5 + --> $DIR/mem_forget.rs:21:5 | -22 | std::mem::forget(seven); +21 | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:26:5 + --> $DIR/mem_forget.rs:24:5 | -26 | forgetSomething(eight); +24 | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors From 9ece185c45125ba9011e8e647f587a0cde8a3134 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:37:35 +0100 Subject: [PATCH 29/55] clean tests/ui/methods.rs Cleaning the empty lines for clarity. --- tests/ui/methods.rs | 174 ----------------- tests/ui/methods.stderr | 412 ++++++++++++++++++++-------------------- 2 files changed, 206 insertions(+), 380 deletions(-) diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index e1cd7ae38ea..71b4c48f3de 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -28,8 +28,6 @@ impl T { fn to_something(self) -> u32 { 0 } fn new(self) {} - - } struct Lt<'a> { @@ -195,8 +193,6 @@ fn filter_next() { // check single-line case let _ = v.iter().filter(|&x| *x < 0).next(); - - // check multi-line case let _ = v.iter().filter(|&x| { *x < 0 @@ -215,8 +211,6 @@ fn search_is_some() { // check `find().is_some()`, single-line let _ = v.iter().find(|&x| *x < 0).is_some(); - - // check `find().is_some()`, multi-line let _ = v.iter().find(|&x| { *x < 0 @@ -226,8 +220,6 @@ fn search_is_some() { // check `position().is_some()`, single-line let _ = v.iter().position(|&x| x < 0).is_some(); - - // check `position().is_some()`, multi-line let _ = v.iter().position(|&x| { x < 0 @@ -237,8 +229,6 @@ fn search_is_some() { // check `rposition().is_some()`, single-line let _ = v.iter().rposition(|&x| x < 0).is_some(); - - // check `rposition().is_some()`, multi-line let _ = v.iter().rposition(|&x| { x < 0 @@ -277,74 +267,40 @@ fn or_fun_call() { let with_constructor = Some(vec![1]); with_constructor.unwrap_or(make()); - - - let with_new = Some(vec![1]); with_new.unwrap_or(Vec::new()); - - - let with_const_args = Some(vec![1]); with_const_args.unwrap_or(Vec::with_capacity(12)); - - - let with_err : Result<_, ()> = Ok(vec![1]); with_err.unwrap_or(make()); - - - let with_err_args : Result<_, ()> = Ok(vec![1]); with_err_args.unwrap_or(Vec::with_capacity(12)); - - - let with_default_trait = Some(1); with_default_trait.unwrap_or(Default::default()); - - - let with_default_type = Some(1); with_default_type.unwrap_or(u64::default()); - - - let with_vec = Some(vec![1]); with_vec.unwrap_or(vec![]); - // FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]); let without_default = Some(Foo); without_default.unwrap_or(Foo::new()); - - - let mut map = HashMap::::new(); map.entry(42).or_insert(String::new()); - - - let mut btree = BTreeMap::::new(); btree.entry(42).or_insert(String::new()); - - - let stringy = Some(String::from("")); let _ = stringy.unwrap_or("".to_owned()); - - - } /// Checks implementation of `ITER_NTH` lint @@ -356,27 +312,20 @@ fn iter_nth() { { // Make sure we lint `.iter()` for relevant types let bad_vec = some_vec.iter().nth(3); - let bad_slice = &some_vec[..].iter().nth(3); - let bad_boxed_slice = boxed_slice.iter().nth(3); - let bad_vec_deque = some_vec_deque.iter().nth(3); - } { // Make sure we lint `.iter_mut()` for relevant types let bad_vec = some_vec.iter_mut().nth(3); - } { let bad_slice = &some_vec[..].iter_mut().nth(3); - } { let bad_vec_deque = some_vec_deque.iter_mut().nth(3); - } // Make sure we don't lint for non-relevant types @@ -388,19 +337,10 @@ fn iter_nth() { /// Checks implementation of `ITER_SKIP_NEXT` lint fn iter_skip_next() { let mut some_vec = vec![0, 1, 2, 3]; - let _ = some_vec.iter().skip(42).next(); - - let _ = some_vec.iter().cycle().skip(42).next(); - - let _ = (1..10).skip(10).next(); - - let _ = &some_vec[..].iter().skip(3).next(); - - let foo = IteratorFalsePositives { foo : 0 }; let _ = foo.skip(42).next(); let _ = foo.filter().skip(42).next(); @@ -427,51 +367,19 @@ fn get_unwrap() { { // Test `get().unwrap()` let _ = boxed_slice.get(1).unwrap(); - - - let _ = some_slice.get(0).unwrap(); - - - let _ = some_vec.get(0).unwrap(); - - - let _ = some_vecdeque.get(0).unwrap(); - - - let _ = some_hashmap.get(&1).unwrap(); - - - let _ = some_btreemap.get(&1).unwrap(); - - - - let _ = false_positive.get(0).unwrap(); } { // Test `get_mut().unwrap()` *boxed_slice.get_mut(0).unwrap() = 1; - - - *some_slice.get_mut(0).unwrap() = 1; - - - *some_vec.get_mut(0).unwrap() = 1; - - - *some_vecdeque.get_mut(0).unwrap() = 1; - - - - // Check false positives *some_hashmap.get_mut(&1).unwrap() = 'b'; *some_btreemap.get_mut(&1).unwrap() = 'b'; @@ -515,14 +423,7 @@ struct MyErrorWithParam { #[allow(unnecessary_operation)] fn starts_with() { "".chars().next() == Some(' '); - - - - Some(' ') != "".chars().next(); - - - } fn str_extend_chars() { @@ -533,21 +434,12 @@ fn str_extend_chars() { s.push_str(abc); s.extend(abc.chars()); - - - s.push_str("abc"); s.extend("abc".chars()); - - - s.push_str(&def); s.extend(def.chars()); - - - s.extend(abc.chars().skip(1)); s.extend("abc".chars().skip(1)); s.extend(['a', 'b', 'c'].iter()); @@ -559,21 +451,15 @@ fn str_extend_chars() { fn clone_on_copy() { 42.clone(); - vec![1].clone(); // ok, not a Copy type Some(vec![1]).clone(); // ok, not a Copy type (&42).clone(); - - } fn clone_on_copy_generic(t: T) { t.clone(); - Some(t).clone(); - - } fn clone_on_double_ref() { @@ -581,24 +467,17 @@ fn clone_on_double_ref() { let y = &&x; let z: &Vec<_> = y.clone(); - println!("{:p} {:p}",*y, z); } fn single_char_pattern() { let x = "foo"; x.split("x"); - - - - x.split("xx"); - x.split('x'); let y = "x"; x.split(y); - // Not yet testing for multi-byte characters // Changing `r.len() == 1` to `r.chars().count() == 1` in `lint_single_char_pattern` // should have done this but produced an ICE @@ -610,72 +489,23 @@ fn single_char_pattern() { x.split("💣"); // Can't use this lint for unicode code points which don't fit in a char x.split("❤️"); - x.contains("x"); - - - x.starts_with("x"); - - - x.ends_with("x"); - - - x.find("x"); - - - x.rfind("x"); - - - x.rsplit("x"); - - - x.split_terminator("x"); - - - x.rsplit_terminator("x"); - - - x.splitn(0, "x"); - - - x.rsplitn(0, "x"); - - - x.matches("x"); - - - x.rmatches("x"); - - - x.match_indices("x"); - - - x.rmatch_indices("x"); - - - x.trim_left_matches("x"); - - - x.trim_right_matches("x"); - - - let h = HashSet::::new(); h.contains("X"); // should not warn } @@ -685,15 +515,11 @@ fn temporary_cstring() { use std::ffi::CString; CString::new("foo").unwrap().as_ptr(); - - - } fn iter_clone_collect() { let v = [1,2,3,4,5]; let v2 : Vec = v.iter().cloned().collect(); - let v3 : HashSet = v.iter().cloned().collect(); let v4 : VecDeque = v.iter().cloned().collect(); } diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index da8d300c058..9c77d4dac87 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -62,53 +62,53 @@ note: lint level defined here | ^^^^^^ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead - --> $DIR/methods.rs:99:13 - | -99 | let _ = opt.map(|x| x + 1) - | _____________^ -100 | | -101 | | .unwrap_or(0); // should lint even though this call is on a separate line - | |____________________________^ - | - = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] + --> $DIR/methods.rs:97:13 + | +97 | let _ = opt.map(|x| x + 1) + | _____________^ +98 | | +99 | | .unwrap_or(0); // should lint even though this call is on a separate line + | |____________________________^ + | + = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] note: lint level defined here - --> $DIR/methods.rs:5:17 - | -5 | #![deny(clippy, clippy_pedantic)] - | ^^^^^^^^^^^^^^^ - = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)` + --> $DIR/methods.rs:5:17 + | +5 | #![deny(clippy, clippy_pedantic)] + | ^^^^^^^^^^^^^^^ + = note: replace `map(|x| x + 1).unwrap_or(0)` with `map_or(0, |x| x + 1)` error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead - --> $DIR/methods.rs:103:13 + --> $DIR/methods.rs:101:13 | -103 | let _ = opt.map(|x| { +101 | let _ = opt.map(|x| { | _____________^ -104 | | x + 1 -105 | | } -106 | | ).unwrap_or(0); +102 | | x + 1 +103 | | } +104 | | ).unwrap_or(0); | |____________________________^ | = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead - --> $DIR/methods.rs:107:13 + --> $DIR/methods.rs:105:13 | -107 | let _ = opt.map(|x| x + 1) +105 | let _ = opt.map(|x| x + 1) | _____________^ -108 | | .unwrap_or({ -109 | | 0 -110 | | }); +106 | | .unwrap_or({ +107 | | 0 +108 | | }); | |__________________^ | = note: #[deny(option_map_unwrap_or)] implied by #[deny(clippy_pedantic)] error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead - --> $DIR/methods.rs:116:13 + --> $DIR/methods.rs:114:13 | -116 | let _ = opt.map(|x| x + 1) +114 | let _ = opt.map(|x| x + 1) | _____________^ -117 | | -118 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line +115 | | +116 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line | |____________________________________^ | = note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)] @@ -120,33 +120,33 @@ note: lint level defined here = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)` error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead - --> $DIR/methods.rs:120:13 + --> $DIR/methods.rs:118:13 | -120 | let _ = opt.map(|x| { +118 | let _ = opt.map(|x| { | _____________^ -121 | | x + 1 -122 | | } -123 | | ).unwrap_or_else(|| 0); +119 | | x + 1 +120 | | } +121 | | ).unwrap_or_else(|| 0); | |____________________________________^ | = note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)] error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead - --> $DIR/methods.rs:124:13 + --> $DIR/methods.rs:122:13 | -124 | let _ = opt.map(|x| x + 1) +122 | let _ = opt.map(|x| x + 1) | _____________^ -125 | | .unwrap_or_else(|| -126 | | 0 -127 | | ); +123 | | .unwrap_or_else(|| +124 | | 0 +125 | | ); | |_________________^ | = note: #[deny(option_map_unwrap_or_else)] implied by #[deny(clippy_pedantic)] error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. - --> $DIR/methods.rs:196:13 + --> $DIR/methods.rs:194:13 | -196 | let _ = v.iter().filter(|&x| *x < 0).next(); +194 | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(filter_next)] implied by #[deny(clippy)] @@ -158,21 +158,21 @@ note: lint level defined here = note: replace `filter(|&x| *x < 0).next()` with `find(|&x| *x < 0)` error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. - --> $DIR/methods.rs:201:13 + --> $DIR/methods.rs:197:13 | -201 | let _ = v.iter().filter(|&x| { +197 | let _ = v.iter().filter(|&x| { | _____________^ -202 | | *x < 0 -203 | | } -204 | | ).next(); +198 | | *x < 0 +199 | | } +200 | | ).next(); | |___________________________^ | = note: #[deny(filter_next)] implied by #[deny(clippy)] error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:216:13 + --> $DIR/methods.rs:212:13 | -216 | let _ = v.iter().find(|&x| *x < 0).is_some(); +212 | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(search_is_some)] implied by #[deny(clippy)] @@ -184,63 +184,63 @@ note: lint level defined here = note: replace `find(|&x| *x < 0).is_some()` with `any(|&x| *x < 0)` error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:221:13 + --> $DIR/methods.rs:215:13 | -221 | let _ = v.iter().find(|&x| { +215 | let _ = v.iter().find(|&x| { | _____________^ -222 | | *x < 0 -223 | | } -224 | | ).is_some(); +216 | | *x < 0 +217 | | } +218 | | ).is_some(); | |______________________________^ | = note: #[deny(search_is_some)] implied by #[deny(clippy)] error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:227:13 + --> $DIR/methods.rs:221:13 | -227 | let _ = v.iter().position(|&x| x < 0).is_some(); +221 | let _ = v.iter().position(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(search_is_some)] implied by #[deny(clippy)] = note: replace `position(|&x| x < 0).is_some()` with `any(|&x| x < 0)` error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:232:13 + --> $DIR/methods.rs:224:13 | -232 | let _ = v.iter().position(|&x| { +224 | let _ = v.iter().position(|&x| { | _____________^ -233 | | x < 0 -234 | | } -235 | | ).is_some(); +225 | | x < 0 +226 | | } +227 | | ).is_some(); | |______________________________^ | = note: #[deny(search_is_some)] implied by #[deny(clippy)] error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:238:13 + --> $DIR/methods.rs:230:13 | -238 | let _ = v.iter().rposition(|&x| x < 0).is_some(); +230 | let _ = v.iter().rposition(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(search_is_some)] implied by #[deny(clippy)] = note: replace `rposition(|&x| x < 0).is_some()` with `any(|&x| x < 0)` error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. - --> $DIR/methods.rs:243:13 + --> $DIR/methods.rs:233:13 | -243 | let _ = v.iter().rposition(|&x| { +233 | let _ = v.iter().rposition(|&x| { | _____________^ -244 | | x < 0 -245 | | } -246 | | ).is_some(); +234 | | x < 0 +235 | | } +236 | | ).is_some(); | |______________________________^ | = note: #[deny(search_is_some)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:278:5 + --> $DIR/methods.rs:268:5 | -278 | with_constructor.unwrap_or(make()); +268 | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_constructor.unwrap_or_else(make)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] @@ -251,97 +251,97 @@ note: lint level defined here | ^^^^^^ error: use of `unwrap_or` followed by a call to `new` - --> $DIR/methods.rs:284:5 + --> $DIR/methods.rs:271:5 | -284 | with_new.unwrap_or(Vec::new()); +271 | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_new.unwrap_or_default()` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:290:5 + --> $DIR/methods.rs:274:5 | -290 | with_const_args.unwrap_or(Vec::with_capacity(12)); +274 | with_const_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_const_args.unwrap_or_else(|| Vec::with_capacity(12))` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:296:5 + --> $DIR/methods.rs:277:5 | -296 | with_err.unwrap_or(make()); +277 | with_err.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_err.unwrap_or_else(|_| make())` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:302:5 + --> $DIR/methods.rs:280:5 | -302 | with_err_args.unwrap_or(Vec::with_capacity(12)); +280 | with_err_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_err_args.unwrap_or_else(|_| Vec::with_capacity(12))` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a call to `default` - --> $DIR/methods.rs:308:5 + --> $DIR/methods.rs:283:5 | -308 | with_default_trait.unwrap_or(Default::default()); +283 | with_default_trait.unwrap_or(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_default_trait.unwrap_or_default()` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a call to `default` - --> $DIR/methods.rs:314:5 + --> $DIR/methods.rs:286:5 | -314 | with_default_type.unwrap_or(u64::default()); +286 | with_default_type.unwrap_or(u64::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_default_type.unwrap_or_default()` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:320:5 + --> $DIR/methods.rs:289:5 | -320 | with_vec.unwrap_or(vec![]); +289 | with_vec.unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `with_vec.unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ))` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:326:5 + --> $DIR/methods.rs:294:5 | -326 | without_default.unwrap_or(Foo::new()); +294 | without_default.unwrap_or(Foo::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `without_default.unwrap_or_else(Foo::new)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `or_insert` followed by a function call - --> $DIR/methods.rs:332:5 + --> $DIR/methods.rs:297:5 | -332 | map.entry(42).or_insert(String::new()); +297 | map.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `map.entry(42).or_insert_with(String::new)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `or_insert` followed by a function call - --> $DIR/methods.rs:338:5 + --> $DIR/methods.rs:300:5 | -338 | btree.entry(42).or_insert(String::new()); +300 | btree.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `btree.entry(42).or_insert_with(String::new)` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: use of `unwrap_or` followed by a function call - --> $DIR/methods.rs:344:13 + --> $DIR/methods.rs:303:13 | -344 | let _ = stringy.unwrap_or("".to_owned()); +303 | let _ = stringy.unwrap_or("".to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `stringy.unwrap_or_else(|| "".to_owned())` | = note: #[deny(or_fun_call)] implied by #[deny(clippy)] error: called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:358:23 + --> $DIR/methods.rs:314:23 | -358 | let bad_vec = some_vec.iter().nth(3); +314 | let bad_vec = some_vec.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] @@ -352,57 +352,57 @@ note: lint level defined here | ^^^^^^ error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:360:26 + --> $DIR/methods.rs:315:26 | -360 | let bad_slice = &some_vec[..].iter().nth(3); +315 | let bad_slice = &some_vec[..].iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] error: called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:362:31 + --> $DIR/methods.rs:316:31 | -362 | let bad_boxed_slice = boxed_slice.iter().nth(3); +316 | let bad_boxed_slice = boxed_slice.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] error: called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable - --> $DIR/methods.rs:364:29 + --> $DIR/methods.rs:317:29 | -364 | let bad_vec_deque = some_vec_deque.iter().nth(3); +317 | let bad_vec_deque = some_vec_deque.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] error: called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable - --> $DIR/methods.rs:370:23 + --> $DIR/methods.rs:322:23 | -370 | let bad_vec = some_vec.iter_mut().nth(3); +322 | let bad_vec = some_vec.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] error: called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable - --> $DIR/methods.rs:374:26 + --> $DIR/methods.rs:325:26 | -374 | let bad_slice = &some_vec[..].iter_mut().nth(3); +325 | let bad_slice = &some_vec[..].iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] error: called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable - --> $DIR/methods.rs:378:29 + --> $DIR/methods.rs:328:29 | -378 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); +328 | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_nth)] implied by #[deny(clippy)] error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/methods.rs:392:13 + --> $DIR/methods.rs:340:13 | -392 | let _ = some_vec.iter().skip(42).next(); +340 | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_skip_next)] implied by #[deny(clippy)] @@ -413,33 +413,33 @@ note: lint level defined here | ^^^^^^ error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/methods.rs:395:13 + --> $DIR/methods.rs:341:13 | -395 | let _ = some_vec.iter().cycle().skip(42).next(); +341 | let _ = some_vec.iter().cycle().skip(42).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_skip_next)] implied by #[deny(clippy)] error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/methods.rs:398:13 + --> $DIR/methods.rs:342:13 | -398 | let _ = (1..10).skip(10).next(); +342 | let _ = (1..10).skip(10).next(); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_skip_next)] implied by #[deny(clippy)] error: called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` - --> $DIR/methods.rs:401:14 + --> $DIR/methods.rs:343:14 | -401 | let _ = &some_vec[..].iter().skip(3).next(); +343 | let _ = &some_vec[..].iter().skip(3).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_skip_next)] implied by #[deny(clippy)] error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/methods.rs:429:17 + --> $DIR/methods.rs:369:17 | -429 | let _ = boxed_slice.get(1).unwrap(); +369 | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&boxed_slice[1]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] @@ -450,81 +450,81 @@ note: lint level defined here | ^^^^^^ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/methods.rs:433:17 + --> $DIR/methods.rs:370:17 | -433 | let _ = some_slice.get(0).unwrap(); +370 | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_slice[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/methods.rs:437:17 + --> $DIR/methods.rs:371:17 | -437 | let _ = some_vec.get(0).unwrap(); +371 | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_vec[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/methods.rs:441:17 + --> $DIR/methods.rs:372:17 | -441 | let _ = some_vecdeque.get(0).unwrap(); +372 | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_vecdeque[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/methods.rs:445:17 + --> $DIR/methods.rs:373:17 | -445 | let _ = some_hashmap.get(&1).unwrap(); +373 | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_hashmap[&1]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/methods.rs:449:17 + --> $DIR/methods.rs:374:17 | -449 | let _ = some_btreemap.get(&1).unwrap(); +374 | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&some_btreemap[&1]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/methods.rs:458:10 + --> $DIR/methods.rs:379:10 | -458 | *boxed_slice.get_mut(0).unwrap() = 1; +379 | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut boxed_slice[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/methods.rs:462:10 + --> $DIR/methods.rs:380:10 | -462 | *some_slice.get_mut(0).unwrap() = 1; +380 | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_slice[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/methods.rs:466:10 + --> $DIR/methods.rs:381:10 | -466 | *some_vec.get_mut(0).unwrap() = 1; +381 | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_vec[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/methods.rs:470:10 + --> $DIR/methods.rs:382:10 | -470 | *some_vecdeque.get_mut(0).unwrap() = 1; +382 | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&mut some_vecdeque[0]` | = note: #[deny(get_unwrap)] implied by #[deny(clippy)] error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message - --> $DIR/methods.rs:488:13 + --> $DIR/methods.rs:396:13 | -488 | let _ = opt.unwrap(); +396 | let _ = opt.unwrap(); | ^^^^^^^^^^^^ | = note: #[deny(option_unwrap_used)] implied by #[deny(clippy_pedantic)] @@ -535,9 +535,9 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: used unwrap() on a Result value. If you don't want to handle the Err case gracefully, consider using expect() to provide a better panic message - --> $DIR/methods.rs:491:13 + --> $DIR/methods.rs:399:13 | -491 | let _ = res.unwrap(); +399 | let _ = res.unwrap(); | ^^^^^^^^^^^^ | = note: #[deny(result_unwrap_used)] implied by #[deny(clippy_pedantic)] @@ -548,9 +548,9 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/methods.rs:493:5 + --> $DIR/methods.rs:401:5 | -493 | res.ok().expect("disaster!"); +401 | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] @@ -561,41 +561,41 @@ note: lint level defined here | ^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/methods.rs:499:5 + --> $DIR/methods.rs:407:5 | -499 | res3.ok().expect("whoof"); +407 | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/methods.rs:501:5 + --> $DIR/methods.rs:409:5 | -501 | res4.ok().expect("argh"); +409 | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/methods.rs:503:5 + --> $DIR/methods.rs:411:5 | -503 | res5.ok().expect("oops"); +411 | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/methods.rs:505:5 + --> $DIR/methods.rs:413:5 | -505 | res6.ok().expect("meh"); +413 | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] error: you should use the `starts_with` method - --> $DIR/methods.rs:517:5 + --> $DIR/methods.rs:425:5 | -517 | "".chars().next() == Some(' '); +425 | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this `"".starts_with(' ')` | = note: #[deny(chars_next_cmp)] implied by #[deny(clippy)] @@ -606,17 +606,17 @@ note: lint level defined here | ^^^^^^ error: you should use the `starts_with` method - --> $DIR/methods.rs:522:5 + --> $DIR/methods.rs:426:5 | -522 | Some(' ') != "".chars().next(); +426 | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this `!"".starts_with(' ')` | = note: #[deny(chars_next_cmp)] implied by #[deny(clippy)] error: calling `.extend(_.chars())` - --> $DIR/methods.rs:534:5 + --> $DIR/methods.rs:435:5 | -534 | s.extend(abc.chars()); +435 | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str(abc)` | = note: #[deny(string_extend_chars)] implied by #[deny(clippy)] @@ -627,25 +627,25 @@ note: lint level defined here | ^^^^^^ error: calling `.extend(_.chars())` - --> $DIR/methods.rs:540:5 + --> $DIR/methods.rs:438:5 | -540 | s.extend("abc".chars()); +438 | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str("abc")` | = note: #[deny(string_extend_chars)] implied by #[deny(clippy)] error: calling `.extend(_.chars())` - --> $DIR/methods.rs:546:5 + --> $DIR/methods.rs:441:5 | -546 | s.extend(def.chars()); +441 | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this `s.push_str(&def)` | = note: #[deny(string_extend_chars)] implied by #[deny(clippy)] error: using `clone` on a `Copy` type - --> $DIR/methods.rs:560:5 + --> $DIR/methods.rs:452:5 | -560 | 42.clone(); +452 | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call `42` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] @@ -656,33 +656,33 @@ note: lint level defined here | ^^^^^^ error: using `clone` on a `Copy` type - --> $DIR/methods.rs:565:5 + --> $DIR/methods.rs:456:5 | -565 | (&42).clone(); +456 | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it `*(&42)` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] error: using `clone` on a `Copy` type - --> $DIR/methods.rs:571:5 + --> $DIR/methods.rs:460:5 | -571 | t.clone(); +460 | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call `t` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] error: using `clone` on a `Copy` type - --> $DIR/methods.rs:574:5 + --> $DIR/methods.rs:462:5 | -574 | Some(t).clone(); +462 | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call `Some(t)` | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type - --> $DIR/methods.rs:582:22 + --> $DIR/methods.rs:468:22 | -582 | let z: &Vec<_> = y.clone(); +468 | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ help: try dereferencing it `(*y).clone()` | = note: #[deny(clone_double_ref)] implied by #[deny(clippy)] @@ -693,9 +693,9 @@ note: lint level defined here | ^^^^^^ error: single-character string constant used as pattern - --> $DIR/methods.rs:590:13 + --> $DIR/methods.rs:475:13 | -590 | x.split("x"); +475 | x.split("x"); | --------^^^- help: try using a char instead: `x.split('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] @@ -706,137 +706,137 @@ note: lint level defined here | ^^^^^^ error: single-character string constant used as pattern - --> $DIR/methods.rs:614:16 + --> $DIR/methods.rs:492:16 | -614 | x.contains("x"); +492 | x.contains("x"); | -----------^^^- help: try using a char instead: `x.contains('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:618:19 + --> $DIR/methods.rs:493:19 | -618 | x.starts_with("x"); +493 | x.starts_with("x"); | --------------^^^- help: try using a char instead: `x.starts_with('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:622:17 + --> $DIR/methods.rs:494:17 | -622 | x.ends_with("x"); +494 | x.ends_with("x"); | ------------^^^- help: try using a char instead: `x.ends_with('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:626:12 + --> $DIR/methods.rs:495:12 | -626 | x.find("x"); +495 | x.find("x"); | -------^^^- help: try using a char instead: `x.find('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:630:13 + --> $DIR/methods.rs:496:13 | -630 | x.rfind("x"); +496 | x.rfind("x"); | --------^^^- help: try using a char instead: `x.rfind('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:634:14 + --> $DIR/methods.rs:497:14 | -634 | x.rsplit("x"); +497 | x.rsplit("x"); | ---------^^^- help: try using a char instead: `x.rsplit('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:638:24 + --> $DIR/methods.rs:498:24 | -638 | x.split_terminator("x"); +498 | x.split_terminator("x"); | -------------------^^^- help: try using a char instead: `x.split_terminator('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:642:25 + --> $DIR/methods.rs:499:25 | -642 | x.rsplit_terminator("x"); +499 | x.rsplit_terminator("x"); | --------------------^^^- help: try using a char instead: `x.rsplit_terminator('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:646:17 + --> $DIR/methods.rs:500:17 | -646 | x.splitn(0, "x"); +500 | x.splitn(0, "x"); | ------------^^^- help: try using a char instead: `x.splitn(0, 'x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:650:18 + --> $DIR/methods.rs:501:18 | -650 | x.rsplitn(0, "x"); +501 | x.rsplitn(0, "x"); | -------------^^^- help: try using a char instead: `x.rsplitn(0, 'x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:654:15 + --> $DIR/methods.rs:502:15 | -654 | x.matches("x"); +502 | x.matches("x"); | ----------^^^- help: try using a char instead: `x.matches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:658:16 + --> $DIR/methods.rs:503:16 | -658 | x.rmatches("x"); +503 | x.rmatches("x"); | -----------^^^- help: try using a char instead: `x.rmatches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:662:21 + --> $DIR/methods.rs:504:21 | -662 | x.match_indices("x"); +504 | x.match_indices("x"); | ----------------^^^- help: try using a char instead: `x.match_indices('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:666:22 + --> $DIR/methods.rs:505:22 | -666 | x.rmatch_indices("x"); +505 | x.rmatch_indices("x"); | -----------------^^^- help: try using a char instead: `x.rmatch_indices('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:670:25 + --> $DIR/methods.rs:506:25 | -670 | x.trim_left_matches("x"); +506 | x.trim_left_matches("x"); | --------------------^^^- help: try using a char instead: `x.trim_left_matches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: single-character string constant used as pattern - --> $DIR/methods.rs:674:26 + --> $DIR/methods.rs:507:26 | -674 | x.trim_right_matches("x"); +507 | x.trim_right_matches("x"); | ---------------------^^^- help: try using a char instead: `x.trim_right_matches('x')` | = note: #[deny(single_char_pattern)] implied by #[deny(clippy)] error: you are getting the inner pointer of a temporary `CString` - --> $DIR/methods.rs:687:5 + --> $DIR/methods.rs:517:5 | -687 | CString::new("foo").unwrap().as_ptr(); +517 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(temporary_cstring_as_ptr)] implied by #[deny(clippy)] @@ -847,15 +847,15 @@ note: lint level defined here | ^^^^^^ = note: that pointer will be invalid outside this expression help: assign the `CString` to a variable to extend its lifetime - --> $DIR/methods.rs:687:5 + --> $DIR/methods.rs:517:5 | -687 | CString::new("foo").unwrap().as_ptr(); +517 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/methods.rs:695:27 + --> $DIR/methods.rs:522:27 | -695 | let v2 : Vec = v.iter().cloned().collect(); +522 | let v2 : Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(iter_cloned_collect)] implied by #[deny(clippy)] From ac00b1d70b370eee67f218d62f9598a0e69d21f2 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:46:48 +0100 Subject: [PATCH 30/55] clean tests/ui/mut_mut.rs Cleaning the empty lines for clarity. --- tests/ui/mut_mut.rs | 11 ---------- tests/ui/mut_mut.stderr | 46 ++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index 457a79152ef..b938c822f95 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -17,7 +17,6 @@ fn less_fun(x : *mut *mut u32) { macro_rules! mut_ptr { ($p:expr) => { &mut $p } - } #[allow(unused_mut, unused_variables)] @@ -29,25 +28,15 @@ fn main() { if fun(x) { let y : &mut &mut u32 = &mut &mut 2; - - - **y + **x; } if fun(x) { let y : &mut &mut &mut u32 = &mut &mut &mut 2; - - - - - - ***y + **x; } let mut z = mut_ptr!(&mut 3u32); - } fn issue939() { diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index 2149d3d8824..82120f583ef 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -11,9 +11,9 @@ note: lint level defined here | ^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:25:17 + --> $DIR/mut_mut.rs:24:17 | -25 | let mut x = &mut &mut 1u32; +24 | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible @@ -22,67 +22,67 @@ error: generally you want to avoid `&mut &mut _` if possible 19 | ($p:expr) => { &mut $p } | ^^^^^^^ ... -49 | let mut z = mut_ptr!(&mut 3u32); +39 | let mut z = mut_ptr!(&mut 3u32); | ------------------- in this macro invocation error: this expression mutably borrows a mutable reference. Consider reborrowing - --> $DIR/mut_mut.rs:27:21 + --> $DIR/mut_mut.rs:26:21 | -27 | let mut y = &mut x; +26 | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:31:17 + --> $DIR/mut_mut.rs:30:17 | -31 | let y : &mut &mut u32 = &mut &mut 2; +30 | let y : &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:31:33 + --> $DIR/mut_mut.rs:30:33 | -31 | let y : &mut &mut u32 = &mut &mut 2; +30 | let y : &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:31:17 + --> $DIR/mut_mut.rs:30:17 | -31 | let y : &mut &mut u32 = &mut &mut 2; +30 | let y : &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:39:17 + --> $DIR/mut_mut.rs:35:17 | -39 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; +35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:39:22 + --> $DIR/mut_mut.rs:35:22 | -39 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; +35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:39:38 + --> $DIR/mut_mut.rs:35:38 | -39 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; +35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:39:17 + --> $DIR/mut_mut.rs:35:17 | -39 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; +35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:39:22 + --> $DIR/mut_mut.rs:35:22 | -39 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; +35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:39:22 + --> $DIR/mut_mut.rs:35:22 | -39 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; +35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ error: aborting due to 13 previous errors From b4a20aedf9391271526021b72eb157e0b28cceb3 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:49:12 +0100 Subject: [PATCH 31/55] clean tests/ui/needless_bool.rs Cleaning the empty lines for clarity. --- tests/ui/needless_bool.rs | 23 ----------------------- tests/ui/needless_bool.stderr | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/tests/ui/needless_bool.rs b/tests/ui/needless_bool.rs index ebbff145482..d2b0e76f6e1 100644 --- a/tests/ui/needless_bool.rs +++ b/tests/ui/needless_bool.rs @@ -9,17 +9,8 @@ fn main() { if x { true } else { true }; if x { false } else { false }; if x { true } else { false }; - - - if x { false } else { true }; - - - if x && y { false } else { true }; - - - if x { x } else { false }; // would also be questionable, but we don't catch this yet bool_ret(x); bool_ret2(x); @@ -32,43 +23,29 @@ fn main() { #[allow(if_same_then_else, needless_return)] fn bool_ret(x: bool) -> bool { if x { return true } else { return true }; - } #[allow(if_same_then_else, needless_return)] fn bool_ret2(x: bool) -> bool { if x { return false } else { return false }; - } #[allow(needless_return)] fn bool_ret3(x: bool) -> bool { if x { return true } else { return false }; - - - } #[allow(needless_return)] fn bool_ret5(x: bool, y: bool) -> bool { if x && y { return true } else { return false }; - - - } #[allow(needless_return)] fn bool_ret4(x: bool) -> bool { if x { return false } else { return true }; - - - } #[allow(needless_return)] fn bool_ret6(x: bool, y: bool) -> bool { if x && y { return false } else { return true }; - - - } diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index b978085b6a9..edf596c2ec9 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -23,51 +23,51 @@ error: this if-then-else expression returns a bool literal | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:15:5 + --> $DIR/needless_bool.rs:12:5 | -15 | if x { false } else { true }; +12 | if x { false } else { true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `!x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:19:5 + --> $DIR/needless_bool.rs:13:5 | -19 | if x && y { false } else { true }; +13 | if x && y { false } else { true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `!(x && y)` error: this if-then-else expression will always return true - --> $DIR/needless_bool.rs:34:5 + --> $DIR/needless_bool.rs:25:5 | -34 | if x { return true } else { return true }; +25 | if x { return true } else { return true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:40:5 + --> $DIR/needless_bool.rs:30:5 | -40 | if x { return false } else { return false }; +30 | if x { return false } else { return false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:46:5 + --> $DIR/needless_bool.rs:35:5 | -46 | if x { return true } else { return false }; +35 | if x { return true } else { return false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:54:5 + --> $DIR/needless_bool.rs:40:5 | -54 | if x && y { return true } else { return false }; +40 | if x && y { return true } else { return false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:62:5 + --> $DIR/needless_bool.rs:45:5 | -62 | if x { return false } else { return true }; +45 | if x { return false } else { return true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:70:5 + --> $DIR/needless_bool.rs:50:5 | -70 | if x && y { return false } else { return true }; +50 | if x && y { return false } else { return true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to `return !(x && y)` error: aborting due to 11 previous errors From cd55b87874163d251283235eaef181502e726048 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:50:46 +0100 Subject: [PATCH 32/55] clean tests/ui/needless_return.rs Cleaning the empty lines for clarity. --- tests/ui/needless_return.rs | 25 ------------------------- tests/ui/needless_return.stderr | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/tests/ui/needless_return.rs b/tests/ui/needless_return.rs index 2751089bdda..d4c365ca510 100644 --- a/tests/ui/needless_return.rs +++ b/tests/ui/needless_return.rs @@ -9,44 +9,25 @@ fn test_end_of_fn() -> bool { return true; } return true; - - - } fn test_no_semicolon() -> bool { return true - - - } fn test_if_block() -> bool { if true { return true; - - - } else { return false; - - - } } fn test_match(x: bool) -> bool { match x { true => return false, - - - - false => { return true; - - - } } } @@ -54,14 +35,8 @@ fn test_match(x: bool) -> bool { fn test_closure() { let _ = || { return true; - - - }; let _ = || return true; - - - } fn main() { diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 300713202c7..f4e386281f7 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -11,45 +11,45 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: unneeded return statement - --> $DIR/needless_return.rs:18:5 + --> $DIR/needless_return.rs:15:5 | -18 | return true +15 | return true | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:26:9 + --> $DIR/needless_return.rs:20:9 | -26 | return true; +20 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:31:9 + --> $DIR/needless_return.rs:22:9 | -31 | return false; +22 | return false; | ^^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:40:17 + --> $DIR/needless_return.rs:28:17 | -40 | true => return false, +28 | true => return false, | ^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:46:13 + --> $DIR/needless_return.rs:30:13 | -46 | return true; +30 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:56:9 + --> $DIR/needless_return.rs:37:9 | -56 | return true; +37 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:61:16 + --> $DIR/needless_return.rs:39:16 | -61 | let _ = || return true; +39 | let _ = || return true; | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: aborting due to 8 previous errors From 747a20153c2ebc912c20026aa1403ee61ed71b2e Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:52:39 +0100 Subject: [PATCH 33/55] clean tests/ui/neg_multiply.rs Cleaning the empty lines for clarity. --- tests/ui/neg_multiply.rs | 2 -- tests/ui/neg_multiply.stderr | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs index 748a2e53609..9abbd417803 100644 --- a/tests/ui/neg_multiply.rs +++ b/tests/ui/neg_multiply.rs @@ -29,10 +29,8 @@ fn main() { x * -1; - -1 * x; - -1 * -1; // should be ok X * -1; // should be ok diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 11460a5583f..e65f11da16d 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -11,9 +11,9 @@ note: lint level defined here | ^^^^^^^^^^^^ error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:33:5 + --> $DIR/neg_multiply.rs:32:5 | -33 | -1 * x; +32 | -1 * x; | ^^^^^^ error: aborting due to 2 previous errors From 47c17e63e7aa7d4c0c45138db26ee5620cdf3905 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 14:58:24 +0100 Subject: [PATCH 34/55] clean tests/ui/new_without_default.rs Cleaning the empty lines for clarity. --- tests/ui/new_without_default.rs | 15 --------------- tests/ui/new_without_default.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index a5673b622ba..1662e8072af 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -6,22 +6,14 @@ pub struct Foo; - - - impl Foo { pub fn new() -> Foo { Foo } - } pub struct Bar; - - - impl Bar { pub fn new() -> Self { Bar } - } pub struct Ok; @@ -70,13 +62,6 @@ pub struct LtKo<'a> { impl<'c> LtKo<'c> { pub fn new() -> LtKo<'c> { unimplemented!() } - - - - - - - // FIXME: that suggestion is missing lifetimes } diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index e2b10894af8..24df4607b19 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,7 +1,7 @@ error: you should consider deriving a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:13:5 + --> $DIR/new_without_default.rs:10:5 | -13 | pub fn new() -> Foo { Foo } +10 | pub fn new() -> Foo { Foo } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -14,9 +14,9 @@ help: try this | pub struct Foo; error: you should consider deriving a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:23:5 + --> $DIR/new_without_default.rs:16:5 | -23 | pub fn new() -> Self { Bar } +16 | pub fn new() -> Self { Bar } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: try this @@ -24,9 +24,9 @@ help: try this | pub struct Bar; error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:72:5 + --> $DIR/new_without_default.rs:64:5 | -72 | pub fn new() -> LtKo<'c> { unimplemented!() } +64 | pub fn new() -> LtKo<'c> { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here From efbaf09308c7d1d32e6df4871f0a8c4774caf16a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:26:26 +0100 Subject: [PATCH 35/55] clean tests/ui/no_effect.rs Cleaning the empty lines for clarity. --- tests/ui/no_effect.rs | 38 --------- tests/ui/no_effect.stderr | 166 +++++++++++++++++++------------------- 2 files changed, 83 insertions(+), 121 deletions(-) diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index 3759986ae9d..6963e9b92ed 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -63,60 +63,22 @@ fn main() { unsafe { unsafe_fn() }; Tuple(get_number()); - - Struct { field: get_number() }; - - Struct { ..get_struct() }; - - Enum::Tuple(get_number()); - - Enum::Struct { field: get_number() }; - - 5 + get_number(); - - *&get_number(); - - &get_number(); - - (5, 6, get_number()); - - box get_number(); - - get_number()..; - - ..get_number(); - - 5..get_number(); - - [42, get_number()]; - - [42, 55][get_number() as usize]; - - (42, get_number()).1; - - [get_number(); 55]; - - [42; 55][get_number() as usize]; - - {get_number()}; - - } diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 7a74473dd3b..0427fbf91f5 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -166,113 +166,113 @@ note: lint level defined here 4 | #![deny(no_effect, unnecessary_operation)] | ^^^^^^^^^^^^^^^^^^^^^ +error: statement can be reduced + --> $DIR/no_effect.rs:66:5 + | +66 | Struct { field: get_number() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:67:5 + | +67 | Struct { ..get_struct() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_struct();` + error: statement can be reduced --> $DIR/no_effect.rs:68:5 | -68 | Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` +68 | Enum::Tuple(get_number()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:69:5 + | +69 | Enum::Struct { field: get_number() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:70:5 + | +70 | 5 + get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:71:5 | -71 | Struct { ..get_struct() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_struct();` +71 | *&get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:72:5 + | +72 | &get_number(); + | ^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:73:5 + | +73 | (5, 6, get_number()); + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `5;6;get_number();` error: statement can be reduced --> $DIR/no_effect.rs:74:5 | -74 | Enum::Tuple(get_number()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` +74 | box get_number(); + | ^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:75:5 + | +75 | get_number()..; + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:76:5 + | +76 | ..get_number(); + | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` error: statement can be reduced --> $DIR/no_effect.rs:77:5 | -77 | Enum::Struct { field: get_number() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` +77 | 5..get_number(); + | ^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:78:5 + | +78 | [42, get_number()]; + | ^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:79:5 + | +79 | [42, 55][get_number() as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `[42, 55];get_number() as usize;` error: statement can be reduced --> $DIR/no_effect.rs:80:5 | -80 | 5 + get_number(); - | ^^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();` +80 | (42, get_number()).1; + | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:81:5 + | +81 | [get_number(); 55]; + | ^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` + +error: statement can be reduced + --> $DIR/no_effect.rs:82:5 + | +82 | [42; 55][get_number() as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `[42; 55];get_number() as usize;` error: statement can be reduced --> $DIR/no_effect.rs:83:5 | -83 | *&get_number(); +83 | {get_number()}; | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` -error: statement can be reduced - --> $DIR/no_effect.rs:86:5 - | -86 | &get_number(); - | ^^^^^^^^^^^^^^ help: replace it with `get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:89:5 - | -89 | (5, 6, get_number()); - | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `5;6;get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:92:5 - | -92 | box get_number(); - | ^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:95:5 - | -95 | get_number()..; - | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:98:5 - | -98 | ..get_number(); - | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:101:5 - | -101 | 5..get_number(); - | ^^^^^^^^^^^^^^^^ help: replace it with `5;get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:104:5 - | -104 | [42, get_number()]; - | ^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:107:5 - | -107 | [42, 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `[42, 55];get_number() as usize;` - -error: statement can be reduced - --> $DIR/no_effect.rs:110:5 - | -110 | (42, get_number()).1; - | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with `42;get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:113:5 - | -113 | [get_number(); 55]; - | ^^^^^^^^^^^^^^^^^^^ help: replace it with `get_number();` - -error: statement can be reduced - --> $DIR/no_effect.rs:116:5 - | -116 | [42; 55][get_number() as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `[42; 55];get_number() as usize;` - -error: statement can be reduced - --> $DIR/no_effect.rs:119:5 - | -119 | {get_number()}; - | ^^^^^^^^^^^^^^^ help: replace it with `get_number();` - error: aborting due to 44 previous errors From c9190f681dce97c27e5e458bc76b41dd2d203c92 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:28:34 +0100 Subject: [PATCH 36/55] clean tests/ui/non_expressive.rs Cleaning the empty lines for clarity. --- tests/ui/non_expressive_names.rs | 14 ----- tests/ui/non_expressive_names.stderr | 88 ++++++++++++++-------------- 2 files changed, 44 insertions(+), 58 deletions(-) diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 649a5ecb812..8f8c110b9da 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -1,17 +1,6 @@ #![feature(plugin)] #![plugin(clippy)] #![deny(clippy,similar_names)] - - - - - - - - - - - #![allow(unused)] @@ -129,18 +118,15 @@ fn bla() { } { let e: i32; - } { let e: i32; - let f: i32; } match 5 { 1 => println!(""), e => panic!(), - } match 5 { 1 => println!(""), diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index c47f5a449a2..63fc607b802 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,7 +1,7 @@ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:29:9 + --> $DIR/non_expressive_names.rs:18:9 | -29 | let bpple: i32; +18 | let bpple: i32; | ^^^^^ | note: lint level defined here @@ -10,107 +10,107 @@ note: lint level defined here 3 | #![deny(clippy,similar_names)] | ^^^^^^^^^^^^^ note: existing binding defined here - --> $DIR/non_expressive_names.rs:27:9 + --> $DIR/non_expressive_names.rs:16:9 | -27 | let apple: i32; +16 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `b_pple` - --> $DIR/non_expressive_names.rs:29:9 + --> $DIR/non_expressive_names.rs:18:9 | -29 | let bpple: i32; +18 | let bpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:31:9 + --> $DIR/non_expressive_names.rs:20:9 | -31 | let cpple: i32; +20 | let cpple: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:27:9 + --> $DIR/non_expressive_names.rs:16:9 | -27 | let apple: i32; +16 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `c_pple` - --> $DIR/non_expressive_names.rs:31:9 + --> $DIR/non_expressive_names.rs:20:9 | -31 | let cpple: i32; +20 | let cpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:56:9 + --> $DIR/non_expressive_names.rs:45:9 | -56 | let bluby: i32; +45 | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:55:9 + --> $DIR/non_expressive_names.rs:44:9 | -55 | let blubx: i32; +44 | let blubx: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `blub_y` - --> $DIR/non_expressive_names.rs:56:9 + --> $DIR/non_expressive_names.rs:45:9 | -56 | let bluby: i32; +45 | let bluby: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:61:9 + --> $DIR/non_expressive_names.rs:50:9 | -61 | let coke: i32; +50 | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:59:9 + --> $DIR/non_expressive_names.rs:48:9 | -59 | let cake: i32; +48 | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:79:9 + --> $DIR/non_expressive_names.rs:68:9 | -79 | let xyzeabc: i32; +68 | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:77:9 + --> $DIR/non_expressive_names.rs:66:9 | -77 | let xyz1abc: i32; +66 | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:83:9 + --> $DIR/non_expressive_names.rs:72:9 | -83 | let parsee: i32; +72 | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:81:9 + --> $DIR/non_expressive_names.rs:70:9 | -81 | let parser: i32; +70 | let parser: i32; | ^^^^^^ help: separate the discriminating character by an underscore like: `parse_e` - --> $DIR/non_expressive_names.rs:83:9 + --> $DIR/non_expressive_names.rs:72:9 | -83 | let parsee: i32; +72 | let parsee: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:97:16 + --> $DIR/non_expressive_names.rs:86:16 | -97 | bpple: sprang } = unimplemented!(); +86 | bpple: sprang } = unimplemented!(); | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:96:22 + --> $DIR/non_expressive_names.rs:85:22 | -96 | let Foo { apple: spring, +85 | let Foo { apple: spring, | ^^^^^^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:131:17 + --> $DIR/non_expressive_names.rs:120:17 | -131 | let e: i32; +120 | let e: i32; | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] @@ -121,25 +121,25 @@ note: lint level defined here | ^^^^^^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:135:17 + --> $DIR/non_expressive_names.rs:123:17 | -135 | let e: i32; +123 | let e: i32; | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] error: 6th binding whose name is just one char - --> $DIR/non_expressive_names.rs:137:17 + --> $DIR/non_expressive_names.rs:124:17 | -137 | let f: i32; +124 | let f: i32; | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:142:13 + --> $DIR/non_expressive_names.rs:129:13 | -142 | e => panic!(), +129 | e => panic!(), | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] From 69139facb2137f4c5daf0e9a149bc342ac8b7288 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:30:21 +0100 Subject: [PATCH 37/55] clean tests/ui/ok_if_let.rs Cleaning the empty lines for clarity. --- tests/ui/ok_if_let.rs | 1 - tests/ui/ok_if_let.stderr | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/ui/ok_if_let.rs b/tests/ui/ok_if_let.rs index fdde6303b08..e8a55a552d4 100644 --- a/tests/ui/ok_if_let.rs +++ b/tests/ui/ok_if_let.rs @@ -5,7 +5,6 @@ fn str_to_int(x: &str) -> i32 { if let Some(y) = x.parse().ok() { - y } else { 0 diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index 42f60d4097d..bf58e1281cf 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -2,11 +2,10 @@ error: Matching on `Some` with `ok()` is redundant --> $DIR/ok_if_let.rs:7:5 | 7 | / if let Some(y) = x.parse().ok() { -8 | | -9 | | y -10 | | } else { -11 | | 0 -12 | | } +8 | | y +9 | | } else { +10 | | 0 +11 | | } | |_____^ | note: lint level defined here From ec343e1524bc2eb7e3c022e53177e40c96d2e18f Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:32:42 +0100 Subject: [PATCH 38/55] clean tests/ui/precedence.rs Cleaning the empty lines for clarity. --- tests/ui/partialeq_ne_impl.rs | 1 - tests/ui/precedence.rs | 19 ----------- tests/ui/precedence.stderr | 62 +++++++++++++++++------------------ 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/tests/ui/partialeq_ne_impl.rs b/tests/ui/partialeq_ne_impl.rs index 9ee1f48b01c..aadbd8d693a 100644 --- a/tests/ui/partialeq_ne_impl.rs +++ b/tests/ui/partialeq_ne_impl.rs @@ -9,7 +9,6 @@ struct Foo; impl PartialEq for Foo { fn eq(&self, _: &Foo) -> bool { true } fn ne(&self, _: &Foo) -> bool { false } - } fn main() {} diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index 1c6019fdecf..c37769d816e 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -6,34 +6,15 @@ #[allow(eq_op)] fn main() { 1 << 2 + 3; - - 1 + 2 << 3; - - 4 >> 1 + 1; - - 1 + 3 >> 2; - - 1 ^ 1 - 1; - - 3 | 2 - 1; - - 3 & 5 - 2; - - - -1i32.abs(); - - -1f32.abs(); - - // These should not trigger an error let _ = (-1i32).abs(); let _ = (-1f32).abs(); diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 9dd86d19181..6090be0ab0f 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -10,52 +10,52 @@ note: lint level defined here 4 | #[deny(precedence)] | ^^^^^^^^^^ +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:9:5 + | +9 | 1 + 2 << 3; + | ^^^^^^^^^^ help: consider parenthesizing your expression `(1 + 2) << 3` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:10:5 + | +10 | 4 >> 1 + 1; + | ^^^^^^^^^^ help: consider parenthesizing your expression `4 >> (1 + 1)` + error: operator precedence can trip the unwary --> $DIR/precedence.rs:11:5 | -11 | 1 + 2 << 3; - | ^^^^^^^^^^ help: consider parenthesizing your expression `(1 + 2) << 3` +11 | 1 + 3 >> 2; + | ^^^^^^^^^^ help: consider parenthesizing your expression `(1 + 3) >> 2` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:12:5 + | +12 | 1 ^ 1 - 1; + | ^^^^^^^^^ help: consider parenthesizing your expression `1 ^ (1 - 1)` + +error: operator precedence can trip the unwary + --> $DIR/precedence.rs:13:5 + | +13 | 3 | 2 - 1; + | ^^^^^^^^^ help: consider parenthesizing your expression `3 | (2 - 1)` error: operator precedence can trip the unwary --> $DIR/precedence.rs:14:5 | -14 | 4 >> 1 + 1; - | ^^^^^^^^^^ help: consider parenthesizing your expression `4 >> (1 + 1)` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:17:5 - | -17 | 1 + 3 >> 2; - | ^^^^^^^^^^ help: consider parenthesizing your expression `(1 + 3) >> 2` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:20:5 - | -20 | 1 ^ 1 - 1; - | ^^^^^^^^^ help: consider parenthesizing your expression `1 ^ (1 - 1)` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:23:5 - | -23 | 3 | 2 - 1; - | ^^^^^^^^^ help: consider parenthesizing your expression `3 | (2 - 1)` - -error: operator precedence can trip the unwary - --> $DIR/precedence.rs:26:5 - | -26 | 3 & 5 - 2; +14 | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:30:5 + --> $DIR/precedence.rs:15:5 | -30 | -1i32.abs(); +15 | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:33:5 + --> $DIR/precedence.rs:16:5 | -33 | -1f32.abs(); +16 | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent `-(1f32.abs())` error: aborting due to 9 previous errors From 169f35712c264866986227a78ce135638b270f0f Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:34:14 +0100 Subject: [PATCH 39/55] clean tests/ui/print.rs Cleaning the empty lines for clarity. --- tests/ui/print.rs | 5 ----- tests/ui/print.stderr | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/tests/ui/print.rs b/tests/ui/print.rs index e6b114b897b..7a53fef480d 100644 --- a/tests/ui/print.rs +++ b/tests/ui/print.rs @@ -10,7 +10,6 @@ struct Foo; impl Display for Foo { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{:?}", 43.1415) - } } @@ -29,12 +28,8 @@ fn main() { print!("Hello {:?}", "World"); - - print!("Hello {:#?}", "#orld"); - - assert_eq!(42, 1337); vec![1, 2]; diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 5afb8ae504d..e21a49a7477 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -11,9 +11,9 @@ note: lint level defined here | ^^^^^^^^^ error: use of `println!` - --> $DIR/print.rs:25:5 + --> $DIR/print.rs:24:5 | -25 | println!("Hello"); +24 | println!("Hello"); | ^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -23,39 +23,39 @@ note: lint level defined here | ^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:26:5 + --> $DIR/print.rs:25:5 | -26 | print!("Hello"); +25 | print!("Hello"); | ^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:28:5 + --> $DIR/print.rs:27:5 | -28 | print!("Hello {}", "World"); +27 | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:30:5 + --> $DIR/print.rs:29:5 | -30 | print!("Hello {:?}", "World"); +29 | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:30:26 + --> $DIR/print.rs:29:26 | -30 | print!("Hello {:?}", "World"); +29 | print!("Hello {:?}", "World"); | ^^^^^^^ error: use of `print!` - --> $DIR/print.rs:34:5 + --> $DIR/print.rs:31:5 | -34 | print!("Hello {:#?}", "#orld"); +31 | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:34:27 + --> $DIR/print.rs:31:27 | -34 | print!("Hello {:#?}", "#orld"); +31 | print!("Hello {:#?}", "#orld"); | ^^^^^^^ error: aborting due to 8 previous errors From 7d2e0cb4353ae5164bdc1ec19480838e8f7232ec Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:36:28 +0100 Subject: [PATCH 40/55] clean tests/ui/redundant_closure_call.rs Cleaning the empty lines for clarity. --- tests/ui/redundant_closure_call.rs | 4 ---- tests/ui/redundant_closure_call.stderr | 16 ++++++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/ui/redundant_closure_call.rs b/tests/ui/redundant_closure_call.rs index a431e05e72f..30a8de4fd1c 100644 --- a/tests/ui/redundant_closure_call.rs +++ b/tests/ui/redundant_closure_call.rs @@ -6,9 +6,6 @@ fn main() { let a = (|| 42)(); - - - let mut i = 1; let k = (|m| m+1)(i); @@ -22,4 +19,3 @@ fn main() { i = closure(4); } - diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index bc3ceef0f70..591a48a1a38 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -1,7 +1,7 @@ error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:18:2 + --> $DIR/redundant_closure_call.rs:15:2 | -18 | \ti = closure(); +15 | \ti = closure(); | \t^^^^^^^^^^^^^ | note: lint level defined here @@ -11,9 +11,9 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^^ error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:21:2 + --> $DIR/redundant_closure_call.rs:18:2 | -21 | \ti = closure(3); +18 | \ti = closure(3); | \t^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. @@ -23,15 +23,15 @@ error: Try not to call a closure in the expression where it is declared. | \t ^^^^^^^^^ help: Try doing something like: `42` error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:13:10 + --> $DIR/redundant_closure_call.rs:10:10 | -13 | \tlet k = (|m| m+1)(i); +10 | \tlet k = (|m| m+1)(i); | \t ^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:15:6 + --> $DIR/redundant_closure_call.rs:12:6 | -15 | \tk = (|a,b| a*b)(1,5); +12 | \tk = (|a,b| a*b)(1,5); | \t ^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors From 36ba4885abc4cb6243560535988bd774f744f566 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:38:19 +0100 Subject: [PATCH 41/55] clean tests/ui/reference.rs Cleaning the empty lines for clarity. --- tests/ui/reference.rs | 33 ------------------------ tests/ui/reference.stderr | 54 +++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 60 deletions(-) diff --git a/tests/ui/reference.rs b/tests/ui/reference.rs index d1160df9e12..6928f16d10a 100644 --- a/tests/ui/reference.rs +++ b/tests/ui/reference.rs @@ -18,62 +18,32 @@ fn main() { let b = *&a; - - - let b = *&get_number(); - - - let b = *get_reference(&a); let bytes : Vec = vec![1, 2, 3, 4]; let b = *&bytes[1..2][0]; - - - //This produces a suggestion of 'let b = (a);' which //will trigger the 'unused_parens' lint let b = *&(a); - - - let b = *(&a); - - - let b = *((&a)); - - - let b = *&&a; - - - let b = **&aref; - - - //This produces a suggestion of 'let b = *&a;' which //will trigger the 'deref_addrof' lint again let b = **&&a; - - - { let mut x = 10; let y = *&mut x; - - - } { @@ -81,8 +51,5 @@ fn main() { //will trigger the 'deref_addrof' lint again let mut x = 10; let y = **&mut &mut x; - - - } } diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 5d41c1809b4..b25f7737c79 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -11,63 +11,63 @@ note: lint level defined here | ^^^^^^^^^^^^ error: immediately dereferencing a reference - --> $DIR/reference.rs:24:13 + --> $DIR/reference.rs:21:13 | -24 | let b = *&get_number(); +21 | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try this `get_number()` +error: immediately dereferencing a reference + --> $DIR/reference.rs:26:13 + | +26 | let b = *&bytes[1..2][0]; + | ^^^^^^^^^^^^^^^^ help: try this `bytes[1..2][0]` + +error: immediately dereferencing a reference + --> $DIR/reference.rs:30:13 + | +30 | let b = *&(a); + | ^^^^^ help: try this `(a)` + error: immediately dereferencing a reference --> $DIR/reference.rs:32:13 | -32 | let b = *&bytes[1..2][0]; - | ^^^^^^^^^^^^^^^^ help: try this `bytes[1..2][0]` - -error: immediately dereferencing a reference - --> $DIR/reference.rs:39:13 - | -39 | let b = *&(a); - | ^^^^^ help: try this `(a)` - -error: immediately dereferencing a reference - --> $DIR/reference.rs:44:13 - | -44 | let b = *(&a); +32 | let b = *(&a); | ^^^^^ help: try this `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:49:13 + --> $DIR/reference.rs:34:13 | -49 | let b = *((&a)); +34 | let b = *((&a)); | ^^^^^^^ help: try this `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:54:13 + --> $DIR/reference.rs:36:13 | -54 | let b = *&&a; +36 | let b = *&&a; | ^^^^ help: try this `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:59:14 + --> $DIR/reference.rs:38:14 | -59 | let b = **&aref; +38 | let b = **&aref; | ^^^^^^ help: try this `aref` error: immediately dereferencing a reference - --> $DIR/reference.rs:66:14 + --> $DIR/reference.rs:42:14 | -66 | let b = **&&a; +42 | let b = **&&a; | ^^^^ help: try this `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:73:17 + --> $DIR/reference.rs:46:17 | -73 | let y = *&mut x; +46 | let y = *&mut x; | ^^^^^^^ help: try this `x` error: immediately dereferencing a reference - --> $DIR/reference.rs:83:18 + --> $DIR/reference.rs:53:18 | -83 | let y = **&mut &mut x; +53 | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this `&mut x` error: aborting due to 11 previous errors From bf6d4b7129485715639a29bdf65f800c66d090bc Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:41:40 +0100 Subject: [PATCH 42/55] clean tests/ui/regex.rs Cleaning the empty lines for clarity. --- tests/ui/regex.rs | 32 ---------------- tests/ui/regex.stderr | 88 +++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 76 deletions(-) diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index 245ceb83561..154fef54cea 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -14,24 +14,16 @@ const NOT_A_REAL_REGEX : &'static str = "foobar"; fn syntax_error() { let pipe_in_wrong_position = Regex::new("|"); - let pipe_in_wrong_position_builder = RegexBuilder::new("|"); - let wrong_char_ranice = Regex::new("[z-a]"); - let some_unicode = Regex::new("[é-è]"); - let some_regex = Regex::new(OPENING_PAREN); - let binary_pipe_in_wrong_position = BRegex::new("|"); - let some_binary_regex = BRegex::new(OPENING_PAREN); - let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); - let closing_paren = ")"; let not_linted = Regex::new(closing_paren); @@ -46,12 +38,10 @@ fn syntax_error() { let set_error = RegexSet::new(&[ OPENING_PAREN, - r"[a-z]+\.(com|org|net)", ]); let bset_error = BRegexSet::new(&[ OPENING_PAREN, - r"[a-z]+\.(com|org|net)", ]); } @@ -59,49 +49,27 @@ fn syntax_error() { fn trivial_regex() { let trivial_eq = Regex::new("^foobar$"); - - let trivial_eq_builder = RegexBuilder::new("^foobar$"); - - let trivial_starts_with = Regex::new("^foobar"); - - let trivial_ends_with = Regex::new("foobar$"); - - let trivial_contains = Regex::new("foobar"); - - let trivial_contains = Regex::new(NOT_A_REAL_REGEX); - - let trivial_backslash = Regex::new("a\\.b"); - - // unlikely corner cases let trivial_empty = Regex::new(""); - - let trivial_empty = Regex::new("^"); - - let trivial_empty = Regex::new("^$"); - - let binary_trivial_empty = BRegex::new("^$"); - - // non-trivial regexes let non_trivial_dot = Regex::new("a.b"); let non_trivial_dot_builder = RegexBuilder::new("a.b"); diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index f59d0c6b5dc..ad9e7ba4c75 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -7,81 +7,81 @@ error: regex syntax error: empty alternate = note: #[deny(invalid_regex)] on by default error: regex syntax error: empty alternate - --> $DIR/regex.rs:18:60 + --> $DIR/regex.rs:17:60 | -18 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); +17 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error: invalid character class range - --> $DIR/regex.rs:20:40 + --> $DIR/regex.rs:18:40 | -20 | let wrong_char_ranice = Regex::new("[z-a]"); +18 | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error: invalid character class range - --> $DIR/regex.rs:22:35 + --> $DIR/regex.rs:19:35 | -22 | let some_unicode = Regex::new("[é-è]"); +19 | let some_unicode = Regex::new("[é-è]"); | ^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error on position 0: unclosed parenthesis - --> $DIR/regex.rs:25:33 + --> $DIR/regex.rs:21:33 | -25 | let some_regex = Regex::new(OPENING_PAREN); +21 | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error: empty alternate - --> $DIR/regex.rs:28:53 + --> $DIR/regex.rs:23:53 | -28 | let binary_pipe_in_wrong_position = BRegex::new("|"); +23 | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error on position 0: unclosed parenthesis - --> $DIR/regex.rs:30:41 + --> $DIR/regex.rs:24:41 | -30 | let some_binary_regex = BRegex::new(OPENING_PAREN); +24 | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error on position 0: unclosed parenthesis - --> $DIR/regex.rs:32:56 + --> $DIR/regex.rs:25:56 | -32 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); +25 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error on position 0: unclosed parenthesis - --> $DIR/regex.rs:48:9 + --> $DIR/regex.rs:40:9 | -48 | OPENING_PAREN, +40 | OPENING_PAREN, | ^^^^^^^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: regex syntax error on position 0: unclosed parenthesis - --> $DIR/regex.rs:53:9 + --> $DIR/regex.rs:44:9 | -53 | OPENING_PAREN, +44 | OPENING_PAREN, | ^^^^^^^^^^^^^ | = note: #[deny(invalid_regex)] on by default error: trivial regex - --> $DIR/regex.rs:60:33 + --> $DIR/regex.rs:50:33 | -60 | let trivial_eq = Regex::new("^foobar$"); +50 | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ | note: lint level defined here @@ -92,84 +92,84 @@ note: lint level defined here = help: consider using consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:64:48 + --> $DIR/regex.rs:52:48 | -64 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); +52 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:68:42 + --> $DIR/regex.rs:54:42 | -68 | let trivial_starts_with = Regex::new("^foobar"); +54 | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ | = help: consider using consider using `str::starts_with` error: trivial regex - --> $DIR/regex.rs:72:40 + --> $DIR/regex.rs:56:40 | -72 | let trivial_ends_with = Regex::new("foobar$"); +56 | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ | = help: consider using consider using `str::ends_with` error: trivial regex - --> $DIR/regex.rs:76:39 + --> $DIR/regex.rs:58:39 | -76 | let trivial_contains = Regex::new("foobar"); +58 | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ | = help: consider using consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:80:39 + --> $DIR/regex.rs:60:39 | -80 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); +60 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ | = help: consider using consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:84:40 + --> $DIR/regex.rs:62:40 | -84 | let trivial_backslash = Regex::new("a//.b"); +62 | let trivial_backslash = Regex::new("a//.b"); | ^^^^^^^ | = help: consider using consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:89:36 + --> $DIR/regex.rs:65:36 | -89 | let trivial_empty = Regex::new(""); +65 | let trivial_empty = Regex::new(""); | ^^ | = help: consider using the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:93:36 + --> $DIR/regex.rs:67:36 | -93 | let trivial_empty = Regex::new("^"); +67 | let trivial_empty = Regex::new("^"); | ^^^ | = help: consider using the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:97:36 + --> $DIR/regex.rs:69:36 | -97 | let trivial_empty = Regex::new("^$"); +69 | let trivial_empty = Regex::new("^$"); | ^^^^ | = help: consider using consider using `str::is_empty` error: trivial regex - --> $DIR/regex.rs:101:44 - | -101 | let binary_trivial_empty = BRegex::new("^$"); - | ^^^^ - | - = help: consider using consider using `str::is_empty` + --> $DIR/regex.rs:71:44 + | +71 | let binary_trivial_empty = BRegex::new("^$"); + | ^^^^ + | + = help: consider using consider using `str::is_empty` error: aborting due to 21 previous errors From ffb768cf8db6acd843f7416d961882c4a07e58d9 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:42:56 +0100 Subject: [PATCH 43/55] clean tests/ui/serde.rs Cleaning the empty lines for clarity. --- tests/ui/serde.rs | 1 - tests/ui/serde.stderr | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/ui/serde.rs b/tests/ui/serde.rs index 83150638ac1..8c4143b0dcf 100644 --- a/tests/ui/serde.rs +++ b/tests/ui/serde.rs @@ -37,7 +37,6 @@ impl<'de> serde::de::Visitor<'de> for B { } fn visit_string(self, _v: String) -> Result - where E: serde::de::Error, { unimplemented!() diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index b8b489165d0..8b7daae9909 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -2,11 +2,10 @@ error: you should not implement `visit_string` without also implementing `visit_ --> $DIR/serde.rs:39:5 | 39 | / fn visit_string(self, _v: String) -> Result -40 | | -41 | | where E: serde::de::Error, -42 | | { -43 | | unimplemented!() -44 | | } +40 | | where E: serde::de::Error, +41 | | { +42 | | unimplemented!() +43 | | } | |_____^ | note: lint level defined here From c79a350c55a1d53988aeb58b0af2bcbd9127d77c Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:45:02 +0100 Subject: [PATCH 44/55] clean tests/ui/short_circuit_statement.rs Cleaning the empty lines for clarity. --- tests/ui/short_circuit_statement.rs | 9 --------- tests/ui/short_circuit_statement.stderr | 16 ++++++++-------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index 55ff4a83b87..c51bdcbe693 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -5,17 +5,8 @@ fn main() { f() && g(); - - - f() || g(); - - - 1 == 2 || g(); - - - } fn f() -> bool { diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 09e24fa7de6..60b7ca801ab 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -11,16 +11,16 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^^^ error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:11:5 - | -11 | f() || g(); - | ^^^^^^^^^^^ help: replace it with `if !f() { g(); }` + --> $DIR/short_circuit_statement.rs:8:5 + | +8 | f() || g(); + | ^^^^^^^^^^^ help: replace it with `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:15:5 - | -15 | 1 == 2 || g(); - | ^^^^^^^^^^^^^^ help: replace it with `if !(1 == 2) { g(); }` + --> $DIR/short_circuit_statement.rs:9:5 + | +9 | 1 == 2 || g(); + | ^^^^^^^^^^^^^^ help: replace it with `if !(1 == 2) { g(); }` error: aborting due to 3 previous errors From a7635aa1c8b9355e7d4564f5cbf5c472c6332178 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:47:31 +0100 Subject: [PATCH 45/55] clean tests/ui/strings.rs Cleaning the empty lines for clarity. --- tests/ui/strings.rs | 6 ------ tests/ui/strings.stderr | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/ui/strings.rs b/tests/ui/strings.rs index f893d99491b..b4aef1ba62c 100644 --- a/tests/ui/strings.rs +++ b/tests/ui/strings.rs @@ -49,9 +49,6 @@ fn both() { fn str_lit_as_bytes() { let bs = "hello there".as_bytes(); - - - // no warning, because this cannot be written as a byte string literal: let ubs = "☃".as_bytes(); @@ -66,8 +63,5 @@ fn main() { // the add is only caught for `String` let mut x = 1; ; x = x + 1; - - - assert_eq!(2, x); } diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index 57502888744..197d52a8781 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -65,9 +65,9 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^ warning: manual implementation of an assign operation - --> $DIR/strings.rs:68:7 + --> $DIR/strings.rs:65:7 | -68 | ; x = x + 1; +65 | ; x = x + 1; | ^^^^^^^^^ help: replace it with `x += 1` | = note: #[warn(assign_op_pattern)] on by default From 80ca0484c7395845a2784bd965767c42366f7a6a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:49:54 +0100 Subject: [PATCH 46/55] clean tests/ui/swap.rs Cleaning the empty lines for clarity. --- tests/ui/swap.rs | 25 ------------------------- tests/ui/swap.stderr | 44 ++++++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 47 deletions(-) diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index 95478dda0d3..0c23af966eb 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -12,9 +12,6 @@ fn array() { foo[0] = foo[1]; foo[1] = temp; - - - foo.swap(0, 1); } @@ -24,9 +21,6 @@ fn slice() { foo[0] = foo[1]; foo[1] = temp; - - - foo.swap(0, 1); } @@ -36,9 +30,6 @@ fn vec() { foo[0] = foo[1]; foo[1] = temp; - - - foo.swap(0, 1); } @@ -53,32 +44,16 @@ fn main() { a = b; b = a; - - - - ; let t = a; a = b; b = t; - - - - let mut c = Foo(42); c.0 = a; a = c.0; - - - - ; let t = c.0; c.0 = a; a = t; - - - - } diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 0bd8721b4ff..a6a0e8bbae9 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -14,54 +14,54 @@ note: lint level defined here | ^^^^^^ error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:23:5 + --> $DIR/swap.rs:20:5 | -23 | / let temp = foo[0]; -24 | | foo[0] = foo[1]; -25 | | foo[1] = temp; +20 | / let temp = foo[0]; +21 | | foo[0] = foo[1]; +22 | | foo[1] = temp; | |_________________^ help: try `foo.swap(0, 1)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:35:5 + --> $DIR/swap.rs:29:5 | -35 | / let temp = foo[0]; -36 | | foo[0] = foo[1]; -37 | | foo[1] = temp; +29 | / let temp = foo[0]; +30 | | foo[0] = foo[1]; +31 | | foo[1] = temp; | |_________________^ help: try `foo.swap(0, 1)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:60:7 + --> $DIR/swap.rs:47:7 | -60 | ; let t = a; +47 | ; let t = a; | _______^ -61 | | a = b; -62 | | b = t; +48 | | a = b; +49 | | b = t; | |_________^ help: try `std::mem::swap(&mut a, &mut b)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:77:7 + --> $DIR/swap.rs:56:7 | -77 | ; let t = c.0; +56 | ; let t = c.0; | _______^ -78 | | c.0 = a; -79 | | a = t; +57 | | c.0 = a; +58 | | a = t; | |_________^ help: try `std::mem::swap(&mut c.0, &mut a)` | = note: #[deny(manual_swap)] implied by #[deny(clippy)] = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:53:5 + --> $DIR/swap.rs:44:5 | -53 | / a = b; -54 | | b = a; +44 | / a = b; +45 | | b = a; | |_________^ help: try `std::mem::swap(&mut a, &mut b)` | = note: #[deny(almost_swapped)] implied by #[deny(clippy)] @@ -73,10 +73,10 @@ note: lint level defined here = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:70:5 + --> $DIR/swap.rs:53:5 | -70 | / c.0 = a; -71 | | a = c.0; +53 | / c.0 = a; +54 | | a = c.0; | |___________^ help: try `std::mem::swap(&mut c.0, &mut a)` | = note: #[deny(almost_swapped)] implied by #[deny(clippy)] From 24324f84d85dce08bb50448a1dfd85932ed08b80 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:51:28 +0100 Subject: [PATCH 47/55] clean tests/ui/toplevel_ref_arg.rs Cleaning the empty lines for clarity. --- tests/ui/toplevel_ref_arg.rs | 12 ------------ tests/ui/toplevel_ref_arg.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/ui/toplevel_ref_arg.rs b/tests/ui/toplevel_ref_arg.rs index a69600899af..7df2f5c86b7 100644 --- a/tests/ui/toplevel_ref_arg.rs +++ b/tests/ui/toplevel_ref_arg.rs @@ -17,24 +17,12 @@ fn main() { let ref x = 1; - - - let ref y: (&_, u8) = (&1, 2); - - - let ref z = 1 + 2; - - - let ref mut z = 1 + 2; - - - let (ref x, _) = (1,2); // okay, not top level println!("The answer is {}.", x); } diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 85faa0d15ab..8e01e76897d 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -20,25 +20,25 @@ error: `ref` on an entire `let` pattern is discouraged, take a reference with `& = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:23:7 + --> $DIR/toplevel_ref_arg.rs:20:7 | -23 | let ref y: (&_, u8) = (&1, 2); +20 | let ref y: (&_, u8) = (&1, 2); | ----^^^^^--------------------- help: try `let y: &(&_, u8) = &(&1, 2);` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:28:7 + --> $DIR/toplevel_ref_arg.rs:22:7 | -28 | let ref z = 1 + 2; +22 | let ref z = 1 + 2; | ----^^^^^--------- help: try `let z = &(1 + 2);` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:33:7 + --> $DIR/toplevel_ref_arg.rs:24:7 | -33 | let ref mut z = 1 + 2; +24 | let ref mut z = 1 + 2; | ----^^^^^^^^^--------- help: try `let z = &mut (1 + 2);` | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] From 81ee7f752e8766102d1ce57b8caea0bbdf4929d8 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 15:55:55 +0100 Subject: [PATCH 48/55] clean tests/ui/transmute.rs Cleaning the empty lines for clarity. --- tests/ui/transmute.rs | 53 ----------- tests/ui/transmute.stderr | 154 ++++++++++++++++---------------- tests/ui/transmute_32bit.rs | 4 - tests/ui/transmute_64bit.rs | 2 - tests/ui/transmute_64bit.stderr | 4 +- 5 files changed, 79 insertions(+), 138 deletions(-) diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs index 6f0a831f5d5..b70b846d32d 100644 --- a/tests/ui/transmute.rs +++ b/tests/ui/transmute.rs @@ -21,67 +21,36 @@ fn my_vec() -> MyVec { unsafe fn _generic<'a, T, U: 'a>(t: &'a T) { let _: &'a T = core::intrinsics::transmute(t); - let _: &'a U = core::intrinsics::transmute(t); let _: *const T = core::intrinsics::transmute(t); - - - let _: *mut T = core::intrinsics::transmute(t); - - - let _: *const U = core::intrinsics::transmute(t); - - - } #[deny(transmute_ptr_to_ref)] unsafe fn _ptr_to_ref(p: *const T, m: *mut T, o: *const U, om: *mut U) { let _: &T = std::mem::transmute(p); - - - let _: &T = &*p; let _: &mut T = std::mem::transmute(m); - - - let _: &mut T = &mut *m; let _: &T = std::mem::transmute(m); - - - let _: &T = &*m; let _: &mut T = std::mem::transmute(p as *mut T); - - - let _ = &mut *(p as *mut T); let _: &T = std::mem::transmute(o); - - - let _: &T = &*(o as *const T); let _: &mut T = std::mem::transmute(om); - - - let _: &mut T = &mut *(om as *mut T); let _: &T = std::mem::transmute(om); - - - let _: &T = &*(om as *const T); } @@ -94,20 +63,11 @@ fn issue1231() { let raw = 42 as *const i32; let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; - - - let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; - - - type Bar<'a> = &'a u8; let raw = 42 as *const i32; unsafe { std::mem::transmute::<_, Bar>(raw) }; - - - } #[deny(useless_transmute)] @@ -115,19 +75,14 @@ fn useless() { unsafe { let _: Vec = core::intrinsics::transmute(my_vec()); - let _: Vec = core::mem::transmute(my_vec()); - let _: Vec = std::intrinsics::transmute(my_vec()); - let _: Vec = std::mem::transmute(my_vec()); - let _: Vec = my_transmute(my_vec()); - let _: Vec = core::intrinsics::transmute(my_vec()); let _: Vec = core::mem::transmute(my_vec()); let _: Vec = std::intrinsics::transmute(my_vec()); @@ -136,14 +91,10 @@ fn useless() { let _: *const usize = std::mem::transmute(5_isize); - - let _ = 5_isize as *const usize; let _: *const usize = std::mem::transmute(1+1usize); - - let _ = (1+1_usize) as *const usize; } } @@ -159,15 +110,11 @@ fn crosspointer() { unsafe { let _: Usize = core::intrinsics::transmute(int_const_ptr); - let _: Usize = core::intrinsics::transmute(int_mut_ptr); - let _: *const Usize = core::intrinsics::transmute(my_int()); - let _: *mut Usize = core::intrinsics::transmute(my_int()); - } } diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index 49a35e48bf6..b2bce16abe0 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -11,171 +11,171 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^ error: transmute from a reference to a pointer - --> $DIR/transmute.rs:27:23 + --> $DIR/transmute.rs:26:23 | -27 | let _: *const T = core::intrinsics::transmute(t); +26 | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:32:21 + --> $DIR/transmute.rs:28:21 | -32 | let _: *mut T = core::intrinsics::transmute(t); +28 | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *mut T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:37:23 + --> $DIR/transmute.rs:30:23 | -37 | let _: *const U = core::intrinsics::transmute(t); +30 | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `t as *const T as *const U` error: transmute from a pointer type (`*const T`) to a reference type (`&T`) - --> $DIR/transmute.rs:45:17 + --> $DIR/transmute.rs:35:17 | -45 | let _: &T = std::mem::transmute(p); +35 | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*p` | note: lint level defined here - --> $DIR/transmute.rs:43:8 + --> $DIR/transmute.rs:33:8 | -43 | #[deny(transmute_ptr_to_ref)] +33 | #[deny(transmute_ptr_to_ref)] | ^^^^^^^^^^^^^^^^^^^^ error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:51:21 + --> $DIR/transmute.rs:38:21 | -51 | let _: &mut T = std::mem::transmute(m); +38 | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) - --> $DIR/transmute.rs:57:17 + --> $DIR/transmute.rs:41:17 | -57 | let _: &T = std::mem::transmute(m); +41 | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:63:21 + --> $DIR/transmute.rs:44:21 | -63 | let _: &mut T = std::mem::transmute(p as *mut T); +44 | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) - --> $DIR/transmute.rs:69:17 + --> $DIR/transmute.rs:47:17 | -69 | let _: &T = std::mem::transmute(o); +47 | let _: &T = std::mem::transmute(o); | ^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:75:21 + --> $DIR/transmute.rs:50:21 | -75 | let _: &mut T = std::mem::transmute(om); +50 | let _: &mut T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) - --> $DIR/transmute.rs:81:17 + --> $DIR/transmute.rs:53:17 | -81 | let _: &T = std::mem::transmute(om); +53 | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) - --> $DIR/transmute.rs:95:32 + --> $DIR/transmute.rs:64:32 | -95 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; +64 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<_>)` | note: lint level defined here - --> $DIR/transmute.rs:88:8 + --> $DIR/transmute.rs:57:8 | -88 | #[deny(transmute_ptr_to_ref)] +57 | #[deny(transmute_ptr_to_ref)] | ^^^^^^^^^^^^^^^^^^^^ error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) - --> $DIR/transmute.rs:100:33 - | -100 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<&_>)` + --> $DIR/transmute.rs:66:33 + | +66 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const Foo<&_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) - --> $DIR/transmute.rs:107:14 - | -107 | unsafe { std::mem::transmute::<_, Bar>(raw) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const u8)` + --> $DIR/transmute.rs:70:14 + | +70 | unsafe { std::mem::transmute::<_, Bar>(raw) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `&*(raw as *const u8)` error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:116:27 - | -116 | let _: Vec = core::intrinsics::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | + --> $DIR/transmute.rs:76:27 + | +76 | let _: Vec = core::intrinsics::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | note: lint level defined here - --> $DIR/transmute.rs:113:8 - | -113 | #[deny(useless_transmute)] - | ^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:73:8 + | +73 | #[deny(useless_transmute)] + | ^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:119:27 - | -119 | let _: Vec = core::mem::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:78:27 + | +78 | let _: Vec = core::mem::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:122:27 - | -122 | let _: Vec = std::intrinsics::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:80:27 + | +80 | let _: Vec = std::intrinsics::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:125:27 - | -125 | let _: Vec = std::mem::transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:82:27 + | +82 | let _: Vec = std::mem::transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:128:27 - | -128 | let _: Vec = my_transmute(my_vec()); - | ^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/transmute.rs:84:27 + | +84 | let _: Vec = my_transmute(my_vec()); + | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer - --> $DIR/transmute.rs:137:31 - | -137 | let _: *const usize = std::mem::transmute(5_isize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `5_isize as *const usize` + --> $DIR/transmute.rs:92:31 + | +92 | let _: *const usize = std::mem::transmute(5_isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `5_isize as *const usize` error: transmute from an integer to a pointer - --> $DIR/transmute.rs:143:31 - | -143 | let _: *const usize = std::mem::transmute(1+1usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `(1+1usize) as *const usize` + --> $DIR/transmute.rs:96:31 + | +96 | let _: *const usize = std::mem::transmute(1+1usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `(1+1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:160:24 + --> $DIR/transmute.rs:111:24 | -160 | let _: Usize = core::intrinsics::transmute(int_const_ptr); +111 | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/transmute.rs:153:8 + --> $DIR/transmute.rs:104:8 | -153 | #[deny(crosspointer_transmute)] +104 | #[deny(crosspointer_transmute)] | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:163:24 + --> $DIR/transmute.rs:113:24 | -163 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); +113 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> $DIR/transmute.rs:166:31 + --> $DIR/transmute.rs:115:31 | -166 | let _: *const Usize = core::intrinsics::transmute(my_int()); +115 | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> $DIR/transmute.rs:169:29 + --> $DIR/transmute.rs:117:29 | -169 | let _: *mut Usize = core::intrinsics::transmute(my_int()); +117 | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 25 previous errors diff --git a/tests/ui/transmute_32bit.rs b/tests/ui/transmute_32bit.rs index 9c63a6fe0d9..f391b728ec5 100644 --- a/tests/ui/transmute_32bit.rs +++ b/tests/ui/transmute_32bit.rs @@ -7,14 +7,10 @@ fn main() { unsafe { let _: *const usize = std::mem::transmute(6.0f32); - let _: *mut usize = std::mem::transmute(6.0f32); - let _: *const usize = std::mem::transmute('x'); - let _: *mut usize = std::mem::transmute('x'); - } } diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index bf7066245a1..4caa9d1f305 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -8,8 +8,6 @@ fn main() { unsafe { let _: *const usize = std::mem::transmute(6.0f64); - let _: *mut usize = std::mem::transmute(6.0f64); - } } diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index 1559809eb83..3d06348b147 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -11,9 +11,9 @@ note: lint level defined here | ^^^^^^^^^^^^^^^ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:12:29 + --> $DIR/transmute_64bit.rs:11:29 | -12 | let _: *mut usize = std::mem::transmute(6.0f64); +11 | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors From cf7303d217dc2a7235786287c6a684f17d033228 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:00:41 +0100 Subject: [PATCH 49/55] clean tests/ui/unicode.rs Cleaning the empty lines for clarity. --- tests/ui/unicode.rs | 1 - tests/ui/unicode.stderr | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/ui/unicode.rs b/tests/ui/unicode.rs index a12276b9851..02605794539 100644 --- a/tests/ui/unicode.rs +++ b/tests/ui/unicode.rs @@ -4,7 +4,6 @@ #[deny(zero_width_space)] fn zero() { print!("Here >​< is a ZWS, and ​another"); - print!("This\u{200B}is\u{200B}fine"); } diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 407220d1ae0..62ada6fcb1c 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -9,29 +9,29 @@ error: zero-width space detected ""Here >/u{200B}< is a ZWS, and /u{200B}another"" error: non-nfc unicode sequence detected - --> $DIR/unicode.rs:13:12 + --> $DIR/unicode.rs:12:12 | -13 | print!("̀àh?"); +12 | print!("̀àh?"); | ^^^^^^^ | note: lint level defined here - --> $DIR/unicode.rs:11:8 + --> $DIR/unicode.rs:10:8 | -11 | #[deny(unicode_not_nfc)] +10 | #[deny(unicode_not_nfc)] | ^^^^^^^^^^^^^^^ = help: Consider replacing the string with: ""̀àh?"" error: literal non-ASCII character detected - --> $DIR/unicode.rs:19:12 + --> $DIR/unicode.rs:18:12 | -19 | print!("Üben!"); +18 | print!("Üben!"); | ^^^^^^^ | note: lint level defined here - --> $DIR/unicode.rs:17:8 + --> $DIR/unicode.rs:16:8 | -17 | #[deny(non_ascii_literal)] +16 | #[deny(non_ascii_literal)] | ^^^^^^^^^^^^^^^^^ = help: Consider replacing the string with: ""/u{dc}ben!"" From d0b932fb5327a019f7718eba290a17c2284646e5 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:02:19 +0100 Subject: [PATCH 50/55] clean tests/ui/unsafe_removed_from_name.rs Cleaning the empty lines for clarity. --- tests/ui/unsafe_removed_from_name.rs | 3 --- tests/ui/unsafe_removed_from_name.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/ui/unsafe_removed_from_name.rs b/tests/ui/unsafe_removed_from_name.rs index 7ff20223bd2..98b9841c00a 100644 --- a/tests/ui/unsafe_removed_from_name.rs +++ b/tests/ui/unsafe_removed_from_name.rs @@ -6,10 +6,8 @@ use std::cell::{UnsafeCell as TotallySafeCell}; - use std::cell::UnsafeCell as TotallySafeCellAgain; - // Shouldn't error use std::cell::{UnsafeCell as SuperDangerousUnsafeCell}; use std::cell::{UnsafeCell as Dangerunsafe}; @@ -24,7 +22,6 @@ mod mod_with_some_unsafe_things { use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; - // Shouldn't error use mod_with_some_unsafe_things::Safe as IPromiseItsSafeThisTime; use mod_with_some_unsafe_things::Unsafe as SuperUnsafeModThing; diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 4080353efbd..de34d88e503 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -11,15 +11,15 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^^^^ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` - --> $DIR/unsafe_removed_from_name.rs:10:1 - | -10 | use std::cell::UnsafeCell as TotallySafeCellAgain; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/unsafe_removed_from_name.rs:9:1 + | +9 | use std::cell::UnsafeCell as TotallySafeCellAgain; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed "unsafe" from the name of `Unsafe` in use as `LieAboutModSafety` - --> $DIR/unsafe_removed_from_name.rs:25:1 + --> $DIR/unsafe_removed_from_name.rs:23:1 | -25 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; +23 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors From fd3c001ec9266a54d3343a0fff2a1e0791081353 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:03:26 +0100 Subject: [PATCH 51/55] clean tests/ui/unused_io_amount.rs Cleaning the empty lines for clarity. --- tests/ui/unused_io_amount.rs | 4 ---- tests/ui/unused_io_amount.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index 7456a3602d6..0ee9069a17c 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -15,19 +15,15 @@ fn try_macro(s: &mut T) -> io::Result<()> { fn question_mark(s: &mut T) -> io::Result<()> { s.write(b"test")?; - let mut buf = [0u8; 4]; s.read(&mut buf)?; - Ok(()) } fn unwrap(s: &mut T) { s.write(b"test").unwrap(); - let mut buf = [0u8; 4]; s.read(&mut buf).unwrap(); - } fn main() { diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 54d8158908f..7a5643e831c 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -25,25 +25,25 @@ error: handle written amount returned or use `Write::write_all` instead = note: #[deny(unused_io_amount)] on by default error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:20:5 + --> $DIR/unused_io_amount.rs:19:5 | -20 | s.read(&mut buf)?; +19 | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ | = note: #[deny(unused_io_amount)] on by default error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:26:5 + --> $DIR/unused_io_amount.rs:24:5 | -26 | s.write(b"test").unwrap(); +24 | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(unused_io_amount)] on by default error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:29:5 + --> $DIR/unused_io_amount.rs:26:5 | -29 | s.read(&mut buf).unwrap(); +26 | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(unused_io_amount)] on by default From 300a82c29588e21005b0bbcc00f2ccffec8aba13 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:05:22 +0100 Subject: [PATCH 52/55] clean tests/ui/used_underscore_binding.rs Cleaning the empty lines for clarity. --- tests/ui/used_underscore_binding.rs | 3 --- tests/ui/used_underscore_binding.stderr | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index fe0db6346ca..21d91bab689 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -20,11 +20,8 @@ fn prefix_underscore(_foo: u32) -> u32 { /// Test that we lint if we use a `_`-variable defined outside within a macro expansion fn in_macro(_foo: u32) { println!("{}", _foo); - assert_eq!(_foo, _foo); - - test_macro!() + 1; } diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 35179ac3703..f532b4c9022 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -17,21 +17,21 @@ error: used binding `_foo` which is prefixed with an underscore. A leading under | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:24:16 + --> $DIR/used_underscore_binding.rs:23:16 | -24 | assert_eq!(_foo, _foo); +23 | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:24:22 + --> $DIR/used_underscore_binding.rs:23:22 | -24 | assert_eq!(_foo, _foo); +23 | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:39:5 + --> $DIR/used_underscore_binding.rs:36:5 | -39 | s._underscore_field += 1; +36 | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors From 45949c0da91470601952014db2dcfa864245d0b7 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:07:49 +0100 Subject: [PATCH 53/55] clean tests/ui/vec.rs Cleaning the empty lines for clarity. --- tests/ui/useless_attribute.rs | 2 -- tests/ui/vec.rs | 18 ------------------ tests/ui/vec.stderr | 32 ++++++++++++++++---------------- 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index 2b8a4cf56d7..0e30048163f 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -3,8 +3,6 @@ #![deny(useless_attribute)] #[allow(dead_code)] - - extern crate clippy_lints; // don't lint on unused_import for `use` items diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index 3717192fb98..f86137622b6 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -22,33 +22,18 @@ impl Line { fn main() { on_slice(&vec![]); - - - on_slice(&[]); on_slice(&vec![1, 2]); - - - on_slice(&[1, 2]); on_slice(&vec ![1, 2]); - - - on_slice(&[1, 2]); on_slice(&vec!(1, 2)); - - - on_slice(&[1, 2]); on_slice(&vec![1; 2]); - - - on_slice(&[1; 2]); on_vec(&vec![]); @@ -62,9 +47,6 @@ fn main() { on_slice(&vec![2; line.length()]); for a in vec![1, 2, 3] { - - - println!("{:?}", a); } diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index bffd30297d9..5243d882baa 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -10,34 +10,34 @@ note: lint level defined here 4 | #![deny(useless_vec)] | ^^^^^^^^^^^ +error: useless use of `vec!` + --> $DIR/vec.rs:27:14 + | +27 | on_slice(&vec![1, 2]); + | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` + error: useless use of `vec!` --> $DIR/vec.rs:30:14 | -30 | on_slice(&vec![1, 2]); +30 | on_slice(&vec ![1, 2]); + | ^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` + +error: useless use of `vec!` + --> $DIR/vec.rs:33:14 + | +33 | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` error: useless use of `vec!` --> $DIR/vec.rs:36:14 | -36 | on_slice(&vec ![1, 2]); - | ^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` - -error: useless use of `vec!` - --> $DIR/vec.rs:42:14 - | -42 | on_slice(&vec!(1, 2)); - | ^^^^^^^^^^^ help: you can use a slice directly `&[1, 2]` - -error: useless use of `vec!` - --> $DIR/vec.rs:48:14 - | -48 | on_slice(&vec![1; 2]); +36 | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly `&[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:64:14 + --> $DIR/vec.rs:49:14 | -64 | for a in vec![1, 2, 3] { +49 | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly `&[1, 2, 3]` error: aborting due to 6 previous errors From b5a124bc27e2a0c8d30988c680deabe7c504dcf1 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:13:32 +0100 Subject: [PATCH 54/55] clean tests/ui/while_loop.rs Cleaning the empty lines for clarity. --- tests/ui/while_loop.rs | 27 --------- tests/ui/while_loop.stderr | 115 +++++++++++++++++-------------------- 2 files changed, 54 insertions(+), 88 deletions(-) diff --git a/tests/ui/while_loop.rs b/tests/ui/while_loop.rs index 253aebe4444..ddf1d6413cd 100644 --- a/tests/ui/while_loop.rs +++ b/tests/ui/while_loop.rs @@ -7,9 +7,6 @@ fn main() { let y = Some(true); loop { - - - if let Some(_x) = y { let _v = 1; } else { @@ -23,18 +20,12 @@ fn main() { break; } loop { - - - match y { Some(_x) => true, None => break }; } loop { - - - let x = match y { Some(x) => x, None => break @@ -43,9 +34,6 @@ fn main() { let _str = "foo"; } loop { - - - let x = match y { Some(x) => x, None => break, @@ -68,9 +56,6 @@ fn main() { // #675, this used to have a wrong suggestion loop { - - - let (e, l) = match "".split_whitespace().next() { Some(word) => (word.is_empty(), word.len()), None => break @@ -81,26 +66,17 @@ fn main() { let mut iter = 1..20; while let Option::Some(x) = iter.next() { - - - println!("{}", x); } let mut iter = 1..20; while let Some(x) = iter.next() { - - - println!("{}", x); } let mut iter = 1..20; while let Some(_) = iter.next() {} - - - let mut iter = 1..20; while let None = iter.next() {} // this is fine (if nonsensical) @@ -140,9 +116,6 @@ fn main() { fn no_panic(slice: &[T]) { let mut iter = slice.iter(); loop { - - - let _ = match iter.next() { Some(ele) => ele, None => break diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index 319d099c41e..a942693b469 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -2,12 +2,12 @@ error: this loop could be written as a `while let` loop --> $DIR/while_loop.rs:9:5 | 9 | / loop { -10 | | -11 | | -12 | | -... | -17 | | } -18 | | } +10 | | if let Some(_x) = y { +11 | | let _v = 1; +12 | | } else { +13 | | break +14 | | } +15 | | } | |_____^ help: try `while let Some(_x) = y { .. }` | note: lint level defined here @@ -17,62 +17,58 @@ note: lint level defined here | ^^^^^^^^^^^^^^ error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:25:5 + --> $DIR/while_loop.rs:22:5 | -25 | / loop { -26 | | -27 | | -28 | | -... | -32 | | }; -33 | | } +22 | / loop { +23 | | match y { +24 | | Some(_x) => true, +25 | | None => break +26 | | }; +27 | | } | |_____^ help: try `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:34:5 + --> $DIR/while_loop.rs:28:5 | -34 | / loop { -35 | | -36 | | -37 | | +28 | / loop { +29 | | let x = match y { +30 | | Some(x) => x, +31 | | None => break ... | -43 | | let _str = "foo"; -44 | | } +34 | | let _str = "foo"; +35 | | } | |_____^ help: try `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:45:5 + --> $DIR/while_loop.rs:36:5 | -45 | / loop { -46 | | -47 | | -48 | | +36 | / loop { +37 | | let x = match y { +38 | | Some(x) => x, +39 | | None => break, ... | -54 | | { let _b = "foobar"; } -55 | | } +42 | | { let _b = "foobar"; } +43 | | } | |_____^ help: try `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:70:5 + --> $DIR/while_loop.rs:58:5 | -70 | / loop { -71 | | -72 | | -73 | | +58 | / loop { +59 | | let (e, l) = match "".split_whitespace().next() { +60 | | Some(word) => (word.is_empty(), word.len()), +61 | | None => break ... | -79 | | let _ = (e, l); -80 | | } +64 | | let _ = (e, l); +65 | | } | |_____^ help: try `while let Some(word) = "".split_whitespace().next() { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:83:5 + --> $DIR/while_loop.rs:68:5 | -83 | / while let Option::Some(x) = iter.next() { -84 | | -85 | | -86 | | -87 | | println!("{}", x); -88 | | } +68 | / while let Option::Some(x) = iter.next() { +69 | | println!("{}", x); +70 | | } | |_____^ help: try `for x in iter { .. }` | note: lint level defined here @@ -82,38 +78,35 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^ error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:91:5 + --> $DIR/while_loop.rs:73:5 | -91 | / while let Some(x) = iter.next() { -92 | | -93 | | -94 | | -95 | | println!("{}", x); -96 | | } +73 | / while let Some(x) = iter.next() { +74 | | println!("{}", x); +75 | | } | |_____^ help: try `for x in iter { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:99:5 + --> $DIR/while_loop.rs:78:5 | -99 | while let Some(_) = iter.next() {} +78 | while let Some(_) = iter.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `for _ in iter { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:142:5 + --> $DIR/while_loop.rs:118:5 | -142 | / loop { -143 | | -144 | | -145 | | -... | -150 | | loop {} -151 | | } +118 | / loop { +119 | | let _ = match iter.next() { +120 | | Some(ele) => ele, +121 | | None => break +122 | | }; +123 | | loop {} +124 | | } | |_____^ help: try `while let Some(ele) = iter.next() { .. }` error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body. - --> $DIR/while_loop.rs:150:9 + --> $DIR/while_loop.rs:123:9 | -150 | loop {} +123 | loop {} | ^^^^^^^ | note: lint level defined here From 6f3679b8e4b1e9ae34850e15d43a2b9846703e3a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 11 May 2017 16:16:19 +0100 Subject: [PATCH 55/55] clean tests/ui/zero_div_zero.rs Cleaning the empty lines for clarity. --- tests/ui/wrong_macro_span.rs_ | 3 --- tests/ui/zero_div_zero.rs | 4 ---- tests/ui/zero_div_zero.stderr | 40 +++++++++++++++++------------------ 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/tests/ui/wrong_macro_span.rs_ b/tests/ui/wrong_macro_span.rs_ index fcacb030b85..040615d067e 100644 --- a/tests/ui/wrong_macro_span.rs_ +++ b/tests/ui/wrong_macro_span.rs_ @@ -19,9 +19,6 @@ fn main() { let t = &thingy; match t.$idx { Foo::A(ref val) => { println!("42"); }, _ => {} } - - - }} } diff --git a/tests/ui/zero_div_zero.rs b/tests/ui/zero_div_zero.rs index 6f126337246..22253476c23 100644 --- a/tests/ui/zero_div_zero.rs +++ b/tests/ui/zero_div_zero.rs @@ -5,13 +5,9 @@ #[deny(zero_divided_by_zero)] fn main() { let nan = 0.0 / 0.0; - let f64_nan = 0.0 / 0.0f64; - let other_f64_nan = 0.0f64 / 0.0; - let one_more_f64_nan = 0.0f64/0.0f64; - let zero = 0.0; let other_zero = 0.0; let other_nan = zero / other_zero; // fine - this lint doesn't propegate constants. diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 6b34e2da13c..4853c2dc70c 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -20,49 +20,49 @@ note: lint level defined here = help: Consider using `std::f32::NAN` if you would like a constant representing NaN warning: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:9:19 + --> $DIR/zero_div_zero.rs:8:19 | -9 | let f64_nan = 0.0 / 0.0f64; +8 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = note: #[warn(eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:9:19 + --> $DIR/zero_div_zero.rs:8:19 | -9 | let f64_nan = 0.0 / 0.0f64; +8 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN warning: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:11:25 - | -11 | let other_f64_nan = 0.0f64 / 0.0; - | ^^^^^^^^^^^^ - | - = note: #[warn(eq_op)] on by default + --> $DIR/zero_div_zero.rs:9:25 + | +9 | let other_f64_nan = 0.0f64 / 0.0; + | ^^^^^^^^^^^^ + | + = note: #[warn(eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:11:25 - | -11 | let other_f64_nan = 0.0f64 / 0.0; - | ^^^^^^^^^^^^ - | - = help: Consider using `std::f64::NAN` if you would like a constant representing NaN + --> $DIR/zero_div_zero.rs:9:25 + | +9 | let other_f64_nan = 0.0f64 / 0.0; + | ^^^^^^^^^^^^ + | + = help: Consider using `std::f64::NAN` if you would like a constant representing NaN warning: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:13:28 + --> $DIR/zero_div_zero.rs:10:28 | -13 | let one_more_f64_nan = 0.0f64/0.0f64; +10 | let one_more_f64_nan = 0.0f64/0.0f64; | ^^^^^^^^^^^^^ | = note: #[warn(eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:13:28 + --> $DIR/zero_div_zero.rs:10:28 | -13 | let one_more_f64_nan = 0.0f64/0.0f64; +10 | let one_more_f64_nan = 0.0f64/0.0f64; | ^^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN