Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Oct 26, 2019
1 parent e402ddd commit 4a52dd6
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/ui/assign_ops2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a += 1 + a;
| ^^^^^^^^^^
|
help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with
|
LL | a += 1;
Expand All @@ -33,6 +34,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a -= a - 1;
| ^^^^^^^^^^
|
help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with
|
LL | a -= 1;
Expand All @@ -47,6 +49,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a *= a * 99;
| ^^^^^^^^^^^
|
help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with
|
LL | a *= 99;
Expand All @@ -61,6 +64,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a *= 42 * a;
| ^^^^^^^^^^^
|
help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with
|
LL | a *= 42;
Expand All @@ -75,6 +79,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a /= a / 2;
| ^^^^^^^^^^
|
help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with
|
LL | a /= 2;
Expand All @@ -89,6 +94,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a %= a % 5;
| ^^^^^^^^^^
|
help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with
|
LL | a %= 5;
Expand All @@ -103,6 +109,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a &= a & 1;
| ^^^^^^^^^^
|
help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with
|
LL | a &= 1;
Expand All @@ -117,6 +124,7 @@ error: variable appears on both sides of an assignment operation
|
LL | a *= a * a;
| ^^^^^^^^^^
|
help: Did you mean a = a * a or a = a * a * a? Consider replacing it with
|
LL | a *= a;
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/booleans.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ error: this boolean expression can be simplified
|
LL | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL | let _ = a == b && c == 5;
Expand All @@ -84,6 +85,7 @@ error: this boolean expression can be simplified
|
LL | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL | let _ = a == b && c == 5;
Expand Down Expand Up @@ -120,6 +122,7 @@ error: this boolean expression can be simplified
|
LL | let _ = a != b || !(a != b || c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try
|
LL | let _ = c != d || a != b;
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/collapsible_if.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ LL | | println!("Hello world!");
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
Expand All @@ -41,6 +42,7 @@ LL | | println!("Hello world!");
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
Expand All @@ -57,6 +59,7 @@ LL | | println!("Hello world!");
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
Expand All @@ -73,6 +76,7 @@ LL | | println!("Hello world!");
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | if x == "hello" && x == "world" && y == "world" && y == "hello" {
Expand All @@ -89,6 +93,7 @@ LL | | println!("world!")
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | if 42 == 1337 && 'a' != 'A' {
Expand All @@ -106,6 +111,7 @@ LL | | println!("world!")
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if y == "world" {
Expand All @@ -123,6 +129,7 @@ LL | | println!("world!")
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if let Some(42) = Some(42) {
Expand All @@ -142,6 +149,7 @@ LL | | }
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if y == "world" {
Expand All @@ -164,6 +172,7 @@ LL | | }
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if let Some(42) = Some(42) {
Expand All @@ -186,6 +195,7 @@ LL | | }
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if let Some(42) = Some(42) {
Expand All @@ -208,6 +218,7 @@ LL | | }
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if x == "hello" {
Expand All @@ -230,6 +241,7 @@ LL | | }
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | } else if let Some(42) = Some(42) {
Expand All @@ -249,6 +261,7 @@ LL | | println!("Hello world!");
LL | | }
LL | | }
| |_____^
|
help: try
|
LL | if x == "hello" && y == "world" { // Collapsible
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/dbg_macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ error: `dbg!` macro is intended as a debugging tool
|
LL | if dbg!(n <= 1) {
| ^^^^^^^^^^^^
|
help: ensure to avoid having uses of it in version control
|
LL | if n <= 1 {
Expand All @@ -25,6 +26,7 @@ error: `dbg!` macro is intended as a debugging tool
|
LL | dbg!(1)
| ^^^^^^^
|
help: ensure to avoid having uses of it in version control
|
LL | 1
Expand All @@ -35,6 +37,7 @@ error: `dbg!` macro is intended as a debugging tool
|
LL | dbg!(n * factorial(n - 1))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: ensure to avoid having uses of it in version control
|
LL | n * factorial(n - 1)
Expand All @@ -45,6 +48,7 @@ error: `dbg!` macro is intended as a debugging tool
|
LL | dbg!(42);
| ^^^^^^^^
|
help: ensure to avoid having uses of it in version control
|
LL | 42;
Expand All @@ -55,6 +59,7 @@ error: `dbg!` macro is intended as a debugging tool
|
LL | dbg!(dbg!(dbg!(42)));
| ^^^^^^^^^^^^^^^^^^^^
|
help: ensure to avoid having uses of it in version control
|
LL | dbg!(dbg!(42));
Expand All @@ -65,6 +70,7 @@ error: `dbg!` macro is intended as a debugging tool
|
LL | foo(3) + dbg!(factorial(4));
| ^^^^^^^^^^^^^^^^^^
|
help: ensure to avoid having uses of it in version control
|
LL | foo(3) + factorial(4);
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/for_kv_map.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ error: you seem to want to iterate on a map's values
|
LL | for (_, v) in &*m {
| ^^^
|
help: use the corresponding method
|
LL | for v in (*m).values() {
Expand All @@ -25,6 +26,7 @@ error: you seem to want to iterate on a map's values
|
LL | for (_, v) in &mut m {
| ^^^^^^
|
help: use the corresponding method
|
LL | for v in m.values_mut() {
Expand All @@ -35,6 +37,7 @@ error: you seem to want to iterate on a map's values
|
LL | for (_, v) in &mut *m {
| ^^^^^^^
|
help: use the corresponding method
|
LL | for v in (*m).values_mut() {
Expand All @@ -45,6 +48,7 @@ error: you seem to want to iterate on a map's keys
|
LL | for (k, _value) in rm {
| ^^
|
help: use the corresponding method
|
LL | for k in rm.keys() {
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/for_loop_fixable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ error: this range is empty so this for loop will never run
|
LL | for i in 10..=0 {
| ^^^^^^
|
help: consider using the following if you are attempting to iterate over this range in reverse
|
LL | for i in (0..=10).rev() {
Expand All @@ -25,6 +26,7 @@ error: this range is empty so this for loop will never run
|
LL | for i in MAX_LEN..0 {
| ^^^^^^^^^^
|
help: consider using the following if you are attempting to iterate over this range in reverse
|
LL | for i in (0..MAX_LEN).rev() {
Expand All @@ -35,6 +37,7 @@ error: this range is empty so this for loop will never run
|
LL | for i in 10..5 + 4 {
| ^^^^^^^^^
|
help: consider using the following if you are attempting to iterate over this range in reverse
|
LL | for i in (5 + 4..10).rev() {
Expand All @@ -45,6 +48,7 @@ error: this range is empty so this for loop will never run
|
LL | for i in (5 + 2)..(3 - 1) {
| ^^^^^^^^^^^^^^^^
|
help: consider using the following if you are attempting to iterate over this range in reverse
|
LL | for i in ((3 - 1)..(5 + 2)).rev() {
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/implicit_hasher.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ error: impl for `HashMap` should be generalized over different hashers
|
LL | impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) {
| ^^^^^^^^^^^^^
|
help: consider adding a type parameter
|
LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for (HashMap<K, V, S>,) {
Expand All @@ -33,6 +34,7 @@ error: impl for `HashMap` should be generalized over different hashers
|
LL | impl Foo<i16> for HashMap<String, String> {
| ^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider adding a type parameter
|
LL | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashMap<String, String, S> {
Expand All @@ -47,6 +49,7 @@ error: impl for `HashSet` should be generalized over different hashers
|
LL | impl<T: Hash + Eq> Foo<i8> for HashSet<T> {
| ^^^^^^^^^^
|
help: consider adding a type parameter
|
LL | impl<T: Hash + Eq, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashSet<T, S> {
Expand All @@ -61,6 +64,7 @@ error: impl for `HashSet` should be generalized over different hashers
|
LL | impl Foo<i16> for HashSet<String> {
| ^^^^^^^^^^^^^^^
|
help: consider adding a type parameter
|
LL | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashSet<String, S> {
Expand All @@ -75,6 +79,7 @@ error: parameter of type `HashMap` should be generalized over different hashers
|
LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
| ^^^^^^^^^^^^^^^^^
|
help: consider adding a type parameter
|
LL | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {}
Expand All @@ -85,6 +90,7 @@ error: parameter of type `HashSet` should be generalized over different hashers
|
LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
| ^^^^^^^^^^^^
|
help: consider adding a type parameter
|
LL | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {}
Expand All @@ -98,6 +104,7 @@ LL | impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
...
LL | gen!(impl);
| ----------- in this macro invocation
|
help: consider adding a type parameter
|
LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<u8> for HashMap<K, V, S> {
Expand All @@ -115,6 +122,7 @@ LL | pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>)
...
LL | gen!(fn bar);
| ------------- in this macro invocation
|
help: consider adding a type parameter
|
LL | pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {}
Expand All @@ -128,6 +136,7 @@ LL | pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>)
...
LL | gen!(fn bar);
| ------------- in this macro invocation
|
help: consider adding a type parameter
|
LL | pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {}
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/large_enum_variant.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ error: large size difference between variants
|
LL | ContainingLargeEnum(LargeEnum),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider boxing the large fields to reduce the total size of the enum
|
LL | ContainingLargeEnum(Box<LargeEnum>),
Expand Down Expand Up @@ -61,6 +62,7 @@ error: large size difference between variants
|
LL | StructLikeLarge2 { x: [i32; 8000] },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider boxing the large fields to reduce the total size of the enum
|
LL | StructLikeLarge2 { x: Box<[i32; 8000]> },
Expand Down
1 change: 1 addition & 0 deletions tests/ui/let_return.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LL | let x = 5;
| ---------- unnecessary let binding
LL | x
| ^
|
help: return the expression directly
|
LL |
Expand Down
Loading

0 comments on commit 4a52dd6

Please sign in to comment.