mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-26 22:50:56 +00:00
tests: revert some changs and add further rustfmt::skip attributes.
This commit is contained in:
parent
0a6e568f07
commit
f1d5194e3d
11 changed files with 61 additions and 60 deletions
|
@ -51,7 +51,8 @@ fn main() {
|
|||
false as bool;
|
||||
&1i32 as &i32;
|
||||
// Should not trigger
|
||||
let v = vec![1];
|
||||
#[rustfmt::skip]
|
||||
let v = vec!(1);
|
||||
&v as &[i32];
|
||||
1.0 as f64;
|
||||
1 as u64;
|
||||
|
|
|
@ -18,6 +18,7 @@ const ZERO: i64 = 0;
|
|||
clippy::double_parens
|
||||
)]
|
||||
#[warn(clippy::identity_op)]
|
||||
#[rustfmt::skip]
|
||||
fn main() {
|
||||
let x = 0;
|
||||
|
||||
|
@ -28,7 +29,7 @@ fn main() {
|
|||
1 + x;
|
||||
x - ZERO; //no error, as we skip lookups (for now)
|
||||
x | (0);
|
||||
(ZERO) | x; //no error, as we skip lookups (for now)
|
||||
((ZERO)) | x; //no error, as we skip lookups (for now)
|
||||
|
||||
x * 1;
|
||||
1 * x;
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:24:5
|
||||
--> $DIR/identity_op.rs:25:5
|
||||
|
|
||||
24 | x + 0;
|
||||
25 | x + 0;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::identity-op` implied by `-D warnings`
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:25:5
|
||||
--> $DIR/identity_op.rs:26:5
|
||||
|
|
||||
25 | x + (1 - 1);
|
||||
26 | x + (1 - 1);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:27:5
|
||||
--> $DIR/identity_op.rs:28:5
|
||||
|
|
||||
27 | 0 + x;
|
||||
28 | 0 + x;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:30:5
|
||||
--> $DIR/identity_op.rs:31:5
|
||||
|
|
||||
30 | x | (0);
|
||||
31 | x | (0);
|
||||
| ^^^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:33:5
|
||||
|
|
||||
33 | x * 1;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:34:5
|
||||
|
|
||||
34 | 1 * x;
|
||||
34 | x * 1;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:40:5
|
||||
--> $DIR/identity_op.rs:35:5
|
||||
|
|
||||
40 | -1 & x;
|
||||
35 | 1 * x;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:41:5
|
||||
|
|
||||
41 | -1 & x;
|
||||
| ^^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `u`
|
||||
--> $DIR/identity_op.rs:43:5
|
||||
--> $DIR/identity_op.rs:44:5
|
||||
|
|
||||
43 | u & 255;
|
||||
44 | u & 255;
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
|
|
@ -27,10 +27,11 @@ fn test_if_block() -> bool {
|
|||
}
|
||||
|
||||
#[allow(clippy::match_bool)]
|
||||
#[rustfmt::skip]
|
||||
fn test_match(x: bool) -> bool {
|
||||
match x {
|
||||
true => false,
|
||||
false => true,
|
||||
false => { true },
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +43,8 @@ fn test_loop() -> bool {
|
|||
}
|
||||
|
||||
fn test_closure() {
|
||||
let _ = || true;
|
||||
#[rustfmt::skip]
|
||||
let _ = || { true };
|
||||
let _ = || true;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,33 +19,33 @@ error: missing return statement
|
|||
| ^^^^^ help: add `return` as shown: `return false`
|
||||
|
||||
error: missing return statement
|
||||
--> $DIR/implicit_return.rs:32:17
|
||||
--> $DIR/implicit_return.rs:33:17
|
||||
|
|
||||
32 | true => false,
|
||||
33 | true => false,
|
||||
| ^^^^^ help: add `return` as shown: `return false`
|
||||
|
||||
error: missing return statement
|
||||
--> $DIR/implicit_return.rs:33:18
|
||||
--> $DIR/implicit_return.rs:34:20
|
||||
|
|
||||
33 | false => true,
|
||||
| ^^^^ help: add `return` as shown: `return true`
|
||||
34 | false => { true },
|
||||
| ^^^^ help: add `return` as shown: `return true`
|
||||
|
||||
error: missing return statement
|
||||
--> $DIR/implicit_return.rs:40:9
|
||||
--> $DIR/implicit_return.rs:41:9
|
||||
|
|
||||
40 | break true;
|
||||
41 | break true;
|
||||
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
|
||||
|
||||
error: missing return statement
|
||||
--> $DIR/implicit_return.rs:45:16
|
||||
--> $DIR/implicit_return.rs:47:18
|
||||
|
|
||||
45 | let _ = || true;
|
||||
| ^^^^ help: add `return` as shown: `return true`
|
||||
47 | let _ = || { true };
|
||||
| ^^^^ help: add `return` as shown: `return true`
|
||||
|
||||
error: missing return statement
|
||||
--> $DIR/implicit_return.rs:46:16
|
||||
--> $DIR/implicit_return.rs:48:16
|
||||
|
|
||||
46 | let _ = || true;
|
||||
48 | let _ = || true;
|
||||
| ^^^^ help: add `return` as shown: `return true`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
|
|
@ -37,7 +37,8 @@ fn main() {
|
|||
|
||||
let b = *(&a);
|
||||
|
||||
let b = *(&a);
|
||||
#[rustfmt::skip]
|
||||
let b = *((&a));
|
||||
|
||||
let b = *&&a;
|
||||
|
||||
|
|
|
@ -31,39 +31,39 @@ error: immediately dereferencing a reference
|
|||
| ^^^^^ help: try this: `a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/reference.rs:40:13
|
||||
--> $DIR/reference.rs:41:13
|
||||
|
|
||||
40 | let b = *(&a);
|
||||
| ^^^^^ help: try this: `a`
|
||||
41 | let b = *((&a));
|
||||
| ^^^^^^^ help: try this: `a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/reference.rs:42:13
|
||||
--> $DIR/reference.rs:43:13
|
||||
|
|
||||
42 | let b = *&&a;
|
||||
43 | let b = *&&a;
|
||||
| ^^^^ help: try this: `&a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/reference.rs:44:14
|
||||
--> $DIR/reference.rs:45:14
|
||||
|
|
||||
44 | let b = **&aref;
|
||||
45 | let b = **&aref;
|
||||
| ^^^^^^ help: try this: `aref`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/reference.rs:48:14
|
||||
--> $DIR/reference.rs:49:14
|
||||
|
|
||||
48 | let b = **&&a;
|
||||
49 | let b = **&&a;
|
||||
| ^^^^ help: try this: `&a`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/reference.rs:52:17
|
||||
--> $DIR/reference.rs:53:17
|
||||
|
|
||||
52 | let y = *&mut x;
|
||||
53 | let y = *&mut x;
|
||||
| ^^^^^^^ help: try this: `x`
|
||||
|
||||
error: immediately dereferencing a reference
|
||||
--> $DIR/reference.rs:59:18
|
||||
--> $DIR/reference.rs:60:18
|
||||
|
|
||||
59 | let y = **&mut &mut x;
|
||||
60 | let y = **&mut &mut x;
|
||||
| ^^^^^^^^^^^^ help: try this: `&mut x`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
|
||||
#[allow(dead_code)]
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
#[rustfmt::skip]
|
||||
#[cfg_attr(feature = "cargo-clippy",
|
||||
allow(dead_code))]
|
||||
#[allow(unused_imports)]
|
||||
#[allow(unused_extern_crates)]
|
||||
#[macro_use]
|
||||
|
|
|
@ -12,11 +12,5 @@ error: useless lint attribute
|
|||
13 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
|
||||
|
||||
error: useless lint attribute
|
||||
--> $DIR/useless_attribute.rs:14:1
|
||||
|
|
||||
14 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ fn main() {
|
|||
|
||||
on_slice(&vec![1, 2]);
|
||||
on_slice(&[1, 2]);
|
||||
|
||||
on_slice(&vec![1, 2]);
|
||||
#[rustfmt::skip]
|
||||
on_slice(&vec!(1, 2));
|
||||
on_slice(&[1, 2]);
|
||||
|
||||
on_slice(&vec![1; 2]);
|
||||
|
|
|
@ -21,7 +21,7 @@ error: useless use of `vec!`
|
|||
error: useless use of `vec!`
|
||||
--> $DIR/vec.rs:39:14
|
||||
|
|
||||
39 | on_slice(&vec![1, 2]);
|
||||
39 | on_slice(&vec!(1, 2));
|
||||
| ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]`
|
||||
|
||||
error: useless use of `vec!`
|
||||
|
|
Loading…
Reference in a new issue