diff --git a/clippy_lints/src/methods/obfuscated_if_else.rs b/clippy_lints/src/methods/obfuscated_if_else.rs index 4d7427b26621..5480e54f333f 100644 --- a/clippy_lints/src/methods/obfuscated_if_else.rs +++ b/clippy_lints/src/methods/obfuscated_if_else.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use super::OBFUSCATED_IF_ELSE; use clippy_utils::{diagnostics::span_lint_and_sugg, source::snippet_with_applicability}; diff --git a/tests/ui-cargo/cargo_common_metadata/fail/Cargo.stderr b/tests/ui-cargo/cargo_common_metadata/fail/Cargo.stderr new file mode 100644 index 000000000000..8302e04536b0 --- /dev/null +++ b/tests/ui-cargo/cargo_common_metadata/fail/Cargo.stderr @@ -0,0 +1,20 @@ +warning: package `cargo_common_metadata_fail` is missing `package.description` metadata + | +note: the lint level is defined here + --> src/main.rs:2:9 + | +2 | #![warn(clippy::cargo_common_metadata)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: package `cargo_common_metadata_fail` is missing `either package.license or package.license_file` metadata + +warning: package `cargo_common_metadata_fail` is missing `package.repository` metadata + +warning: package `cargo_common_metadata_fail` is missing `package.readme` metadata + +warning: package `cargo_common_metadata_fail` is missing `package.keywords` metadata + +warning: package `cargo_common_metadata_fail` is missing `package.categories` metadata + +warning: `cargo_common_metadata_fail` (bin "cargo_common_metadata_fail") generated 6 warnings + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_common_metadata/fail/src/main.rs b/tests/ui-cargo/cargo_common_metadata/fail/src/main.rs index 27841e18aa9e..1a69bb24101e 100644 --- a/tests/ui-cargo/cargo_common_metadata/fail/src/main.rs +++ b/tests/ui-cargo/cargo_common_metadata/fail/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=cargo_common_metadata +//@compile-flags: --crate-name=cargo_common_metadata #![warn(clippy::cargo_common_metadata)] fn main() {} diff --git a/tests/ui-cargo/cargo_common_metadata/fail/src/main.stderr b/tests/ui-cargo/cargo_common_metadata/fail/src/main.stderr deleted file mode 100644 index 86953142befa..000000000000 --- a/tests/ui-cargo/cargo_common_metadata/fail/src/main.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: package `cargo_common_metadata_fail` is missing `package.description` metadata - | - = note: `-D clippy::cargo-common-metadata` implied by `-D warnings` - -error: package `cargo_common_metadata_fail` is missing `either package.license or package.license_file` metadata - -error: package `cargo_common_metadata_fail` is missing `package.repository` metadata - -error: package `cargo_common_metadata_fail` is missing `package.readme` metadata - -error: package `cargo_common_metadata_fail` is missing `package.keywords` metadata - -error: package `cargo_common_metadata_fail` is missing `package.categories` metadata - -error: aborting due to 6 previous errors - diff --git a/tests/ui-cargo/cargo_common_metadata/fail_publish/Cargo.stderr b/tests/ui-cargo/cargo_common_metadata/fail_publish/Cargo.stderr new file mode 100644 index 000000000000..4d9ddbd62994 --- /dev/null +++ b/tests/ui-cargo/cargo_common_metadata/fail_publish/Cargo.stderr @@ -0,0 +1,20 @@ +warning: package `cargo_common_metadata_fail_publish` is missing `package.description` metadata + | +note: the lint level is defined here + --> src/main.rs:2:9 + | +2 | #![warn(clippy::cargo_common_metadata)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: package `cargo_common_metadata_fail_publish` is missing `either package.license or package.license_file` metadata + +warning: package `cargo_common_metadata_fail_publish` is missing `package.repository` metadata + +warning: package `cargo_common_metadata_fail_publish` is missing `package.readme` metadata + +warning: package `cargo_common_metadata_fail_publish` is missing `package.keywords` metadata + +warning: package `cargo_common_metadata_fail_publish` is missing `package.categories` metadata + +warning: `cargo_common_metadata_fail_publish` (bin "cargo_common_metadata_fail_publish") generated 6 warnings + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.rs b/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.rs index 27841e18aa9e..1a69bb24101e 100644 --- a/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.rs +++ b/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=cargo_common_metadata +//@compile-flags: --crate-name=cargo_common_metadata #![warn(clippy::cargo_common_metadata)] fn main() {} diff --git a/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.stderr b/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.stderr deleted file mode 100644 index ac1b5e8e9034..000000000000 --- a/tests/ui-cargo/cargo_common_metadata/fail_publish/src/main.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: package `cargo_common_metadata_fail_publish` is missing `package.description` metadata - | - = note: `-D clippy::cargo-common-metadata` implied by `-D warnings` - -error: package `cargo_common_metadata_fail_publish` is missing `either package.license or package.license_file` metadata - -error: package `cargo_common_metadata_fail_publish` is missing `package.repository` metadata - -error: package `cargo_common_metadata_fail_publish` is missing `package.readme` metadata - -error: package `cargo_common_metadata_fail_publish` is missing `package.keywords` metadata - -error: package `cargo_common_metadata_fail_publish` is missing `package.categories` metadata - -error: aborting due to 6 previous errors - diff --git a/tests/ui-cargo/cargo_common_metadata/fail_publish_true/Cargo.stderr b/tests/ui-cargo/cargo_common_metadata/fail_publish_true/Cargo.stderr new file mode 100644 index 000000000000..076f4c30abfd --- /dev/null +++ b/tests/ui-cargo/cargo_common_metadata/fail_publish_true/Cargo.stderr @@ -0,0 +1,20 @@ +warning: package `cargo_common_metadata_fail_publish_true` is missing `package.description` metadata + | +note: the lint level is defined here + --> src/main.rs:2:9 + | +2 | #![warn(clippy::cargo_common_metadata)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: package `cargo_common_metadata_fail_publish_true` is missing `either package.license or package.license_file` metadata + +warning: package `cargo_common_metadata_fail_publish_true` is missing `package.repository` metadata + +warning: package `cargo_common_metadata_fail_publish_true` is missing `package.readme` metadata + +warning: package `cargo_common_metadata_fail_publish_true` is missing `package.keywords` metadata + +warning: package `cargo_common_metadata_fail_publish_true` is missing `package.categories` metadata + +warning: `cargo_common_metadata_fail_publish_true` (bin "cargo_common_metadata_fail_publish_true") generated 6 warnings + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.rs b/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.rs index 27841e18aa9e..1a69bb24101e 100644 --- a/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.rs +++ b/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=cargo_common_metadata +//@compile-flags: --crate-name=cargo_common_metadata #![warn(clippy::cargo_common_metadata)] fn main() {} diff --git a/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.stderr b/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.stderr deleted file mode 100644 index be32c0dc418f..000000000000 --- a/tests/ui-cargo/cargo_common_metadata/fail_publish_true/src/main.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: package `cargo_common_metadata_fail_publish_true` is missing `package.description` metadata - | - = note: `-D clippy::cargo-common-metadata` implied by `-D warnings` - -error: package `cargo_common_metadata_fail_publish_true` is missing `either package.license or package.license_file` metadata - -error: package `cargo_common_metadata_fail_publish_true` is missing `package.repository` metadata - -error: package `cargo_common_metadata_fail_publish_true` is missing `package.readme` metadata - -error: package `cargo_common_metadata_fail_publish_true` is missing `package.keywords` metadata - -error: package `cargo_common_metadata_fail_publish_true` is missing `package.categories` metadata - -error: aborting due to 6 previous errors - diff --git a/tests/ui-cargo/cargo_common_metadata/pass/Cargo.stderr b/tests/ui-cargo/cargo_common_metadata/pass/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_common_metadata/pass/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_common_metadata/pass/src/main.rs b/tests/ui-cargo/cargo_common_metadata/pass/src/main.rs index 27841e18aa9e..1a69bb24101e 100644 --- a/tests/ui-cargo/cargo_common_metadata/pass/src/main.rs +++ b/tests/ui-cargo/cargo_common_metadata/pass/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=cargo_common_metadata +//@compile-flags: --crate-name=cargo_common_metadata #![warn(clippy::cargo_common_metadata)] fn main() {} diff --git a/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/Cargo.stderr b/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/src/main.rs b/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/src/main.rs index 27841e18aa9e..1a69bb24101e 100644 --- a/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/src/main.rs +++ b/tests/ui-cargo/cargo_common_metadata/pass_publish_empty/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=cargo_common_metadata +//@compile-flags: --crate-name=cargo_common_metadata #![warn(clippy::cargo_common_metadata)] fn main() {} diff --git a/tests/ui-cargo/cargo_common_metadata/pass_publish_false/Cargo.stderr b/tests/ui-cargo/cargo_common_metadata/pass_publish_false/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_common_metadata/pass_publish_false/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_common_metadata/pass_publish_false/src/main.rs b/tests/ui-cargo/cargo_common_metadata/pass_publish_false/src/main.rs index 27841e18aa9e..1a69bb24101e 100644 --- a/tests/ui-cargo/cargo_common_metadata/pass_publish_false/src/main.rs +++ b/tests/ui-cargo/cargo_common_metadata/pass_publish_false/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=cargo_common_metadata +//@compile-flags: --crate-name=cargo_common_metadata #![warn(clippy::cargo_common_metadata)] fn main() {} diff --git a/tests/ui-cargo/cargo_rust_version/fail_both_diff/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/fail_both_diff/Cargo.stderr new file mode 100644 index 000000000000..04aea70d1a72 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/fail_both_diff/Cargo.stderr @@ -0,0 +1,22 @@ +warning: the MSRV in `clippy.toml` and `Cargo.toml` differ; using `1.59.0` from `clippy.toml` + +error: unnecessary structure name repetition + --> src/main.rs:6:21 + | +6 | pub fn bar() -> Foo { + | ^^^ help: use the applicable keyword: `Self` + | +note: the lint level is defined here + --> src/main.rs:1:9 + | +1 | #![deny(clippy::use_self)] + | ^^^^^^^^^^^^^^^^ + +error: unnecessary structure name repetition + --> src/main.rs:7:9 + | +7 | Foo + | ^^^ help: use the applicable keyword: `Self` + +warning: `fail-both-diff` (bin "fail-both-diff") generated 1 warning +error: could not compile `fail-both-diff` due to 2 previous errors; 1 warning emitted diff --git a/tests/ui-cargo/cargo_rust_version/fail_both_diff/src/main.stderr b/tests/ui-cargo/cargo_rust_version/fail_both_diff/src/main.stderr deleted file mode 100644 index 163f8bb35e79..000000000000 --- a/tests/ui-cargo/cargo_rust_version/fail_both_diff/src/main.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: the MSRV in `clippy.toml` and `Cargo.toml` differ; using `1.59.0` from `clippy.toml` - -error: unnecessary structure name repetition - --> $DIR/main.rs:6:21 - | -LL | pub fn bar() -> Foo { - | ^^^ help: use the applicable keyword: `Self` - | -note: the lint level is defined here - --> $DIR/main.rs:1:9 - | -LL | #![deny(clippy::use_self)] - | ^^^^^^^^^^^^^^^^ - -error: unnecessary structure name repetition - --> $DIR/main.rs:7:9 - | -LL | Foo - | ^^^ help: use the applicable keyword: `Self` - -error: aborting due to 2 previous errors; 1 warning emitted - diff --git a/tests/ui-cargo/cargo_rust_version/fail_both_same/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/fail_both_same/Cargo.stderr new file mode 100644 index 000000000000..3f52202bd867 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/fail_both_same/Cargo.stderr @@ -0,0 +1,19 @@ +error: unnecessary structure name repetition + --> src/main.rs:6:21 + | +6 | pub fn bar() -> Foo { + | ^^^ help: use the applicable keyword: `Self` + | +note: the lint level is defined here + --> src/main.rs:1:9 + | +1 | #![deny(clippy::use_self)] + | ^^^^^^^^^^^^^^^^ + +error: unnecessary structure name repetition + --> src/main.rs:7:9 + | +7 | Foo + | ^^^ help: use the applicable keyword: `Self` + +error: could not compile `fail-both-same` due to 2 previous errors diff --git a/tests/ui-cargo/cargo_rust_version/fail_both_same/src/main.stderr b/tests/ui-cargo/cargo_rust_version/fail_both_same/src/main.stderr deleted file mode 100644 index 259d39b12526..000000000000 --- a/tests/ui-cargo/cargo_rust_version/fail_both_same/src/main.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: unnecessary structure name repetition - --> $DIR/main.rs:6:21 - | -LL | pub fn bar() -> Foo { - | ^^^ help: use the applicable keyword: `Self` - | -note: the lint level is defined here - --> $DIR/main.rs:1:9 - | -LL | #![deny(clippy::use_self)] - | ^^^^^^^^^^^^^^^^ - -error: unnecessary structure name repetition - --> $DIR/main.rs:7:9 - | -LL | Foo - | ^^^ help: use the applicable keyword: `Self` - -error: aborting due to 2 previous errors - diff --git a/tests/ui-cargo/cargo_rust_version/fail_cargo/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/fail_cargo/Cargo.stderr new file mode 100644 index 000000000000..e4feed81cd6e --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/fail_cargo/Cargo.stderr @@ -0,0 +1,19 @@ +error: unnecessary structure name repetition + --> src/main.rs:6:21 + | +6 | pub fn bar() -> Foo { + | ^^^ help: use the applicable keyword: `Self` + | +note: the lint level is defined here + --> src/main.rs:1:9 + | +1 | #![deny(clippy::use_self)] + | ^^^^^^^^^^^^^^^^ + +error: unnecessary structure name repetition + --> src/main.rs:7:9 + | +7 | Foo + | ^^^ help: use the applicable keyword: `Self` + +error: could not compile `fail-cargo` due to 2 previous errors diff --git a/tests/ui-cargo/cargo_rust_version/fail_cargo/src/main.stderr b/tests/ui-cargo/cargo_rust_version/fail_cargo/src/main.stderr deleted file mode 100644 index 259d39b12526..000000000000 --- a/tests/ui-cargo/cargo_rust_version/fail_cargo/src/main.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: unnecessary structure name repetition - --> $DIR/main.rs:6:21 - | -LL | pub fn bar() -> Foo { - | ^^^ help: use the applicable keyword: `Self` - | -note: the lint level is defined here - --> $DIR/main.rs:1:9 - | -LL | #![deny(clippy::use_self)] - | ^^^^^^^^^^^^^^^^ - -error: unnecessary structure name repetition - --> $DIR/main.rs:7:9 - | -LL | Foo - | ^^^ help: use the applicable keyword: `Self` - -error: aborting due to 2 previous errors - diff --git a/tests/ui-cargo/cargo_rust_version/fail_clippy/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/fail_clippy/Cargo.stderr new file mode 100644 index 000000000000..f6e6fe210e21 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/fail_clippy/Cargo.stderr @@ -0,0 +1,19 @@ +error: unnecessary structure name repetition + --> src/main.rs:6:21 + | +6 | pub fn bar() -> Foo { + | ^^^ help: use the applicable keyword: `Self` + | +note: the lint level is defined here + --> src/main.rs:1:9 + | +1 | #![deny(clippy::use_self)] + | ^^^^^^^^^^^^^^^^ + +error: unnecessary structure name repetition + --> src/main.rs:7:9 + | +7 | Foo + | ^^^ help: use the applicable keyword: `Self` + +error: could not compile `fail-clippy` due to 2 previous errors diff --git a/tests/ui-cargo/cargo_rust_version/fail_clippy/src/main.stderr b/tests/ui-cargo/cargo_rust_version/fail_file_attr/Cargo.stderr similarity index 58% rename from tests/ui-cargo/cargo_rust_version/fail_clippy/src/main.stderr rename to tests/ui-cargo/cargo_rust_version/fail_file_attr/Cargo.stderr index 259d39b12526..525ca10c040a 100644 --- a/tests/ui-cargo/cargo_rust_version/fail_clippy/src/main.stderr +++ b/tests/ui-cargo/cargo_rust_version/fail_file_attr/Cargo.stderr @@ -1,20 +1,19 @@ error: unnecessary structure name repetition - --> $DIR/main.rs:6:21 + --> src/main.rs:11:21 | -LL | pub fn bar() -> Foo { +11 | pub fn bar() -> Foo { | ^^^ help: use the applicable keyword: `Self` | note: the lint level is defined here - --> $DIR/main.rs:1:9 + --> src/main.rs:6:9 | -LL | #![deny(clippy::use_self)] +6 | #![deny(clippy::use_self)] | ^^^^^^^^^^^^^^^^ error: unnecessary structure name repetition - --> $DIR/main.rs:7:9 + --> src/main.rs:12:9 | -LL | Foo +12 | Foo | ^^^ help: use the applicable keyword: `Self` -error: aborting due to 2 previous errors - +error: could not compile `fail-file-attr` due to 2 previous errors diff --git a/tests/ui-cargo/cargo_rust_version/fail_file_attr/src/main.stderr b/tests/ui-cargo/cargo_rust_version/fail_file_attr/src/main.stderr deleted file mode 100644 index 97e6c3d5a559..000000000000 --- a/tests/ui-cargo/cargo_rust_version/fail_file_attr/src/main.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: unnecessary structure name repetition - --> $DIR/main.rs:11:21 - | -LL | pub fn bar() -> Foo { - | ^^^ help: use the applicable keyword: `Self` - | -note: the lint level is defined here - --> $DIR/main.rs:6:9 - | -LL | #![deny(clippy::use_self)] - | ^^^^^^^^^^^^^^^^ - -error: unnecessary structure name repetition - --> $DIR/main.rs:12:9 - | -LL | Foo - | ^^^ help: use the applicable keyword: `Self` - -error: aborting due to 2 previous errors - diff --git a/tests/ui-cargo/cargo_rust_version/pass_both_same/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/pass_both_same/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/pass_both_same/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_rust_version/pass_cargo/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/pass_cargo/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/pass_cargo/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_rust_version/pass_clippy/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/pass_clippy/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/pass_clippy/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_rust_version/pass_file_attr/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/pass_file_attr/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/pass_file_attr/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_rust_version/warn_both_diff/Cargo.stderr b/tests/ui-cargo/cargo_rust_version/warn_both_diff/Cargo.stderr new file mode 100644 index 000000000000..14f354bb9261 --- /dev/null +++ b/tests/ui-cargo/cargo_rust_version/warn_both_diff/Cargo.stderr @@ -0,0 +1,4 @@ +warning: the MSRV in `clippy.toml` and `Cargo.toml` differ; using `1.13.0` from `clippy.toml` + +warning: `warn-both-diff` (bin "warn-both-diff") generated 1 warning + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/cargo_rust_version/warn_both_diff/src/main.stderr b/tests/ui-cargo/cargo_rust_version/warn_both_diff/src/main.stderr deleted file mode 100644 index eeae5b7b275e..000000000000 --- a/tests/ui-cargo/cargo_rust_version/warn_both_diff/src/main.stderr +++ /dev/null @@ -1,4 +0,0 @@ -warning: the MSRV in `clippy.toml` and `Cargo.toml` differ; using `1.13.0` from `clippy.toml` - -warning: 1 warning emitted - diff --git a/tests/ui-cargo/duplicate_mod/fail/Cargo.stderr b/tests/ui-cargo/duplicate_mod/fail/Cargo.stderr new file mode 100644 index 000000000000..7682e3071659 --- /dev/null +++ b/tests/ui-cargo/duplicate_mod/fail/Cargo.stderr @@ -0,0 +1,53 @@ +warning: file is loaded as a module multiple times: `src/b.rs` + --> src/main.rs:5:1 + | +5 | mod b; + | ^^^^^^ first loaded here +6 | / #[path = "b.rs"] +7 | | mod b2; + | |_______^ loaded again here + | + = help: replace all but one `mod` item with `use` items + = note: `#[warn(clippy::duplicate_mod)]` on by default + +warning: file is loaded as a module multiple times: `src/c.rs` + --> src/main.rs:9:1 + | +9 | mod c; + | ^^^^^^ first loaded here +10 | / #[path = "c.rs"] +11 | | mod c2; + | |_______^ loaded again here +12 | / #[path = "c.rs"] +13 | | mod c3; + | |_______^ loaded again here + | + = help: replace all but one `mod` item with `use` items + +warning: file is loaded as a module multiple times: `src/d.rs` + --> src/main.rs:18:1 + | +18 | mod d; + | ^^^^^^ first loaded here +19 | / #[path = "d.rs"] +20 | | mod d2; + | |_______^ loaded again here + | + = help: replace all but one `mod` item with `use` items + +warning: file is loaded as a module multiple times: `src/from_other_module.rs` + --> src/main.rs:15:1 + | +15 | mod from_other_module; + | ^^^^^^^^^^^^^^^^^^^^^^ first loaded here + | + ::: src/other_module/mod.rs:1:1 + | +1 | / #[path = "../from_other_module.rs"] +2 | | mod m; + | |______^ loaded again here + | + = help: replace all but one `mod` item with `use` items + +warning: `duplicate_mod` (bin "duplicate_mod") generated 4 warnings + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/duplicate_mod/fail/src/main.stderr b/tests/ui-cargo/duplicate_mod/fail/src/main.stderr deleted file mode 100644 index 3b80d89a6865..000000000000 --- a/tests/ui-cargo/duplicate_mod/fail/src/main.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error: file is loaded as a module multiple times: `$DIR/b.rs` - --> $DIR/main.rs:5:1 - | -LL | mod b; - | ^^^^^^ first loaded here -LL | / #[path = "b.rs"] -LL | | mod b2; - | |_______^ loaded again here - | - = help: replace all but one `mod` item with `use` items - = note: `-D clippy::duplicate-mod` implied by `-D warnings` - -error: file is loaded as a module multiple times: `$DIR/c.rs` - --> $DIR/main.rs:9:1 - | -LL | mod c; - | ^^^^^^ first loaded here -LL | / #[path = "c.rs"] -LL | | mod c2; - | |_______^ loaded again here -LL | / #[path = "c.rs"] -LL | | mod c3; - | |_______^ loaded again here - | - = help: replace all but one `mod` item with `use` items - -error: file is loaded as a module multiple times: `$DIR/d.rs` - --> $DIR/main.rs:18:1 - | -LL | mod d; - | ^^^^^^ first loaded here -LL | / #[path = "d.rs"] -LL | | mod d2; - | |_______^ loaded again here - | - = help: replace all but one `mod` item with `use` items - -error: file is loaded as a module multiple times: `$DIR/from_other_module.rs` - --> $DIR/main.rs:15:1 - | -LL | mod from_other_module; - | ^^^^^^^^^^^^^^^^^^^^^^ first loaded here - | - ::: $DIR/other_module/mod.rs:1:1 - | -LL | / #[path = "../from_other_module.rs"] -LL | | mod m; - | |______^ loaded again here - | - = help: replace all but one `mod` item with `use` items - -error: aborting due to 4 previous errors - diff --git a/tests/ui-cargo/feature_name/fail/Cargo.stderr b/tests/ui-cargo/feature_name/fail/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/feature_name/fail/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/feature_name/fail/src/main.rs b/tests/ui-cargo/feature_name/fail/src/main.rs index 64f01a98c90e..4dd9582aff89 100644 --- a/tests/ui-cargo/feature_name/fail/src/main.rs +++ b/tests/ui-cargo/feature_name/fail/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=feature_name +//@compile-flags: --crate-name=feature_name #![warn(clippy::redundant_feature_names)] #![warn(clippy::negative_feature_names)] diff --git a/tests/ui-cargo/feature_name/fail/src/main.stderr b/tests/ui-cargo/feature_name/fail/src/main.stderr deleted file mode 100644 index c6a11fa93eb5..000000000000 --- a/tests/ui-cargo/feature_name/fail/src/main.stderr +++ /dev/null @@ -1,44 +0,0 @@ -error: the "no-" prefix in the feature name "no-qaq" is negative - | - = help: consider renaming the feature to "qaq", but make sure the feature adds functionality - = note: `-D clippy::negative-feature-names` implied by `-D warnings` - -error: the "no_" prefix in the feature name "no_qaq" is negative - | - = help: consider renaming the feature to "qaq", but make sure the feature adds functionality - -error: the "not-" prefix in the feature name "not-orz" is negative - | - = help: consider renaming the feature to "orz", but make sure the feature adds functionality - -error: the "not_" prefix in the feature name "not_orz" is negative - | - = help: consider renaming the feature to "orz", but make sure the feature adds functionality - -error: the "-support" suffix in the feature name "qvq-support" is redundant - | - = help: consider renaming the feature to "qvq" - = note: `-D clippy::redundant-feature-names` implied by `-D warnings` - -error: the "_support" suffix in the feature name "qvq_support" is redundant - | - = help: consider renaming the feature to "qvq" - -error: the "use-" prefix in the feature name "use-qwq" is redundant - | - = help: consider renaming the feature to "qwq" - -error: the "use_" prefix in the feature name "use_qwq" is redundant - | - = help: consider renaming the feature to "qwq" - -error: the "with-" prefix in the feature name "with-owo" is redundant - | - = help: consider renaming the feature to "owo" - -error: the "with_" prefix in the feature name "with_owo" is redundant - | - = help: consider renaming the feature to "owo" - -error: aborting due to 10 previous errors - diff --git a/tests/ui-cargo/feature_name/pass/Cargo.stderr b/tests/ui-cargo/feature_name/pass/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/feature_name/pass/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/feature_name/pass/src/main.rs b/tests/ui-cargo/feature_name/pass/src/main.rs index 64f01a98c90e..4dd9582aff89 100644 --- a/tests/ui-cargo/feature_name/pass/src/main.rs +++ b/tests/ui-cargo/feature_name/pass/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=feature_name +//@compile-flags: --crate-name=feature_name #![warn(clippy::redundant_feature_names)] #![warn(clippy::negative_feature_names)] diff --git a/tests/ui-cargo/module_style/fail_mod/Cargo.stderr b/tests/ui-cargo/module_style/fail_mod/Cargo.stderr new file mode 100644 index 000000000000..9401b19e2775 --- /dev/null +++ b/tests/ui-cargo/module_style/fail_mod/Cargo.stderr @@ -0,0 +1,23 @@ +warning: `mod.rs` files are required, found `src/bad/inner.rs` + --> src/bad/inner.rs:1:1 + | +1 | pub mod stuff; + | ^ + | + = help: move `src/bad/inner.rs` to `src/bad/inner/mod.rs` +note: the lint level is defined here + --> src/main.rs:1:9 + | +1 | #![warn(clippy::self_named_module_files)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `mod.rs` files are required, found `src/bad/inner/stuff.rs` + --> src/bad/inner/stuff.rs:1:1 + | +1 | pub mod most; + | ^ + | + = help: move `src/bad/inner/stuff.rs` to `src/bad/inner/stuff/mod.rs` + +warning: `fail-mod` (bin "fail-mod") generated 2 warnings + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/module_style/fail_mod/src/main.stderr b/tests/ui-cargo/module_style/fail_mod/src/main.stderr deleted file mode 100644 index 697c8b57c4a2..000000000000 --- a/tests/ui-cargo/module_style/fail_mod/src/main.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: `mod.rs` files are required, found `bad/inner.rs` - --> $DIR/bad/inner.rs:1:1 - | -LL | pub mod stuff; - | ^ - | - = help: move `bad/inner.rs` to `bad/inner/mod.rs` - = note: `-D clippy::self-named-module-files` implied by `-D warnings` - -error: `mod.rs` files are required, found `bad/inner/stuff.rs` - --> $DIR/bad/inner/stuff.rs:1:1 - | -LL | pub mod most; - | ^ - | - = help: move `bad/inner/stuff.rs` to `bad/inner/stuff/mod.rs` - -error: aborting due to 2 previous errors - diff --git a/tests/ui-cargo/module_style/fail_mod_remap/Cargo.stderr b/tests/ui-cargo/module_style/fail_mod_remap/Cargo.stderr new file mode 100644 index 000000000000..f1f32f75d2a1 --- /dev/null +++ b/tests/ui-cargo/module_style/fail_mod_remap/Cargo.stderr @@ -0,0 +1,15 @@ +warning: `mod.rs` files are required, found `src/bad.rs` + --> src/bad.rs:1:1 + | +1 | pub mod inner; + | ^ + | + = help: move `src/bad.rs` to `src/bad/mod.rs` +note: the lint level is defined here + --> src/main.rs:3:9 + | +3 | #![warn(clippy::self_named_module_files)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `fail-mod-remap` (bin "fail-mod-remap") generated 1 warning + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/module_style/fail_mod_remap/src/main.rs b/tests/ui-cargo/module_style/fail_mod_remap/src/main.rs index ba4c8c873dd5..c70d92e359e4 100644 --- a/tests/ui-cargo/module_style/fail_mod_remap/src/main.rs +++ b/tests/ui-cargo/module_style/fail_mod_remap/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --remap-path-prefix {{src-base}}=/remapped +//@compile-flags: --remap-path-prefix {{src-base}}=/remapped #![warn(clippy::self_named_module_files)] diff --git a/tests/ui-cargo/module_style/fail_mod_remap/src/main.stderr b/tests/ui-cargo/module_style/fail_mod_remap/src/main.stderr deleted file mode 100644 index ea6ea98064a7..000000000000 --- a/tests/ui-cargo/module_style/fail_mod_remap/src/main.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: `mod.rs` files are required, found `bad.rs` - --> /remapped/module_style/fail_mod_remap/src/bad.rs:1:1 - | -LL | pub mod inner; - | ^ - | - = help: move `bad.rs` to `bad/mod.rs` - = note: `-D clippy::self-named-module-files` implied by `-D warnings` - -error: aborting due to previous error - diff --git a/tests/ui-cargo/module_style/fail_no_mod/Cargo.stderr b/tests/ui-cargo/module_style/fail_no_mod/Cargo.stderr new file mode 100644 index 000000000000..e2b9d411325f --- /dev/null +++ b/tests/ui-cargo/module_style/fail_no_mod/Cargo.stderr @@ -0,0 +1,15 @@ +warning: `mod.rs` files are not allowed, found `src/bad/mod.rs` + --> src/bad/mod.rs:1:1 + | +1 | pub struct Thing; + | ^ + | + = help: move `src/bad/mod.rs` to `src/bad.rs` +note: the lint level is defined here + --> src/main.rs:1:9 + | +1 | #![warn(clippy::mod_module_files)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `fail-no-mod` (bin "fail-no-mod") generated 1 warning + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/module_style/fail_no_mod/src/main.stderr b/tests/ui-cargo/module_style/fail_no_mod/src/main.stderr deleted file mode 100644 index f40ceea234b9..000000000000 --- a/tests/ui-cargo/module_style/fail_no_mod/src/main.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: `mod.rs` files are not allowed, found `bad/mod.rs` - --> $DIR/bad/mod.rs:1:1 - | -LL | pub struct Thing; - | ^ - | - = help: move `bad/mod.rs` to `bad.rs` - = note: `-D clippy::mod-module-files` implied by `-D warnings` - -error: aborting due to previous error - diff --git a/tests/ui-cargo/module_style/pass_mod/Cargo.stderr b/tests/ui-cargo/module_style/pass_mod/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/module_style/pass_mod/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/module_style/pass_no_mod/Cargo.stderr b/tests/ui-cargo/module_style/pass_no_mod/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/module_style/pass_no_mod/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/multiple_config_files/no_warn/Cargo.stderr b/tests/ui-cargo/multiple_config_files/no_warn/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/multiple_config_files/no_warn/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr b/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr new file mode 100644 index 000000000000..91c4eef73b4b --- /dev/null +++ b/tests/ui-cargo/multiple_config_files/warn/Cargo.stderr @@ -0,0 +1,3 @@ +Using config file `$DIR/$DIR/.clippy.toml` +Warning: `$DIR/$DIR/clippy.toml` will be ignored. + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/multiple_config_files/warn/src/main.stderr b/tests/ui-cargo/multiple_config_files/warn/src/main.stderr deleted file mode 100644 index 98697e001f99..000000000000 --- a/tests/ui-cargo/multiple_config_files/warn/src/main.stderr +++ /dev/null @@ -1,2 +0,0 @@ -Using config file `$SRC_DIR/.clippy.toml` -Warning: `$SRC_DIR/clippy.toml` will be ignored. diff --git a/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/Cargo.stderr b/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/src/main.rs b/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/src/main.rs index 1b2d3ec9459f..ece260b743df 100644 --- a/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/src/main.rs +++ b/tests/ui-cargo/multiple_crate_versions/5041_allow_dev_build/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=multiple_crate_versions +//@compile-flags: --crate-name=multiple_crate_versions #![warn(clippy::multiple_crate_versions)] fn main() {} diff --git a/tests/ui-cargo/multiple_crate_versions/fail/Cargo.stderr b/tests/ui-cargo/multiple_crate_versions/fail/Cargo.stderr new file mode 100644 index 000000000000..842c2b2e635b --- /dev/null +++ b/tests/ui-cargo/multiple_crate_versions/fail/Cargo.stderr @@ -0,0 +1,10 @@ +warning: multiple versions for dependency `winapi`: 0.2.8, 0.3.9 + | +note: the lint level is defined here + --> src/main.rs:2:9 + | +2 | #![warn(clippy::multiple_crate_versions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `multiple_crate_versions` (bin "multiple_crate_versions") generated 1 warning + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/multiple_crate_versions/fail/src/main.rs b/tests/ui-cargo/multiple_crate_versions/fail/src/main.rs index 1b2d3ec9459f..ece260b743df 100644 --- a/tests/ui-cargo/multiple_crate_versions/fail/src/main.rs +++ b/tests/ui-cargo/multiple_crate_versions/fail/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=multiple_crate_versions +//@compile-flags: --crate-name=multiple_crate_versions #![warn(clippy::multiple_crate_versions)] fn main() {} diff --git a/tests/ui-cargo/multiple_crate_versions/fail/src/main.stderr b/tests/ui-cargo/multiple_crate_versions/fail/src/main.stderr deleted file mode 100644 index f3113e093650..000000000000 --- a/tests/ui-cargo/multiple_crate_versions/fail/src/main.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error: multiple versions for dependency `winapi`: 0.2.8, 0.3.9 - | - = note: `-D clippy::multiple-crate-versions` implied by `-D warnings` - -error: aborting due to previous error - diff --git a/tests/ui-cargo/multiple_crate_versions/pass/Cargo.stderr b/tests/ui-cargo/multiple_crate_versions/pass/Cargo.stderr new file mode 100644 index 000000000000..77488925e440 --- /dev/null +++ b/tests/ui-cargo/multiple_crate_versions/pass/Cargo.stderr @@ -0,0 +1 @@ + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/multiple_crate_versions/pass/src/main.rs b/tests/ui-cargo/multiple_crate_versions/pass/src/main.rs index 1b2d3ec9459f..ece260b743df 100644 --- a/tests/ui-cargo/multiple_crate_versions/pass/src/main.rs +++ b/tests/ui-cargo/multiple_crate_versions/pass/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=multiple_crate_versions +//@compile-flags: --crate-name=multiple_crate_versions #![warn(clippy::multiple_crate_versions)] fn main() {} diff --git a/tests/ui-cargo/wildcard_dependencies/fail/Cargo.stderr b/tests/ui-cargo/wildcard_dependencies/fail/Cargo.stderr new file mode 100644 index 000000000000..864f9f439e44 --- /dev/null +++ b/tests/ui-cargo/wildcard_dependencies/fail/Cargo.stderr @@ -0,0 +1,10 @@ +warning: wildcard dependency for `regex` + | +note: the lint level is defined here + --> src/main.rs:2:9 + | +2 | #![warn(clippy::wildcard_dependencies)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `wildcard_dependencies` (bin "wildcard_dependencies") generated 1 warning + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/wildcard_dependencies/fail/src/main.rs b/tests/ui-cargo/wildcard_dependencies/fail/src/main.rs index 581babfeacbf..bb3a39d0720a 100644 --- a/tests/ui-cargo/wildcard_dependencies/fail/src/main.rs +++ b/tests/ui-cargo/wildcard_dependencies/fail/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=wildcard_dependencies +//@compile-flags: --crate-name=wildcard_dependencies #![warn(clippy::wildcard_dependencies)] fn main() {} diff --git a/tests/ui-cargo/wildcard_dependencies/fail/src/main.stderr b/tests/ui-cargo/wildcard_dependencies/fail/src/main.stderr deleted file mode 100644 index 9e65d2f99420..000000000000 --- a/tests/ui-cargo/wildcard_dependencies/fail/src/main.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error: wildcard dependency for `regex` - | - = note: `-D clippy::wildcard-dependencies` implied by `-D warnings` - -error: aborting due to previous error - diff --git a/tests/ui-cargo/wildcard_dependencies/pass/Cargo.stderr b/tests/ui-cargo/wildcard_dependencies/pass/Cargo.stderr new file mode 100644 index 000000000000..864f9f439e44 --- /dev/null +++ b/tests/ui-cargo/wildcard_dependencies/pass/Cargo.stderr @@ -0,0 +1,10 @@ +warning: wildcard dependency for `regex` + | +note: the lint level is defined here + --> src/main.rs:2:9 + | +2 | #![warn(clippy::wildcard_dependencies)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `wildcard_dependencies` (bin "wildcard_dependencies") generated 1 warning + Finished dev [unoptimized + debuginfo] target(s) diff --git a/tests/ui-cargo/wildcard_dependencies/pass/src/main.rs b/tests/ui-cargo/wildcard_dependencies/pass/src/main.rs index 581babfeacbf..bb3a39d0720a 100644 --- a/tests/ui-cargo/wildcard_dependencies/pass/src/main.rs +++ b/tests/ui-cargo/wildcard_dependencies/pass/src/main.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=wildcard_dependencies +//@compile-flags: --crate-name=wildcard_dependencies #![warn(clippy::wildcard_dependencies)] fn main() {} diff --git a/tests/ui-internal/check_clippy_version_attribute.rs b/tests/ui-internal/check_clippy_version_attribute.rs index 31acac89cc63..2e1d3a1cae91 100644 --- a/tests/ui-internal/check_clippy_version_attribute.rs +++ b/tests/ui-internal/check_clippy_version_attribute.rs @@ -1,4 +1,4 @@ -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![feature(rustc_private)] #[macro_use] diff --git a/tests/ui-internal/check_clippy_version_attribute.stderr b/tests/ui-internal/check_clippy_version_attribute.stderr index fd8c8379f5bf..1af5bbb2d28a 100644 --- a/tests/ui-internal/check_clippy_version_attribute.stderr +++ b/tests/ui-internal/check_clippy_version_attribute.stderr @@ -1,4 +1,4 @@ -error: this item has an invalid `clippy::version` attribute +warning: this item has an invalid `clippy::version` attribute --> $DIR/check_clippy_version_attribute.rs:40:1 | LL | / declare_tool_lint! { @@ -14,12 +14,12 @@ LL | | } note: the lint level is defined here --> $DIR/check_clippy_version_attribute.rs:1:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::invalid_clippy_version_attribute)]` implied by `#[deny(clippy::internal)]` - = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(clippy::invalid_clippy_version_attribute)]` implied by `#[warn(clippy::internal)]` + = note: this warning originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this item has an invalid `clippy::version` attribute +warning: this item has an invalid `clippy::version` attribute --> $DIR/check_clippy_version_attribute.rs:48:1 | LL | / declare_tool_lint! { @@ -32,9 +32,9 @@ LL | | } | |_^ | = help: please use a valid semantic version, see `doc/adding_lints.md` - = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this lint is missing the `clippy::version` attribute or version value +warning: this lint is missing the `clippy::version` attribute or version value --> $DIR/check_clippy_version_attribute.rs:59:1 | LL | / declare_tool_lint! { @@ -47,10 +47,10 @@ LL | | } | |_^ | = help: please use a `clippy::version` attribute, see `doc/adding_lints.md` - = note: `#[deny(clippy::missing_clippy_version_attribute)]` implied by `#[deny(clippy::internal)]` - = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(clippy::missing_clippy_version_attribute)]` implied by `#[warn(clippy::internal)]` + = note: this warning originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this lint is missing the `clippy::version` attribute or version value +warning: this lint is missing the `clippy::version` attribute or version value --> $DIR/check_clippy_version_attribute.rs:67:1 | LL | / declare_tool_lint! { @@ -62,7 +62,7 @@ LL | | } | |_^ | = help: please use a `clippy::version` attribute, see `doc/adding_lints.md` - = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui-internal/collapsible_span_lint_calls.fixed b/tests/ui-internal/collapsible_span_lint_calls.fixed index 9f299d7dec72..e1cf8ed4eb88 100644 --- a/tests/ui-internal/collapsible_span_lint_calls.fixed +++ b/tests/ui-internal/collapsible_span_lint_calls.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::internal)] +//@run-rustfix +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/collapsible_span_lint_calls.rs b/tests/ui-internal/collapsible_span_lint_calls.rs index 2b113f555e46..5772d163d71e 100644 --- a/tests/ui-internal/collapsible_span_lint_calls.rs +++ b/tests/ui-internal/collapsible_span_lint_calls.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::internal)] +//@run-rustfix +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/collapsible_span_lint_calls.stderr b/tests/ui-internal/collapsible_span_lint_calls.stderr index 0852fe65aafd..c2189fe90231 100644 --- a/tests/ui-internal/collapsible_span_lint_calls.stderr +++ b/tests/ui-internal/collapsible_span_lint_calls.stderr @@ -1,4 +1,4 @@ -error: this call is collapsible +warning: this call is collapsible --> $DIR/collapsible_span_lint_calls.rs:36:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { @@ -9,11 +9,11 @@ LL | | }); note: the lint level is defined here --> $DIR/collapsible_span_lint_calls.rs:2:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]` + = note: `#[warn(clippy::collapsible_span_lint_calls)]` implied by `#[warn(clippy::internal)]` -error: this call is collapsible +warning: this call is collapsible --> $DIR/collapsible_span_lint_calls.rs:39:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { @@ -21,7 +21,7 @@ LL | | db.span_help(expr.span, help_msg); LL | | }); | |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg)` -error: this call is collapsible +warning: this call is collapsible --> $DIR/collapsible_span_lint_calls.rs:42:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { @@ -29,7 +29,7 @@ LL | | db.help(help_msg); LL | | }); | |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg)` -error: this call is collapsible +warning: this call is collapsible --> $DIR/collapsible_span_lint_calls.rs:45:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { @@ -37,7 +37,7 @@ LL | | db.span_note(expr.span, note_msg); LL | | }); | |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg)` -error: this call is collapsible +warning: this call is collapsible --> $DIR/collapsible_span_lint_calls.rs:48:9 | LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| { @@ -45,5 +45,5 @@ LL | | db.note(note_msg); LL | | }); | |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None, note_msg)` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui-internal/custom_ice_message.rs b/tests/ui-internal/custom_ice_message.rs index 837811bdf1ef..acb98d7ba98e 100644 --- a/tests/ui-internal/custom_ice_message.rs +++ b/tests/ui-internal/custom_ice_message.rs @@ -1,9 +1,9 @@ -// rustc-env:RUST_BACKTRACE=0 -// normalize-stderr-test: "Clippy version: .*" -> "Clippy version: foo" -// normalize-stderr-test: "produce_ice.rs:\d*:\d*" -> "produce_ice.rs" -// normalize-stderr-test: "', .*clippy_lints" -> "', clippy_lints" -// normalize-stderr-test: "'rustc'" -> "''" -// normalize-stderr-test: "(?ms)query stack during panic:\n.*end of query stack\n" -> "" +//@rustc-env:RUST_BACKTRACE=0 +//@normalize-stderr-test: "Clippy version: .*" -> "Clippy version: foo" +//@normalize-stderr-test: "produce_ice.rs:\d*:\d*" -> "produce_ice.rs" +//@normalize-stderr-test: "', .*clippy_lints" -> "', clippy_lints" +//@normalize-stderr-test: "'rustc'" -> "''" +//@normalize-stderr-test: "(?ms)query stack during panic:\n.*end of query stack\n" -> "" #![deny(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] diff --git a/tests/ui-internal/default_deprecation_reason.rs b/tests/ui-internal/default_deprecation_reason.rs index c8961d5e1f0b..bd36525ecfec 100644 --- a/tests/ui-internal/default_deprecation_reason.rs +++ b/tests/ui-internal/default_deprecation_reason.rs @@ -1,4 +1,4 @@ -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![feature(rustc_private)] #[macro_use] diff --git a/tests/ui-internal/default_deprecation_reason.stderr b/tests/ui-internal/default_deprecation_reason.stderr index ca26b649f986..10f65e12fbb3 100644 --- a/tests/ui-internal/default_deprecation_reason.stderr +++ b/tests/ui-internal/default_deprecation_reason.stderr @@ -1,4 +1,4 @@ -error: the lint `COOL_LINT_DEFAULT` has the default deprecation reason +warning: the lint `COOL_LINT_DEFAULT` has the default deprecation reason --> $DIR/default_deprecation_reason.rs:8:1 | LL | / declare_deprecated_lint! { @@ -13,10 +13,10 @@ LL | | } note: the lint level is defined here --> $DIR/default_deprecation_reason.rs:1:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::default_deprecation_reason)]` implied by `#[deny(clippy::internal)]` - = note: this error originates in the macro `declare_deprecated_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(clippy::default_deprecation_reason)]` implied by `#[warn(clippy::internal)]` + = note: this warning originates in the macro `declare_deprecated_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui-internal/default_lint.rs b/tests/ui-internal/default_lint.rs index da29aedb2a3a..96bca1dae00d 100644 --- a/tests/ui-internal/default_lint.rs +++ b/tests/ui-internal/default_lint.rs @@ -1,4 +1,4 @@ -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/default_lint.stderr b/tests/ui-internal/default_lint.stderr index 8961bd4624f4..73d1b3d53443 100644 --- a/tests/ui-internal/default_lint.stderr +++ b/tests/ui-internal/default_lint.stderr @@ -1,4 +1,4 @@ -error: the lint `TEST_LINT_DEFAULT` has the default lint description +warning: the lint `TEST_LINT_DEFAULT` has the default lint description --> $DIR/default_lint.rs:18:1 | LL | / declare_tool_lint! { @@ -12,10 +12,10 @@ LL | | } note: the lint level is defined here --> $DIR/default_lint.rs:1:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::default_lint)]` implied by `#[deny(clippy::internal)]` - = note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(clippy::default_lint)]` implied by `#[warn(clippy::internal)]` + = note: this warning originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui-internal/if_chain_style.stderr b/tests/ui-internal/if_chain_style.stderr index d8f1ffb21ba6..464b7e0293cb 100644 --- a/tests/ui-internal/if_chain_style.stderr +++ b/tests/ui-internal/if_chain_style.stderr @@ -1,4 +1,4 @@ -error: this `if` can be part of the inner `if_chain!` +warning: this `if` can be part of the inner `if_chain!` --> $DIR/if_chain_style.rs:9:5 | LL | / if true { @@ -15,9 +15,13 @@ help: this `let` statement can also be in the `if_chain!` | LL | let x = ""; | ^^^^^^^^^^^ - = note: `-D clippy::if-chain-style` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/if_chain_style.rs:1:9 + | +LL | #![warn(clippy::if_chain_style)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: `if a && b;` should be `if a; if b;` +warning: `if a && b;` should be `if a; if b;` --> $DIR/if_chain_style.rs:19:12 | LL | if true @@ -26,13 +30,13 @@ LL | | // multi-line AND'ed conditions LL | | && false; | |____________________^ -error: `let` expression should be inside `then { .. }` +warning: `let` expression should be inside `then { .. }` --> $DIR/if_chain_style.rs:24:9 | LL | let x = ""; | ^^^^^^^^^^^ -error: this `if` can be part of the outer `if_chain!` +warning: this `if` can be part of the outer `if_chain!` --> $DIR/if_chain_style.rs:35:13 | LL | if true {} @@ -44,7 +48,7 @@ help: this `let` statement can also be in the `if_chain!` LL | let x = ""; | ^^^^^^^^^^^ -error: `if_chain!` only has one `if` +warning: `if_chain!` only has one `if` --> $DIR/if_chain_style.rs:29:5 | LL | / if_chain! { @@ -56,15 +60,15 @@ LL | | } LL | | } | |_____^ | - = note: this error originates in the macro `__if_chain` which comes from the expansion of the macro `if_chain` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `__if_chain` which comes from the expansion of the macro `if_chain` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `let` expression should be above the `if_chain!` +warning: `let` expression should be above the `if_chain!` --> $DIR/if_chain_style.rs:40:9 | LL | let x = ""; | ^^^^^^^^^^^ -error: this `if_chain!` can be merged with the outer `if_chain!` +warning: this `if_chain!` can be merged with the outer `if_chain!` --> $DIR/if_chain_style.rs:46:13 | LL | / if_chain! { @@ -81,5 +85,5 @@ LL | / let x = ""; LL | | let x = ""; | |_______________________^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui-internal/interning_defined_symbol.fixed b/tests/ui-internal/interning_defined_symbol.fixed index eaea218e1288..dc0402328333 100644 --- a/tests/ui-internal/interning_defined_symbol.fixed +++ b/tests/ui-internal/interning_defined_symbol.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::internal)] +//@run-rustfix +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)] #![feature(rustc_private)] diff --git a/tests/ui-internal/interning_defined_symbol.rs b/tests/ui-internal/interning_defined_symbol.rs index 7efebb8fae48..418cd172c096 100644 --- a/tests/ui-internal/interning_defined_symbol.rs +++ b/tests/ui-internal/interning_defined_symbol.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::internal)] +//@run-rustfix +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)] #![feature(rustc_private)] diff --git a/tests/ui-internal/interning_defined_symbol.stderr b/tests/ui-internal/interning_defined_symbol.stderr index 4e99636e6839..a59e53aa51a5 100644 --- a/tests/ui-internal/interning_defined_symbol.stderr +++ b/tests/ui-internal/interning_defined_symbol.stderr @@ -1,4 +1,4 @@ -error: interning a defined symbol +warning: interning a defined symbol --> $DIR/interning_defined_symbol.rs:18:13 | LL | let _ = Symbol::intern("f32"); @@ -7,27 +7,27 @@ LL | let _ = Symbol::intern("f32"); note: the lint level is defined here --> $DIR/interning_defined_symbol.rs:2:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]` + = note: `#[warn(clippy::interning_defined_symbol)]` implied by `#[warn(clippy::internal)]` -error: interning a defined symbol +warning: interning a defined symbol --> $DIR/interning_defined_symbol.rs:21:13 | LL | let _ = sym!(f32); | ^^^^^^^^^ help: try: `rustc_span::sym::f32` -error: interning a defined symbol +warning: interning a defined symbol --> $DIR/interning_defined_symbol.rs:24:13 | LL | let _ = Symbol::intern("proc-macro"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro` -error: interning a defined symbol +warning: interning a defined symbol --> $DIR/interning_defined_symbol.rs:27:13 | LL | let _ = Symbol::intern("self"); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::symbol::kw::SelfLower` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui-internal/invalid_msrv_attr_impl.fixed b/tests/ui-internal/invalid_msrv_attr_impl.fixed index 08634063a575..f98e54a20fe0 100644 --- a/tests/ui-internal/invalid_msrv_attr_impl.fixed +++ b/tests/ui-internal/invalid_msrv_attr_impl.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/invalid_msrv_attr_impl.rs b/tests/ui-internal/invalid_msrv_attr_impl.rs index f8af77e6d395..9b2376c55727 100644 --- a/tests/ui-internal/invalid_msrv_attr_impl.rs +++ b/tests/ui-internal/invalid_msrv_attr_impl.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/invalid_msrv_attr_impl.stderr b/tests/ui-internal/invalid_msrv_attr_impl.stderr index ddc06f0be1b3..06becc0f7673 100644 --- a/tests/ui-internal/invalid_msrv_attr_impl.stderr +++ b/tests/ui-internal/invalid_msrv_attr_impl.stderr @@ -1,4 +1,4 @@ -error: `extract_msrv_attr!` macro missing from `LateLintPass` implementation +warning: `extract_msrv_attr!` macro missing from `LateLintPass` implementation --> $DIR/invalid_msrv_attr_impl.rs:30:1 | LL | impl LateLintPass<'_> for Pass { @@ -7,16 +7,16 @@ LL | impl LateLintPass<'_> for Pass { note: the lint level is defined here --> $DIR/invalid_msrv_attr_impl.rs:3:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::missing_msrv_attr_impl)]` implied by `#[deny(clippy::internal)]` + = note: `#[warn(clippy::missing_msrv_attr_impl)]` implied by `#[warn(clippy::internal)]` help: add `extract_msrv_attr!(LateContext)` to the `LateLintPass` implementation | LL + impl LateLintPass<'_> for Pass { LL + extract_msrv_attr!(LateContext); | -error: `extract_msrv_attr!` macro missing from `EarlyLintPass` implementation +warning: `extract_msrv_attr!` macro missing from `EarlyLintPass` implementation --> $DIR/invalid_msrv_attr_impl.rs:34:1 | LL | impl EarlyLintPass for Pass { @@ -28,5 +28,5 @@ LL + impl EarlyLintPass for Pass { LL + extract_msrv_attr!(EarlyContext); | -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui-internal/invalid_paths.stderr b/tests/ui-internal/invalid_paths.stderr index 0e8508869176..cd6550f3aabe 100644 --- a/tests/ui-internal/invalid_paths.stderr +++ b/tests/ui-internal/invalid_paths.stderr @@ -1,22 +1,27 @@ -error: invalid path +warning: invalid path --> $DIR/invalid_paths.rs:15:5 | LL | pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::invalid-paths` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/invalid_paths.rs:1:9 + | +LL | #![warn(clippy::internal)] + | ^^^^^^^^^^^^^^^^ + = note: `#[warn(clippy::invalid_paths)]` implied by `#[warn(clippy::internal)]` -error: invalid path +warning: invalid path --> $DIR/invalid_paths.rs:18:5 | LL | pub const BAD_CRATE_PATH: [&str; 2] = ["bad", "path"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: invalid path +warning: invalid path --> $DIR/invalid_paths.rs:21:5 | LL | pub const BAD_MOD_PATH: [&str; 2] = ["std", "xxx"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui-internal/lint_without_lint_pass.rs b/tests/ui-internal/lint_without_lint_pass.rs index 1fd03cfe36da..57dffeafb26c 100644 --- a/tests/ui-internal/lint_without_lint_pass.rs +++ b/tests/ui-internal/lint_without_lint_pass.rs @@ -1,4 +1,4 @@ -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/lint_without_lint_pass.stderr b/tests/ui-internal/lint_without_lint_pass.stderr index de04920b8e6f..b744b7691e2a 100644 --- a/tests/ui-internal/lint_without_lint_pass.stderr +++ b/tests/ui-internal/lint_without_lint_pass.stderr @@ -1,4 +1,4 @@ -error: the lint `TEST_LINT` is not added to any `LintPass` +warning: the lint `TEST_LINT` is not added to any `LintPass` --> $DIR/lint_without_lint_pass.rs:12:1 | LL | / declare_tool_lint! { @@ -12,10 +12,10 @@ LL | | } note: the lint level is defined here --> $DIR/lint_without_lint_pass.rs:1:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::lint_without_lint_pass)]` implied by `#[deny(clippy::internal)]` - = note: this error originates in the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(clippy::lint_without_lint_pass)]` implied by `#[warn(clippy::internal)]` + = note: this warning originates in the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui-internal/outer_expn_data.fixed b/tests/ui-internal/outer_expn_data.fixed index bb82faf0c904..c0079092a03c 100644 --- a/tests/ui-internal/outer_expn_data.fixed +++ b/tests/ui-internal/outer_expn_data.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/outer_expn_data.rs b/tests/ui-internal/outer_expn_data.rs index 187d468b3925..81d4a8bda47a 100644 --- a/tests/ui-internal/outer_expn_data.rs +++ b/tests/ui-internal/outer_expn_data.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow(clippy::missing_clippy_version_attribute)] #![feature(rustc_private)] diff --git a/tests/ui-internal/outer_expn_data.stderr b/tests/ui-internal/outer_expn_data.stderr index afef696785e8..cbc7e140a1c0 100644 --- a/tests/ui-internal/outer_expn_data.stderr +++ b/tests/ui-internal/outer_expn_data.stderr @@ -1,4 +1,4 @@ -error: usage of `outer_expn().expn_data()` +warning: usage of `outer_expn().expn_data()` --> $DIR/outer_expn_data.rs:25:34 | LL | let _ = expr.span.ctxt().outer_expn().expn_data(); @@ -7,9 +7,9 @@ LL | let _ = expr.span.ctxt().outer_expn().expn_data(); note: the lint level is defined here --> $DIR/outer_expn_data.rs:3:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::outer_expn_expn_data)]` implied by `#[deny(clippy::internal)]` + = note: `#[warn(clippy::outer_expn_expn_data)]` implied by `#[warn(clippy::internal)]` -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui-internal/unnecessary_def_path.fixed b/tests/ui-internal/unnecessary_def_path.fixed index e474f370a5d1..fcc31814a4bc 100644 --- a/tests/ui-internal/unnecessary_def_path.fixed +++ b/tests/ui-internal/unnecessary_def_path.fixed @@ -1,6 +1,6 @@ -// run-rustfix -// aux-build:paths.rs -#![deny(clippy::internal)] +//@run-rustfix +//@aux-build:paths.rs +#![warn(clippy::internal)] #![feature(rustc_private)] extern crate clippy_utils; diff --git a/tests/ui-internal/unnecessary_def_path.rs b/tests/ui-internal/unnecessary_def_path.rs index f17fed6c6530..f08e160243d4 100644 --- a/tests/ui-internal/unnecessary_def_path.rs +++ b/tests/ui-internal/unnecessary_def_path.rs @@ -1,6 +1,6 @@ -// run-rustfix -// aux-build:paths.rs -#![deny(clippy::internal)] +//@run-rustfix +//@aux-build:paths.rs +#![warn(clippy::internal)] #![feature(rustc_private)] extern crate clippy_utils; diff --git a/tests/ui-internal/unnecessary_def_path.stderr b/tests/ui-internal/unnecessary_def_path.stderr index 3ca29f099771..d9c506aceda3 100644 --- a/tests/ui-internal/unnecessary_def_path.stderr +++ b/tests/ui-internal/unnecessary_def_path.stderr @@ -1,4 +1,4 @@ -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:37:13 | LL | let _ = match_type(cx, ty, &OPTION); @@ -7,65 +7,65 @@ LL | let _ = match_type(cx, ty, &OPTION); note: the lint level is defined here --> $DIR/unnecessary_def_path.rs:3:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]` + = note: `#[warn(clippy::unnecessary_def_path)]` implied by `#[warn(clippy::internal)]` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:38:13 | LL | let _ = match_type(cx, ty, RESULT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:39:13 | LL | let _ = match_type(cx, ty, &["core", "result", "Result"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:43:13 | LL | let _ = clippy_utils::ty::match_type(cx, ty, rc_path); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Rc)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:45:13 | LL | let _ = match_type(cx, ty, &paths::OPTION); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:46:13 | LL | let _ = match_type(cx, ty, paths::RESULT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)` -error: use of a def path to a `LangItem` +warning: use of a def path to a `LangItem` --> $DIR/unnecessary_def_path.rs:48:13 | LL | let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_lang_item(cx, ty, LangItem::OwnedBox)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:49:13 | LL | let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit)` -error: use of a def path to a `LangItem` +warning: use of a def path to a `LangItem` --> $DIR/unnecessary_def_path.rs:51:13 | LL | let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:52:13 | LL | let _ = match_def_path(cx, did, &["core", "option", "Option"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.is_diagnostic_item(sym::Option, did)` -error: use of a def path to a `LangItem` +warning: use of a def path to a `LangItem` --> $DIR/unnecessary_def_path.rs:53:13 | LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]); @@ -73,29 +73,29 @@ LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]); | = help: if this `DefId` came from a constructor expression or pattern then the parent `DefId` should be used instead -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:55:13 | LL | let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_trait_method(cx, expr, sym::AsRef)` -error: use of a def path to a diagnostic item +warning: use of a def path to a diagnostic item --> $DIR/unnecessary_def_path.rs:57:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_path_diagnostic_item(cx, expr, sym::Option)` -error: use of a def path to a `LangItem` +warning: use of a def path to a `LangItem` --> $DIR/unnecessary_def_path.rs:58:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id))` -error: use of a def path to a `LangItem` +warning: use of a def path to a `LangItem` --> $DIR/unnecessary_def_path.rs:59:13 | LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome)` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr b/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr index 3ca45404e44b..2ac39116a7d6 100644 --- a/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr +++ b/tests/ui-internal/unnecessary_def_path_hardcoded_path.stderr @@ -1,13 +1,17 @@ -error: hardcoded path to a diagnostic item +warning: hardcoded path to a diagnostic item --> $DIR/unnecessary_def_path_hardcoded_path.rs:10:36 | LL | const DEREF_TRAIT: [&str; 4] = ["core", "ops", "deref", "Deref"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: convert all references to use `sym::Deref` - = note: `-D clippy::unnecessary-def-path` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_def_path_hardcoded_path.rs:3:9 + | +LL | #![warn(clippy::unnecessary_def_path)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: hardcoded path to a language item +warning: hardcoded path to a language item --> $DIR/unnecessary_def_path_hardcoded_path.rs:11:40 | LL | const DEREF_MUT_TRAIT: [&str; 4] = ["core", "ops", "deref", "DerefMut"]; @@ -15,7 +19,7 @@ LL | const DEREF_MUT_TRAIT: [&str; 4] = ["core", "ops", "deref", "DerefMut"] | = help: convert all references to use `LangItem::DerefMut` -error: hardcoded path to a diagnostic item +warning: hardcoded path to a diagnostic item --> $DIR/unnecessary_def_path_hardcoded_path.rs:12:43 | LL | const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"]; @@ -23,5 +27,5 @@ LL | const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", | = help: convert all references to use `sym::deref_method` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui-internal/unnecessary_symbol_str.fixed b/tests/ui-internal/unnecessary_symbol_str.fixed index 6033d06e4f63..4228c15f1bec 100644 --- a/tests/ui-internal/unnecessary_symbol_str.fixed +++ b/tests/ui-internal/unnecessary_symbol_str.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #![feature(rustc_private)] -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow( clippy::borrow_deref_ref, clippy::unnecessary_operation, diff --git a/tests/ui-internal/unnecessary_symbol_str.rs b/tests/ui-internal/unnecessary_symbol_str.rs index 1bb5d55f0b60..9e69d8d853d2 100644 --- a/tests/ui-internal/unnecessary_symbol_str.rs +++ b/tests/ui-internal/unnecessary_symbol_str.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #![feature(rustc_private)] -#![deny(clippy::internal)] +#![warn(clippy::internal)] #![allow( clippy::borrow_deref_ref, clippy::unnecessary_operation, diff --git a/tests/ui-internal/unnecessary_symbol_str.stderr b/tests/ui-internal/unnecessary_symbol_str.stderr index a1f507f331d2..f56c00c2d8ce 100644 --- a/tests/ui-internal/unnecessary_symbol_str.stderr +++ b/tests/ui-internal/unnecessary_symbol_str.stderr @@ -1,4 +1,4 @@ -error: unnecessary `Symbol` to string conversion +warning: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:16:5 | LL | Symbol::intern("foo").as_str() == "clippy"; @@ -7,33 +7,33 @@ LL | Symbol::intern("foo").as_str() == "clippy"; note: the lint level is defined here --> $DIR/unnecessary_symbol_str.rs:3:9 | -LL | #![deny(clippy::internal)] +LL | #![warn(clippy::internal)] | ^^^^^^^^^^^^^^^^ - = note: `#[deny(clippy::unnecessary_symbol_str)]` implied by `#[deny(clippy::internal)]` + = note: `#[warn(clippy::unnecessary_symbol_str)]` implied by `#[warn(clippy::internal)]` -error: unnecessary `Symbol` to string conversion +warning: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:17:5 | LL | Symbol::intern("foo").to_string() == "self"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower` -error: unnecessary `Symbol` to string conversion +warning: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:18:5 | LL | Symbol::intern("foo").to_ident_string() != "Self"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper` -error: unnecessary `Symbol` to string conversion +warning: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:19:5 | LL | &*Ident::empty().as_str() == "clippy"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy` -error: unnecessary `Symbol` to string conversion +warning: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:20:5 | LL | "clippy" == Ident::empty().to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed index aa8b45b5fe7d..afc117143c4a 100644 --- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed +++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::uninlined_format_args)] fn main() { @@ -7,8 +7,8 @@ fn main() { let local_opt: Option = Some(3); println!("val='{local_i32}'"); - println!("Hello x is {local_f64:.local_i32$}"); - println!("Hello {local_i32} is {local_f64:.*}", 5); - println!("Hello {local_i32} is {local_f64:.*}", 5); - println!("{local_i32}, {}", local_opt.unwrap()); + println!("Hello x is {:.*}", local_i32, local_f64); + println!("Hello {} is {:.*}", local_i32, 5, local_f64); + println!("Hello {} is {2:.*}", local_i32, 5, local_f64); + println!("{}, {}", local_i32, local_opt.unwrap()); } diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs index ad2e4863ee8e..d66b2b8ff6a0 100644 --- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs +++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::uninlined_format_args)] fn main() { diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr index ee9417621961..96a5f91d7699 100644 --- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr +++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr @@ -1,76 +1,32 @@ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:9:5 | LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::uninlined-format-args` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/uninlined_format_args.rs:2:9 + | +LL | #![warn(clippy::uninlined_format_args)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to | LL - println!("val='{}'", local_i32); LL + println!("val='{local_i32}'"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/uninlined_format_args.rs:10:35 | LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); | ^^^ | - = note: `-D clippy::print-literal` implied by `-D warnings` + = note: `#[warn(clippy::print_literal)]` on by default help: try this | LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64); LL + println!("Hello x is {:.*}", local_i32, local_f64); | -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:10:5 - | -LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64); -LL + println!("Hello {} is {local_f64:.local_i32$}", "x"); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:11:5 - | -LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("Hello {} is {:.*}", local_i32, 5, local_f64); -LL + println!("Hello {local_i32} is {local_f64:.*}", 5); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:12:5 - | -LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("Hello {} is {2:.*}", local_i32, 5, local_f64); -LL + println!("Hello {local_i32} is {local_f64:.*}", 5); - | - -error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:13:5 - | -LL | println!("{}, {}", local_i32, local_opt.unwrap()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: change this to - | -LL - println!("{}, {}", local_i32, local_opt.unwrap()); -LL + println!("{local_i32}, {}", local_opt.unwrap()); - | - -error: aborting due to 6 previous errors +warning: 2 warnings emitted diff --git a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr index ad89534aa1b0..6c03bac3e0b9 100644 --- a/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr +++ b/tests/ui-toml/arithmetic_side_effects_allowed/arithmetic_side_effects_allowed.stderr @@ -1,58 +1,140 @@ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:62:13 + | +LL | let _ = OutOfNames + OutOfNames; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/arithmetic_side_effects_allowed.rs:1:9 + | +LL | #![warn(clippy::arithmetic_side_effects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:64:13 + | +LL | let _ = Foo + Foo; + | ^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:66:13 + | +LL | let _ = Bar + Bar; + | ^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:68:13 | LL | let _ = Baz + Baz; | ^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:73:13 | - = note: `-D clippy::arithmetic-side-effects` implied by `-D warnings` +LL | let _ = 1i32 + OutOfNames; + | ^^^^^^^^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:75:13 + | +LL | let _ = 1i32 + Foo; + | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:77:13 + | +LL | let _ = 1i32 + Bar; + | ^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:79:13 | LL | let _ = 1i32 + Baz; | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:82:13 | LL | let _ = 1i64 + Foo; | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:84:13 + | +LL | let _ = 1i64 + Bar; + | ^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:86:13 | LL | let _ = 1i64 + Baz; | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:91:13 + | +LL | let _ = OutOfNames + 1i32; + | ^^^^^^^^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:93:13 + | +LL | let _ = Foo + 1i32; + | ^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:95:13 + | +LL | let _ = Bar + 1i32; + | ^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:97:13 | LL | let _ = Baz + 1i32; | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:100:13 | LL | let _ = Foo + 1i64; | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:102:13 + | +LL | let _ = Bar + 1i64; + | ^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:104:13 | LL | let _ = Baz + 1i64; | ^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:109:13 + | +LL | let _ = -OutOfNames; + | ^^^^^^^^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects + --> $DIR/arithmetic_side_effects_allowed.rs:111:13 + | +LL | let _ = -Foo; + | ^^^^ + +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:113:13 | LL | let _ = -Bar; | ^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects_allowed.rs:115:13 | LL | let _ = -Baz; | ^^^^ -error: aborting due to 9 previous errors +warning: 22 warnings emitted diff --git a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr deleted file mode 100644 index ac017b20916d..000000000000 --- a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error: large array defined as const - --> $DIR/array_size_threshold.rs:4:1 - | -LL | const ABOVE: [u8; 11] = [0; 11]; - | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | help: make this a static item: `static` - | - = note: `-D clippy::large-const-arrays` implied by `-D warnings` - -error: allocating a local array larger than 10 bytes - --> $DIR/array_size_threshold.rs:4:25 - | -LL | const ABOVE: [u8; 11] = [0; 11]; - | ^^^^^^^ - | - = help: consider allocating on the heap with `vec![0; 11].into_boxed_slice()` - = note: `-D clippy::large-stack-arrays` implied by `-D warnings` - -error: allocating a local array larger than 10 bytes - --> $DIR/array_size_threshold.rs:8:17 - | -LL | let above = [0u8; 11]; - | ^^^^^^^^^ - | - = help: consider allocating on the heap with `vec![0u8; 11].into_boxed_slice()` - -error: aborting due to 3 previous errors - diff --git a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr deleted file mode 100644 index 825aa1487e7a..000000000000 --- a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:5:9 - | -LL | let _x = String::from("hello"); - | ^^ - | - = note: strings are bad (from clippy.toml) - = note: `-D clippy::await-holding-invalid-type` implied by `-D warnings` - -error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:10:9 - | -LL | let _x = Ipv4Addr::new(127, 0, 0, 1); - | ^^ - -error: `std::string::String` may not be held across an `await` point per `clippy.toml` - --> $DIR/await_holding_invalid_type.rs:31:13 - | -LL | let _x = String::from("hi!"); - | ^^ - | - = note: strings are bad (from clippy.toml) - -error: aborting due to 3 previous errors - diff --git a/tests/ui-toml/bad_toml/conf_bad_toml.stderr b/tests/ui-toml/bad_toml/conf_bad_toml.stderr deleted file mode 100644 index 28c1a568a632..000000000000 --- a/tests/ui-toml/bad_toml/conf_bad_toml.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: error reading Clippy's configuration file `$DIR/clippy.toml`: expected an equals, found an identifier at line 1 column 4 - -error: aborting due to previous error - diff --git a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr deleted file mode 100644 index e3ec60192040..000000000000 --- a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: error reading Clippy's configuration file `$DIR/clippy.toml`: invalid type: integer `42`, expected a sequence for key `disallowed-names` - -error: aborting due to previous error - diff --git a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr deleted file mode 100644 index 630bad07c5b7..000000000000 --- a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: error reading Clippy's configuration file `$DIR/clippy.toml`: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - -warning: error reading Clippy's configuration file `$DIR/clippy.toml`: deprecated field `blacklisted-names`. Please use `disallowed-names` instead - -error: the function has a cognitive complexity of (3/2) - --> $DIR/conf_deprecated_key.rs:6:4 - | -LL | fn cognitive_complexity() { - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: you could split it up into multiple smaller functions - = note: `-D clippy::cognitive-complexity` implied by `-D warnings` - -error: aborting due to previous error; 2 warnings emitted - diff --git a/tests/ui-toml/dbg_macro/dbg_macro.rs b/tests/ui-toml/dbg_macro/dbg_macro.rs index 5d9ce18f631b..21e4fce26e4e 100644 --- a/tests/ui-toml/dbg_macro/dbg_macro.rs +++ b/tests/ui-toml/dbg_macro/dbg_macro.rs @@ -1,4 +1,4 @@ -// compile-flags: --test +//@compile-flags: --test #![warn(clippy::dbg_macro)] fn foo(n: u32) -> u32 { diff --git a/tests/ui-toml/dbg_macro/dbg_macro.stderr b/tests/ui-toml/dbg_macro/dbg_macro.stderr index 859383a71194..4da3611b5157 100644 --- a/tests/ui-toml/dbg_macro/dbg_macro.stderr +++ b/tests/ui-toml/dbg_macro/dbg_macro.stderr @@ -1,16 +1,20 @@ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:5:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::dbg-macro` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/dbg_macro.rs:2:9 + | +LL | #![warn(clippy::dbg_macro)] + | ^^^^^^^^^^^^^^^^^ help: remove the invocation before committing it to a version control system | LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:9:8 | LL | if dbg!(n <= 1) { @@ -21,7 +25,7 @@ help: remove the invocation before committing it to a version control system LL | if n <= 1 { | ~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:10:9 | LL | dbg!(1) @@ -32,7 +36,7 @@ help: remove the invocation before committing it to a version control system LL | 1 | -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:12:9 | LL | dbg!(n * factorial(n - 1)) @@ -43,7 +47,7 @@ help: remove the invocation before committing it to a version control system LL | n * factorial(n - 1) | -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:17:5 | LL | dbg!(42); @@ -54,7 +58,7 @@ help: remove the invocation before committing it to a version control system LL | 42; | ~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:18:5 | LL | dbg!(dbg!(dbg!(42))); @@ -65,7 +69,7 @@ help: remove the invocation before committing it to a version control system LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:19:14 | LL | foo(3) + dbg!(factorial(4)); @@ -76,7 +80,7 @@ help: remove the invocation before committing it to a version control system LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:20:5 | LL | dbg!(1, 2, dbg!(3, 4)); @@ -87,7 +91,7 @@ help: remove the invocation before committing it to a version control system LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:21:5 | LL | dbg!(1, 2, 3, 4, 5); @@ -98,5 +102,38 @@ help: remove the invocation before committing it to a version control system LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ -error: aborting due to 9 previous errors +warning: the `dbg!` macro is intended as a debugging tool + --> $DIR/dbg_macro.rs:26:5 + | +LL | dbg!(1); + | ^^^^^^^ + | +help: remove the invocation before committing it to a version control system + | +LL | 1; + | ~ + +warning: the `dbg!` macro is intended as a debugging tool + --> $DIR/dbg_macro.rs:31:5 + | +LL | dbg!(1); + | ^^^^^^^ + | +help: remove the invocation before committing it to a version control system + | +LL | 1; + | ~ + +warning: the `dbg!` macro is intended as a debugging tool + --> $DIR/dbg_macro.rs:37:9 + | +LL | dbg!(1); + | ^^^^^^^ + | +help: remove the invocation before committing it to a version control system + | +LL | 1; + | ~ + +warning: 12 warnings emitted diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.rs b/tests/ui-toml/disallowed_macros/disallowed_macros.rs index 2bb5376076e2..ba919b487885 100644 --- a/tests/ui-toml/disallowed_macros/disallowed_macros.rs +++ b/tests/ui-toml/disallowed_macros/disallowed_macros.rs @@ -1,4 +1,4 @@ -// aux-build:macros.rs +//@aux-build:macros.rs #![allow(unused)] diff --git a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr b/tests/ui-toml/disallowed_macros/disallowed_macros.stderr deleted file mode 100644 index aed9feb6f796..000000000000 --- a/tests/ui-toml/disallowed_macros/disallowed_macros.stderr +++ /dev/null @@ -1,84 +0,0 @@ -error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros.rs:10:5 - | -LL | println!("one"); - | ^^^^^^^^^^^^^^^ - | - = note: `-D clippy::disallowed-macros` implied by `-D warnings` - -error: use of a disallowed macro `std::println` - --> $DIR/disallowed_macros.rs:11:5 - | -LL | println!("two"); - | ^^^^^^^^^^^^^^^ - -error: use of a disallowed macro `std::cfg` - --> $DIR/disallowed_macros.rs:12:5 - | -LL | cfg!(unix); - | ^^^^^^^^^^ - -error: use of a disallowed macro `std::vec` - --> $DIR/disallowed_macros.rs:13:5 - | -LL | vec![1, 2, 3]; - | ^^^^^^^^^^^^^ - -error: use of a disallowed macro `serde::Serialize` - --> $DIR/disallowed_macros.rs:15:14 - | -LL | #[derive(Serialize)] - | ^^^^^^^^^ - | - = note: no serializing (from clippy.toml) - -error: use of a disallowed macro `macros::expr` - --> $DIR/disallowed_macros.rs:18:13 - | -LL | let _ = macros::expr!(); - | ^^^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::stmt` - --> $DIR/disallowed_macros.rs:19:5 - | -LL | macros::stmt!(); - | ^^^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::pat` - --> $DIR/disallowed_macros.rs:20:9 - | -LL | let macros::pat!() = 1; - | ^^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::ty` - --> $DIR/disallowed_macros.rs:21:12 - | -LL | let _: macros::ty!() = ""; - | ^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:22:5 - | -LL | macros::item!(); - | ^^^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:30:5 - | -LL | macros::item!(); - | ^^^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:34:5 - | -LL | macros::item!(); - | ^^^^^^^^^^^^^^^ - -error: use of a disallowed macro `macros::item` - --> $DIR/disallowed_macros.rs:38:5 - | -LL | macros::item!(); - | ^^^^^^^^^^^^^^^ - -error: aborting due to 13 previous errors - diff --git a/tests/ui-toml/disallowed_names_append/disallowed_names.stderr b/tests/ui-toml/disallowed_names_append/disallowed_names.stderr index 23c3e96a8d08..69ab41bb7be4 100644 --- a/tests/ui-toml/disallowed_names_append/disallowed_names.stderr +++ b/tests/ui-toml/disallowed_names_append/disallowed_names.stderr @@ -1,16 +1,14 @@ -error: use of a disallowed/placeholder name `foo` +warning: use of a disallowed/placeholder name `foo` --> $DIR/disallowed_names.rs:5:9 | LL | let foo = "bar"; | ^^^ | - = note: `-D clippy::disallowed-names` implied by `-D warnings` - -error: use of a disallowed/placeholder name `ducks` - --> $DIR/disallowed_names.rs:7:9 +note: the lint level is defined here + --> $DIR/disallowed_names.rs:1:8 | -LL | let ducks = ["quack", "quack"]; - | ^^^^^ +LL | #[warn(clippy::disallowed_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 1 warning emitted diff --git a/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr b/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr index d961fa34074b..69ab41bb7be4 100644 --- a/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr +++ b/tests/ui-toml/disallowed_names_replace/disallowed_names.stderr @@ -1,10 +1,14 @@ -error: use of a disallowed/placeholder name `ducks` - --> $DIR/disallowed_names.rs:7:9 +warning: use of a disallowed/placeholder name `foo` + --> $DIR/disallowed_names.rs:5:9 | -LL | let ducks = ["quack", "quack"]; - | ^^^^^ +LL | let foo = "bar"; + | ^^^ | - = note: `-D clippy::disallowed-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/disallowed_names.rs:1:8 + | +LL | #[warn(clippy::disallowed_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr b/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr index 0f767c9b8559..f60718c0edac 100644 --- a/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr +++ b/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr @@ -1,14 +1,29 @@ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks + --> $DIR/doc_markdown.rs:3:37 + | +LL | /// This is a special interface for ClipPy which doesn't require backticks + | ^^^^^^ + | +note: the lint level is defined here + --> $DIR/doc_markdown.rs:1:9 + | +LL | #![warn(clippy::doc_markdown)] + | ^^^^^^^^^^^^^^^^^^^^ +help: try + | +LL | /// This is a special interface for `ClipPy` which doesn't require backticks + | ~~~~~~~~ + +warning: item in documentation is missing backticks --> $DIR/doc_markdown.rs:9:5 | LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted. | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::doc-markdown` implied by `-D warnings` help: try | LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to previous error +warning: 2 warnings emitted diff --git a/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr b/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr index e0613eb863b3..f60718c0edac 100644 --- a/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr +++ b/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr @@ -1,27 +1,20 @@ -error: item in documentation is missing backticks - --> $DIR/doc_markdown.rs:6:5 +warning: item in documentation is missing backticks + --> $DIR/doc_markdown.rs:3:37 | -LL | /// OAuth and LaTeX are inside Clippy's default list. - | ^^^^^ +LL | /// This is a special interface for ClipPy which doesn't require backticks + | ^^^^^^ | - = note: `-D clippy::doc-markdown` implied by `-D warnings` -help: try - | -LL | /// `OAuth` and LaTeX are inside Clippy's default list. - | ~~~~~~~ - -error: item in documentation is missing backticks - --> $DIR/doc_markdown.rs:6:15 - | -LL | /// OAuth and LaTeX are inside Clippy's default list. - | ^^^^^ +note: the lint level is defined here + --> $DIR/doc_markdown.rs:1:9 | +LL | #![warn(clippy::doc_markdown)] + | ^^^^^^^^^^^^^^^^^^^^ help: try | -LL | /// OAuth and `LaTeX` are inside Clippy's default list. - | ~~~~~~~ +LL | /// This is a special interface for `ClipPy` which doesn't require backticks + | ~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc_markdown.rs:9:5 | LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted. @@ -32,5 +25,5 @@ help: try LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 3 previous errors +warning: 2 warnings emitted diff --git a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr deleted file mode 100644 index d99490a242d4..000000000000 --- a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: error reading Clippy's configuration file `$DIR/clippy.toml`: duplicate field `cognitive_complexity_threshold` (provided as `cyclomatic_complexity_threshold`) - -error: error reading Clippy's configuration file `$DIR/clippy.toml`: duplicate field `cognitive-complexity-threshold` - -warning: error reading Clippy's configuration file `$DIR/clippy.toml`: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead - -error: aborting due to 2 previous errors; 1 warning emitted - diff --git a/tests/ui-toml/expect_used/expect_used.rs b/tests/ui-toml/expect_used/expect_used.rs index 89f142a150d9..9e267c893005 100644 --- a/tests/ui-toml/expect_used/expect_used.rs +++ b/tests/ui-toml/expect_used/expect_used.rs @@ -1,4 +1,4 @@ -// compile-flags: --test +//@compile-flags: --test #![warn(clippy::expect_used)] fn expect_option() { diff --git a/tests/ui-toml/expect_used/expect_used.stderr b/tests/ui-toml/expect_used/expect_used.stderr index 1e9bb48c333c..04b39ec07274 100644 --- a/tests/ui-toml/expect_used/expect_used.stderr +++ b/tests/ui-toml/expect_used/expect_used.stderr @@ -1,13 +1,17 @@ -error: used `expect()` on an `Option` value +warning: used `expect()` on an `Option` value --> $DIR/expect_used.rs:6:13 | LL | let _ = opt.expect(""); | ^^^^^^^^^^^^^^ | = help: if this value is `None`, it will panic - = note: `-D clippy::expect-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/expect_used.rs:2:9 + | +LL | #![warn(clippy::expect_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: used `expect()` on a `Result` value +warning: used `expect()` on a `Result` value --> $DIR/expect_used.rs:11:13 | LL | let _ = res.expect(""); @@ -15,5 +19,37 @@ LL | let _ = res.expect(""); | = help: if this value is an `Err`, it will panic -error: aborting due to 2 previous errors +warning: used `expect()` on an `Option` value + --> $DIR/expect_used.rs:22:13 + | +LL | let _ = opt.expect(""); + | ^^^^^^^^^^^^^^ + | + = help: if this value is `None`, it will panic + +warning: used `expect()` on a `Result` value + --> $DIR/expect_used.rs:28:13 + | +LL | let _ = res.expect(""); + | ^^^^^^^^^^^^^^ + | + = help: if this value is an `Err`, it will panic + +warning: used `expect()` on a `Result` value + --> $DIR/expect_used.rs:37:22 + | +LL | let _a: u8 = 3.try_into().expect(""); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if this value is an `Err`, it will panic + +warning: used `expect()` on a `Result` value + --> $DIR/expect_used.rs:44:22 + | +LL | let _a: u8 = 5.try_into().expect(""); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if this value is an `Err`, it will panic + +warning: 6 warnings emitted diff --git a/tests/ui-toml/fn_params_excessive_bools/test.stderr b/tests/ui-toml/fn_params_excessive_bools/test.stderr deleted file mode 100644 index 87bdb61c6a5e..000000000000 --- a/tests/ui-toml/fn_params_excessive_bools/test.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: more than 1 bools in function parameters - --> $DIR/test.rs:4:1 - | -LL | fn g(_: bool, _: bool) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider refactoring bools into two-variant enums - = note: `-D clippy::fn-params-excessive-bools` implied by `-D warnings` - -error: aborting due to previous error - diff --git a/tests/ui-toml/functions_maxlines/test.stderr b/tests/ui-toml/functions_maxlines/test.stderr deleted file mode 100644 index dc255bdcabaf..000000000000 --- a/tests/ui-toml/functions_maxlines/test.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error: this function has too many lines (2/1) - --> $DIR/test.rs:19:1 - | -LL | / fn too_many_lines() { -LL | | println!("This is bad."); -LL | | println!("This is bad."); -LL | | } - | |_^ - | - = note: `-D clippy::too-many-lines` implied by `-D warnings` - -error: this function has too many lines (4/1) - --> $DIR/test.rs:25:1 - | -LL | / async fn async_too_many_lines() { -LL | | println!("This is bad."); -LL | | println!("This is bad."); -LL | | } - | |_^ - -error: this function has too many lines (4/1) - --> $DIR/test.rs:31:1 - | -LL | / fn closure_too_many_lines() { -LL | | let _ = { -LL | | println!("This is bad."); -LL | | println!("This is bad."); -LL | | }; -LL | | } - | |_^ - -error: this function has too many lines (2/1) - --> $DIR/test.rs:53:1 - | -LL | / fn comment_before_code() { -LL | | let _ = "test"; -LL | | /* This comment extends to the front of -LL | | the code but this line should still count. */ let _ = 5; -LL | | } - | |_^ - -error: aborting due to 4 previous errors - diff --git a/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr b/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr deleted file mode 100644 index e9d8fd2e0f52..000000000000 --- a/tests/ui-toml/invalid_min_rust_version/invalid_min_rust_version.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: error reading Clippy's configuration file. `invalid.version` is not a valid Rust version - -error: aborting due to previous error - diff --git a/tests/ui-toml/large_include_file/large_include_file.stderr b/tests/ui-toml/large_include_file/large_include_file.stderr deleted file mode 100644 index 7b5fb9e87659..000000000000 --- a/tests/ui-toml/large_include_file/large_include_file.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: attempted to include a large file - --> $DIR/large_include_file.rs:13:43 - | -LL | const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the configuration allows a maximum size of 600 bytes - = note: `-D clippy::large-include-file` implied by `-D warnings` - = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: attempted to include a large file - --> $DIR/large_include_file.rs:14:35 - | -LL | const TOO_BIG_INCLUDE_STR: &str = include_str!("too_big.txt"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the configuration allows a maximum size of 600 bytes - = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors - diff --git a/tests/ui-toml/lint_decimal_readability/test.rs b/tests/ui-toml/lint_decimal_readability/test.rs index 2498672d77fb..bd5110138c8c 100644 --- a/tests/ui-toml/lint_decimal_readability/test.rs +++ b/tests/ui-toml/lint_decimal_readability/test.rs @@ -1,5 +1,5 @@ #![allow(clippy::excessive_precision)] -#[deny(clippy::unreadable_literal)] +#![warn(clippy::unreadable_literal)] fn allow_inconsistent_digit_grouping() { #![allow(clippy::inconsistent_digit_grouping)] diff --git a/tests/ui-toml/lint_decimal_readability/test.stderr b/tests/ui-toml/lint_decimal_readability/test.stderr index be505bda4792..fba4b2cee8ed 100644 --- a/tests/ui-toml/lint_decimal_readability/test.stderr +++ b/tests/ui-toml/lint_decimal_readability/test.stderr @@ -1,10 +1,38 @@ -error: digits grouped inconsistently by underscores +warning: long literal lacking separators + --> $DIR/test.rs:6:18 + | +LL | let _pass1 = 100_200_300.123456789; + | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789` + | +note: the lint level is defined here + --> $DIR/test.rs:2:9 + | +LL | #![warn(clippy::unreadable_literal)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: long literal lacking separators + --> $DIR/test.rs:13:18 + | +LL | let _pass2 = 1.123456789; + | ^^^^^^^^^^^ help: consider: `1.123_456_789` + +warning: long literal lacking separators + --> $DIR/test.rs:16:18 + | +LL | let _pass5 = 1.123456789e1; + | ^^^^^^^^^^^^^ help: consider: `1.123_456_789e1` + +warning: long literal lacking separators --> $DIR/test.rs:19:18 | LL | let _fail1 = 100_200_300.123456789; | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789` + +warning: long literal lacking separators + --> $DIR/test.rs:22:18 | - = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` +LL | let _fail2 = 100200300.300200100; + | ^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.300_200_100` -error: aborting due to previous error +warning: 5 warnings emitted diff --git a/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr b/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr deleted file mode 100644 index d319e65d06ce..000000000000 --- a/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: this binding can be a slice pattern to avoid indexing - --> $DIR/index_refutable_slice.rs:5:17 - | -LL | if let Some(slice) = slice { - | ^^^^^ - | -note: the lint level is defined here - --> $DIR/index_refutable_slice.rs:1:9 - | -LL | #![deny(clippy::index_refutable_slice)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: try using a slice pattern here - | -LL | if let Some([_, _, _, _, _, _, _, slice_7, ..]) = slice { - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -help: and replace the index expressions here - | -LL | println!("{}", slice_7); - | ~~~~~~~ - -error: aborting due to previous error - diff --git a/tests/ui-toml/min_rust_version/min_rust_version.rs b/tests/ui-toml/min_rust_version/min_rust_version.rs index 1e3ec123a3c8..e1dc3f4389c0 100644 --- a/tests/ui-toml/min_rust_version/min_rust_version.rs +++ b/tests/ui-toml/min_rust_version/min_rust_version.rs @@ -41,7 +41,7 @@ fn match_like_matches() { fn match_same_arms() { match (1, 2, 3) { (1, .., 3) => 42, - (.., 3) => 42, //~ ERROR match arms have same body + (.., 3) => 42, _ => 0, }; } @@ -49,7 +49,7 @@ fn match_same_arms() { fn match_same_arms2() { let _ = match Some(42) { Some(_) => 24, - None => 24, //~ ERROR match arms have same body + None => 24, }; } diff --git a/tests/ui-toml/min_rust_version/min_rust_version.stderr b/tests/ui-toml/min_rust_version/min_rust_version.stderr index 5dae5af7eb5a..e960c18b140e 100644 --- a/tests/ui-toml/min_rust_version/min_rust_version.stderr +++ b/tests/ui-toml/min_rust_version/min_rust_version.stderr @@ -1,10 +1,139 @@ -error: you are using an explicit closure for cloning elements +warning: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead + --> $DIR/min_rust_version.rs:28:13 + | +LL | let _ = opt.as_ref().map(String::as_str); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` + | + = note: `#[warn(clippy::option_as_ref_deref)]` on by default + +warning: called `.as_ref().map(|x| x.as_str())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead + --> $DIR/min_rust_version.rs:29:13 + | +LL | let _ = opt.as_ref().map(|x| x.as_str()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` + +warning: called `.as_mut().map(String::as_mut_str)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead + --> $DIR/min_rust_version.rs:30:13 + | +LL | let _ = opt.as_mut().map(String::as_mut_str); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()` + +warning: called `.as_mut().map(|x| x.as_mut_str())` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead + --> $DIR/min_rust_version.rs:31:13 + | +LL | let _ = opt.as_mut().map(|x| x.as_mut_str()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()` + +warning: match expression looks like `matches!` macro + --> $DIR/min_rust_version.rs:35:14 + | +LL | let _y = match Some(5) { + | ______________^ +LL | | Some(0) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try this: `matches!(Some(5), Some(0))` + | + = note: `#[warn(clippy::match_like_matches_macro)]` on by default + +warning: stripping a prefix manually + --> $DIR/min_rust_version.rs:59:20 + | +LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!"); + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the prefix was tested here + --> $DIR/min_rust_version.rs:58:5 + | +LL | if s.starts_with("hello, ") { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(clippy::manual_strip)]` on by default +help: try using the `strip_prefix` method + | +LL ~ if let Some() = s.strip_prefix("hello, ") { +LL ~ assert_eq!(.to_uppercase(), "WORLD!"); + | + +warning: you are using an explicit closure for copying elements --> $DIR/min_rust_version.rs:74:26 | LL | let _: Option = Some(&16).map(|b| *b); - | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()` + | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()` + | + = note: `#[warn(clippy::map_clone)]` on by default + +warning: borrow as raw pointer + --> $DIR/min_rust_version.rs:79:14 + | +LL | let _p = &val as *const i32; + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)` + | +note: the lint level is defined here + --> $DIR/min_rust_version.rs:2:40 + | +LL | #![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)] + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: borrow as raw pointer + --> $DIR/min_rust_version.rs:82:18 + | +LL | let _p_mut = &mut val_mut as *mut i32; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)` + +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits + --> $DIR/min_rust_version.rs:86:5 + | +LL | size_of::() * 8; + | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` + | +note: the lint level is defined here + --> $DIR/min_rust_version.rs:2:63 + | +LL | #![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this seems like a manual implementation of the non-exhaustive pattern + --> $DIR/min_rust_version.rs:8:5 + | +LL | enum E { + | ^----- + | | + | _____help: add the attribute: `#[non_exhaustive] enum E` + | | +LL | | A, +LL | | B, +LL | | #[doc(hidden)] +LL | | _C, +LL | | } + | |_____^ + | +help: remove this variant + --> $DIR/min_rust_version.rs:12:9 + | +LL | _C, + | ^^ +note: the lint level is defined here + --> $DIR/min_rust_version.rs:2:9 + | +LL | #![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: this seems like a manual implementation of the non-exhaustive pattern + --> $DIR/min_rust_version.rs:17:5 + | +LL | / enum Ep { +LL | | A, +LL | | B, +LL | | #[doc(hidden)] +LL | | _C, +LL | | } + | |_____^ + | +help: remove this variant + --> $DIR/min_rust_version.rs:21:9 | - = note: `-D clippy::map-clone` implied by `-D warnings` +LL | _C, + | ^^ -error: aborting due to previous error +warning: 12 warnings emitted diff --git a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr b/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr deleted file mode 100644 index 45de8fdffef7..000000000000 --- a/tests/ui-toml/missing_enforced_import_rename/conf_missing_enforced_import_rename.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:5:20 - | -LL | use std::process::{exit as wrong_exit, Child as Kid}; - | ^^^^^^^^^^^^^^^^^^ help: try: `exit as goodbye` - | - = note: `-D clippy::missing-enforced-import-renames` implied by `-D warnings` - -error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:6:1 - | -LL | use std::thread::sleep; - | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::thread::sleep as thread_sleep` - -error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:9:11 - | -LL | any::{type_name, Any}, - | ^^^^^^^^^ help: try: `type_name as ident` - -error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:10:5 - | -LL | clone, - | ^^^^^ help: try: `clone as foo` - -error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:11:5 - | -LL | sync :: Mutex, - | ^^^^^^^^^^^^^ help: try: `sync :: Mutex as StdMutie` - -error: this import should be renamed - --> $DIR/conf_missing_enforced_import_rename.rs:15:5 - | -LL | use std::collections::BTreeMap as OopsWrongRename; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `use std::collections::BTreeMap as Map` - -error: aborting due to 6 previous errors - diff --git a/tests/ui-toml/mut_key/mut_key.rs b/tests/ui-toml/mut_key/mut_key.rs index 667c51cb4a3f..095e0d15448a 100644 --- a/tests/ui-toml/mut_key/mut_key.rs +++ b/tests/ui-toml/mut_key/mut_key.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name mut_key +//@compile-flags: --crate-name mut_key #![warn(clippy::mutable_key_type)] diff --git a/tests/ui-toml/mut_key/mut_key.stderr b/tests/ui-toml/mut_key/mut_key.stderr new file mode 100644 index 000000000000..eff7e4fac37b --- /dev/null +++ b/tests/ui-toml/mut_key/mut_key.stderr @@ -0,0 +1,14 @@ +warning: mutable key type + --> $DIR/mut_key.rs:49:33 + | +LL | fn should_not_take_this_arg(_v: HashSet>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/mut_key.rs:3:9 + | +LL | #![warn(clippy::mutable_key_type)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui-toml/nonstandard_macro_braces/auxiliary/proc_macro_derive.rs b/tests/ui-toml/nonstandard_macro_braces/auxiliary/proc_macro_derive.rs index 6452189a4615..d7adc3a68f9c 100644 --- a/tests/ui-toml/nonstandard_macro_braces/auxiliary/proc_macro_derive.rs +++ b/tests/ui-toml/nonstandard_macro_braces/auxiliary/proc_macro_derive.rs @@ -1,6 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic - #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed index 01d135764dff..79899acb93d0 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.fixed @@ -1,5 +1,5 @@ -// aux-build:proc_macro_derive.rs -// run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro +//@run-rustfix #![warn(clippy::nonstandard_macro_braces)] @@ -44,8 +44,8 @@ fn main() { let _ = vec![1, 2, 3]; let _ = format!("ugh {} stop being such a good compiler", "hello"); let _ = matches!({}, ()); - let _ = quote!{let x = 1;}; - let _ = quote::quote!{match match match}; + let _ = quote!(let x = 1;); + let _ = quote::quote!(match match match); let _ = test!(); // trigger when macro def is inside our own crate let _ = vec![1,2,3]; @@ -54,9 +54,9 @@ fn main() { let _ = format!("fds{}fds", 10); let _ = test2!["{}{}{}", 1, 2, 3]; - let _: type_pos![usize] = vec![]; + let _: type_pos!(usize) = vec![]; - eprint!["test if user config overrides defaults"]; + eprint!("test if user config overrides defaults"); printlnfoo!["test if printlnfoo is triggered by println"]; } diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs index 72883e8270c3..95d1a2297e53 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.rs @@ -1,5 +1,5 @@ -// aux-build:proc_macro_derive.rs -// run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro +//@run-rustfix #![warn(clippy::nonstandard_macro_braces)] diff --git a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr index 7ae3815978c7..32f8f763ccc2 100644 --- a/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr +++ b/tests/ui-toml/nonstandard_macro_braces/conf_nonstandard_macro_braces.stderr @@ -1,36 +1,28 @@ -error: use of irregular braces for `vec!` macro +warning: use of irregular braces for `vec!` macro --> $DIR/conf_nonstandard_macro_braces.rs:44:13 | LL | let _ = vec! {1, 2, 3}; | ^^^^^^^^^^^^^^ help: consider writing: `vec![1, 2, 3]` | - = note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/conf_nonstandard_macro_braces.rs:4:9 + | +LL | #![warn(clippy::nonstandard_macro_braces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of irregular braces for `format!` macro +warning: use of irregular braces for `format!` macro --> $DIR/conf_nonstandard_macro_braces.rs:45:13 | LL | let _ = format!["ugh {} stop being such a good compiler", "hello"]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `format!("ugh {} stop being such a good compiler", "hello")` -error: use of irregular braces for `matches!` macro +warning: use of irregular braces for `matches!` macro --> $DIR/conf_nonstandard_macro_braces.rs:46:13 | LL | let _ = matches!{{}, ()}; | ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())` -error: use of irregular braces for `quote!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:47:13 - | -LL | let _ = quote!(let x = 1;); - | ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}` - -error: use of irregular braces for `quote::quote!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:48:13 - | -LL | let _ = quote::quote!(match match match); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}` - -error: use of irregular braces for `vec!` macro +warning: use of irregular braces for `vec!` macro --> $DIR/conf_nonstandard_macro_braces.rs:19:9 | LL | vec!{0, 0, 0} @@ -39,19 +31,7 @@ LL | vec!{0, 0, 0} LL | let _ = test!(); // trigger when macro def is inside our own crate | ------- in this macro invocation | - = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: use of irregular braces for `type_pos!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:57:12 - | -LL | let _: type_pos!(usize) = vec![]; - | ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]` - -error: use of irregular braces for `eprint!` macro - --> $DIR/conf_nonstandard_macro_braces.rs:59:5 - | -LL | eprint!("test if user config overrides defaults"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `eprint!["test if user config overrides defaults"]` + = note: this warning originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 8 previous errors +warning: 4 warnings emitted diff --git a/tests/ui-toml/print_macro/print_macro.rs b/tests/ui-toml/print_macro/print_macro.rs index 5aefb6a6b4d4..3a8b30cca36a 100644 --- a/tests/ui-toml/print_macro/print_macro.rs +++ b/tests/ui-toml/print_macro/print_macro.rs @@ -1,4 +1,4 @@ -// compile-flags: --test +//@compile-flags: --test #![warn(clippy::print_stdout)] #![warn(clippy::print_stderr)] diff --git a/tests/ui-toml/print_macro/print_macro.stderr b/tests/ui-toml/print_macro/print_macro.stderr index d4b1ae84fd7d..338af48de678 100644 --- a/tests/ui-toml/print_macro/print_macro.stderr +++ b/tests/ui-toml/print_macro/print_macro.stderr @@ -1,18 +1,50 @@ -error: use of `print!` +warning: use of `print!` --> $DIR/print_macro.rs:6:5 | LL | print!("{n}"); | ^^^^^^^^^^^^^ | - = note: `-D clippy::print-stdout` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print_macro.rs:2:9 + | +LL | #![warn(clippy::print_stdout)] + | ^^^^^^^^^^^^^^^^^^^^ -error: use of `eprint!` +warning: use of `eprint!` --> $DIR/print_macro.rs:7:5 | LL | eprint!("{n}"); | ^^^^^^^^^^^^^^ | - = note: `-D clippy::print-stderr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print_macro.rs:3:9 + | +LL | #![warn(clippy::print_stderr)] + | ^^^^^^^^^^^^^^^^^^^^ + +warning: use of `print!` + --> $DIR/print_macro.rs:12:5 + | +LL | print!("{}", 1); + | ^^^^^^^^^^^^^^^ + +warning: use of `eprint!` + --> $DIR/print_macro.rs:13:5 + | +LL | eprint!("{}", 1); + | ^^^^^^^^^^^^^^^^ + +warning: use of `print!` + --> $DIR/print_macro.rs:18:5 + | +LL | print!("{}", 1); + | ^^^^^^^^^^^^^^^ + +warning: use of `eprint!` + --> $DIR/print_macro.rs:19:5 + | +LL | eprint!("{}", 1); + | ^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 6 warnings emitted diff --git a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr index a474187050c1..2d1d4a384f7d 100644 --- a/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr +++ b/tests/ui-toml/pub_crate_missing_docs/pub_crate_missing_doc.stderr @@ -1,30 +1,70 @@ -error: missing documentation for a function +warning: missing documentation for a function + --> $DIR/pub_crate_missing_doc.rs:9:5 + | +LL | fn priv_no_docs() {} + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/pub_crate_missing_doc.rs:3:9 + | +LL | #![warn(clippy::missing_docs_in_private_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: missing documentation for a function --> $DIR/pub_crate_missing_doc.rs:12:5 | LL | pub(crate) fn crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` -error: missing documentation for a function +warning: missing documentation for a function --> $DIR/pub_crate_missing_doc.rs:15:5 | LL | pub(super) fn super_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a function +warning: missing documentation for a module + --> $DIR/pub_crate_missing_doc.rs:17:5 + | +LL | / mod my_sub { +LL | | /// some docs +LL | | fn sub_priv_with_docs() {} +LL | | fn sub_priv_no_docs() {} +... | +LL | | pub(super) fn sub_super_no_docs() {} +LL | | } + | |_____^ + +warning: missing documentation for a function + --> $DIR/pub_crate_missing_doc.rs:20:9 + | +LL | fn sub_priv_no_docs() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: missing documentation for a function --> $DIR/pub_crate_missing_doc.rs:23:9 | LL | pub(crate) fn sub_crate_no_docs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a struct field +warning: missing documentation for a function + --> $DIR/pub_crate_missing_doc.rs:26:9 + | +LL | pub(super) fn sub_super_no_docs() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: missing documentation for a struct field --> $DIR/pub_crate_missing_doc.rs:33:9 | LL | pub(crate) crate_field_no_docs: (), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a struct +warning: missing documentation for a struct field + --> $DIR/pub_crate_missing_doc.rs:36:9 + | +LL | priv_field_no_docs: (), + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: missing documentation for a struct --> $DIR/pub_crate_missing_doc.rs:39:5 | LL | / pub(crate) struct CrateStructNoDocs { @@ -36,17 +76,23 @@ LL | | priv_field_no_docs: (), LL | | } | |_____^ -error: missing documentation for a struct field +warning: missing documentation for a struct field --> $DIR/pub_crate_missing_doc.rs:42:9 | LL | pub(crate) crate_field_no_docs: (), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a type alias +warning: missing documentation for a struct field + --> $DIR/pub_crate_missing_doc.rs:45:9 + | +LL | priv_field_no_docs: (), + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: missing documentation for a type alias --> $DIR/pub_crate_missing_doc.rs:51:1 | LL | type CrateTypedefNoDocs = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 13 warnings emitted diff --git a/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr index c72f8c6488db..d5dae73af6a3 100644 --- a/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr +++ b/tests/ui-toml/strict_non_send_fields_in_send_ty/test.stderr @@ -1,4 +1,4 @@ -error: some fields in `NoGeneric` are not safe to be sent to another thread +warning: some fields in `NoGeneric` are not safe to be sent to another thread --> $DIR/test.rs:11:1 | LL | unsafe impl Send for NoGeneric {} @@ -10,9 +10,13 @@ note: it is not safe to send field `rc_is_not_send` to another thread LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` - = note: `-D clippy::non-send-fields-in-send-ty` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/test.rs:1:9 + | +LL | #![warn(clippy::non_send_fields_in_send_ty)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: some fields in `MultiField` are not safe to be sent to another thread +warning: some fields in `MultiField` are not safe to be sent to another thread --> $DIR/test.rs:19:1 | LL | unsafe impl Send for MultiField {} @@ -37,7 +41,7 @@ LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl -error: some fields in `MyOption` are not safe to be sent to another thread +warning: some fields in `MyOption` are not safe to be sent to another thread --> $DIR/test.rs:26:1 | LL | unsafe impl Send for MyOption {} @@ -50,42 +54,18 @@ LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl -error: some fields in `HeuristicTest` are not safe to be sent to another thread +warning: some fields in `HeuristicTest` are not safe to be sent to another thread --> $DIR/test.rs:41:1 | LL | unsafe impl Send for HeuristicTest {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: it is not safe to send field `field1` to another thread - --> $DIR/test.rs:34:5 - | -LL | field1: Vec<*const NonSend>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use a thread-safe type that implements `Send` -note: it is not safe to send field `field2` to another thread - --> $DIR/test.rs:35:5 - | -LL | field2: [*const NonSend; 3], - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use a thread-safe type that implements `Send` -note: it is not safe to send field `field3` to another thread - --> $DIR/test.rs:36:5 - | -LL | field3: (*const NonSend, *const NonSend, *const NonSend), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use a thread-safe type that implements `Send` note: it is not safe to send field `field4` to another thread --> $DIR/test.rs:37:5 | LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` -note: it is not safe to send field `field5` to another thread - --> $DIR/test.rs:38:5 - | -LL | field5: Vec>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use a thread-safe type that implements `Send` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui-toml/struct_excessive_bools/test.stderr b/tests/ui-toml/struct_excessive_bools/test.stderr deleted file mode 100644 index 4e7c70d18385..000000000000 --- a/tests/ui-toml/struct_excessive_bools/test.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: more than 0 bools in a struct - --> $DIR/test.rs:3:1 - | -LL | / struct S { -LL | | a: bool, -LL | | } - | |_^ - | - = help: consider using a state machine or refactoring bools into two-variant enums - = note: `-D clippy::struct-excessive-bools` implied by `-D warnings` - -error: aborting due to previous error - diff --git a/tests/ui-toml/suppress_lint_in_const/test.rs b/tests/ui-toml/suppress_lint_in_const/test.rs index 5a2df9f6c5d9..eaa628db183a 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.rs +++ b/tests/ui-toml/suppress_lint_in_const/test.rs @@ -8,6 +8,7 @@ const ARR: [i32; 2] = [1, 2]; const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. +//~^ ERROR: failed const fn idx() -> usize { 1 @@ -29,6 +30,8 @@ fn main() { x[const { idx4() }]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays. const { &ARR[idx()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. + // + //~^^ ERROR: failed let y = &x; y[0]; // Ok, referencing shouldn't affect this lint. See the issue 6021 diff --git a/tests/ui-toml/suppress_lint_in_const/test.stderr b/tests/ui-toml/suppress_lint_in_const/test.stderr index bc178b7e1319..73fd9e23e617 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -1,70 +1,119 @@ +warning: indexing may panic + --> $DIR/test.rs:9:20 + | +LL | const REF: &i32 = &ARR[idx()]; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. + | ^^^^^^^^^^ + | + = help: consider using `.get(n)` or `.get_mut(n)` instead + = note: the suggestion might not be applicable in constant blocks +note: the lint level is defined here + --> $DIR/test.rs:2:9 + | +LL | #![warn(clippy::indexing_slicing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: indexing may panic + --> $DIR/test.rs:10:24 + | +LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. + | ^^^^^^^^^^^ + | + = help: consider using `.get(n)` or `.get_mut(n)` instead + = note: the suggestion might not be applicable in constant blocks + error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/test.rs:31:14 + --> $DIR/test.rs:32:14 | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant used - --> $DIR/test.rs:31:5 + --> $DIR/test.rs:32:5 | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^^^^^^^^^^^^ -error: indexing may panic - --> $DIR/test.rs:22:5 +warning: indexing may panic + --> $DIR/test.rs:23:5 | LL | x[index]; | ^^^^^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead - = note: `-D clippy::indexing-slicing` implied by `-D warnings` -error: indexing may panic - --> $DIR/test.rs:38:5 +warning: indexing may panic + --> $DIR/test.rs:31:14 + | +LL | const { &ARR[idx()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. + | ^^^^^^^^^^ + | + = help: consider using `.get(n)` or `.get_mut(n)` instead + = note: the suggestion might not be applicable in constant blocks + +warning: indexing may panic + --> $DIR/test.rs:32:14 + | +LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. + | ^^^^^^^^^^^ + | + = help: consider using `.get(n)` or `.get_mut(n)` instead + = note: the suggestion might not be applicable in constant blocks + +warning: indexing may panic + --> $DIR/test.rs:41:5 | LL | v[0]; | ^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/test.rs:39:5 +warning: indexing may panic + --> $DIR/test.rs:42:5 | LL | v[10]; | ^^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/test.rs:40:5 +warning: indexing may panic + --> $DIR/test.rs:43:5 | LL | v[1 << 3]; | ^^^^^^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/test.rs:46:5 +warning: indexing may panic + --> $DIR/test.rs:49:5 | LL | v[N]; | ^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/test.rs:47:5 +warning: indexing may panic + --> $DIR/test.rs:50:5 | LL | v[M]; | ^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead +warning: indexing may panic + --> $DIR/test.rs:61:9 + | +LL | self.value[0] & 0b1000_0000 != 0 + | ^^^^^^^^^^^^^ + | + = help: consider using `.get(n)` or `.get_mut(n)` instead + = note: the suggestion might not be applicable in constant blocks + error[E0080]: evaluation of constant value failed --> $DIR/test.rs:10:24 | LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 -error: aborting due to 8 previous errors +error: aborting due to 2 previous errors; 11 warnings emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr b/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr deleted file mode 100644 index 9082c1c54c36..000000000000 --- a/tests/ui-toml/toml_disallow/conf_french_disallowed_name.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error: use of a disallowed/placeholder name `toto` - --> $DIR/conf_french_disallowed_name.rs:6:9 - | -LL | fn test(toto: ()) {} - | ^^^^ - | - = note: `-D clippy::disallowed-names` implied by `-D warnings` - -error: use of a disallowed/placeholder name `toto` - --> $DIR/conf_french_disallowed_name.rs:9:9 - | -LL | let toto = 42; - | ^^^^ - -error: use of a disallowed/placeholder name `tata` - --> $DIR/conf_french_disallowed_name.rs:10:9 - | -LL | let tata = 42; - | ^^^^ - -error: use of a disallowed/placeholder name `titi` - --> $DIR/conf_french_disallowed_name.rs:11:9 - | -LL | let titi = 42; - | ^^^^ - -error: use of a disallowed/placeholder name `toto` - --> $DIR/conf_french_disallowed_name.rs:17:10 - | -LL | (toto, Some(tata), titi @ Some(_)) => (), - | ^^^^ - -error: use of a disallowed/placeholder name `tata` - --> $DIR/conf_french_disallowed_name.rs:17:21 - | -LL | (toto, Some(tata), titi @ Some(_)) => (), - | ^^^^ - -error: use of a disallowed/placeholder name `titi` - --> $DIR/conf_french_disallowed_name.rs:17:28 - | -LL | (toto, Some(tata), titi @ Some(_)) => (), - | ^^^^ - -error: aborting due to 7 previous errors - diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs index 2f3160c83383..8e1a1710a6ce 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name conf_disallowed_methods +//@compile-flags: --crate-name conf_disallowed_methods #![warn(clippy::disallowed_methods)] diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr deleted file mode 100644 index 148d1cae51f1..000000000000 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr +++ /dev/null @@ -1,90 +0,0 @@ -error: use of a disallowed method `regex::Regex::new` - --> $DIR/conf_disallowed_methods.rs:33:14 - | -LL | let re = Regex::new(r"ab.*c").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::disallowed-methods` implied by `-D warnings` - -error: use of a disallowed method `regex::Regex::is_match` - --> $DIR/conf_disallowed_methods.rs:34:5 - | -LL | re.is_match("abc"); - | ^^^^^^^^^^^^^^^^^^ - | - = note: no matching allowed (from clippy.toml) - -error: use of a disallowed method `std::iter::Iterator::sum` - --> $DIR/conf_disallowed_methods.rs:37:5 - | -LL | a.iter().sum::(); - | ^^^^^^^^^^^^^^^^^^^^^ - -error: use of a disallowed method `slice::sort_unstable` - --> $DIR/conf_disallowed_methods.rs:39:5 - | -LL | a.sort_unstable(); - | ^^^^^^^^^^^^^^^^^ - -error: use of a disallowed method `f32::clamp` - --> $DIR/conf_disallowed_methods.rs:41:13 - | -LL | let _ = 2.0f32.clamp(3.0f32, 4.0f32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: use of a disallowed method `regex::Regex::new` - --> $DIR/conf_disallowed_methods.rs:44:61 - | -LL | let indirect: fn(&str) -> Result = Regex::new; - | ^^^^^^^^^^ - -error: use of a disallowed method `f32::clamp` - --> $DIR/conf_disallowed_methods.rs:47:28 - | -LL | let in_call = Box::new(f32::clamp); - | ^^^^^^^^^^ - -error: use of a disallowed method `regex::Regex::new` - --> $DIR/conf_disallowed_methods.rs:48:53 - | -LL | let in_method_call = ["^", "$"].into_iter().map(Regex::new); - | ^^^^^^^^^^ - -error: use of a disallowed method `futures::stream::select_all` - --> $DIR/conf_disallowed_methods.rs:51:31 - | -LL | let same_name_as_module = select_all(vec![empty::<()>()]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: use of a disallowed method `conf_disallowed_methods::local_fn` - --> $DIR/conf_disallowed_methods.rs:53:5 - | -LL | local_fn(); - | ^^^^^^^^^^ - -error: use of a disallowed method `conf_disallowed_methods::local_mod::f` - --> $DIR/conf_disallowed_methods.rs:54:5 - | -LL | local_mod::f(); - | ^^^^^^^^^^^^^^ - -error: use of a disallowed method `conf_disallowed_methods::Struct::method` - --> $DIR/conf_disallowed_methods.rs:56:5 - | -LL | s.method(); - | ^^^^^^^^^^ - -error: use of a disallowed method `conf_disallowed_methods::Trait::provided_method` - --> $DIR/conf_disallowed_methods.rs:57:5 - | -LL | s.provided_method(); - | ^^^^^^^^^^^^^^^^^^^ - -error: use of a disallowed method `conf_disallowed_methods::Trait::implemented_method` - --> $DIR/conf_disallowed_methods.rs:58:5 - | -LL | s.implemented_method(); - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 14 previous errors - diff --git a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr b/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr deleted file mode 100644 index e3ece799c7ce..000000000000 --- a/tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr +++ /dev/null @@ -1,132 +0,0 @@ -error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:7:1 - | -LL | use std::sync::atomic::AtomicU32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::disallowed-types` implied by `-D warnings` - -error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:8:1 - | -LL | use std::time::Instant as Sneaky; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:12:33 - | -LL | fn bad_return_type() -> fn() -> Sneaky { - | ^^^^^^ - -error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:16:28 - | -LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} - | ^^^^^^ - -error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:16:39 - | -LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: `std::io::Read` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:18:22 - | -LL | fn trait_obj(_: &dyn std::io::Read) {} - | ^^^^^^^^^^^^^ - -error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:20:33 - | -LL | fn full_and_single_path_prim(_: usize, _: bool) {} - | ^^^^^ - -error: `bool` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:20:43 - | -LL | fn full_and_single_path_prim(_: usize, _: bool) {} - | ^^^^ - -error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:22:28 - | -LL | fn const_generics() {} - | ^^^^^ - -error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:24:24 - | -LL | struct GenArg([u8; U]); - | ^^^^^ - -error: `std::net::Ipv4Addr` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:28:10 - | -LL | fn ip(_: std::net::Ipv4Addr) {} - | ^^^^^^^^^^^^^^^^^^ - | - = note: no IPv4 allowed (from clippy.toml) - -error: `std::net::TcpListener` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:30:16 - | -LL | fn listener(_: std::net::TcpListener) {} - | ^^^^^^^^^^^^^^^^^^^^^ - -error: `std::collections::HashMap` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:34:48 - | -LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `std::collections::HashMap` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:34:12 - | -LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `std::time::Instant` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:35:13 - | -LL | let _ = Sneaky::now(); - | ^^^^^^ - -error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:36:13 - | -LL | let _ = foo::atomic::AtomicU32::new(0); - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:37:17 - | -LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `std::sync::atomic::AtomicU32` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:37:48 - | -LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1); - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: `syn::TypePath` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:38:43 - | -LL | let _: std::collections::BTreeMap<(), syn::TypePath> = Default::default(); - | ^^^^^^^^^^^^^ - -error: `syn::Ident` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:39:13 - | -LL | let _ = syn::Ident::new("", todo!()); - | ^^^^^^^^^^ - -error: `usize` is not allowed according to config - --> $DIR/conf_disallowed_types.rs:41:12 - | -LL | let _: usize = 64_usize; - | ^^^^^ - -error: aborting due to 21 previous errors - diff --git a/tests/ui-toml/toml_trivially_copy/test.rs b/tests/ui-toml/toml_trivially_copy/test.rs index fb0e226f3aa4..f267a67f40ee 100644 --- a/tests/ui-toml/toml_trivially_copy/test.rs +++ b/tests/ui-toml/toml_trivially_copy/test.rs @@ -1,7 +1,7 @@ -// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)" -// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)" +//@normalize-stderr-test: "\(\d+ byte\)" -> "(N byte)" +//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)" -#![deny(clippy::trivially_copy_pass_by_ref)] +#![warn(clippy::trivially_copy_pass_by_ref)] #[derive(Copy, Clone)] struct Foo(u8); diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index b3ef5928e8ea..fea01604ca93 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,20 +1,32 @@ -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) - --> $DIR/test.rs:14:11 +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) + --> $DIR/test.rs:12:33 | -LL | fn bad(x: &u16, y: &Foo) {} - | ^^^^ help: consider passing by value instead: `u16` +LL | fn good(a: &mut u32, b: u32, c: &Bar, d: &u32) {} + | ^^^^ help: consider passing by value instead: `Bar` | note: the lint level is defined here --> $DIR/test.rs:4:9 | -LL | #![deny(clippy::trivially_copy_pass_by_ref)] +LL | #![warn(clippy::trivially_copy_pass_by_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) + --> $DIR/test.rs:12:42 + | +LL | fn good(a: &mut u32, b: u32, c: &Bar, d: &u32) {} + | ^^^^ help: consider passing by value instead: `u32` + +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) + --> $DIR/test.rs:14:11 + | +LL | fn bad(x: &u16, y: &Foo) {} + | ^^^^ help: consider passing by value instead: `u16` + +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/test.rs:14:20 | LL | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` -error: aborting due to 2 previous errors +warning: 4 warnings emitted diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr deleted file mode 100644 index 6a246afac76e..000000000000 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of - allow-dbg-in-tests - allow-expect-in-tests - allow-mixed-uninlined-format-args - allow-print-in-tests - allow-unwrap-in-tests - allowed-scripts - arithmetic-side-effects-allowed - arithmetic-side-effects-allowed-binary - arithmetic-side-effects-allowed-unary - array-size-threshold - avoid-breaking-exported-api - await-holding-invalid-types - blacklisted-names - cargo-ignore-publish - cognitive-complexity-threshold - cyclomatic-complexity-threshold - disallowed-macros - disallowed-methods - disallowed-names - disallowed-types - doc-valid-idents - enable-raw-pointer-heuristic-for-send - enforced-import-renames - enum-variant-name-threshold - enum-variant-size-threshold - ignore-interior-mutability - large-error-threshold - literal-representation-threshold - matches-for-let-else - max-fn-params-bools - max-include-file-size - max-struct-bools - max-suggested-slice-pattern-length - max-trait-bounds - missing-docs-in-crate-items - msrv - pass-by-value-size-limit - single-char-binding-names-threshold - standard-macro-braces - suppress-restriction-lint-in-const - third-party - too-large-for-stack - too-many-arguments-threshold - too-many-lines-threshold - trivial-copy-size-limit - type-complexity-threshold - unreadable-literal-lint-fractions - upper-case-acronyms-aggressive - vec-box-size-threshold - verbose-bit-mask-threshold - warn-on-all-wildcard-imports - at line 5 column 1 - -error: aborting due to previous error - diff --git a/tests/ui-toml/unwrap_used/unwrap_used.rs b/tests/ui-toml/unwrap_used/unwrap_used.rs index 6525ea5bfc3f..3ec32458e349 100644 --- a/tests/ui-toml/unwrap_used/unwrap_used.rs +++ b/tests/ui-toml/unwrap_used/unwrap_used.rs @@ -1,8 +1,8 @@ -// compile-flags: --test +//@compile-flags: --test #![allow(unused_mut, clippy::get_first, clippy::from_iter_instead_of_collect)] #![warn(clippy::unwrap_used)] -#![deny(clippy::get_unwrap)] +#![warn(clippy::get_unwrap)] use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/tests/ui-toml/unwrap_used/unwrap_used.stderr b/tests/ui-toml/unwrap_used/unwrap_used.stderr index 8a32750e3c92..49a5bf9866c0 100644 --- a/tests/ui-toml/unwrap_used/unwrap_used.stderr +++ b/tests/ui-toml/unwrap_used/unwrap_used.stderr @@ -1,4 +1,4 @@ -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:35:17 | LL | let _ = boxed_slice.get(1).unwrap(); @@ -7,25 +7,29 @@ LL | let _ = boxed_slice.get(1).unwrap(); note: the lint level is defined here --> $DIR/unwrap_used.rs:5:9 | -LL | #![deny(clippy::get_unwrap)] +LL | #![warn(clippy::get_unwrap)] | ^^^^^^^^^^^^^^^^^^ -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:35:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message - = note: `-D clippy::unwrap-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap_used.rs:4:9 + | +LL | #![warn(clippy::unwrap_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:36:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:36:17 | LL | let _ = some_slice.get(0).unwrap(); @@ -33,13 +37,13 @@ LL | let _ = some_slice.get(0).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:37:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:37:17 | LL | let _ = some_vec.get(0).unwrap(); @@ -47,13 +51,13 @@ LL | let _ = some_vec.get(0).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:38:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:38:17 | LL | let _ = some_vecdeque.get(0).unwrap(); @@ -61,13 +65,13 @@ LL | let _ = some_vecdeque.get(0).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:39:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:39:17 | LL | let _ = some_hashmap.get(&1).unwrap(); @@ -75,13 +79,13 @@ LL | let _ = some_hashmap.get(&1).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:40:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:40:17 | LL | let _ = some_btreemap.get(&1).unwrap(); @@ -89,13 +93,13 @@ LL | let _ = some_btreemap.get(&1).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:44:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:44:22 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); @@ -103,13 +107,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:49:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:49:10 | LL | *boxed_slice.get_mut(0).unwrap() = 1; @@ -117,13 +121,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:50:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:50:10 | LL | *some_slice.get_mut(0).unwrap() = 1; @@ -131,13 +135,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:51:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:51:10 | LL | *some_vec.get_mut(0).unwrap() = 1; @@ -145,13 +149,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:52:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:52:10 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; @@ -159,13 +163,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:64:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:64:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); @@ -173,13 +177,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:65:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:65:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); @@ -187,17 +191,49 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:72:13 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]` -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: used `unwrap()` on an `Option` value + --> $DIR/unwrap_used.rs:72:13 + | +LL | let _ = boxed_slice.get(1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message + +warning: used `unwrap()` on a `Result` value + --> $DIR/unwrap_used.rs:80:22 + | +LL | let _a: u8 = 2.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message + +warning: used `unwrap()` on a `Result` value + --> $DIR/unwrap_used.rs:87:22 + | +LL | let _a: u8 = 4.try_into().unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message + +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/unwrap_used.rs:90:17 | LL | let _ = Box::new([0]).get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&Box::new([0])[1]` -error: aborting due to 28 previous errors +warning: used `unwrap()` on an `Option` value + --> $DIR/unwrap_used.rs:90:17 + | +LL | let _ = Box::new([0]).get(1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message + +warning: 32 warnings emitted diff --git a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr index 02f29bbefe14..3c3462940e13 100644 --- a/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr +++ b/tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr @@ -1,82 +1,74 @@ -error: name `HTTPResponse` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:3:8 - | -LL | struct HTTPResponse; // not linted by default, but with cfg option - | ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse` - | - = note: `-D clippy::upper-case-acronyms` implied by `-D warnings` - -error: name `NS` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:8:5 - | -LL | NS, // not linted - | ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns` - -error: name `CWR` contains a capitalized acronym +warning: name `CWR` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:9:5 | LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` + | +note: the lint level is defined here + --> $DIR/upper_case_acronyms.rs:1:9 + | +LL | #![warn(clippy::upper_case_acronyms)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: name `ECE` contains a capitalized acronym +warning: name `ECE` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:10:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` -error: name `URG` contains a capitalized acronym +warning: name `URG` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:11:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` -error: name `ACK` contains a capitalized acronym +warning: name `ACK` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:12:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` -error: name `PSH` contains a capitalized acronym +warning: name `PSH` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:13:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` -error: name `RST` contains a capitalized acronym +warning: name `RST` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:14:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` -error: name `SYN` contains a capitalized acronym +warning: name `SYN` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:15:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` -error: name `FIN` contains a capitalized acronym +warning: name `FIN` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:16:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` -error: name `GCCLLVMSomething` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:21:8 +warning: name `FULLCAPITAL` contains a capitalized acronym + --> $DIR/upper_case_acronyms.rs:26:12 + | +LL | pub struct FULLCAPITAL; + | ^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `Fullcapital` + +warning: name `FULLCAPITAL` contains a capitalized acronym + --> $DIR/upper_case_acronyms.rs:30:5 | -LL | struct GCCLLVMSomething; - | ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething` +LL | FULLCAPITAL(u8), + | ^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `Fullcapital` -error: name `WASD` contains a capitalized acronym +warning: name `WASD` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:38:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` -error: name `WASDMixed` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:39:5 - | -LL | WASDMixed(String), - | ^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `WasdMixed` - -error: aborting due to 13 previous errors +warning: 11 warnings emitted diff --git a/tests/ui-toml/vec_box_sized/test.stderr b/tests/ui-toml/vec_box_sized/test.stderr index 55de68f8ecf4..a315a22dca5c 100644 --- a/tests/ui-toml/vec_box_sized/test.stderr +++ b/tests/ui-toml/vec_box_sized/test.stderr @@ -1,22 +1,40 @@ -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/test.rs:9:12 | LL | struct Foo(Vec>); | ^^^^^^^^^^^^ help: try: `Vec` | - = note: `-D clippy::vec-box` implied by `-D warnings` + = note: `#[warn(clippy::vec_box)]` on by default -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/test.rs:10:12 | LL | struct Bar(Vec>); | ^^^^^^^^^^^^^ help: try: `Vec` -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary + --> $DIR/test.rs:11:13 + | +LL | struct Quux(Vec>); + | ^^^^^^^^^^^^^ help: try: `Vec` + +warning: `Vec` is already on the heap, the boxing is unnecessary + --> $DIR/test.rs:12:12 + | +LL | struct Baz(Vec>); + | ^^^^^^^^^^^^^^^^^^^^ help: try: `Vec<(u16, u16)>` + +warning: `Vec` is already on the heap, the boxing is unnecessary + --> $DIR/test.rs:13:15 + | +LL | struct BarBaz(Vec>); + | ^^^^^^^^^^^ help: try: `Vec` + +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/test.rs:14:18 | LL | struct FooBarBaz(Vec>); | ^^^^^^^^^^^ help: try: `Vec` -error: aborting due to 3 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index f682b280c1b8..4509fd394bf6 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -1,4 +1,4 @@ -#![warn(clippy::absurd_extreme_comparisons)] +#![warn(clippy::absurd_extreme_comparisons, clippy::unit_cmp)] #![allow( unused, clippy::eq_op, diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 21cb11fa1bb8..7626ef6f4c66 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,13 +1,17 @@ -error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false +warning: 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:14:5 | LL | u <= 0; | ^^^^^^ | = 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 - = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/absurd-extreme-comparisons.rs:1:9 + | +LL | #![warn(clippy::absurd_extreme_comparisons, clippy::unit_cmp)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false +warning: 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 | LL | u <= Z; @@ -15,7 +19,7 @@ LL | 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 +warning: 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:16:5 | LL | u < Z; @@ -23,7 +27,7 @@ LL | 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 +warning: 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:17:5 | LL | Z >= u; @@ -31,7 +35,7 @@ LL | 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 +warning: 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 | LL | Z > u; @@ -39,7 +43,7 @@ LL | 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 +warning: 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:19:5 | LL | u > u32::MAX; @@ -47,7 +51,7 @@ LL | u > u32::MAX; | = help: because `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 +warning: 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:20:5 | LL | u >= u32::MAX; @@ -55,7 +59,7 @@ LL | u >= u32::MAX; | = help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == 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 +warning: 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 | LL | u32::MAX < u; @@ -63,7 +67,7 @@ LL | u32::MAX < u; | = help: because `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 +warning: 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:22:5 | LL | u32::MAX <= u; @@ -71,7 +75,7 @@ LL | u32::MAX <= u; | = help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `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 +warning: 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:23:5 | LL | 1-1 > u; @@ -79,7 +83,7 @@ LL | 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 +warning: 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 | LL | u >= !0; @@ -87,7 +91,7 @@ LL | 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 +warning: 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:25:5 | LL | u <= 12 - 2*6; @@ -95,7 +99,7 @@ LL | 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 +warning: 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 | LL | i < -127 - 1; @@ -103,7 +107,7 @@ LL | 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 +warning: 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:28:5 | LL | i8::MAX >= i; @@ -111,7 +115,7 @@ LL | i8::MAX >= i; | = help: because `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 +warning: 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:29:5 | LL | 3-7 < i32::MIN; @@ -119,7 +123,7 @@ LL | 3-7 < i32::MIN; | = help: because `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 +warning: 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:31:5 | LL | b >= true; @@ -127,7 +131,7 @@ LL | 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 +warning: 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:32:5 | LL | false > b; @@ -135,13 +139,17 @@ LL | false > b; | = help: because `false` is the minimum value for this type, this comparison is always false -error: <-comparison of unit values detected. This will always be false +warning: <-comparison of unit values detected. This will always be false --> $DIR/absurd-extreme-comparisons.rs:35:5 | LL | () < {}; | ^^^^^^^ | - = note: `#[deny(clippy::unit_cmp)]` on by default +note: the lint level is defined here + --> $DIR/absurd-extreme-comparisons.rs:1:45 + | +LL | #![warn(clippy::absurd_extreme_comparisons, clippy::unit_cmp)] + | ^^^^^^^^^^^^^^^^ -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/allow_attributes_without_reason.rs b/tests/ui/allow_attributes_without_reason.rs index 1a0d4e886576..da2dc4bdca8e 100644 --- a/tests/ui/allow_attributes_without_reason.rs +++ b/tests/ui/allow_attributes_without_reason.rs @@ -3,7 +3,9 @@ // These should trigger the lint #[allow(dead_code)] +//~^ ERROR: attribute without specifying a reason #[allow(dead_code, deprecated)] +//~^ ERROR: attribute without specifying a reason // These should be fine #[allow(dead_code, reason = "This should be allowed")] #[warn(dyn_drop, reason = "Warnings can also have reasons")] diff --git a/tests/ui/allow_attributes_without_reason.stderr b/tests/ui/allow_attributes_without_reason.stderr index 23f17e9a7afb..a29839a23011 100644 --- a/tests/ui/allow_attributes_without_reason.stderr +++ b/tests/ui/allow_attributes_without_reason.stderr @@ -12,7 +12,7 @@ LL | #![deny(clippy::allow_attributes_without_reason)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `allow` attribute without specifying a reason - --> $DIR/allow_attributes_without_reason.rs:6:1 + --> $DIR/allow_attributes_without_reason.rs:7:1 | LL | #[allow(dead_code, deprecated)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/almost_complete_range.fixed b/tests/ui/almost_complete_range.fixed index 6046addf7196..465d1b1ee546 100644 --- a/tests/ui/almost_complete_range.fixed +++ b/tests/ui/almost_complete_range.fixed @@ -1,6 +1,6 @@ -// run-rustfix -// edition:2018 -// aux-build:macro_rules.rs +//@run-rustfix +//@edition:2018 +//@aux-build:macro_rules.rs #![feature(exclusive_range_pattern)] #![feature(stmt_expr_attributes)] @@ -30,40 +30,40 @@ macro_rules! zero { macro_rules! b { () => { - let _ = 'a'..='z'; - let _ = 'A'..='Z'; - let _ = '0'..='9'; + let _ = 'a'..'z'; + let _ = 'A'..'Z'; + let _ = '0'..'9'; }; } fn main() { #[rustfmt::skip] { - let _ = ('a') ..='z'; - let _ = 'A' ..= ('Z'); - let _ = ((('0'))) ..= ('9'); + let _ = ('a') ..'z'; + let _ = 'A' .. ('Z'); + let _ = ((('0'))) .. ('9'); } let _ = 'b'..'z'; let _ = 'B'..'Z'; let _ = '1'..'9'; - let _ = (b'a')..=(b'z'); - let _ = b'A'..=b'Z'; - let _ = b'0'..=b'9'; + let _ = (b'a')..(b'z'); + let _ = b'A'..b'Z'; + let _ = b'0'..b'9'; let _ = b'b'..b'z'; let _ = b'B'..b'Z'; let _ = b'1'..b'9'; - let _ = a!()..='z'; - let _ = A!()..='Z'; - let _ = zero!()..='9'; + let _ = a!()..'z'; + let _ = A!()..'Z'; + let _ = zero!()..'9'; let _ = match 0u8 { - b'a'..=b'z' if true => 1, - b'A'..=b'Z' if true => 2, - b'0'..=b'9' if true => 3, + b'a'..b'z' if true => 1, + b'A'..b'Z' if true => 2, + b'0'..b'9' if true => 3, b'b'..b'z' => 4, b'B'..b'Z' => 5, b'1'..b'9' => 6, @@ -71,9 +71,9 @@ fn main() { }; let _ = match 'x' { - 'a'..='z' if true => 1, - 'A'..='Z' if true => 2, - '0'..='9' if true => 3, + 'a'..'z' if true => 1, + 'A'..'Z' if true => 2, + '0'..'9' if true => 3, 'b'..'z' => 4, 'B'..'Z' => 5, '1'..'9' => 6, @@ -87,22 +87,22 @@ fn main() { #[clippy::msrv = "1.25"] fn _under_msrv() { let _ = match 'a' { - 'a'...'z' => 1, - 'A'...'Z' => 2, - '0'...'9' => 3, + 'a'..'z' => 1, + 'A'..'Z' => 2, + '0'..'9' => 3, _ => 4, }; } #[clippy::msrv = "1.26"] fn _meets_msrv() { - let _ = 'a'..='z'; - let _ = 'A'..='Z'; - let _ = '0'..='9'; + let _ = 'a'..'z'; + let _ = 'A'..'Z'; + let _ = '0'..'9'; let _ = match 'a' { - 'a'..='z' => 1, - 'A'..='Z' => 1, - '0'..='9' => 3, + 'a'..'z' => 1, + 'A'..'Z' => 1, + '0'..'9' => 3, _ => 4, }; } diff --git a/tests/ui/almost_complete_range.rs b/tests/ui/almost_complete_range.rs index ae7e07ab872b..465d1b1ee546 100644 --- a/tests/ui/almost_complete_range.rs +++ b/tests/ui/almost_complete_range.rs @@ -1,6 +1,6 @@ -// run-rustfix -// edition:2018 -// aux-build:macro_rules.rs +//@run-rustfix +//@edition:2018 +//@aux-build:macro_rules.rs #![feature(exclusive_range_pattern)] #![feature(stmt_expr_attributes)] diff --git a/tests/ui/almost_complete_range.stderr b/tests/ui/almost_complete_range.stderr index a7a532878502..af8750f193b7 100644 --- a/tests/ui/almost_complete_range.stderr +++ b/tests/ui/almost_complete_range.stderr @@ -1,4 +1,4 @@ -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:42:17 | LL | let _ = ('a') ..'z'; @@ -6,9 +6,13 @@ LL | let _ = ('a') ..'z'; | | | help: use an inclusive range: `..=` | - = note: `-D clippy::almost-complete-range` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/almost_complete_range.rs:7:9 + | +LL | #![warn(clippy::almost_complete_range)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:43:17 | LL | let _ = 'A' .. ('Z'); @@ -16,7 +20,7 @@ LL | let _ = 'A' .. ('Z'); | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:44:17 | LL | let _ = ((('0'))) .. ('9'); @@ -24,7 +28,7 @@ LL | let _ = ((('0'))) .. ('9'); | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:51:13 | LL | let _ = (b'a')..(b'z'); @@ -32,7 +36,7 @@ LL | let _ = (b'a')..(b'z'); | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:52:13 | LL | let _ = b'A'..b'Z'; @@ -40,7 +44,7 @@ LL | let _ = b'A'..b'Z'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:53:13 | LL | let _ = b'0'..b'9'; @@ -48,7 +52,7 @@ LL | let _ = b'0'..b'9'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:59:13 | LL | let _ = a!()..'z'; @@ -56,7 +60,7 @@ LL | let _ = a!()..'z'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:60:13 | LL | let _ = A!()..'Z'; @@ -64,7 +68,7 @@ LL | let _ = A!()..'Z'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:61:13 | LL | let _ = zero!()..'9'; @@ -72,7 +76,7 @@ LL | let _ = zero!()..'9'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:64:9 | LL | b'a'..b'z' if true => 1, @@ -80,7 +84,7 @@ LL | b'a'..b'z' if true => 1, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:65:9 | LL | b'A'..b'Z' if true => 2, @@ -88,7 +92,7 @@ LL | b'A'..b'Z' if true => 2, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:66:9 | LL | b'0'..b'9' if true => 3, @@ -96,7 +100,7 @@ LL | b'0'..b'9' if true => 3, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:74:9 | LL | 'a'..'z' if true => 1, @@ -104,7 +108,7 @@ LL | 'a'..'z' if true => 1, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:75:9 | LL | 'A'..'Z' if true => 2, @@ -112,7 +116,7 @@ LL | 'A'..'Z' if true => 2, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:76:9 | LL | '0'..'9' if true => 3, @@ -120,7 +124,7 @@ LL | '0'..'9' if true => 3, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:33:17 | LL | let _ = 'a'..'z'; @@ -131,9 +135,9 @@ LL | let _ = 'a'..'z'; LL | b!(); | ---- in this macro invocation | - = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:34:17 | LL | let _ = 'A'..'Z'; @@ -144,9 +148,9 @@ LL | let _ = 'A'..'Z'; LL | b!(); | ---- in this macro invocation | - = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:35:17 | LL | let _ = '0'..'9'; @@ -157,9 +161,9 @@ LL | let _ = '0'..'9'; LL | b!(); | ---- in this macro invocation | - = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:90:9 | LL | 'a'..'z' => 1, @@ -167,7 +171,7 @@ LL | 'a'..'z' => 1, | | | help: use an inclusive range: `...` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:91:9 | LL | 'A'..'Z' => 2, @@ -175,7 +179,7 @@ LL | 'A'..'Z' => 2, | | | help: use an inclusive range: `...` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:92:9 | LL | '0'..'9' => 3, @@ -183,7 +187,7 @@ LL | '0'..'9' => 3, | | | help: use an inclusive range: `...` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:99:13 | LL | let _ = 'a'..'z'; @@ -191,7 +195,7 @@ LL | let _ = 'a'..'z'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:100:13 | LL | let _ = 'A'..'Z'; @@ -199,7 +203,7 @@ LL | let _ = 'A'..'Z'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:101:13 | LL | let _ = '0'..'9'; @@ -207,7 +211,7 @@ LL | let _ = '0'..'9'; | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:103:9 | LL | 'a'..'z' => 1, @@ -215,7 +219,7 @@ LL | 'a'..'z' => 1, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:104:9 | LL | 'A'..'Z' => 1, @@ -223,7 +227,7 @@ LL | 'A'..'Z' => 1, | | | help: use an inclusive range: `..=` -error: almost complete ascii range +warning: almost complete ascii range --> $DIR/almost_complete_range.rs:105:9 | LL | '0'..'9' => 3, @@ -231,5 +235,5 @@ LL | '0'..'9' => 3, | | | help: use an inclusive range: `..=` -error: aborting due to 27 previous errors +warning: 27 warnings emitted diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index 0932a2eec520..2147a2bda0d8 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,13 +1,17 @@ -error: approximate value of `f{32, 64}::consts::E` found +warning: approximate value of `f{32, 64}::consts::E` found --> $DIR/approx_const.rs:4:16 | LL | let my_e = 2.7182; | ^^^^^^ | = help: consider using the constant directly - = note: `-D clippy::approx-constant` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/approx_const.rs:1:8 + | +LL | #[warn(clippy::approx_constant)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: approximate value of `f{32, 64}::consts::E` found +warning: approximate value of `f{32, 64}::consts::E` found --> $DIR/approx_const.rs:5:20 | LL | let almost_e = 2.718; @@ -15,7 +19,7 @@ LL | let almost_e = 2.718; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found +warning: approximate value of `f{32, 64}::consts::FRAC_1_PI` found --> $DIR/approx_const.rs:8:24 | LL | let my_1_frac_pi = 0.3183; @@ -23,7 +27,7 @@ LL | let my_1_frac_pi = 0.3183; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found +warning: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found --> $DIR/approx_const.rs:11:28 | LL | let my_frac_1_sqrt_2 = 0.70710678; @@ -31,7 +35,7 @@ LL | let my_frac_1_sqrt_2 = 0.70710678; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found +warning: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found --> $DIR/approx_const.rs:12:32 | LL | let almost_frac_1_sqrt_2 = 0.70711; @@ -39,7 +43,7 @@ LL | let almost_frac_1_sqrt_2 = 0.70711; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found +warning: approximate value of `f{32, 64}::consts::FRAC_2_PI` found --> $DIR/approx_const.rs:15:24 | LL | let my_frac_2_pi = 0.63661977; @@ -47,7 +51,7 @@ LL | let my_frac_2_pi = 0.63661977; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found +warning: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found --> $DIR/approx_const.rs:18:27 | LL | let my_frac_2_sq_pi = 1.128379; @@ -55,7 +59,7 @@ LL | let my_frac_2_sq_pi = 1.128379; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found +warning: approximate value of `f{32, 64}::consts::FRAC_PI_2` found --> $DIR/approx_const.rs:21:24 | LL | let my_frac_pi_2 = 1.57079632679; @@ -63,7 +67,7 @@ LL | let my_frac_pi_2 = 1.57079632679; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found +warning: approximate value of `f{32, 64}::consts::FRAC_PI_3` found --> $DIR/approx_const.rs:24:24 | LL | let my_frac_pi_3 = 1.04719755119; @@ -71,7 +75,7 @@ LL | let my_frac_pi_3 = 1.04719755119; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found +warning: approximate value of `f{32, 64}::consts::FRAC_PI_4` found --> $DIR/approx_const.rs:27:24 | LL | let my_frac_pi_4 = 0.785398163397; @@ -79,7 +83,7 @@ LL | let my_frac_pi_4 = 0.785398163397; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found +warning: approximate value of `f{32, 64}::consts::FRAC_PI_6` found --> $DIR/approx_const.rs:30:24 | LL | let my_frac_pi_6 = 0.523598775598; @@ -87,7 +91,7 @@ LL | let my_frac_pi_6 = 0.523598775598; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found +warning: approximate value of `f{32, 64}::consts::FRAC_PI_8` found --> $DIR/approx_const.rs:33:24 | LL | let my_frac_pi_8 = 0.3926990816987; @@ -95,7 +99,7 @@ LL | let my_frac_pi_8 = 0.3926990816987; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LN_10` found +warning: approximate value of `f{32, 64}::consts::LN_10` found --> $DIR/approx_const.rs:36:20 | LL | let my_ln_10 = 2.302585092994046; @@ -103,7 +107,7 @@ LL | let my_ln_10 = 2.302585092994046; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LN_2` found +warning: approximate value of `f{32, 64}::consts::LN_2` found --> $DIR/approx_const.rs:39:19 | LL | let my_ln_2 = 0.6931471805599453; @@ -111,7 +115,7 @@ LL | let my_ln_2 = 0.6931471805599453; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG10_E` found +warning: approximate value of `f{32, 64}::consts::LOG10_E` found --> $DIR/approx_const.rs:42:22 | LL | let my_log10_e = 0.4342944819032518; @@ -119,7 +123,7 @@ LL | let my_log10_e = 0.4342944819032518; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG2_E` found +warning: approximate value of `f{32, 64}::consts::LOG2_E` found --> $DIR/approx_const.rs:45:21 | LL | let my_log2_e = 1.4426950408889634; @@ -127,7 +131,7 @@ LL | let my_log2_e = 1.4426950408889634; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG2_10` found +warning: approximate value of `f{32, 64}::consts::LOG2_10` found --> $DIR/approx_const.rs:48:19 | LL | let log2_10 = 3.321928094887362; @@ -135,7 +139,7 @@ LL | let log2_10 = 3.321928094887362; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG10_2` found +warning: approximate value of `f{32, 64}::consts::LOG10_2` found --> $DIR/approx_const.rs:51:19 | LL | let log10_2 = 0.301029995663981; @@ -143,7 +147,7 @@ LL | let log10_2 = 0.301029995663981; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::PI` found +warning: approximate value of `f{32, 64}::consts::PI` found --> $DIR/approx_const.rs:54:17 | LL | let my_pi = 3.1415; @@ -151,7 +155,7 @@ LL | let my_pi = 3.1415; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::PI` found +warning: approximate value of `f{32, 64}::consts::PI` found --> $DIR/approx_const.rs:55:21 | LL | let almost_pi = 3.14; @@ -159,7 +163,7 @@ LL | let almost_pi = 3.14; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::SQRT_2` found +warning: approximate value of `f{32, 64}::consts::SQRT_2` found --> $DIR/approx_const.rs:58:18 | LL | let my_sq2 = 1.4142; @@ -167,7 +171,7 @@ LL | let my_sq2 = 1.4142; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::TAU` found +warning: approximate value of `f{32, 64}::consts::TAU` found --> $DIR/approx_const.rs:61:18 | LL | let my_tau = 6.2832; @@ -175,7 +179,7 @@ LL | let my_tau = 6.2832; | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::TAU` found +warning: approximate value of `f{32, 64}::consts::TAU` found --> $DIR/approx_const.rs:62:22 | LL | let almost_tau = 6.28; @@ -183,5 +187,5 @@ LL | let almost_tau = 6.28; | = help: consider using the constant directly -error: aborting due to 23 previous errors +warning: 23 warnings emitted diff --git a/tests/ui/arithmetic_side_effects.stderr b/tests/ui/arithmetic_side_effects.stderr index 17a2448fbfca..e63f1b2e022f 100644 --- a/tests/ui/arithmetic_side_effects.stderr +++ b/tests/ui/arithmetic_side_effects.stderr @@ -1,598 +1,602 @@ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:270:5 | LL | _n += 1; | ^^^^^^^ | - = note: `-D clippy::arithmetic-side-effects` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/arithmetic_side_effects.rs:12:9 + | +LL | #![warn(clippy::arithmetic_side_effects)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:271:5 | LL | _n += &1; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:272:5 | LL | _n -= 1; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:273:5 | LL | _n -= &1; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:274:5 | LL | _n /= 0; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:275:5 | LL | _n /= &0; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:276:5 | LL | _n %= 0; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:277:5 | LL | _n %= &0; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:278:5 | LL | _n *= 2; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:279:5 | LL | _n *= &2; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:280:5 | LL | _n += -1; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:281:5 | LL | _n += &-1; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:282:5 | LL | _n -= -1; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:283:5 | LL | _n -= &-1; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:284:5 | LL | _n /= -0; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:285:5 | LL | _n /= &-0; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:286:5 | LL | _n %= -0; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:287:5 | LL | _n %= &-0; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:288:5 | LL | _n *= -2; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:289:5 | LL | _n *= &-2; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:290:5 | LL | _custom += Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:291:5 | LL | _custom += &Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:292:5 | LL | _custom -= Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:293:5 | LL | _custom -= &Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:294:5 | LL | _custom /= Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:295:5 | LL | _custom /= &Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:296:5 | LL | _custom %= Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:297:5 | LL | _custom %= &Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:298:5 | LL | _custom *= Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:299:5 | LL | _custom *= &Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:300:5 | LL | _custom += -Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:301:5 | LL | _custom += &-Custom; | ^^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:302:5 | LL | _custom -= -Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:303:5 | LL | _custom -= &-Custom; | ^^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:304:5 | LL | _custom /= -Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:305:5 | LL | _custom /= &-Custom; | ^^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:306:5 | LL | _custom %= -Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:307:5 | LL | _custom %= &-Custom; | ^^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:308:5 | LL | _custom *= -Custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:309:5 | LL | _custom *= &-Custom; | ^^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:312:10 | LL | _n = _n + 1; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:313:10 | LL | _n = _n + &1; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:314:10 | LL | _n = 1 + _n; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:315:10 | LL | _n = &1 + _n; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:316:10 | LL | _n = _n - 1; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:317:10 | LL | _n = _n - &1; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:318:10 | LL | _n = 1 - _n; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:319:10 | LL | _n = &1 - _n; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:320:10 | LL | _n = _n / 0; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:321:10 | LL | _n = _n / &0; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:322:10 | LL | _n = _n % 0; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:323:10 | LL | _n = _n % &0; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:324:10 | LL | _n = _n * 2; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:325:10 | LL | _n = _n * &2; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:326:10 | LL | _n = 2 * _n; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:327:10 | LL | _n = &2 * _n; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:328:10 | LL | _n = 23 + &85; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:329:10 | LL | _n = &23 + 85; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:330:10 | LL | _n = &23 + &85; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:331:15 | LL | _custom = _custom + _custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:332:15 | LL | _custom = _custom + &_custom; | ^^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:333:15 | LL | _custom = Custom + _custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:334:15 | LL | _custom = &Custom + _custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:335:15 | LL | _custom = _custom - Custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:336:15 | LL | _custom = _custom - &Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:337:15 | LL | _custom = Custom - _custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:338:15 | LL | _custom = &Custom - _custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:339:15 | LL | _custom = _custom / Custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:340:15 | LL | _custom = _custom / &Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:341:15 | LL | _custom = _custom % Custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:342:15 | LL | _custom = _custom % &Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:343:15 | LL | _custom = _custom * Custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:344:15 | LL | _custom = _custom * &Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:345:15 | LL | _custom = Custom * _custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:346:15 | LL | _custom = &Custom * _custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:347:15 | LL | _custom = Custom + &Custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:348:15 | LL | _custom = &Custom + Custom; | ^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:349:15 | LL | _custom = &Custom + &Custom; | ^^^^^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:352:10 | LL | _n = -_n; | ^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:353:10 | LL | _n = -&_n; | ^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:354:15 | LL | _custom = -_custom; | ^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:355:15 | LL | _custom = -&_custom; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:364:5 | LL | 1 + i; | ^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:365:5 | LL | i * 2; | ^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:367:5 | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:368:5 | LL | -i; | ^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:369:5 | LL | i >> 1; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:370:5 | LL | i << 1; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:379:5 | LL | i += 1; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:380:5 | LL | i -= 1; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:381:5 | LL | i *= 2; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:383:5 | LL | i /= 0; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:385:5 | LL | i /= var1; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:386:5 | LL | i /= var2; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:388:5 | LL | i %= 0; | ^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:390:5 | LL | i %= var1; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:391:5 | LL | i %= var2; | ^^^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:392:5 | LL | i <<= 3; | ^^^^^^^ -error: arithmetic operation that can potentially result in unexpected side-effects +warning: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:393:5 | LL | i >>= 2; | ^^^^^^^ -error: aborting due to 99 previous errors +warning: 99 warnings emitted diff --git a/tests/ui/as_conversions.rs b/tests/ui/as_conversions.rs index ba4394defbf2..47e9f1f9cde7 100644 --- a/tests/ui/as_conversions.rs +++ b/tests/ui/as_conversions.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::as_conversions)] #![allow(clippy::borrow_as_ptr)] diff --git a/tests/ui/as_conversions.stderr b/tests/ui/as_conversions.stderr index f5d59e1e5d83..90aa06e73a1c 100644 --- a/tests/ui/as_conversions.stderr +++ b/tests/ui/as_conversions.stderr @@ -1,13 +1,17 @@ -error: using a potentially dangerous silent `as` conversion +warning: using a potentially dangerous silent `as` conversion --> $DIR/as_conversions.rs:15:13 | LL | let i = 0u32 as u64; | ^^^^^^^^^^^ | = help: consider using a safe wrapper for this conversion - = note: `-D clippy::as-conversions` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/as_conversions.rs:3:9 + | +LL | #![warn(clippy::as_conversions)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: using a potentially dangerous silent `as` conversion +warning: using a potentially dangerous silent `as` conversion --> $DIR/as_conversions.rs:17:13 | LL | let j = &i as *const u64 as *mut u64; @@ -15,7 +19,7 @@ LL | let j = &i as *const u64 as *mut u64; | = help: consider using a safe wrapper for this conversion -error: using a potentially dangerous silent `as` conversion +warning: using a potentially dangerous silent `as` conversion --> $DIR/as_conversions.rs:17:13 | LL | let j = &i as *const u64 as *mut u64; @@ -23,5 +27,5 @@ LL | let j = &i as *const u64 as *mut u64; | = help: consider using a safe wrapper for this conversion -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/as_ptr_cast_mut.stderr b/tests/ui/as_ptr_cast_mut.stderr index 2189c3d2f855..080072fb19ca 100644 --- a/tests/ui/as_ptr_cast_mut.stderr +++ b/tests/ui/as_ptr_cast_mut.stderr @@ -1,16 +1,20 @@ -error: casting the result of `as_ptr` to *mut u8 +warning: casting the result of `as_ptr` to *mut u8 --> $DIR/as_ptr_cast_mut.rs:21:13 | LL | let _ = string.as_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` | - = note: `-D clippy::as-ptr-cast-mut` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/as_ptr_cast_mut.rs:2:9 + | +LL | #![warn(clippy::as_ptr_cast_mut)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: casting the result of `as_ptr` to *mut i8 +warning: casting the result of `as_ptr` to *mut i8 --> $DIR/as_ptr_cast_mut.rs:22:22 | LL | let _: *mut i8 = string.as_ptr() as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/as_underscore.fixed b/tests/ui/as_underscore.fixed index 948f6d8e6b10..69af84a0eaec 100644 --- a/tests/ui/as_underscore.fixed +++ b/tests/ui/as_underscore.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::as_underscore)] diff --git a/tests/ui/as_underscore.rs b/tests/ui/as_underscore.rs index 97785ed08a8d..a8cfb81d9a3f 100644 --- a/tests/ui/as_underscore.rs +++ b/tests/ui/as_underscore.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::as_underscore)] diff --git a/tests/ui/as_underscore.stderr b/tests/ui/as_underscore.stderr index d7cd58d965ac..dfb55b52b0da 100644 --- a/tests/ui/as_underscore.stderr +++ b/tests/ui/as_underscore.stderr @@ -1,4 +1,4 @@ -error: using `as _` conversion +warning: using `as _` conversion --> $DIR/as_underscore.rs:9:9 | LL | foo(n as _); @@ -6,9 +6,13 @@ LL | foo(n as _); | | | help: consider giving the type explicitly: `usize` | - = note: `-D clippy::as-underscore` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/as_underscore.rs:3:9 + | +LL | #![warn(clippy::as_underscore)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: using `as _` conversion +warning: using `as _` conversion --> $DIR/as_underscore.rs:12:18 | LL | let _n: u8 = n as _; @@ -16,5 +20,5 @@ LL | let _n: u8 = n as _; | | | help: consider giving the type explicitly: `u8` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/asm_syntax.rs b/tests/ui/asm_syntax.rs index 0220bf3331f5..af02e202b17b 100644 --- a/tests/ui/asm_syntax.rs +++ b/tests/ui/asm_syntax.rs @@ -1,5 +1,5 @@ -// only-x86_64 -// ignore-aarch64 +//@only-target-x86_64 +//@ignore-target-aarch64 #[warn(clippy::inline_asm_x86_intel_syntax)] mod warn_intel { diff --git a/tests/ui/asm_syntax.stderr b/tests/ui/asm_syntax.stderr index 9c7c3ba7d87e..e279560c2349 100644 --- a/tests/ui/asm_syntax.stderr +++ b/tests/ui/asm_syntax.stderr @@ -1,13 +1,17 @@ -error: Intel x86 assembly syntax used +warning: Intel x86 assembly syntax used --> $DIR/asm_syntax.rs:8:9 | LL | asm!(""); | ^^^^^^^^ | = help: use AT&T x86 assembly syntax - = note: `-D clippy::inline-asm-x86-intel-syntax` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/asm_syntax.rs:4:8 + | +LL | #[warn(clippy::inline_asm_x86_intel_syntax)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Intel x86 assembly syntax used +warning: Intel x86 assembly syntax used --> $DIR/asm_syntax.rs:9:9 | LL | asm!("", options()); @@ -15,7 +19,7 @@ LL | asm!("", options()); | = help: use AT&T x86 assembly syntax -error: Intel x86 assembly syntax used +warning: Intel x86 assembly syntax used --> $DIR/asm_syntax.rs:10:9 | LL | asm!("", options(nostack)); @@ -23,16 +27,20 @@ LL | asm!("", options(nostack)); | = help: use AT&T x86 assembly syntax -error: AT&T x86 assembly syntax used +warning: AT&T x86 assembly syntax used --> $DIR/asm_syntax.rs:23:9 | LL | asm!("", options(att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use Intel x86 assembly syntax - = note: `-D clippy::inline-asm-x86-att-syntax` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/asm_syntax.rs:16:8 + | +LL | #[warn(clippy::inline_asm_x86_att_syntax)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: AT&T x86 assembly syntax used +warning: AT&T x86 assembly syntax used --> $DIR/asm_syntax.rs:24:9 | LL | asm!("", options(nostack, att_syntax)); @@ -40,5 +48,5 @@ LL | asm!("", options(nostack, att_syntax)); | = help: use Intel x86 assembly syntax -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr index 29fe009035f1..59d9652a2a6e 100644 --- a/tests/ui/assertions_on_constants.stderr +++ b/tests/ui/assertions_on_constants.stderr @@ -1,13 +1,13 @@ -error: `assert!(true)` will be optimized out by the compiler +warning: `assert!(true)` will be optimized out by the compiler --> $DIR/assertions_on_constants.rs:10:5 | LL | assert!(true); | ^^^^^^^^^^^^^ | = help: remove it - = note: `-D clippy::assertions-on-constants` implied by `-D warnings` + = note: `#[warn(clippy::assertions_on_constants)]` on by default -error: `assert!(false)` should probably be replaced +warning: `assert!(false)` should probably be replaced --> $DIR/assertions_on_constants.rs:11:5 | LL | assert!(false); @@ -15,7 +15,7 @@ LL | assert!(false); | = help: use `panic!()` or `unreachable!()` -error: `assert!(true)` will be optimized out by the compiler +warning: `assert!(true)` will be optimized out by the compiler --> $DIR/assertions_on_constants.rs:12:5 | LL | assert!(true, "true message"); @@ -23,7 +23,7 @@ LL | assert!(true, "true message"); | = help: remove it -error: `assert!(false, ..)` should probably be replaced +warning: `assert!(false, ..)` should probably be replaced --> $DIR/assertions_on_constants.rs:13:5 | LL | assert!(false, "false message"); @@ -31,7 +31,7 @@ LL | assert!(false, "false message"); | = help: use `panic!(..)` or `unreachable!(..)` -error: `assert!(false, ..)` should probably be replaced +warning: `assert!(false, ..)` should probably be replaced --> $DIR/assertions_on_constants.rs:16:5 | LL | assert!(false, "{}", msg.to_uppercase()); @@ -39,7 +39,7 @@ LL | assert!(false, "{}", msg.to_uppercase()); | = help: use `panic!(..)` or `unreachable!(..)` -error: `assert!(true)` will be optimized out by the compiler +warning: `assert!(true)` will be optimized out by the compiler --> $DIR/assertions_on_constants.rs:19:5 | LL | assert!(B); @@ -47,7 +47,7 @@ LL | assert!(B); | = help: remove it -error: `assert!(false)` should probably be replaced +warning: `assert!(false)` should probably be replaced --> $DIR/assertions_on_constants.rs:22:5 | LL | assert!(C); @@ -55,7 +55,7 @@ LL | assert!(C); | = help: use `panic!()` or `unreachable!()` -error: `assert!(false, ..)` should probably be replaced +warning: `assert!(false, ..)` should probably be replaced --> $DIR/assertions_on_constants.rs:23:5 | LL | assert!(C, "C message"); @@ -63,7 +63,7 @@ LL | assert!(C, "C message"); | = help: use `panic!(..)` or `unreachable!(..)` -error: `debug_assert!(true)` will be optimized out by the compiler +warning: `debug_assert!(true)` will be optimized out by the compiler --> $DIR/assertions_on_constants.rs:25:5 | LL | debug_assert!(true); @@ -71,5 +71,5 @@ LL | debug_assert!(true); | = help: remove it -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/assertions_on_result_states.fixed b/tests/ui/assertions_on_result_states.fixed index 2bb755290c50..ea8b895664c4 100644 --- a/tests/ui/assertions_on_result_states.fixed +++ b/tests/ui/assertions_on_result_states.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::assertions_on_result_states)] use std::result::Result; diff --git a/tests/ui/assertions_on_result_states.rs b/tests/ui/assertions_on_result_states.rs index d8a9bd2f1c45..6fc20f859887 100644 --- a/tests/ui/assertions_on_result_states.rs +++ b/tests/ui/assertions_on_result_states.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::assertions_on_result_states)] use std::result::Result; diff --git a/tests/ui/assertions_on_result_states.stderr b/tests/ui/assertions_on_result_states.stderr index 298d63c9c34f..24deb26fafd0 100644 --- a/tests/ui/assertions_on_result_states.stderr +++ b/tests/ui/assertions_on_result_states.stderr @@ -1,46 +1,50 @@ -error: called `assert!` with `Result::is_ok` +warning: called `assert!` with `Result::is_ok` --> $DIR/assertions_on_result_states.rs:24:5 | LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` | - = note: `-D clippy::assertions-on-result-states` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/assertions_on_result_states.rs:2:9 + | +LL | #![warn(clippy::assertions_on_result_states)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `assert!` with `Result::is_ok` +warning: called `assert!` with `Result::is_ok` --> $DIR/assertions_on_result_states.rs:42:5 | LL | assert!(get_ok().is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()` -error: called `assert!` with `Result::is_ok` +warning: called `assert!` with `Result::is_ok` --> $DIR/assertions_on_result_states.rs:45:5 | LL | assert!(get_ok_macro!().is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()` -error: called `assert!` with `Result::is_ok` +warning: called `assert!` with `Result::is_ok` --> $DIR/assertions_on_result_states.rs:58:5 | LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` -error: called `assert!` with `Result::is_ok` +warning: called `assert!` with `Result::is_ok` --> $DIR/assertions_on_result_states.rs:64:9 | LL | assert!(r.is_ok()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` -error: called `assert!` with `Result::is_err` +warning: called `assert!` with `Result::is_err` --> $DIR/assertions_on_result_states.rs:72:5 | LL | assert!(r.is_err()); | ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()` -error: called `assert!` with `Result::is_err` +warning: called `assert!` with `Result::is_err` --> $DIR/assertions_on_result_states.rs:82:5 | LL | assert!(res.is_err()) | ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/assign_ops.fixed b/tests/ui/assign_ops.fixed index da034b51cfdb..b50682ea00c4 100644 --- a/tests/ui/assign_ops.fixed +++ b/tests/ui/assign_ops.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use core::num::Wrapping; diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index 337bb02c8a61..780d2d040f12 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use core::num::Wrapping; diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 63a938ab4b43..71b939f324bf 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,70 +1,74 @@ -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:9:5 | LL | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` | - = note: `-D clippy::assign-op-pattern` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/assign_ops.rs:6:8 + | +LL | #[warn(clippy::assign_op_pattern)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:10:5 | LL | a = 1 + a; | ^^^^^^^^^ help: replace it with: `a += 1` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:11:5 | LL | a = a - 1; | ^^^^^^^^^ help: replace it with: `a -= 1` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:12:5 | LL | a = a * 99; | ^^^^^^^^^^ help: replace it with: `a *= 99` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:13:5 | LL | a = 42 * a; | ^^^^^^^^^^ help: replace it with: `a *= 42` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:14:5 | LL | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:15:5 | LL | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:16:5 | LL | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:22:5 | LL | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:26:5 | LL | a = a + Wrapping(1u32); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a += Wrapping(1u32)` -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops.rs:28:5 | LL | v[0] = v[0] + v[1]; | ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 25e74602244d..169d1ff4260a 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,10 +1,14 @@ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:7:5 | LL | a += a + 1; | ^^^^^^^^^^ | - = note: `-D clippy::misrefactored-assign-op` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/assign_ops2.rs:4:8 + | +LL | #[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean `a = a + 1` or `a = a + a + 1`? Consider replacing it with | LL | a += 1; @@ -14,7 +18,7 @@ help: or LL | a = a + a + 1; | ~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:8:5 | LL | a += 1 + a; @@ -29,7 +33,7 @@ help: or LL | a = a + 1 + a; | ~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:9:5 | LL | a -= a - 1; @@ -44,7 +48,7 @@ help: or LL | a = a - (a - 1); | ~~~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:10:5 | LL | a *= a * 99; @@ -59,7 +63,7 @@ help: or LL | a = a * a * 99; | ~~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:11:5 | LL | a *= 42 * a; @@ -74,7 +78,7 @@ help: or LL | a = a * 42 * a; | ~~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:12:5 | LL | a /= a / 2; @@ -89,7 +93,7 @@ help: or LL | a = a / (a / 2); | ~~~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:13:5 | LL | a %= a % 5; @@ -104,7 +108,7 @@ help: or LL | a = a % (a % 5); | ~~~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:14:5 | LL | a &= a & 1; @@ -119,7 +123,7 @@ help: or LL | a = a & a & 1; | ~~~~~~~~~~~~~ -error: variable appears on both sides of an assignment operation +warning: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:15:5 | LL | a *= a * a; @@ -134,13 +138,13 @@ help: or LL | a = a * a * a; | ~~~~~~~~~~~~~ -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/assign_ops2.rs:52:5 | LL | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` | - = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = note: `#[warn(clippy::assign_op_pattern)]` on by default -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/async_yields_async.fixed b/tests/ui/async_yields_async.fixed index 3cf380d2b954..96fc4fba0c3f 100644 --- a/tests/ui/async_yields_async.fixed +++ b/tests/ui/async_yields_async.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![feature(async_closure)] #![warn(clippy::async_yields_async)] @@ -38,10 +38,10 @@ fn main() { let _h = async { async { 3 - }.await + } }; let _i = async { - CustomFutureType.await + CustomFutureType }; let _i = async || { 3 @@ -49,18 +49,18 @@ fn main() { let _j = async || { async { 3 - }.await + } }; let _k = async || { - CustomFutureType.await + CustomFutureType }; - let _l = async || CustomFutureType.await; + let _l = async || CustomFutureType; let _m = async || { println!("I'm bored"); // Some more stuff // Finally something to await - CustomFutureType.await + CustomFutureType }; let _n = async || custom_future_type_ctor(); let _o = async || f(); diff --git a/tests/ui/async_yields_async.rs b/tests/ui/async_yields_async.rs index dd4131b60ab3..96fc4fba0c3f 100644 --- a/tests/ui/async_yields_async.rs +++ b/tests/ui/async_yields_async.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![feature(async_closure)] #![warn(clippy::async_yields_async)] diff --git a/tests/ui/async_yields_async.stderr b/tests/ui/async_yields_async.stderr index 22ce1c6f6471..37435e46e0f8 100644 --- a/tests/ui/async_yields_async.stderr +++ b/tests/ui/async_yields_async.stderr @@ -1,4 +1,4 @@ -error: an async construct yields a type which is itself awaitable +warning: an async construct yields a type which is itself awaitable --> $DIR/async_yields_async.rs:39:9 | LL | let _h = async { @@ -10,7 +10,11 @@ LL | || } LL | | }; | |______- outer async construct | - = note: `-D clippy::async-yields-async` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/async_yields_async.rs:4:9 + | +LL | #![warn(clippy::async_yields_async)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider awaiting this value | LL ~ async { @@ -18,7 +22,7 @@ LL + 3 LL + }.await | -error: an async construct yields a type which is itself awaitable +warning: an async construct yields a type which is itself awaitable --> $DIR/async_yields_async.rs:44:9 | LL | let _i = async { @@ -31,7 +35,7 @@ LL | | CustomFutureType LL | | }; | |_____- outer async construct -error: an async construct yields a type which is itself awaitable +warning: an async construct yields a type which is itself awaitable --> $DIR/async_yields_async.rs:50:9 | LL | let _j = async || { @@ -50,7 +54,7 @@ LL + 3 LL + }.await | -error: an async construct yields a type which is itself awaitable +warning: an async construct yields a type which is itself awaitable --> $DIR/async_yields_async.rs:55:9 | LL | let _k = async || { @@ -63,7 +67,7 @@ LL | | CustomFutureType LL | | }; | |_____- outer async construct -error: an async construct yields a type which is itself awaitable +warning: an async construct yields a type which is itself awaitable --> $DIR/async_yields_async.rs:57:23 | LL | let _l = async || CustomFutureType; @@ -73,7 +77,7 @@ LL | let _l = async || CustomFutureType; | awaitable value not awaited | help: consider awaiting this value: `CustomFutureType.await` -error: an async construct yields a type which is itself awaitable +warning: an async construct yields a type which is itself awaitable --> $DIR/async_yields_async.rs:63:9 | LL | let _m = async || { @@ -90,5 +94,5 @@ LL | | CustomFutureType LL | | }; | |_____- outer async construct -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index df4e9e20b649..7dd50cddb3ed 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,24 +1,32 @@ -error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea +warning: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea --> $DIR/attrs.rs:5:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::inline-always` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/attrs.rs:1:9 + | +LL | #![warn(clippy::inline_always, clippy::deprecated_semver)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: the since field must contain a semver-compliant version +warning: the since field must contain a semver-compliant version --> $DIR/attrs.rs:25:14 | LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::deprecated-semver` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/attrs.rs:1:32 + | +LL | #![warn(clippy::inline_always, clippy::deprecated_semver)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the since field must contain a semver-compliant version +warning: the since field must contain a semver-compliant version --> $DIR/attrs.rs:28:14 | LL | #[deprecated(since = "1")] | ^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/author/blocks.rs b/tests/ui/author/blocks.rs index a7335c01baa3..164f7d0d9d6c 100644 --- a/tests/ui/author/blocks.rs +++ b/tests/ui/author/blocks.rs @@ -1,4 +1,4 @@ -// edition:2018 +//@edition:2018 #![allow(redundant_semicolons, clippy::no_effect)] #![feature(stmt_expr_attributes)] diff --git a/tests/ui/auxiliary/macro_use_helper.rs b/tests/ui/auxiliary/macro_use_helper.rs index ecb55d8cb48d..fa62e4cef107 100644 --- a/tests/ui/auxiliary/macro_use_helper.rs +++ b/tests/ui/auxiliary/macro_use_helper.rs @@ -1,4 +1,5 @@ -extern crate macro_rules; +#[macro_use] +mod macro_rules; // STMT #[macro_export] @@ -13,11 +14,11 @@ pub mod inner { // RE-EXPORT // this will stick in `inner` module - pub use macro_rules::foofoo; - pub use macro_rules::try_err; + pub use crate::foofoo; + pub use crate::try_err; pub mod nested { - pub use macro_rules::string_add; + pub use crate::string_add; } // ITEM diff --git a/tests/ui/auxiliary/proc_macro_attr.rs b/tests/ui/auxiliary/proc_macro_attr.rs index 4914f14b58ff..c37b081d52e1 100644 --- a/tests/ui/auxiliary/proc_macro_attr.rs +++ b/tests/ui/auxiliary/proc_macro_attr.rs @@ -1,6 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic - #![crate_type = "proc-macro"] #![feature(repr128, proc_macro_hygiene, proc_macro_quote, box_patterns)] #![allow(incomplete_features)] diff --git a/tests/ui/auxiliary/proc_macro_derive.rs b/tests/ui/auxiliary/proc_macro_derive.rs index a89a06308d09..6a95768c1f5e 100644 --- a/tests/ui/auxiliary/proc_macro_derive.rs +++ b/tests/ui/auxiliary/proc_macro_derive.rs @@ -1,6 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic - #![crate_type = "proc-macro"] #![feature(repr128, proc_macro_quote)] #![allow(incomplete_features)] diff --git a/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs b/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs index a2ef0fe827c0..e16d12f0a68d 100644 --- a/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs +++ b/tests/ui/auxiliary/proc_macro_suspicious_else_formatting.rs @@ -1,6 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic - #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/tests/ui/auxiliary/proc_macro_unsafe.rs b/tests/ui/auxiliary/proc_macro_unsafe.rs index 3c40f77469b8..9abb8b963fa9 100644 --- a/tests/ui/auxiliary/proc_macro_unsafe.rs +++ b/tests/ui/auxiliary/proc_macro_unsafe.rs @@ -1,6 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic - #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/tests/ui/auxiliary/proc_macro_with_span.rs b/tests/ui/auxiliary/proc_macro_with_span.rs index 8ea631f2bbd4..2b9556a77f69 100644 --- a/tests/ui/auxiliary/proc_macro_with_span.rs +++ b/tests/ui/auxiliary/proc_macro_with_span.rs @@ -1,6 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic - #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/tests/ui/await_holding_lock.stderr b/tests/ui/await_holding_lock.stderr index 81a2d0524383..9f27901b23a4 100644 --- a/tests/ui/await_holding_lock.stderr +++ b/tests/ui/await_holding_lock.stderr @@ -1,4 +1,4 @@ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:9:13 | LL | let guard = x.lock().unwrap(); @@ -12,9 +12,13 @@ LL | / let guard = x.lock().unwrap(); LL | | baz().await LL | | } | |_____^ - = note: `-D clippy::await-holding-lock` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/await_holding_lock.rs:1:9 + | +LL | #![warn(clippy::await_holding_lock)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:24:13 | LL | let guard = x.read().unwrap(); @@ -29,7 +33,7 @@ LL | | baz().await LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:29:13 | LL | let mut guard = x.write().unwrap(); @@ -44,7 +48,7 @@ LL | | baz().await LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:50:13 | LL | let guard = x.lock().unwrap(); @@ -63,7 +67,7 @@ LL | | first + second + third LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:63:17 | LL | let guard = x.lock().unwrap(); @@ -78,7 +82,7 @@ LL | | baz().await LL | | }; | |_________^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:75:17 | LL | let guard = x.lock().unwrap(); @@ -93,7 +97,7 @@ LL | | baz().await LL | | } | |_________^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:87:13 | LL | let guard = x.lock(); @@ -108,7 +112,7 @@ LL | | baz().await LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:102:13 | LL | let guard = x.read(); @@ -123,7 +127,7 @@ LL | | baz().await LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:107:13 | LL | let mut guard = x.write(); @@ -138,7 +142,7 @@ LL | | baz().await LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:128:13 | LL | let guard = x.lock(); @@ -157,7 +161,7 @@ LL | | first + second + third LL | | } | |_____^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:141:17 | LL | let guard = x.lock(); @@ -172,7 +176,7 @@ LL | | baz().await LL | | }; | |_________^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:153:17 | LL | let guard = x.lock(); @@ -187,7 +191,7 @@ LL | | baz().await LL | | } | |_________^ -error: this `MutexGuard` is held across an `await` point +warning: this `MutexGuard` is held across an `await` point --> $DIR/await_holding_lock.rs:173:9 | LL | let mut guard = x.lock().unwrap(); @@ -204,5 +208,5 @@ LL | | baz().await; LL | | } | |_^ -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/await_holding_refcell_ref.stderr b/tests/ui/await_holding_refcell_ref.stderr index 25c15ab80602..b67cce8e6da2 100644 --- a/tests/ui/await_holding_refcell_ref.stderr +++ b/tests/ui/await_holding_refcell_ref.stderr @@ -1,4 +1,4 @@ -error: this `RefCell` reference is held across an `await` point +warning: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:6:9 | LL | let b = x.borrow(); @@ -12,9 +12,13 @@ LL | / let b = x.borrow(); LL | | baz().await LL | | } | |_^ - = note: `-D clippy::await-holding-refcell-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/await_holding_refcell_ref.rs:1:9 + | +LL | #![warn(clippy::await_holding_refcell_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `RefCell` reference is held across an `await` point +warning: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:11:9 | LL | let b = x.borrow_mut(); @@ -29,7 +33,7 @@ LL | | baz().await LL | | } | |_^ -error: this `RefCell` reference is held across an `await` point +warning: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:32:9 | LL | let b = x.borrow_mut(); @@ -48,7 +52,7 @@ LL | | first + second + third LL | | } | |_^ -error: this `RefCell` reference is held across an `await` point +warning: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:44:9 | LL | let b = x.borrow_mut(); @@ -67,7 +71,7 @@ LL | | first + second + third LL | | } | |_^ -error: this `RefCell` reference is held across an `await` point +warning: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:59:13 | LL | let b = x.borrow_mut(); @@ -82,7 +86,7 @@ LL | | baz().await LL | | }; | |_____^ -error: this `RefCell` reference is held across an `await` point +warning: this `RefCell` reference is held across an `await` point --> $DIR/await_holding_refcell_ref.rs:71:13 | LL | let b = x.borrow_mut(); @@ -97,5 +101,5 @@ LL | | baz().await LL | | } | |_____^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/bind_instead_of_map.fixed b/tests/ui/bind_instead_of_map.fixed index d94e2ac6072d..e6c44aa217e8 100644 --- a/tests/ui/bind_instead_of_map.fixed +++ b/tests/ui/bind_instead_of_map.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::bind_instead_of_map)] +//@run-rustfix +#![warn(clippy::bind_instead_of_map)] #![allow(clippy::uninlined_format_args)] // need a main anyway, use it get rid of unused warnings too diff --git a/tests/ui/bind_instead_of_map.rs b/tests/ui/bind_instead_of_map.rs index 86f31f58284a..37aec0fac57a 100644 --- a/tests/ui/bind_instead_of_map.rs +++ b/tests/ui/bind_instead_of_map.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::bind_instead_of_map)] +//@run-rustfix +#![warn(clippy::bind_instead_of_map)] #![allow(clippy::uninlined_format_args)] // need a main anyway, use it get rid of unused warnings too diff --git a/tests/ui/bind_instead_of_map.stderr b/tests/ui/bind_instead_of_map.stderr index b6a81d21bb20..5d8740aea854 100644 --- a/tests/ui/bind_instead_of_map.stderr +++ b/tests/ui/bind_instead_of_map.stderr @@ -1,4 +1,4 @@ -error: using `Option.and_then(Some)`, which is a no-op +warning: using `Option.and_then(Some)`, which is a no-op --> $DIR/bind_instead_of_map.rs:9:13 | LL | let _ = x.and_then(Some); @@ -7,20 +7,20 @@ LL | let _ = x.and_then(Some); note: the lint level is defined here --> $DIR/bind_instead_of_map.rs:2:9 | -LL | #![deny(clippy::bind_instead_of_map)] +LL | #![warn(clippy::bind_instead_of_map)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` +warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` --> $DIR/bind_instead_of_map.rs:10:13 | LL | let _ = x.and_then(|o| Some(o + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.map(|o| o + 1)` -error: using `Result.and_then(Ok)`, which is a no-op +warning: using `Result.and_then(Ok)`, which is a no-op --> $DIR/bind_instead_of_map.rs:16:13 | LL | let _ = x.and_then(Ok); | ^^^^^^^^^^^^^^ help: use the expression directly: `x` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/bind_instead_of_map_multipart.fixed b/tests/ui/bind_instead_of_map_multipart.fixed index e1589843226c..82fd38b0b0a9 100644 --- a/tests/ui/bind_instead_of_map_multipart.fixed +++ b/tests/ui/bind_instead_of_map_multipart.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::bind_instead_of_map)] +//@run-rustfix +#![warn(clippy::bind_instead_of_map)] #![allow(clippy::blocks_in_if_conditions)] pub fn main() { diff --git a/tests/ui/bind_instead_of_map_multipart.rs b/tests/ui/bind_instead_of_map_multipart.rs index 49944403f6dd..635567eba0ee 100644 --- a/tests/ui/bind_instead_of_map_multipart.rs +++ b/tests/ui/bind_instead_of_map_multipart.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::bind_instead_of_map)] +//@run-rustfix +#![warn(clippy::bind_instead_of_map)] #![allow(clippy::blocks_in_if_conditions)] pub fn main() { diff --git a/tests/ui/bind_instead_of_map_multipart.stderr b/tests/ui/bind_instead_of_map_multipart.stderr index 0152a93feee4..4347c5fd756b 100644 --- a/tests/ui/bind_instead_of_map_multipart.stderr +++ b/tests/ui/bind_instead_of_map_multipart.stderr @@ -1,4 +1,4 @@ -error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` +warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` --> $DIR/bind_instead_of_map_multipart.rs:6:13 | LL | let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) }); @@ -7,14 +7,14 @@ LL | let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some note: the lint level is defined here --> $DIR/bind_instead_of_map_multipart.rs:2:9 | -LL | #![deny(clippy::bind_instead_of_map)] +LL | #![warn(clippy::bind_instead_of_map)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this | LL | let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() }); | ~~~ ~ ~~~~~~~ -error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)` +warning: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)` --> $DIR/bind_instead_of_map_multipart.rs:9:13 | LL | let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) }); @@ -25,7 +25,7 @@ help: try this LL | let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len() }); | ~~~ ~ ~~~~~~~ -error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)` +warning: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)` --> $DIR/bind_instead_of_map_multipart.rs:12:13 | LL | let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) }); @@ -36,7 +36,7 @@ help: try this LL | let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 } else { s.len() }); | ~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~ -error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` +warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` --> $DIR/bind_instead_of_map_multipart.rs:20:5 | LL | / Some("42").and_then(|s| { @@ -76,7 +76,7 @@ LL ~ 40 => 30, LL ~ _ => 1, | -error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` +warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` --> $DIR/bind_instead_of_map_multipart.rs:61:13 | LL | let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) }); @@ -87,5 +87,5 @@ help: try this LL | let _ = Some("").map(|s| if s.len() == 20 { m!() } else { Some(20) }); | ~~~ ~~~~ ~~~~~~~~ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/bit_masks.rs b/tests/ui/bit_masks.rs index cfb493fb52af..6372c293da59 100644 --- a/tests/ui/bit_masks.rs +++ b/tests/ui/bit_masks.rs @@ -1,7 +1,7 @@ const THREE_BITS: i64 = 7; const EVEN_MORE_REDIRECTION: i64 = THREE_BITS; -#[warn(clippy::bad_bit_mask)] +#[warn(clippy::bad_bit_mask, clippy::erasing_op)] #[allow( clippy::ineffective_bit_mask, clippy::identity_op, diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index dc5ad6dfbdff..42bc419e769e 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,110 +1,122 @@ -error: &-masking with zero +warning: &-masking with zero --> $DIR/bit_masks.rs:14:5 | LL | x & 0 == 0; | ^^^^^^^^^^ | - = note: `-D clippy::bad-bit-mask` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bit_masks.rs:4:8 + | +LL | #[warn(clippy::bad_bit_mask, clippy::erasing_op)] + | ^^^^^^^^^^^^^^^^^^^^ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/bit_masks.rs:14:5 | LL | x & 0 == 0; | ^^^^^ | - = note: `#[deny(clippy::erasing_op)]` on by default +note: the lint level is defined here + --> $DIR/bit_masks.rs:4:30 + | +LL | #[warn(clippy::bad_bit_mask, clippy::erasing_op)] + | ^^^^^^^^^^^^^^^^^^ -error: incompatible bit mask: `_ & 2` can never be equal to `1` +warning: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:17:5 | LL | x & 2 == 1; | ^^^^^^^^^^ -error: incompatible bit mask: `_ | 3` can never be equal to `2` +warning: incompatible bit mask: `_ | 3` can never be equal to `2` --> $DIR/bit_masks.rs:21:5 | LL | x | 3 == 2; | ^^^^^^^^^^ -error: incompatible bit mask: `_ & 1` will never be higher than `1` +warning: incompatible bit mask: `_ & 1` will never be higher than `1` --> $DIR/bit_masks.rs:23:5 | LL | x & 1 > 1; | ^^^^^^^^^ -error: incompatible bit mask: `_ | 2` will always be higher than `1` +warning: incompatible bit mask: `_ | 2` will always be higher than `1` --> $DIR/bit_masks.rs:27:5 | LL | x | 2 > 1; | ^^^^^^^^^ -error: incompatible bit mask: `_ & 7` can never be equal to `8` +warning: incompatible bit mask: `_ & 7` can never be equal to `8` --> $DIR/bit_masks.rs:34:5 | LL | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ -error: incompatible bit mask: `_ | 7` will never be lower than `7` +warning: incompatible bit mask: `_ | 7` will never be lower than `7` --> $DIR/bit_masks.rs:35:5 | LL | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: &-masking with zero +warning: &-masking with zero --> $DIR/bit_masks.rs:37:5 | LL | 0 & x == 0; | ^^^^^^^^^^ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/bit_masks.rs:37:5 | LL | 0 & x == 0; | ^^^^^ -error: incompatible bit mask: `_ | 2` will always be higher than `1` +warning: incompatible bit mask: `_ | 2` will always be higher than `1` --> $DIR/bit_masks.rs:41:5 | LL | 1 < 2 | x; | ^^^^^^^^^ -error: incompatible bit mask: `_ | 3` can never be equal to `2` +warning: incompatible bit mask: `_ | 3` can never be equal to `2` --> $DIR/bit_masks.rs:42:5 | LL | 2 == 3 | x; | ^^^^^^^^^^ -error: incompatible bit mask: `_ & 2` can never be equal to `1` +warning: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:43:5 | LL | 1 == x & 2; | ^^^^^^^^^^ -error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly +warning: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly --> $DIR/bit_masks.rs:54:5 | LL | x | 1 > 3; | ^^^^^^^^^ | - = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bit_masks.rs:49:8 + | +LL | #[warn(clippy::ineffective_bit_mask)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly +warning: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly --> $DIR/bit_masks.rs:55:5 | LL | x | 1 < 4; | ^^^^^^^^^ -error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly +warning: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly --> $DIR/bit_masks.rs:56:5 | LL | x | 1 <= 3; | ^^^^^^^^^^ -error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly +warning: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly --> $DIR/bit_masks.rs:57:5 | LL | x | 1 >= 8; | ^^^^^^^^^^ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/blanket_clippy_restriction_lints.rs b/tests/ui/blanket_clippy_restriction_lints.rs index 554745368bca..e1ff25c54cfc 100644 --- a/tests/ui/blanket_clippy_restriction_lints.rs +++ b/tests/ui/blanket_clippy_restriction_lints.rs @@ -1,4 +1,4 @@ -// compile-flags: -W clippy::restriction +//@compile-flags: -W clippy::restriction #![warn(clippy::blanket_clippy_restriction_lints)] diff --git a/tests/ui/blanket_clippy_restriction_lints.stderr b/tests/ui/blanket_clippy_restriction_lints.stderr index 2bf89ab69a40..af3372b95943 100644 --- a/tests/ui/blanket_clippy_restriction_lints.stderr +++ b/tests/ui/blanket_clippy_restriction_lints.stderr @@ -1,10 +1,14 @@ -error: `clippy::restriction` is not meant to be enabled as a group +warning: `clippy::restriction` is not meant to be enabled as a group | = note: because of the command line `--warn clippy::restriction` = help: enable the restriction lints you need individually - = note: `-D clippy::blanket-clippy-restriction-lints` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/blanket_clippy_restriction_lints.rs:3:9 + | +LL | #![warn(clippy::blanket_clippy_restriction_lints)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `clippy::restriction` is not meant to be enabled as a group +warning: `clippy::restriction` is not meant to be enabled as a group --> $DIR/blanket_clippy_restriction_lints.rs:6:9 | LL | #![warn(clippy::restriction)] @@ -12,7 +16,7 @@ LL | #![warn(clippy::restriction)] | = help: enable the restriction lints you need individually -error: `clippy::restriction` is not meant to be enabled as a group +warning: `clippy::restriction` is not meant to be enabled as a group --> $DIR/blanket_clippy_restriction_lints.rs:7:9 | LL | #![deny(clippy::restriction)] @@ -20,7 +24,7 @@ LL | #![deny(clippy::restriction)] | = help: enable the restriction lints you need individually -error: `clippy::restriction` is not meant to be enabled as a group +warning: `clippy::restriction` is not meant to be enabled as a group --> $DIR/blanket_clippy_restriction_lints.rs:8:11 | LL | #![forbid(clippy::restriction)] @@ -28,5 +32,5 @@ LL | #![forbid(clippy::restriction)] | = help: enable the restriction lints you need individually -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/blocks_in_if_conditions.fixed b/tests/ui/blocks_in_if_conditions.fixed index e6e40a9948c9..5e013eec1d50 100644 --- a/tests/ui/blocks_in_if_conditions.fixed +++ b/tests/ui/blocks_in_if_conditions.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::blocks_in_if_conditions)] #![allow(unused, clippy::let_and_return)] #![warn(clippy::nonminimal_bool)] @@ -37,7 +37,7 @@ fn condition_has_block_with_single_expression() -> i32 { fn condition_is_normal() -> i32 { let x = 3; - if x == 3 { 6 } else { 10 } + if true && x == 3 { 6 } else { 10 } } fn condition_is_unsafe_block() { diff --git a/tests/ui/blocks_in_if_conditions.rs b/tests/ui/blocks_in_if_conditions.rs index 69387ff5782b..0a70317c4d40 100644 --- a/tests/ui/blocks_in_if_conditions.rs +++ b/tests/ui/blocks_in_if_conditions.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::blocks_in_if_conditions)] #![allow(unused, clippy::let_and_return)] #![warn(clippy::nonminimal_bool)] diff --git a/tests/ui/blocks_in_if_conditions.stderr b/tests/ui/blocks_in_if_conditions.stderr index 079f2feb5c48..024a448c32ce 100644 --- a/tests/ui/blocks_in_if_conditions.stderr +++ b/tests/ui/blocks_in_if_conditions.stderr @@ -1,4 +1,4 @@ -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` +warning: 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/blocks_in_if_conditions.rs:24:5 | LL | / if { @@ -7,7 +7,11 @@ LL | | x == 3 LL | | } { | |_____^ | - = note: `-D clippy::blocks-in-if-conditions` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/blocks_in_if_conditions.rs:2:9 + | +LL | #![warn(clippy::blocks_in_if_conditions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | LL ~ let res = { @@ -16,19 +20,23 @@ LL + x == 3 LL ~ }; if res { | -error: omit braces around single expression condition +warning: omit braces around single expression condition --> $DIR/blocks_in_if_conditions.rs:35:8 | LL | if { true } { 6 } else { 10 } | ^^^^^^^^ help: try: `true` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/blocks_in_if_conditions.rs:40:8 | LL | if true && x == 3 { 6 } else { 10 } | ^^^^^^^^^^^^^^ help: try: `x == 3` | - = note: `-D clippy::nonminimal-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/blocks_in_if_conditions.rs:4:9 + | +LL | #![warn(clippy::nonminimal_bool)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/blocks_in_if_conditions_closure.stderr b/tests/ui/blocks_in_if_conditions_closure.stderr index 941d604dd5f9..8181720a1aeb 100644 --- a/tests/ui/blocks_in_if_conditions_closure.stderr +++ b/tests/ui/blocks_in_if_conditions_closure.stderr @@ -1,4 +1,4 @@ -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` +warning: 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/blocks_in_if_conditions_closure.rs:18:17 | LL | |x| { @@ -8,9 +8,13 @@ LL | | x == target LL | | }, | |_____________^ | - = note: `-D clippy::blocks-in-if-conditions` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/blocks_in_if_conditions_closure.rs:1:9 + | +LL | #![warn(clippy::blocks_in_if_conditions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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` +warning: 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/blocks_in_if_conditions_closure.rs:27:13 | LL | |x| { @@ -20,5 +24,5 @@ LL | | x == target LL | | }, | |_________^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/bool_assert_comparison.fixed b/tests/ui/bool_assert_comparison.fixed index b8dd92906c8d..53f63444aefe 100644 --- a/tests/ui/bool_assert_comparison.fixed +++ b/tests/ui/bool_assert_comparison.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::assertions_on_constants)] #![warn(clippy::bool_assert_comparison)] diff --git a/tests/ui/bool_assert_comparison.rs b/tests/ui/bool_assert_comparison.rs index 0a8ad34fda52..151d93a9233b 100644 --- a/tests/ui/bool_assert_comparison.rs +++ b/tests/ui/bool_assert_comparison.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::assertions_on_constants)] #![warn(clippy::bool_assert_comparison)] diff --git a/tests/ui/bool_assert_comparison.stderr b/tests/ui/bool_assert_comparison.stderr index 89cefc95a9f6..180cf6b72e9f 100644 --- a/tests/ui/bool_assert_comparison.stderr +++ b/tests/ui/bool_assert_comparison.stderr @@ -1,17 +1,21 @@ -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:89:5 | LL | assert_eq!("a".is_empty(), false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::bool-assert-comparison` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bool_assert_comparison.rs:4:9 + | +LL | #![warn(clippy::bool_assert_comparison)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with `assert!(..)` | LL - assert_eq!("a".is_empty(), false); LL + assert!(!"a".is_empty()); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:90:5 | LL | assert_eq!("".is_empty(), true); @@ -23,7 +27,7 @@ LL - assert_eq!("".is_empty(), true); LL + assert!("".is_empty()); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:91:5 | LL | assert_eq!(true, "".is_empty()); @@ -35,7 +39,7 @@ LL - assert_eq!(true, "".is_empty()); LL + assert!("".is_empty()); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:96:5 | LL | assert_eq!(b, true); @@ -47,7 +51,7 @@ LL - assert_eq!(b, true); LL + assert!(b); | -error: used `assert_ne!` with a literal bool +warning: used `assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:99:5 | LL | assert_ne!("a".is_empty(), false); @@ -59,7 +63,7 @@ LL - assert_ne!("a".is_empty(), false); LL + assert!("a".is_empty()); | -error: used `assert_ne!` with a literal bool +warning: used `assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:100:5 | LL | assert_ne!("".is_empty(), true); @@ -71,7 +75,7 @@ LL - assert_ne!("".is_empty(), true); LL + assert!(!"".is_empty()); | -error: used `assert_ne!` with a literal bool +warning: used `assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:101:5 | LL | assert_ne!(true, "".is_empty()); @@ -83,7 +87,7 @@ LL - assert_ne!(true, "".is_empty()); LL + assert!(!"".is_empty()); | -error: used `assert_ne!` with a literal bool +warning: used `assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:106:5 | LL | assert_ne!(b, true); @@ -95,7 +99,7 @@ LL - assert_ne!(b, true); LL + assert!(!b); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:109:5 | LL | debug_assert_eq!("a".is_empty(), false); @@ -107,7 +111,7 @@ LL - debug_assert_eq!("a".is_empty(), false); LL + debug_assert!(!"a".is_empty()); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:110:5 | LL | debug_assert_eq!("".is_empty(), true); @@ -119,7 +123,7 @@ LL - debug_assert_eq!("".is_empty(), true); LL + debug_assert!("".is_empty()); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:111:5 | LL | debug_assert_eq!(true, "".is_empty()); @@ -131,7 +135,7 @@ LL - debug_assert_eq!(true, "".is_empty()); LL + debug_assert!("".is_empty()); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:116:5 | LL | debug_assert_eq!(b, true); @@ -143,7 +147,7 @@ LL - debug_assert_eq!(b, true); LL + debug_assert!(b); | -error: used `debug_assert_ne!` with a literal bool +warning: used `debug_assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:119:5 | LL | debug_assert_ne!("a".is_empty(), false); @@ -155,7 +159,7 @@ LL - debug_assert_ne!("a".is_empty(), false); LL + debug_assert!("a".is_empty()); | -error: used `debug_assert_ne!` with a literal bool +warning: used `debug_assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:120:5 | LL | debug_assert_ne!("".is_empty(), true); @@ -167,7 +171,7 @@ LL - debug_assert_ne!("".is_empty(), true); LL + debug_assert!(!"".is_empty()); | -error: used `debug_assert_ne!` with a literal bool +warning: used `debug_assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:121:5 | LL | debug_assert_ne!(true, "".is_empty()); @@ -179,7 +183,7 @@ LL - debug_assert_ne!(true, "".is_empty()); LL + debug_assert!(!"".is_empty()); | -error: used `debug_assert_ne!` with a literal bool +warning: used `debug_assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:126:5 | LL | debug_assert_ne!(b, true); @@ -191,7 +195,7 @@ LL - debug_assert_ne!(b, true); LL + debug_assert!(!b); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:131:5 | LL | assert_eq!("a".is_empty(), false, "tadam {}", 1); @@ -203,7 +207,7 @@ LL - assert_eq!("a".is_empty(), false, "tadam {}", 1); LL + assert!(!"a".is_empty(), "tadam {}", 1); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:132:5 | LL | assert_eq!("a".is_empty(), false, "tadam {}", true); @@ -215,7 +219,7 @@ LL - assert_eq!("a".is_empty(), false, "tadam {}", true); LL + assert!(!"a".is_empty(), "tadam {}", true); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:133:5 | LL | assert_eq!(false, "a".is_empty(), "tadam {}", true); @@ -227,7 +231,7 @@ LL - assert_eq!(false, "a".is_empty(), "tadam {}", true); LL + assert!(!"a".is_empty(), "tadam {}", true); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:138:5 | LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", 1); @@ -239,7 +243,7 @@ LL - debug_assert_eq!("a".is_empty(), false, "tadam {}", 1); LL + debug_assert!(!"a".is_empty(), "tadam {}", 1); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:139:5 | LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", true); @@ -251,7 +255,7 @@ LL - debug_assert_eq!("a".is_empty(), false, "tadam {}", true); LL + debug_assert!(!"a".is_empty(), "tadam {}", true); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:140:5 | LL | debug_assert_eq!(false, "a".is_empty(), "tadam {}", true); @@ -263,7 +267,7 @@ LL - debug_assert_eq!(false, "a".is_empty(), "tadam {}", true); LL + debug_assert!(!"a".is_empty(), "tadam {}", true); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:143:5 | LL | assert_eq!(a!(), true); @@ -275,7 +279,7 @@ LL - assert_eq!(a!(), true); LL + assert!(a!()); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:144:5 | LL | assert_eq!(true, b!()); @@ -287,7 +291,7 @@ LL - assert_eq!(true, b!()); LL + assert!(b!()); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:148:5 | LL | renamed!(b, true); @@ -299,7 +303,7 @@ LL - renamed!(b, true); LL + debug_assert!(b); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:162:5 | LL | assert_eq!("".is_empty(), true); @@ -311,7 +315,7 @@ LL - assert_eq!("".is_empty(), true); LL + assert!("".is_empty()); | -error: used `assert_ne!` with a literal bool +warning: used `assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:163:5 | LL | assert_ne!("".is_empty(), false); @@ -323,7 +327,7 @@ LL - assert_ne!("".is_empty(), false); LL + assert!("".is_empty()); | -error: used `assert_ne!` with a literal bool +warning: used `assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:164:5 | LL | assert_ne!("requires negation".is_empty(), true); @@ -335,7 +339,7 @@ LL - assert_ne!("requires negation".is_empty(), true); LL + assert!(!"requires negation".is_empty()); | -error: used `assert_eq!` with a literal bool +warning: used `assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:165:5 | LL | assert_eq!("requires negation".is_empty(), false); @@ -347,7 +351,7 @@ LL - assert_eq!("requires negation".is_empty(), false); LL + assert!(!"requires negation".is_empty()); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:167:5 | LL | debug_assert_eq!("".is_empty(), true); @@ -359,7 +363,7 @@ LL - debug_assert_eq!("".is_empty(), true); LL + debug_assert!("".is_empty()); | -error: used `debug_assert_ne!` with a literal bool +warning: used `debug_assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:168:5 | LL | debug_assert_ne!("".is_empty(), false); @@ -371,7 +375,7 @@ LL - debug_assert_ne!("".is_empty(), false); LL + debug_assert!("".is_empty()); | -error: used `debug_assert_ne!` with a literal bool +warning: used `debug_assert_ne!` with a literal bool --> $DIR/bool_assert_comparison.rs:169:5 | LL | debug_assert_ne!("requires negation".is_empty(), true); @@ -383,7 +387,7 @@ LL - debug_assert_ne!("requires negation".is_empty(), true); LL + debug_assert!(!"requires negation".is_empty()); | -error: used `debug_assert_eq!` with a literal bool +warning: used `debug_assert_eq!` with a literal bool --> $DIR/bool_assert_comparison.rs:170:5 | LL | debug_assert_eq!("requires negation".is_empty(), false); @@ -395,5 +399,5 @@ LL - debug_assert_eq!("requires negation".is_empty(), false); LL + debug_assert!(!"requires negation".is_empty()); | -error: aborting due to 33 previous errors +warning: 33 warnings emitted diff --git a/tests/ui/bool_comparison.fixed b/tests/ui/bool_comparison.fixed index 5a012ff4d27a..8a31b68e7c77 100644 --- a/tests/ui/bool_comparison.fixed +++ b/tests/ui/bool_comparison.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::bool_comparison)] @@ -148,10 +148,10 @@ fn issue3973() { if cfg!(feature = "debugging") == true {} // lint, could be simplified - if !m!(func) {} - if !m!(func) {} - if m!(func) {} - if m!(func) {} + if false == m!(func) {} + if m!(func) == false {} + if true == m!(func) {} + if m!(func) == true {} // no lint with a variable let is_debug = false; diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index c534bc25c20f..72851be635d0 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::bool_comparison)] diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index 31522d4a5251..31ca9cb959a3 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -1,136 +1,140 @@ -error: equality checks against true are unnecessary +warning: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:7:8 | LL | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` | - = note: `-D clippy::bool-comparison` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bool_comparison.rs:3:9 + | +LL | #![warn(clippy::bool_comparison)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: equality checks against false can be replaced by a negation +warning: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:12:8 | LL | if x == false { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` -error: equality checks against true are unnecessary +warning: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:17:8 | LL | if true == x { | ^^^^^^^^^ help: try simplifying it as shown: `x` -error: equality checks against false can be replaced by a negation +warning: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:22:8 | LL | if false == x { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` -error: inequality checks against true can be replaced by a negation +warning: inequality checks against true can be replaced by a negation --> $DIR/bool_comparison.rs:27:8 | LL | if x != true { | ^^^^^^^^^ help: try simplifying it as shown: `!x` -error: inequality checks against false are unnecessary +warning: inequality checks against false are unnecessary --> $DIR/bool_comparison.rs:32:8 | LL | if x != false { | ^^^^^^^^^^ help: try simplifying it as shown: `x` -error: inequality checks against true can be replaced by a negation +warning: inequality checks against true can be replaced by a negation --> $DIR/bool_comparison.rs:37:8 | LL | if true != x { | ^^^^^^^^^ help: try simplifying it as shown: `!x` -error: inequality checks against false are unnecessary +warning: inequality checks against false are unnecessary --> $DIR/bool_comparison.rs:42:8 | LL | if false != x { | ^^^^^^^^^^ help: try simplifying it as shown: `x` -error: less than comparison against true can be replaced by a negation +warning: less than comparison against true can be replaced by a negation --> $DIR/bool_comparison.rs:47:8 | LL | if x < true { | ^^^^^^^^ help: try simplifying it as shown: `!x` -error: greater than checks against false are unnecessary +warning: greater than checks against false are unnecessary --> $DIR/bool_comparison.rs:52:8 | LL | if false < x { | ^^^^^^^^^ help: try simplifying it as shown: `x` -error: greater than checks against false are unnecessary +warning: greater than checks against false are unnecessary --> $DIR/bool_comparison.rs:57:8 | LL | if x > false { | ^^^^^^^^^ help: try simplifying it as shown: `x` -error: less than comparison against true can be replaced by a negation +warning: less than comparison against true can be replaced by a negation --> $DIR/bool_comparison.rs:62:8 | LL | if true > x { | ^^^^^^^^ help: try simplifying it as shown: `!x` -error: order comparisons between booleans can be simplified +warning: order comparisons between booleans can be simplified --> $DIR/bool_comparison.rs:68:8 | LL | if x < y { | ^^^^^ help: try simplifying it as shown: `!x & y` -error: order comparisons between booleans can be simplified +warning: order comparisons between booleans can be simplified --> $DIR/bool_comparison.rs:73:8 | LL | if x > y { | ^^^^^ help: try simplifying it as shown: `x & !y` -error: this comparison might be written more concisely +warning: this comparison might be written more concisely --> $DIR/bool_comparison.rs:121:8 | LL | if a == !b {}; | ^^^^^^^ help: try simplifying it as shown: `a != b` -error: this comparison might be written more concisely +warning: this comparison might be written more concisely --> $DIR/bool_comparison.rs:122:8 | LL | if !a == b {}; | ^^^^^^^ help: try simplifying it as shown: `a != b` -error: this comparison might be written more concisely +warning: this comparison might be written more concisely --> $DIR/bool_comparison.rs:126:8 | LL | if b == !a {}; | ^^^^^^^ help: try simplifying it as shown: `b != a` -error: this comparison might be written more concisely +warning: this comparison might be written more concisely --> $DIR/bool_comparison.rs:127:8 | LL | if !b == a {}; | ^^^^^^^ help: try simplifying it as shown: `b != a` -error: equality checks against false can be replaced by a negation +warning: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:151:8 | LL | if false == m!(func) {} | ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)` -error: equality checks against false can be replaced by a negation +warning: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:152:8 | LL | if m!(func) == false {} | ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)` -error: equality checks against true are unnecessary +warning: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:153:8 | LL | if true == m!(func) {} | ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)` -error: equality checks against true are unnecessary +warning: equality checks against true are unnecessary --> $DIR/bool_comparison.rs:154:8 | LL | if m!(func) == true {} | ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)` -error: aborting due to 22 previous errors +warning: 22 warnings emitted diff --git a/tests/ui/bool_to_int_with_if.fixed b/tests/ui/bool_to_int_with_if.fixed index 37d3e3286a4b..9831c3373d45 100644 --- a/tests/ui/bool_to_int_with_if.fixed +++ b/tests/ui/bool_to_int_with_if.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(let_chains)] #![warn(clippy::bool_to_int_with_if)] diff --git a/tests/ui/bool_to_int_with_if.rs b/tests/ui/bool_to_int_with_if.rs index ebdf86fd1856..5e3047bb32c6 100644 --- a/tests/ui/bool_to_int_with_if.rs +++ b/tests/ui/bool_to_int_with_if.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(let_chains)] #![warn(clippy::bool_to_int_with_if)] diff --git a/tests/ui/bool_to_int_with_if.stderr b/tests/ui/bool_to_int_with_if.stderr index 5cfb75cc0dfc..057644e602fd 100644 --- a/tests/ui/bool_to_int_with_if.stderr +++ b/tests/ui/bool_to_int_with_if.stderr @@ -1,4 +1,4 @@ -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:16:5 | LL | / if a { @@ -9,9 +9,13 @@ LL | | }; | |_____^ help: replace with from: `i32::from(a)` | = note: `a as i32` or `a.into()` can also be valid options - = note: `-D clippy::bool-to-int-with-if` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bool_to_int_with_if.rs:4:9 + | +LL | #![warn(clippy::bool_to_int_with_if)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:21:5 | LL | / if a { @@ -23,7 +27,7 @@ LL | | }; | = note: `!a as i32` or `(!a).into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:26:5 | LL | / if !a { @@ -35,7 +39,7 @@ LL | | }; | = note: `!a as i32` or `(!a).into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:31:5 | LL | / if a || b { @@ -47,7 +51,7 @@ LL | | }; | = note: `(a || b) as i32` or `(a || b).into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:36:5 | LL | / if cond(a, b) { @@ -59,7 +63,7 @@ LL | | }; | = note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:41:5 | LL | / if x + y < 4 { @@ -71,7 +75,7 @@ LL | | }; | = note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:50:12 | LL | } else if b { @@ -84,7 +88,7 @@ LL | | }; | = note: `b as i32` or `b.into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:59:12 | LL | } else if b { @@ -97,7 +101,7 @@ LL | | }; | = note: `!b as i32` or `(!b).into()` can also be valid options -error: boolean to int conversion using if +warning: boolean to int conversion using if --> $DIR/bool_to_int_with_if.rs:119:5 | LL | if a { 1 } else { 0 } @@ -105,5 +109,5 @@ LL | if a { 1 } else { 0 } | = note: `a as u8` or `a.into()` can also be valid options -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/borrow_as_ptr.fixed b/tests/ui/borrow_as_ptr.fixed index ff5c6a8c3774..3f440ce0045a 100644 --- a/tests/ui/borrow_as_ptr.fixed +++ b/tests/ui/borrow_as_ptr.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::borrow_as_ptr)] fn main() { diff --git a/tests/ui/borrow_as_ptr.rs b/tests/ui/borrow_as_ptr.rs index 0f62ec6ee58b..c1ca9180eef4 100644 --- a/tests/ui/borrow_as_ptr.rs +++ b/tests/ui/borrow_as_ptr.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::borrow_as_ptr)] fn main() { diff --git a/tests/ui/borrow_as_ptr.stderr b/tests/ui/borrow_as_ptr.stderr index be1ed7330567..db64217cf7ac 100644 --- a/tests/ui/borrow_as_ptr.stderr +++ b/tests/ui/borrow_as_ptr.stderr @@ -1,16 +1,20 @@ -error: borrow as raw pointer +warning: borrow as raw pointer --> $DIR/borrow_as_ptr.rs:6:14 | LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)` | - = note: `-D clippy::borrow-as-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/borrow_as_ptr.rs:2:9 + | +LL | #![warn(clippy::borrow_as_ptr)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: borrow as raw pointer +warning: borrow as raw pointer --> $DIR/borrow_as_ptr.rs:9:18 | LL | let _p_mut = &mut val_mut as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/borrow_as_ptr_no_std.fixed b/tests/ui/borrow_as_ptr_no_std.fixed index eaba3b1c20c8..10f2727c793c 100644 --- a/tests/ui/borrow_as_ptr_no_std.fixed +++ b/tests/ui/borrow_as_ptr_no_std.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::borrow_as_ptr)] #![feature(lang_items, start, libc)] #![no_std] diff --git a/tests/ui/borrow_as_ptr_no_std.rs b/tests/ui/borrow_as_ptr_no_std.rs index d83f9d1f875b..311e9341aac2 100644 --- a/tests/ui/borrow_as_ptr_no_std.rs +++ b/tests/ui/borrow_as_ptr_no_std.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::borrow_as_ptr)] #![feature(lang_items, start, libc)] #![no_std] diff --git a/tests/ui/borrow_as_ptr_no_std.stderr b/tests/ui/borrow_as_ptr_no_std.stderr index 84c8ba7d07f1..7f3ab163e368 100644 --- a/tests/ui/borrow_as_ptr_no_std.stderr +++ b/tests/ui/borrow_as_ptr_no_std.stderr @@ -1,16 +1,20 @@ -error: borrow as raw pointer +warning: borrow as raw pointer --> $DIR/borrow_as_ptr_no_std.rs:9:14 | LL | let _p = &val as *const i32; | ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of!(val)` | - = note: `-D clippy::borrow-as-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/borrow_as_ptr_no_std.rs:2:9 + | +LL | #![warn(clippy::borrow_as_ptr)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: borrow as raw pointer +warning: borrow as raw pointer --> $DIR/borrow_as_ptr_no_std.rs:12:18 | LL | let _p_mut = &mut val_mut as *mut i32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of_mut!(val_mut)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/borrow_box.rs b/tests/ui/borrow_box.rs index 3b5b6bf4c950..b09c421f2b57 100644 --- a/tests/ui/borrow_box.rs +++ b/tests/ui/borrow_box.rs @@ -1,4 +1,4 @@ -#![deny(clippy::borrowed_box)] +#![warn(clippy::borrowed_box)] #![allow(dead_code, unused_variables)] #![allow(clippy::uninlined_format_args, clippy::disallowed_names)] diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 99cb60a1ead9..c17182f1d35b 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -1,4 +1,4 @@ -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:20:14 | LL | let foo: &Box; @@ -7,62 +7,62 @@ LL | let foo: &Box; note: the lint level is defined here --> $DIR/borrow_box.rs:1:9 | -LL | #![deny(clippy::borrowed_box)] +LL | #![warn(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:24:10 | LL | foo: &'a Box, | ^^^^^^^^^^^^^ help: try: `&'a bool` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:28:17 | LL | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:94:25 | LL | pub fn test14(_display: &Box) {} | ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:95:25 | LL | pub fn test15(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:96:29 | LL | pub fn test16<'a>(_display: &'a Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:98:25 | LL | pub fn test17(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:99:25 | LL | pub fn test18(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:100:29 | LL | pub fn test19<'a>(_display: &'a Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)` -error: you seem to be trying to use `&Box`. Consider using just `&T` +warning: you seem to be trying to use `&Box`. Consider using just `&T` --> $DIR/borrow_box.rs:105:25 | LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/borrow_deref_ref.fixed b/tests/ui/borrow_deref_ref.fixed index bf4691c5bc97..165e4bc82723 100644 --- a/tests/ui/borrow_deref_ref.fixed +++ b/tests/ui/borrow_deref_ref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_variables)] diff --git a/tests/ui/borrow_deref_ref.rs b/tests/ui/borrow_deref_ref.rs index 28c005fdbef7..66c8d69bef98 100644 --- a/tests/ui/borrow_deref_ref.rs +++ b/tests/ui/borrow_deref_ref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_variables)] diff --git a/tests/ui/borrow_deref_ref.stderr b/tests/ui/borrow_deref_ref.stderr index d72de37c69ff..49f0059790b5 100644 --- a/tests/ui/borrow_deref_ref.stderr +++ b/tests/ui/borrow_deref_ref.stderr @@ -1,22 +1,22 @@ -error: deref on an immutable reference +warning: deref on an immutable reference --> $DIR/borrow_deref_ref.rs:10:17 | LL | let b = &*a; | ^^^ help: if you would like to reborrow, try removing `&*`: `a` | - = note: `-D clippy::borrow-deref-ref` implied by `-D warnings` + = note: `#[warn(clippy::borrow_deref_ref)]` on by default -error: deref on an immutable reference +warning: deref on an immutable reference --> $DIR/borrow_deref_ref.rs:12:22 | LL | let b = &mut &*bar(&12); | ^^^^^^^^^^ help: if you would like to reborrow, try removing `&*`: `bar(&12)` -error: deref on an immutable reference +warning: deref on an immutable reference --> $DIR/borrow_deref_ref.rs:55:23 | LL | let addr_y = &&*x as *const _ as usize; // assert ok | ^^^ help: if you would like to reborrow, try removing `&*`: `x` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/borrow_deref_ref_unfixable.stderr b/tests/ui/borrow_deref_ref_unfixable.stderr index 738b01e7ec1e..d3171af95244 100644 --- a/tests/ui/borrow_deref_ref_unfixable.stderr +++ b/tests/ui/borrow_deref_ref_unfixable.stderr @@ -1,10 +1,10 @@ -error: deref on an immutable reference +warning: deref on an immutable reference --> $DIR/borrow_deref_ref_unfixable.rs:8:23 | LL | let x: &str = &*s; | ^^^ | - = note: `-D clippy::borrow-deref-ref` implied by `-D warnings` + = note: `#[warn(clippy::borrow_deref_ref)]` on by default help: if you would like to reborrow, try removing `&*` | LL | let x: &str = s; @@ -14,5 +14,5 @@ help: if you would like to deref, try using `&**` LL | let x: &str = &**s; | ~~~~ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/borrow_interior_mutable_const/enums.rs b/tests/ui/borrow_interior_mutable_const/enums.rs index 5027db445617..da940a4cfb50 100644 --- a/tests/ui/borrow_interior_mutable_const/enums.rs +++ b/tests/ui/borrow_interior_mutable_const/enums.rs @@ -1,6 +1,6 @@ -// aux-build:helper.rs +//@aux-build:helper.rs -#![warn(clippy::borrow_interior_mutable_const)] +#![deny(clippy::borrow_interior_mutable_const)] #![allow(clippy::declare_interior_mutable_const)] // this file (mostly) replicates its `declare` counterpart. Please see it for more discussions. @@ -19,7 +19,7 @@ const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); const FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen; fn borrow_optional_cell() { - let _ = &UNFROZEN_VARIANT; //~ ERROR interior mutability + let _ = &UNFROZEN_VARIANT; //~ ERROR: interior mutability let _ = &FROZEN_VARIANT; } @@ -34,11 +34,11 @@ trait AssocConsts { // This is the "suboptimal behavior" mentioned in `is_value_unfrozen` // caused by a similar reason to unfrozen types without any default values // get linted even if it has frozen variants'. - let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR interior mutable + let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR: interior mutability // The lint ignores default values because an impl of this trait can set // an unfrozen variant to `DEFAULTED_ON_FROZEN_VARIANT` and use the default impl for `function`. - let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR interior mutable + let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR: interior mutability } } @@ -47,9 +47,9 @@ impl AssocConsts for u64 { const TO_BE_FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen; fn function() { - let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable + let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR: interior mutability let _ = &::TO_BE_FROZEN_VARIANT; - let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR interior mutable + let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR: interior mutability let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; } } @@ -67,11 +67,11 @@ trait AssocTypes { impl AssocTypes for u64 { type ToBeUnfrozen = AtomicUsize; - const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR interior mutable + const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); const TO_BE_FROZEN_VARIANT: Option = None; fn function() { - let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable + let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR: interior mutability let _ = &::TO_BE_FROZEN_VARIANT; } } @@ -83,19 +83,19 @@ enum BothOfCellAndGeneric { } impl BothOfCellAndGeneric { - const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable - const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable + const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); + const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); const FROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Frozen(5); fn function() { - let _ = &Self::UNFROZEN_VARIANT; //~ ERROR interior mutability - let _ = &Self::GENERIC_VARIANT; //~ ERROR interior mutability + let _ = &Self::UNFROZEN_VARIANT; //~ ERROR: interior mutability + let _ = &Self::GENERIC_VARIANT; //~ ERROR: interior mutability let _ = &Self::FROZEN_VARIANT; } } fn main() { // constants defined in foreign crates - let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; //~ ERROR interior mutability + let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; //~ ERROR: interior mutability let _ = &helper::WRAPPED_PRIVATE_FROZEN_VARIANT; } diff --git a/tests/ui/borrow_interior_mutable_const/enums.stderr b/tests/ui/borrow_interior_mutable_const/enums.stderr index b0cab977a038..b753ec92608a 100644 --- a/tests/ui/borrow_interior_mutable_const/enums.stderr +++ b/tests/ui/borrow_interior_mutable_const/enums.stderr @@ -1,16 +1,20 @@ error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:22:14 | -LL | let _ = &UNFROZEN_VARIANT; //~ ERROR interior mutability +LL | let _ = &UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here - = note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/enums.rs:3:9 + | +LL | #![deny(clippy::borrow_interior_mutable_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:37:18 | -LL | let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR interior mutable +LL | let _ = &Self::TO_BE_FROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -18,7 +22,7 @@ LL | let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:41:18 | -LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR interior mutable +LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -26,7 +30,7 @@ LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR interior muta error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:50:18 | -LL | let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable +LL | let _ = &::TO_BE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -34,7 +38,7 @@ LL | let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR i error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:52:18 | -LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR interior mutable +LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -42,7 +46,7 @@ LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR interior mu error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:74:18 | -LL | let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable +LL | let _ = &::TO_BE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -50,7 +54,7 @@ LL | let _ = &::TO_BE_UNFROZEN_VARIANT; //~ ERROR in error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:91:18 | -LL | let _ = &Self::UNFROZEN_VARIANT; //~ ERROR interior mutability +LL | let _ = &Self::UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -58,7 +62,7 @@ LL | let _ = &Self::UNFROZEN_VARIANT; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:92:18 | -LL | let _ = &Self::GENERIC_VARIANT; //~ ERROR interior mutability +LL | let _ = &Self::GENERIC_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -66,7 +70,7 @@ LL | let _ = &Self::GENERIC_VARIANT; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/enums.rs:99:14 | -LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; //~ ERROR interior mutability +LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/borrow_interior_mutable_const/others.rs b/tests/ui/borrow_interior_mutable_const/others.rs index 7c57864245a9..0ea93dd84625 100644 --- a/tests/ui/borrow_interior_mutable_const/others.rs +++ b/tests/ui/borrow_interior_mutable_const/others.rs @@ -1,4 +1,4 @@ -#![warn(clippy::borrow_interior_mutable_const)] +#![deny(clippy::borrow_interior_mutable_const)] #![allow(clippy::declare_interior_mutable_const, clippy::needless_borrow)] #![allow(const_item_mutation)] @@ -51,14 +51,14 @@ impl std::ops::Deref for StaticRef { const CELL_REF: StaticRef<(UnsafeCell,)> = unsafe { StaticRef::new(std::ptr::null()) }; fn main() { - ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability - assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability + ATOMIC.store(1, Ordering::SeqCst); //~ ERROR: interior mutability + assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR: interior mutability let _once = ONCE_INIT; - let _once_ref = &ONCE_INIT; //~ ERROR interior mutability - let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability - let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability - let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability + let _once_ref = &ONCE_INIT; //~ ERROR: interior mutability + let _once_ref_2 = &&ONCE_INIT; //~ ERROR: interior mutability + let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR: interior mutability + let _once_mut = &mut ONCE_INIT; //~ ERROR: interior mutability let _atomic_into_inner = ATOMIC.into_inner(); // these should be all fine. let _twice = (ONCE_INIT, ONCE_INIT); @@ -69,23 +69,23 @@ fn main() { let _ref_array_once = &[ONCE_INIT, ONCE_INIT][0]; // referencing projection is still bad. - let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability - let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability - let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability - let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability - let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability + let _ = &ATOMIC_TUPLE; //~ ERROR: interior mutability + let _ = &ATOMIC_TUPLE.0; //~ ERROR: interior mutability + let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR: interior mutability + let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability + let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR: interior mutability let _ = &*ATOMIC_TUPLE.1; let _ = &ATOMIC_TUPLE.2; let _ = (&&&&ATOMIC_TUPLE).0; let _ = (&&&&ATOMIC_TUPLE).2; let _ = ATOMIC_TUPLE.0; - let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability + let _ = ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability let _ = ATOMIC_TUPLE.1.into_iter(); let _ = ATOMIC_TUPLE.2; let _ = &{ ATOMIC_TUPLE }; - CELL.set(2); //~ ERROR interior mutability - assert_eq!(CELL.get(), 6); //~ ERROR interior mutability + CELL.set(2); //~ ERROR: interior mutability + assert_eq!(CELL.get(), 6); //~ ERROR: interior mutability assert_eq!(INTEGER, 8); assert!(STRING.is_empty()); diff --git a/tests/ui/borrow_interior_mutable_const/others.stderr b/tests/ui/borrow_interior_mutable_const/others.stderr index c87ad206c2ae..200e04b8f6be 100644 --- a/tests/ui/borrow_interior_mutable_const/others.stderr +++ b/tests/ui/borrow_interior_mutable_const/others.stderr @@ -1,16 +1,20 @@ error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:54:5 | -LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability +LL | ATOMIC.store(1, Ordering::SeqCst); | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here - = note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/others.rs:1:9 + | +LL | #![deny(clippy::borrow_interior_mutable_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:55:16 | -LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability +LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -18,7 +22,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutabi error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:58:22 | -LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability +LL | let _once_ref = &ONCE_INIT; | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -26,7 +30,7 @@ LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:59:25 | -LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability +LL | let _once_ref_2 = &&ONCE_INIT; | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -34,7 +38,7 @@ LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:60:27 | -LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability +LL | let _once_ref_4 = &&&&ONCE_INIT; | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -42,7 +46,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:61:26 | -LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability +LL | let _once_mut = &mut ONCE_INIT; | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -50,7 +54,7 @@ LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:72:14 | -LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability +LL | let _ = &ATOMIC_TUPLE; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -58,7 +62,7 @@ LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:73:14 | -LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability +LL | let _ = &ATOMIC_TUPLE.0; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -66,7 +70,7 @@ LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:74:19 | -LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability +LL | let _ = &(&&&&ATOMIC_TUPLE).0; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -74,7 +78,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:75:14 | -LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +LL | let _ = &ATOMIC_TUPLE.0[0]; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -82,7 +86,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:76:13 | -LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability +LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -90,7 +94,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mu error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:82:13 | -LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +LL | let _ = ATOMIC_TUPLE.0[0]; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -98,7 +102,7 @@ LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:87:5 | -LL | CELL.set(2); //~ ERROR interior mutability +LL | CELL.set(2); | ^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -106,7 +110,7 @@ LL | CELL.set(2); //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/others.rs:88:16 | -LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability +LL | assert_eq!(CELL.get(), 6); | ^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/borrow_interior_mutable_const/traits.rs b/tests/ui/borrow_interior_mutable_const/traits.rs index 06b5d62e8f9a..4da3833cbf5a 100644 --- a/tests/ui/borrow_interior_mutable_const/traits.rs +++ b/tests/ui/borrow_interior_mutable_const/traits.rs @@ -1,4 +1,4 @@ -#![warn(clippy::borrow_interior_mutable_const)] +#![deny(clippy::borrow_interior_mutable_const)] #![allow(clippy::declare_interior_mutable_const)] // this file replicates its `declare` counterpart. Please see it for more discussions. @@ -12,7 +12,7 @@ trait ConcreteTypes { const STRING: String; fn function() { - let _ = &Self::ATOMIC; //~ ERROR interior mutable + let _ = &Self::ATOMIC; //~ ERROR: interior mutability let _ = &Self::STRING; } } @@ -23,7 +23,7 @@ impl ConcreteTypes for u64 { fn function() { // Lint this again since implementers can choose not to borrow it. - let _ = &Self::ATOMIC; //~ ERROR interior mutable + let _ = &Self::ATOMIC; //~ ERROR: interior mutability let _ = &Self::STRING; } } @@ -48,7 +48,7 @@ impl GenericTypes for Vec { fn function() { let _ = &Self::TO_REMAIN_GENERIC; - let _ = &Self::TO_BE_CONCRETE; //~ ERROR interior mutable + let _ = &Self::TO_BE_CONCRETE; //~ ERROR: interior mutability } } @@ -83,8 +83,8 @@ impl AssocTypes for Vec { fn function() { let _ = &Self::TO_BE_FROZEN; - let _ = &Self::TO_BE_UNFROZEN; //~ ERROR interior mutable - let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR interior mutable + let _ = &Self::TO_BE_UNFROZEN; //~ ERROR: interior mutability + let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR: interior mutability let _ = &Self::WRAPPED_TO_BE_GENERIC_PARAM; } } @@ -106,7 +106,7 @@ where fn function() { let _ = &Self::NOT_BOUNDED; - let _ = &Self::BOUNDED; //~ ERROR interior mutable + let _ = &Self::BOUNDED; //~ ERROR: interior mutability } } @@ -119,7 +119,7 @@ where fn function() { let _ = &Self::NOT_BOUNDED; - let _ = &Self::BOUNDED; //~ ERROR interior mutable + let _ = &Self::BOUNDED; //~ ERROR: interior mutability } } @@ -148,8 +148,8 @@ impl SelfType for AtomicUsize { const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); fn function() { - let _ = &Self::SELF; //~ ERROR interior mutable - let _ = &Self::WRAPPED_SELF; //~ ERROR interior mutable + let _ = &Self::SELF; //~ ERROR: interior mutability + let _ = &Self::WRAPPED_SELF; //~ ERROR: interior mutability } } @@ -159,7 +159,7 @@ trait BothOfCellAndGeneric { fn function() { let _ = &Self::DIRECT; - let _ = &Self::INDIRECT; //~ ERROR interior mutable + let _ = &Self::INDIRECT; //~ ERROR: interior mutability } } @@ -169,7 +169,7 @@ impl BothOfCellAndGeneric for Vec { fn function() { let _ = &Self::DIRECT; - let _ = &Self::INDIRECT; //~ ERROR interior mutable + let _ = &Self::INDIRECT; //~ ERROR: interior mutability } } @@ -188,15 +188,15 @@ where const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); fn function() { - let _ = &Self::ATOMIC; //~ ERROR interior mutable + let _ = &Self::ATOMIC; //~ ERROR: interior mutability let _ = &Self::COW; let _ = &Self::GENERIC_TYPE; let _ = &Self::ASSOC_TYPE; - let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR interior mutable + let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR: interior mutability } } fn main() { - u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability - assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability + u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR: interior mutability + assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR: interior mutability } diff --git a/tests/ui/borrow_interior_mutable_const/traits.stderr b/tests/ui/borrow_interior_mutable_const/traits.stderr index f34ae8814c33..add223acd68c 100644 --- a/tests/ui/borrow_interior_mutable_const/traits.stderr +++ b/tests/ui/borrow_interior_mutable_const/traits.stderr @@ -1,16 +1,20 @@ error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:15:18 | -LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable +LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here - = note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/traits.rs:1:9 + | +LL | #![deny(clippy::borrow_interior_mutable_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:26:18 | -LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable +LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -18,7 +22,7 @@ LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:51:18 | -LL | let _ = &Self::TO_BE_CONCRETE; //~ ERROR interior mutable +LL | let _ = &Self::TO_BE_CONCRETE; | ^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -26,7 +30,7 @@ LL | let _ = &Self::TO_BE_CONCRETE; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:86:18 | -LL | let _ = &Self::TO_BE_UNFROZEN; //~ ERROR interior mutable +LL | let _ = &Self::TO_BE_UNFROZEN; | ^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -34,7 +38,7 @@ LL | let _ = &Self::TO_BE_UNFROZEN; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:87:18 | -LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR interior mutable +LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -42,7 +46,7 @@ LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:109:18 | -LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable +LL | let _ = &Self::BOUNDED; | ^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -50,7 +54,7 @@ LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:122:18 | -LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable +LL | let _ = &Self::BOUNDED; | ^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -58,7 +62,7 @@ LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:151:18 | -LL | let _ = &Self::SELF; //~ ERROR interior mutable +LL | let _ = &Self::SELF; | ^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -66,7 +70,7 @@ LL | let _ = &Self::SELF; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:152:18 | -LL | let _ = &Self::WRAPPED_SELF; //~ ERROR interior mutable +LL | let _ = &Self::WRAPPED_SELF; | ^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -74,7 +78,7 @@ LL | let _ = &Self::WRAPPED_SELF; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:162:18 | -LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable +LL | let _ = &Self::INDIRECT; | ^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -82,7 +86,7 @@ LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:172:18 | -LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable +LL | let _ = &Self::INDIRECT; | ^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -90,7 +94,7 @@ LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:191:18 | -LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable +LL | let _ = &Self::ATOMIC; | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -98,7 +102,7 @@ LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:195:18 | -LL | let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR interior mutable +LL | let _ = &Self::BOUNDED_ASSOC_TYPE; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -106,7 +110,7 @@ LL | let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR interior mutable error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:200:5 | -LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability +LL | u64::ATOMIC.store(5, Ordering::SeqCst); | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here @@ -114,7 +118,7 @@ LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability error: a `const` item with interior mutability should not be borrowed --> $DIR/traits.rs:201:16 | -LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability +LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/box_collection.stderr b/tests/ui/box_collection.stderr index 40b6f9be61d5..edd950a5961e 100644 --- a/tests/ui/box_collection.stderr +++ b/tests/ui/box_collection.stderr @@ -1,13 +1,18 @@ -error: you seem to be trying to use `Box>`. Consider using just `Vec<..>` +warning: you seem to be trying to use `Box>`. Consider using just `Vec<..>` --> $DIR/box_collection.rs:21:15 | LL | fn test1(foo: Box>) {} | ^^^^^^^^^^^^^^ | = help: `Vec<..>` is already on the heap, `Box>` makes an extra allocation - = note: `-D clippy::box-collection` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/box_collection.rs:1:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::box_collection)]` implied by `#[warn(clippy::all)]` -error: you seem to be trying to use `Box`. Consider using just `String` +warning: you seem to be trying to use `Box`. Consider using just `String` --> $DIR/box_collection.rs:28:15 | LL | fn test3(foo: Box) {} @@ -15,7 +20,7 @@ LL | fn test3(foo: Box) {} | = help: `String` is already on the heap, `Box` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `HashMap<..>` +warning: you seem to be trying to use `Box>`. Consider using just `HashMap<..>` --> $DIR/box_collection.rs:30:15 | LL | fn test4(foo: Box>) {} @@ -23,7 +28,7 @@ LL | fn test4(foo: Box>) {} | = help: `HashMap<..>` is already on the heap, `Box>` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `HashSet<..>` +warning: you seem to be trying to use `Box>`. Consider using just `HashSet<..>` --> $DIR/box_collection.rs:32:15 | LL | fn test5(foo: Box>) {} @@ -31,7 +36,7 @@ LL | fn test5(foo: Box>) {} | = help: `HashSet<..>` is already on the heap, `Box>` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `VecDeque<..>` +warning: you seem to be trying to use `Box>`. Consider using just `VecDeque<..>` --> $DIR/box_collection.rs:34:15 | LL | fn test6(foo: Box>) {} @@ -39,7 +44,7 @@ LL | fn test6(foo: Box>) {} | = help: `VecDeque<..>` is already on the heap, `Box>` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `LinkedList<..>` +warning: you seem to be trying to use `Box>`. Consider using just `LinkedList<..>` --> $DIR/box_collection.rs:36:15 | LL | fn test7(foo: Box>) {} @@ -47,7 +52,7 @@ LL | fn test7(foo: Box>) {} | = help: `LinkedList<..>` is already on the heap, `Box>` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `BTreeMap<..>` +warning: you seem to be trying to use `Box>`. Consider using just `BTreeMap<..>` --> $DIR/box_collection.rs:38:15 | LL | fn test8(foo: Box>) {} @@ -55,7 +60,7 @@ LL | fn test8(foo: Box>) {} | = help: `BTreeMap<..>` is already on the heap, `Box>` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `BTreeSet<..>` +warning: you seem to be trying to use `Box>`. Consider using just `BTreeSet<..>` --> $DIR/box_collection.rs:40:15 | LL | fn test9(foo: Box>) {} @@ -63,7 +68,7 @@ LL | fn test9(foo: Box>) {} | = help: `BTreeSet<..>` is already on the heap, `Box>` makes an extra allocation -error: you seem to be trying to use `Box>`. Consider using just `BinaryHeap<..>` +warning: you seem to be trying to use `Box>`. Consider using just `BinaryHeap<..>` --> $DIR/box_collection.rs:42:16 | LL | fn test10(foo: Box>) {} @@ -71,5 +76,5 @@ LL | fn test10(foo: Box>) {} | = help: `BinaryHeap<..>` is already on the heap, `Box>` makes an extra allocation -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/box_default.fixed b/tests/ui/box_default.fixed index 59c0baf8718a..6afce2087697 100644 --- a/tests/ui/box_default.fixed +++ b/tests/ui/box_default.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::box_default)] #[derive(Default)] diff --git a/tests/ui/box_default.rs b/tests/ui/box_default.rs index f7d832193a3a..09365618e633 100644 --- a/tests/ui/box_default.rs +++ b/tests/ui/box_default.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::box_default)] #[derive(Default)] diff --git a/tests/ui/box_default.stderr b/tests/ui/box_default.stderr index 78e17b9f0359..7c909a73457a 100644 --- a/tests/ui/box_default.stderr +++ b/tests/ui/box_default.stderr @@ -1,100 +1,104 @@ -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:22:32 | LL | let _string: Box = Box::new(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` | - = note: `-D clippy::box-default` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/box_default.rs:2:9 + | +LL | #![warn(clippy::box_default)] + | ^^^^^^^^^^^^^^^^^^^ -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:23:17 | LL | let _byte = Box::new(u8::default()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:24:16 | LL | let _vec = Box::new(Vec::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::>::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:25:17 | LL | let _impl = Box::new(ImplementsDefault::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:26:18 | LL | let _impl2 = Box::new(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:27:42 | LL | let _impl3: Box = Box::new(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:29:28 | LL | let _in_macro = outer!(Box::new(String::new())); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:30:34 | LL | let _string_default = outer!(Box::new(String::from(""))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:31:46 | LL | let _vec2: Box> = Box::new(vec![]); | ^^^^^^^^^^^^^^^^ help: try: `Box::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:32:33 | LL | let _vec3: Box> = Box::new(Vec::from([])); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:33:25 | LL | let _vec4: Box<_> = Box::new(Vec::from([false; 0])); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::>::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:35:16 | LL | call_ty_fn(Box::new(u8::default())); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:40:5 | LL | Box::new(bool::default()) | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:57:28 | LL | let _: Box = Box::new(ImplementsDefault::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:66:17 | LL | let _ = Box::new(WeirdPathed::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: `Box::new(_)` of default value +warning: `Box::new(_)` of default value --> $DIR/box_default.rs:78:18 | LL | Some(Box::new(Foo::default())) | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Box::::default()` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/boxed_local.stderr b/tests/ui/boxed_local.stderr index 9036529f39c5..8730e1d4d014 100644 --- a/tests/ui/boxed_local.stderr +++ b/tests/ui/boxed_local.stderr @@ -1,28 +1,32 @@ -error: local variable doesn't need to be boxed here +warning: local variable doesn't need to be boxed here --> $DIR/boxed_local.rs:41:13 | LL | fn warn_arg(x: Box) { | ^ | - = note: `-D clippy::boxed-local` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/boxed_local.rs:10:9 + | +LL | #![warn(clippy::boxed_local)] + | ^^^^^^^^^^^^^^^^^^^ -error: local variable doesn't need to be boxed here +warning: local variable doesn't need to be boxed here --> $DIR/boxed_local.rs:132:12 | LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ -error: local variable doesn't need to be boxed here +warning: local variable doesn't need to be boxed here --> $DIR/boxed_local.rs:196:44 | LL | fn default_impl_x(self: Box, x: Box) -> u32 { | ^ -error: local variable doesn't need to be boxed here +warning: local variable doesn't need to be boxed here --> $DIR/boxed_local.rs:203:16 | LL | fn foo(x: Box) {} | ^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.rs b/tests/ui/branches_sharing_code/shared_at_bottom.rs index 6a63008b5a74..5f7d473c0560 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.rs +++ b/tests/ui/branches_sharing_code/shared_at_bottom.rs @@ -1,4 +1,4 @@ -#![deny(clippy::if_same_then_else, clippy::branches_sharing_code)] +#![warn(clippy::if_same_then_else, clippy::branches_sharing_code)] #![allow(dead_code)] #![allow(clippy::equatable_if_let, clippy::uninlined_format_args)] diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_bottom.stderr index b9b113dc0c6a..d3df3d31dead 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -1,4 +1,4 @@ -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:31:5 | LL | / let result = false; @@ -11,7 +11,7 @@ LL | | }; note: the lint level is defined here --> $DIR/shared_at_bottom.rs:1:36 | -LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)] +LL | #![warn(clippy::if_same_then_else, clippy::branches_sharing_code)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider moving these statements after the if | @@ -21,7 +21,7 @@ LL + println!("Block end!"); LL ~ result; | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:49:5 | LL | / println!("Same end of block"); @@ -34,7 +34,7 @@ LL ~ } LL + println!("Same end of block"); | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:66:5 | LL | / println!( @@ -53,7 +53,7 @@ LL + outer_scope_value LL + ); | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:78:9 | LL | / println!("Hello World"); @@ -66,7 +66,7 @@ LL ~ } LL + println!("Hello World"); | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:94:5 | LL | / let later_used_value = "A string value"; @@ -83,7 +83,7 @@ LL + let later_used_value = "A string value"; LL + println!("{}", later_used_value); | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:107:5 | LL | / let simple_examples = "I now identify as a &str :)"; @@ -99,7 +99,7 @@ LL + let simple_examples = "I now identify as a &str :)"; LL + println!("This is the new simple_example: {}", simple_examples); | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:172:5 | LL | / x << 2 @@ -113,7 +113,7 @@ LL ~ } LL ~ x << 2; | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:179:5 | LL | / x * 4 @@ -127,7 +127,7 @@ LL ~ } LL + x * 4 | -error: all if blocks contain the same code at the end +warning: all if blocks contain the same code at the end --> $DIR/shared_at_bottom.rs:191:44 | LL | if x == 17 { b = 1; a = 0x99; } else { a = 0x99; } @@ -139,5 +139,5 @@ LL ~ if x == 17 { b = 1; a = 0x99; } else { } LL + a = 0x99; | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/branches_sharing_code/shared_at_top.rs b/tests/ui/branches_sharing_code/shared_at_top.rs index 9e0b99f16665..558361e2e09c 100644 --- a/tests/ui/branches_sharing_code/shared_at_top.rs +++ b/tests/ui/branches_sharing_code/shared_at_top.rs @@ -1,4 +1,4 @@ -#![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +#![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] #![allow(dead_code)] #![allow(clippy::mixed_read_write_in_expression, clippy::uninlined_format_args)] diff --git a/tests/ui/branches_sharing_code/shared_at_top.stderr b/tests/ui/branches_sharing_code/shared_at_top.stderr index 3e3242a75d30..d6a73fbccd1f 100644 --- a/tests/ui/branches_sharing_code/shared_at_top.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top.stderr @@ -1,4 +1,4 @@ -error: all if blocks contain the same code at the start +warning: all if blocks contain the same code at the start --> $DIR/shared_at_top.rs:11:5 | LL | / if true { @@ -8,7 +8,7 @@ LL | | println!("Hello World!"); note: the lint level is defined here --> $DIR/shared_at_top.rs:1:9 | -LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +LL | #![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider moving these statements before the if | @@ -16,7 +16,7 @@ LL ~ println!("Hello World!"); LL + if true { | -error: all if blocks contain the same code at the start +warning: all if blocks contain the same code at the start --> $DIR/shared_at_top.rs:20:5 | LL | / if x == 0 { @@ -34,7 +34,7 @@ LL + let _z = y; LL + if x == 0 { | -error: all if blocks contain the same code at the start +warning: all if blocks contain the same code at the start --> $DIR/shared_at_top.rs:41:5 | LL | / let _ = if x == 7 { @@ -47,7 +47,7 @@ LL ~ let y = 16; LL + let _ = if x == 7 { | -error: all if blocks contain the same code at the start +warning: all if blocks contain the same code at the start --> $DIR/shared_at_top.rs:59:5 | LL | / if x == 10 { @@ -63,7 +63,7 @@ LL + println!("Str: {}", used_value_name); LL + if x == 10 { | -error: all if blocks contain the same code at the start +warning: all if blocks contain the same code at the start --> $DIR/shared_at_top.rs:73:5 | LL | / if x == 11 { @@ -79,7 +79,7 @@ LL + println!("I'm also moveable"); LL + if x == 11 { | -error: all if blocks contain the same code at the start +warning: all if blocks contain the same code at the start --> $DIR/shared_at_top.rs:89:5 | LL | / if x == 2020 { @@ -94,7 +94,7 @@ LL + println!("Because `IF_SAME_THEN_ELSE` is allowed here"); LL + if x == 2020 { | -error: this `if` has identical blocks +warning: this `if` has identical blocks --> $DIR/shared_at_top.rs:97:18 | LL | if x == 2019 { @@ -114,8 +114,8 @@ LL | | } note: the lint level is defined here --> $DIR/shared_at_top.rs:1:40 | -LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +LL | #![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs index 93b8c6e10dae..60e9b09d1b79 100644 --- a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs +++ b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs @@ -1,4 +1,4 @@ -#![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +#![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] #![allow(dead_code)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr index ccd697a42155..20d0b53da268 100644 --- a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr @@ -1,4 +1,4 @@ -error: all if blocks contain the same code at both the start and the end +warning: all if blocks contain the same code at both the start and the end --> $DIR/shared_at_top_and_bottom.rs:17:5 | LL | / if x == 7 { @@ -16,7 +16,7 @@ LL | | } note: the lint level is defined here --> $DIR/shared_at_top_and_bottom.rs:1:9 | -LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +LL | #![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider moving these statements before the if | @@ -31,7 +31,7 @@ LL ~ } LL + let _u = 9; | -error: all if blocks contain the same code at both the start and the end +warning: all if blocks contain the same code at both the start and the end --> $DIR/shared_at_top_and_bottom.rs:33:5 | LL | / if x == 99 { @@ -62,7 +62,7 @@ LL + let _overlap_end = r * r * r; LL + let z = "end"; | -error: all if blocks contain the same code at both the start and the end +warning: all if blocks contain the same code at both the start and the end --> $DIR/shared_at_top_and_bottom.rs:62:5 | LL | / if (x > 7 && y < 13) || (x + y) % 2 == 1 { @@ -101,7 +101,7 @@ LL + }; LL + process_data(pack); | -error: all if blocks contain the same code at both the start and the end +warning: all if blocks contain the same code at both the start and the end --> $DIR/shared_at_top_and_bottom.rs:95:5 | LL | / let _ = if x == 7 { @@ -126,7 +126,7 @@ LL ~ } LL ~ x << 2; | -error: all if blocks contain the same code at both the start and the end +warning: all if blocks contain the same code at both the start and the end --> $DIR/shared_at_top_and_bottom.rs:107:5 | LL | / if x == 9 { @@ -151,5 +151,5 @@ LL ~ } LL + x * 4 | -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/branches_sharing_code/valid_if_blocks.rs b/tests/ui/branches_sharing_code/valid_if_blocks.rs index 2d6055eb6c42..ec05970eaff1 100644 --- a/tests/ui/branches_sharing_code/valid_if_blocks.rs +++ b/tests/ui/branches_sharing_code/valid_if_blocks.rs @@ -1,4 +1,4 @@ -#![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +#![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] #![allow(dead_code)] #![allow(clippy::mixed_read_write_in_expression, clippy::uninlined_format_args)] diff --git a/tests/ui/branches_sharing_code/valid_if_blocks.stderr b/tests/ui/branches_sharing_code/valid_if_blocks.stderr index ce7fff0122f1..021260bea5cb 100644 --- a/tests/ui/branches_sharing_code/valid_if_blocks.stderr +++ b/tests/ui/branches_sharing_code/valid_if_blocks.stderr @@ -1,4 +1,4 @@ -error: this `if` has identical blocks +warning: this `if` has identical blocks --> $DIR/valid_if_blocks.rs:105:14 | LL | if false { @@ -16,10 +16,10 @@ LL | | } note: the lint level is defined here --> $DIR/valid_if_blocks.rs:1:40 | -LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] +LL | #![warn(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `if` has identical blocks +warning: this `if` has identical blocks --> $DIR/valid_if_blocks.rs:116:15 | LL | if x == 0 { @@ -41,7 +41,7 @@ LL | | let _ = "This is a string"; LL | | } | |_____^ -error: this `if` has identical blocks +warning: this `if` has identical blocks --> $DIR/valid_if_blocks.rs:127:23 | LL | let _ = if x == 6 { 7 } else { 7 }; @@ -53,7 +53,7 @@ note: same as this LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ -error: this `if` has identical blocks +warning: this `if` has identical blocks --> $DIR/valid_if_blocks.rs:133:23 | LL | } else if x == 68 { @@ -77,7 +77,7 @@ LL | | if y == 90 { "=^.^=" } else { ":D" } LL | | }; | |_____^ -error: this `if` has identical blocks +warning: this `if` has identical blocks --> $DIR/valid_if_blocks.rs:147:23 | LL | } else if x == 68 { @@ -97,5 +97,5 @@ LL | | println!("I'm a doppelgänger"); LL | | } | |_____^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/builtin_type_shadow.rs b/tests/ui/builtin_type_shadow.rs index 69b8b6a0e68c..c5addd53434c 100644 --- a/tests/ui/builtin_type_shadow.rs +++ b/tests/ui/builtin_type_shadow.rs @@ -3,7 +3,7 @@ fn foo(a: u32) -> u32 { 42 - // ^ rustc's type error + //~^ ERROR: mismatched types } fn main() {} diff --git a/tests/ui/builtin_type_shadow.stderr b/tests/ui/builtin_type_shadow.stderr index 47a8a1e623e8..7869f16f0966 100644 --- a/tests/ui/builtin_type_shadow.stderr +++ b/tests/ui/builtin_type_shadow.stderr @@ -1,10 +1,14 @@ -error: this generic shadows the built-in type `u32` +warning: this generic shadows the built-in type `u32` --> $DIR/builtin_type_shadow.rs:4:8 | LL | fn foo(a: u32) -> u32 { | ^^^ | - = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/builtin_type_shadow.rs:1:9 + | +LL | #![warn(clippy::builtin_type_shadow)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/builtin_type_shadow.rs:5:5 @@ -19,6 +23,6 @@ LL | 42 = note: expected type parameter `u32` found type `{integer}` -error: aborting due to 2 previous errors +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/bytecount.rs b/tests/ui/bytecount.rs index d3ad26921bff..e7c27291d3f9 100644 --- a/tests/ui/bytecount.rs +++ b/tests/ui/bytecount.rs @@ -1,6 +1,6 @@ #![allow(clippy::needless_borrow)] -#[deny(clippy::naive_bytecount)] +#[warn(clippy::naive_bytecount)] fn main() { let x = vec![0_u8; 16]; diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index 68d838c1f828..418f62f898a9 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -1,4 +1,4 @@ -error: you appear to be counting bytes the naive way +warning: you appear to be counting bytes the naive way --> $DIR/bytecount.rs:7:13 | LL | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count @@ -7,20 +7,20 @@ LL | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count note: the lint level is defined here --> $DIR/bytecount.rs:3:8 | -LL | #[deny(clippy::naive_bytecount)] +LL | #[warn(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ -error: you appear to be counting bytes the naive way +warning: you appear to be counting bytes the naive way --> $DIR/bytecount.rs:9:13 | LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count((&x[..]), 0)` -error: you appear to be counting bytes the naive way +warning: you appear to be counting bytes the naive way --> $DIR/bytecount.rs:21:13 | LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, b + 1)` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/bytes_count_to_len.fixed b/tests/ui/bytes_count_to_len.fixed index 860642363b5f..fb3d521badd5 100644 --- a/tests/ui/bytes_count_to_len.fixed +++ b/tests/ui/bytes_count_to_len.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::bytes_count_to_len)] use std::fs::File; use std::io::Read; diff --git a/tests/ui/bytes_count_to_len.rs b/tests/ui/bytes_count_to_len.rs index 162730c2842a..8e256b8f0b8a 100644 --- a/tests/ui/bytes_count_to_len.rs +++ b/tests/ui/bytes_count_to_len.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::bytes_count_to_len)] use std::fs::File; use std::io::Read; diff --git a/tests/ui/bytes_count_to_len.stderr b/tests/ui/bytes_count_to_len.stderr index 224deb779871..75fc8bdf9c3e 100644 --- a/tests/ui/bytes_count_to_len.stderr +++ b/tests/ui/bytes_count_to_len.stderr @@ -1,28 +1,32 @@ -error: using long and hard to read `.bytes().count()` +warning: using long and hard to read `.bytes().count()` --> $DIR/bytes_count_to_len.rs:8:13 | LL | let _ = String::from("foo").bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `String::from("foo").len()` | - = note: `-D clippy::bytes-count-to-len` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bytes_count_to_len.rs:2:9 + | +LL | #![warn(clippy::bytes_count_to_len)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: using long and hard to read `.bytes().count()` +warning: using long and hard to read `.bytes().count()` --> $DIR/bytes_count_to_len.rs:11:13 | LL | let _ = s1.bytes().count(); | ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s1.len()` -error: using long and hard to read `.bytes().count()` +warning: using long and hard to read `.bytes().count()` --> $DIR/bytes_count_to_len.rs:14:13 | LL | let _ = "foo".bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `"foo".len()` -error: using long and hard to read `.bytes().count()` +warning: using long and hard to read `.bytes().count()` --> $DIR/bytes_count_to_len.rs:17:13 | LL | let _ = s2.bytes().count(); | ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s2.len()` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/bytes_nth.fixed b/tests/ui/bytes_nth.fixed index a35c679afb71..d3e0f676b29f 100644 --- a/tests/ui/bytes_nth.fixed +++ b/tests/ui/bytes_nth.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::unnecessary_operation)] #![warn(clippy::bytes_nth)] diff --git a/tests/ui/bytes_nth.rs b/tests/ui/bytes_nth.rs index 1ecffea53035..b7d813fe296a 100644 --- a/tests/ui/bytes_nth.rs +++ b/tests/ui/bytes_nth.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::unnecessary_operation)] #![warn(clippy::bytes_nth)] diff --git a/tests/ui/bytes_nth.stderr b/tests/ui/bytes_nth.stderr index e8b15027829e..cc547e7341c8 100644 --- a/tests/ui/bytes_nth.stderr +++ b/tests/ui/bytes_nth.stderr @@ -1,22 +1,26 @@ -error: called `.bytes().nth()` on a `String` +warning: called `.bytes().nth()` on a `String` --> $DIR/bytes_nth.rs:8:13 | LL | let _ = s.bytes().nth(3); | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3).copied()` | - = note: `-D clippy::bytes-nth` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/bytes_nth.rs:4:9 + | +LL | #![warn(clippy::bytes_nth)] + | ^^^^^^^^^^^^^^^^^ -error: called `.bytes().nth().unwrap()` on a `String` +warning: called `.bytes().nth().unwrap()` on a `String` --> $DIR/bytes_nth.rs:9:14 | LL | let _ = &s.bytes().nth(3).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.as_bytes()[3]` -error: called `.bytes().nth()` on a `str` +warning: called `.bytes().nth()` on a `str` --> $DIR/bytes_nth.rs:10:13 | LL | let _ = s[..].bytes().nth(3); | ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3).copied()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/case_sensitive_file_extension_comparisons.fixed b/tests/ui/case_sensitive_file_extension_comparisons.fixed index 5fbaa64db39e..f5f0a0022a42 100644 --- a/tests/ui/case_sensitive_file_extension_comparisons.fixed +++ b/tests/ui/case_sensitive_file_extension_comparisons.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::case_sensitive_file_extension_comparisons)] use std::string::String; @@ -11,37 +11,25 @@ impl TestStruct { #[allow(dead_code)] fn is_rust_file(filename: &str) -> bool { - std::path::Path::new(filename) - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("rs")) + filename.ends_with(".rs") } fn main() { // std::string::String and &str should trigger the lint failure with .ext12 - let _ = std::path::Path::new(&String::new()) - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); - let _ = std::path::Path::new("str") - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); + let _ = String::new().ends_with(".ext12"); + let _ = "str".ends_with(".ext12"); // The fixup should preserve the indentation level { - let _ = std::path::Path::new("str") - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); + let _ = "str".ends_with(".ext12"); } // The test struct should not trigger the lint failure with .ext12 TestStruct {}.ends_with(".ext12"); // std::string::String and &str should trigger the lint failure with .EXT12 - let _ = std::path::Path::new(&String::new()) - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("EXT12")); - let _ = std::path::Path::new("str") - .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("EXT12")); + let _ = String::new().ends_with(".EXT12"); + let _ = "str".ends_with(".EXT12"); // Should not trigger the lint failure because of the calls to to_lowercase and to_uppercase let _ = String::new().to_lowercase().ends_with(".EXT12"); diff --git a/tests/ui/case_sensitive_file_extension_comparisons.rs b/tests/ui/case_sensitive_file_extension_comparisons.rs index 3c0d4821f9f3..f5f0a0022a42 100644 --- a/tests/ui/case_sensitive_file_extension_comparisons.rs +++ b/tests/ui/case_sensitive_file_extension_comparisons.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::case_sensitive_file_extension_comparisons)] use std::string::String; diff --git a/tests/ui/case_sensitive_file_extension_comparisons.stderr b/tests/ui/case_sensitive_file_extension_comparisons.stderr index 44c8e3fdf740..f441863ed159 100644 --- a/tests/ui/case_sensitive_file_extension_comparisons.stderr +++ b/tests/ui/case_sensitive_file_extension_comparisons.stderr @@ -1,11 +1,15 @@ -error: case-sensitive file extension comparison +warning: case-sensitive file extension comparison --> $DIR/case_sensitive_file_extension_comparisons.rs:14:5 | LL | filename.ends_with(".rs") | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using a case-insensitive comparison instead - = note: `-D clippy::case-sensitive-file-extension-comparisons` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/case_sensitive_file_extension_comparisons.rs:2:9 + | +LL | #![warn(clippy::case_sensitive_file_extension_comparisons)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use std::path::Path | LL ~ std::path::Path::new(filename) @@ -13,7 +17,7 @@ LL + .extension() LL + .map_or(false, |ext| ext.eq_ignore_ascii_case("rs")) | -error: case-sensitive file extension comparison +warning: case-sensitive file extension comparison --> $DIR/case_sensitive_file_extension_comparisons.rs:19:13 | LL | let _ = String::new().ends_with(".ext12"); @@ -27,7 +31,7 @@ LL + .extension() LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | -error: case-sensitive file extension comparison +warning: case-sensitive file extension comparison --> $DIR/case_sensitive_file_extension_comparisons.rs:20:13 | LL | let _ = "str".ends_with(".ext12"); @@ -41,7 +45,7 @@ LL + .extension() LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | -error: case-sensitive file extension comparison +warning: case-sensitive file extension comparison --> $DIR/case_sensitive_file_extension_comparisons.rs:24:17 | LL | let _ = "str".ends_with(".ext12"); @@ -55,7 +59,7 @@ LL + .extension() LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | -error: case-sensitive file extension comparison +warning: case-sensitive file extension comparison --> $DIR/case_sensitive_file_extension_comparisons.rs:31:13 | LL | let _ = String::new().ends_with(".EXT12"); @@ -69,7 +73,7 @@ LL + .extension() LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("EXT12")); | -error: case-sensitive file extension comparison +warning: case-sensitive file extension comparison --> $DIR/case_sensitive_file_extension_comparisons.rs:32:13 | LL | let _ = "str".ends_with(".EXT12"); @@ -83,5 +87,5 @@ LL + .extension() LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("EXT12")); | -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 451078de23b2..5c76434ece4b 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,55 +1,63 @@ -error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +warning: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> $DIR/cast.rs:14:5 | LL | x0 as f32; | ^^^^^^^^^ | - = note: `-D clippy::cast-precision-loss` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast.rs:4:5 + | +LL | clippy::cast_precision_loss, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +warning: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) --> $DIR/cast.rs:16:5 | LL | x1 as f32; | ^^^^^^^^^ -error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +warning: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) --> $DIR/cast.rs:17:5 | LL | x1 as f64; | ^^^^^^^^^ -error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +warning: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> $DIR/cast.rs:19:5 | LL | x2 as f32; | ^^^^^^^^^ -error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) +warning: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) --> $DIR/cast.rs:21:5 | LL | x3 as f32; | ^^^^^^^^^ -error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) +warning: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) --> $DIR/cast.rs:22:5 | LL | x3 as f64; | ^^^^^^^^^ -error: casting `f32` to `i32` may truncate the value +warning: casting `f32` to `i32` may truncate the value --> $DIR/cast.rs:24:5 | LL | 1f32 as i32; | ^^^^^^^^^^^ | = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... - = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast.rs:5:5 + | +LL | clippy::cast_possible_truncation, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ... or use `try_from` and handle the error accordingly | LL | i32::try_from(1f32); | ~~~~~~~~~~~~~~~~~~~ -error: casting `f32` to `u32` may truncate the value +warning: casting `f32` to `u32` may truncate the value --> $DIR/cast.rs:25:5 | LL | 1f32 as u32; @@ -61,15 +69,19 @@ help: ... or use `try_from` and handle the error accordingly LL | u32::try_from(1f32); | ~~~~~~~~~~~~~~~~~~~ -error: casting `f32` to `u32` may lose the sign of the value +warning: casting `f32` to `u32` may lose the sign of the value --> $DIR/cast.rs:25:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ | - = note: `-D clippy::cast-sign-loss` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast.rs:6:5 + | +LL | clippy::cast_sign_loss, + | ^^^^^^^^^^^^^^^^^^^^^^ -error: casting `f64` to `f32` may truncate the value +warning: casting `f64` to `f32` may truncate the value --> $DIR/cast.rs:26:5 | LL | 1f64 as f32; @@ -81,7 +93,7 @@ help: ... or use `try_from` and handle the error accordingly LL | f32::try_from(1f64); | ~~~~~~~~~~~~~~~~~~~ -error: casting `i32` to `i8` may truncate the value +warning: casting `i32` to `i8` may truncate the value --> $DIR/cast.rs:27:5 | LL | 1i32 as i8; @@ -93,7 +105,7 @@ help: ... or use `try_from` and handle the error accordingly LL | i8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ -error: casting `i32` to `u8` may truncate the value +warning: casting `i32` to `u8` may truncate the value --> $DIR/cast.rs:28:5 | LL | 1i32 as u8; @@ -105,7 +117,7 @@ help: ... or use `try_from` and handle the error accordingly LL | u8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ -error: casting `f64` to `isize` may truncate the value +warning: casting `f64` to `isize` may truncate the value --> $DIR/cast.rs:29:5 | LL | 1f64 as isize; @@ -117,7 +129,7 @@ help: ... or use `try_from` and handle the error accordingly LL | isize::try_from(1f64); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `f64` to `usize` may truncate the value +warning: casting `f64` to `usize` may truncate the value --> $DIR/cast.rs:30:5 | LL | 1f64 as usize; @@ -129,13 +141,13 @@ help: ... or use `try_from` and handle the error accordingly LL | usize::try_from(1f64); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `f64` to `usize` may lose the sign of the value +warning: casting `f64` to `usize` may lose the sign of the value --> $DIR/cast.rs:30:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ -error: casting `u32` to `u16` may truncate the value +warning: casting `u32` to `u16` may truncate the value --> $DIR/cast.rs:31:5 | LL | 1f32 as u32 as u16; @@ -147,7 +159,7 @@ help: ... or use `try_from` and handle the error accordingly LL | u16::try_from(1f32 as u32); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: casting `f32` to `u32` may truncate the value +warning: casting `f32` to `u32` may truncate the value --> $DIR/cast.rs:31:5 | LL | 1f32 as u32 as u16; @@ -159,57 +171,61 @@ help: ... or use `try_from` and handle the error accordingly LL | u32::try_from(1f32) as u16; | ~~~~~~~~~~~~~~~~~~~ -error: casting `f32` to `u32` may lose the sign of the value +warning: casting `f32` to `u32` may lose the sign of the value --> $DIR/cast.rs:31:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ -error: casting `u8` to `i8` may wrap around the value +warning: casting `u8` to `i8` may wrap around the value --> $DIR/cast.rs:33:5 | LL | 1u8 as i8; | ^^^^^^^^^ | - = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast.rs:7:5 + | +LL | clippy::cast_possible_wrap + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting `u16` to `i16` may wrap around the value +warning: casting `u16` to `i16` may wrap around the value --> $DIR/cast.rs:34:5 | LL | 1u16 as i16; | ^^^^^^^^^^^ -error: casting `u32` to `i32` may wrap around the value +warning: casting `u32` to `i32` may wrap around the value --> $DIR/cast.rs:35:5 | LL | 1u32 as i32; | ^^^^^^^^^^^ -error: casting `u64` to `i64` may wrap around the value +warning: casting `u64` to `i64` may wrap around the value --> $DIR/cast.rs:36:5 | LL | 1u64 as i64; | ^^^^^^^^^^^ -error: casting `usize` to `isize` may wrap around the value +warning: casting `usize` to `isize` may wrap around the value --> $DIR/cast.rs:37:5 | LL | 1usize as isize; | ^^^^^^^^^^^^^^^ -error: casting `i32` to `u32` may lose the sign of the value +warning: casting `i32` to `u32` may lose the sign of the value --> $DIR/cast.rs:40:5 | LL | -1i32 as u32; | ^^^^^^^^^^^^ -error: casting `isize` to `usize` may lose the sign of the value +warning: casting `isize` to `usize` may lose the sign of the value --> $DIR/cast.rs:42:5 | LL | -1isize as usize; | ^^^^^^^^^^^^^^^^ -error: casting `i64` to `i8` may truncate the value +warning: casting `i64` to `i8` may truncate the value --> $DIR/cast.rs:109:5 | LL | (-99999999999i64).min(1) as i8; // should be linted because signed @@ -221,7 +237,7 @@ help: ... or use `try_from` and handle the error accordingly LL | i8::try_from((-99999999999i64).min(1)); // should be linted because signed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: casting `u64` to `u8` may truncate the value +warning: casting `u64` to `u8` may truncate the value --> $DIR/cast.rs:121:5 | LL | 999999u64.clamp(0, 256) as u8; // should still be linted @@ -233,7 +249,7 @@ help: ... or use `try_from` and handle the error accordingly LL | u8::try_from(999999u64.clamp(0, 256)); // should still be linted | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: casting `main::E2` to `u8` may truncate the value +warning: casting `main::E2` to `u8` may truncate the value --> $DIR/cast.rs:142:21 | LL | let _ = self as u8; @@ -245,15 +261,15 @@ help: ... or use `try_from` and handle the error accordingly LL | let _ = u8::try_from(self); | ~~~~~~~~~~~~~~~~~~ -error: casting `main::E2::B` to `u8` will truncate the value +warning: casting `main::E2::B` to `u8` will truncate the value --> $DIR/cast.rs:143:21 | LL | let _ = Self::B as u8; | ^^^^^^^^^^^^^ | - = note: `-D clippy::cast-enum-truncation` implied by `-D warnings` + = note: `#[warn(clippy::cast_enum_truncation)]` on by default -error: casting `main::E5` to `i8` may truncate the value +warning: casting `main::E5` to `i8` may truncate the value --> $DIR/cast.rs:179:21 | LL | let _ = self as i8; @@ -265,13 +281,13 @@ help: ... or use `try_from` and handle the error accordingly LL | let _ = i8::try_from(self); | ~~~~~~~~~~~~~~~~~~ -error: casting `main::E5::A` to `i8` will truncate the value +warning: casting `main::E5::A` to `i8` will truncate the value --> $DIR/cast.rs:180:21 | LL | let _ = Self::A as i8; | ^^^^^^^^^^^^^ -error: casting `main::E6` to `i16` may truncate the value +warning: casting `main::E6` to `i16` may truncate the value --> $DIR/cast.rs:194:21 | LL | let _ = self as i16; @@ -283,7 +299,7 @@ help: ... or use `try_from` and handle the error accordingly LL | let _ = i16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ -error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers +warning: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast.rs:209:21 | LL | let _ = self as usize; @@ -295,7 +311,7 @@ help: ... or use `try_from` and handle the error accordingly LL | let _ = usize::try_from(self); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `main::E10` to `u16` may truncate the value +warning: casting `main::E10` to `u16` may truncate the value --> $DIR/cast.rs:250:21 | LL | let _ = self as u16; @@ -307,7 +323,7 @@ help: ... or use `try_from` and handle the error accordingly LL | let _ = u16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ -error: casting `u32` to `u8` may truncate the value +warning: casting `u32` to `u8` may truncate the value --> $DIR/cast.rs:258:13 | LL | let c = (q >> 16) as u8; @@ -319,7 +335,7 @@ help: ... or use `try_from` and handle the error accordingly LL | let c = u8::try_from((q >> 16)); | ~~~~~~~~~~~~~~~~~~~~~~~ -error: casting `u32` to `u8` may truncate the value +warning: casting `u32` to `u8` may truncate the value --> $DIR/cast.rs:261:13 | LL | let c = (q / 1000) as u8; @@ -331,5 +347,5 @@ help: ... or use `try_from` and handle the error accordingly LL | let c = u8::try_from((q / 1000)); | ~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 36 previous errors +warning: 36 warnings emitted diff --git a/tests/ui/cast_abs_to_unsigned.fixed b/tests/ui/cast_abs_to_unsigned.fixed index 8676b562b4f9..ef0a93b01d1f 100644 --- a/tests/ui/cast_abs_to_unsigned.fixed +++ b/tests/ui/cast_abs_to_unsigned.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::cast_abs_to_unsigned)] #![allow(clippy::uninlined_format_args, unused)] diff --git a/tests/ui/cast_abs_to_unsigned.rs b/tests/ui/cast_abs_to_unsigned.rs index 5775af874f8f..96ced670a055 100644 --- a/tests/ui/cast_abs_to_unsigned.rs +++ b/tests/ui/cast_abs_to_unsigned.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::cast_abs_to_unsigned)] #![allow(clippy::uninlined_format_args, unused)] diff --git a/tests/ui/cast_abs_to_unsigned.stderr b/tests/ui/cast_abs_to_unsigned.stderr index 4668554f4511..7029aa20b414 100644 --- a/tests/ui/cast_abs_to_unsigned.stderr +++ b/tests/ui/cast_abs_to_unsigned.stderr @@ -1,112 +1,116 @@ -error: casting the result of `i32::abs()` to u32 +warning: casting the result of `i32::abs()` to u32 --> $DIR/cast_abs_to_unsigned.rs:8:18 | LL | let y: u32 = x.abs() as u32; | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` | - = note: `-D clippy::cast-abs-to-unsigned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_abs_to_unsigned.rs:3:9 + | +LL | #![warn(clippy::cast_abs_to_unsigned)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting the result of `i32::abs()` to usize +warning: casting the result of `i32::abs()` to usize --> $DIR/cast_abs_to_unsigned.rs:12:20 | LL | let _: usize = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i32::abs()` to usize +warning: casting the result of `i32::abs()` to usize --> $DIR/cast_abs_to_unsigned.rs:13:20 | LL | let _: usize = a.abs() as _; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i32::abs()` to usize +warning: casting the result of `i32::abs()` to usize --> $DIR/cast_abs_to_unsigned.rs:14:13 | LL | let _ = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to usize +warning: casting the result of `i64::abs()` to usize --> $DIR/cast_abs_to_unsigned.rs:17:13 | LL | let _ = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to u8 +warning: casting the result of `i64::abs()` to u8 --> $DIR/cast_abs_to_unsigned.rs:18:13 | LL | let _ = a.abs() as u8; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to u16 +warning: casting the result of `i64::abs()` to u16 --> $DIR/cast_abs_to_unsigned.rs:19:13 | LL | let _ = a.abs() as u16; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to u32 +warning: casting the result of `i64::abs()` to u32 --> $DIR/cast_abs_to_unsigned.rs:20:13 | LL | let _ = a.abs() as u32; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to u64 +warning: casting the result of `i64::abs()` to u64 --> $DIR/cast_abs_to_unsigned.rs:21:13 | LL | let _ = a.abs() as u64; | ^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to u128 +warning: casting the result of `i64::abs()` to u128 --> $DIR/cast_abs_to_unsigned.rs:22:13 | LL | let _ = a.abs() as u128; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `isize::abs()` to usize +warning: casting the result of `isize::abs()` to usize --> $DIR/cast_abs_to_unsigned.rs:25:13 | LL | let _ = a.abs() as usize; | ^^^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `isize::abs()` to u8 +warning: casting the result of `isize::abs()` to u8 --> $DIR/cast_abs_to_unsigned.rs:26:13 | LL | let _ = a.abs() as u8; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `isize::abs()` to u16 +warning: casting the result of `isize::abs()` to u16 --> $DIR/cast_abs_to_unsigned.rs:27:13 | LL | let _ = a.abs() as u16; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `isize::abs()` to u32 +warning: casting the result of `isize::abs()` to u32 --> $DIR/cast_abs_to_unsigned.rs:28:13 | LL | let _ = a.abs() as u32; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `isize::abs()` to u64 +warning: casting the result of `isize::abs()` to u64 --> $DIR/cast_abs_to_unsigned.rs:29:13 | LL | let _ = a.abs() as u64; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `isize::abs()` to u128 +warning: casting the result of `isize::abs()` to u128 --> $DIR/cast_abs_to_unsigned.rs:30:13 | LL | let _ = a.abs() as u128; | ^^^^^^^ help: replace with: `a.unsigned_abs()` -error: casting the result of `i64::abs()` to u32 +warning: casting the result of `i64::abs()` to u32 --> $DIR/cast_abs_to_unsigned.rs:32:13 | LL | let _ = (x as i64 - y as i64).abs() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `(x as i64 - y as i64).unsigned_abs()` -error: casting the result of `i32::abs()` to u32 +warning: casting the result of `i32::abs()` to u32 --> $DIR/cast_abs_to_unsigned.rs:44:23 | LL | assert_eq!(10u32, x.abs() as u32); | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index 5df2b5b1094b..0447fbb725f4 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,28 +1,32 @@ -error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) +warning: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) --> $DIR/cast_alignment.rs:19:5 | LL | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_alignment.rs:7:8 + | +LL | #[warn(clippy::cast_ptr_alignment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) +warning: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) --> $DIR/cast_alignment.rs:20:5 | LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) +warning: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) --> $DIR/cast_alignment.rs:23:5 | LL | (&1u8 as *const u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) +warning: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) --> $DIR/cast_alignment.rs:24:5 | LL | (&mut 1u8 as *mut u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/cast_enum_constructor.stderr b/tests/ui/cast_enum_constructor.stderr index 710909dd26fa..1e1d47fa5b09 100644 --- a/tests/ui/cast_enum_constructor.stderr +++ b/tests/ui/cast_enum_constructor.stderr @@ -1,16 +1,20 @@ -error: cast of an enum tuple constructor to an integer +warning: cast of an enum tuple constructor to an integer --> $DIR/cast_enum_constructor.rs:13:13 | LL | let _ = Foo::Y as usize; | ^^^^^^^^^^^^^^^ | - = note: `-D clippy::cast-enum-constructor` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_enum_constructor.rs:1:9 + | +LL | #![warn(clippy::cast_enum_constructor)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: cast of an enum tuple constructor to an integer +warning: cast of an enum tuple constructor to an integer --> $DIR/cast_enum_constructor.rs:14:13 | LL | let _ = Foo::Y as isize; | ^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/cast_lossless_bool.fixed b/tests/ui/cast_lossless_bool.fixed index 13b3cf838c9f..c321cc644378 100644 --- a/tests/ui/cast_lossless_bool.fixed +++ b/tests/ui/cast_lossless_bool.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_bool.rs b/tests/ui/cast_lossless_bool.rs index 3eed2135562c..632a718920d4 100644 --- a/tests/ui/cast_lossless_bool.rs +++ b/tests/ui/cast_lossless_bool.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_bool.stderr b/tests/ui/cast_lossless_bool.stderr index ce240b70f891..4fffad9628c9 100644 --- a/tests/ui/cast_lossless_bool.stderr +++ b/tests/ui/cast_lossless_bool.stderr @@ -1,88 +1,92 @@ -error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` +warning: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` --> $DIR/cast_lossless_bool.rs:8:13 | LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` | - = note: `-D clippy::cast-lossless` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_lossless_bool.rs:4:9 + | +LL | #![warn(clippy::cast_lossless)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` +warning: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` --> $DIR/cast_lossless_bool.rs:9:13 | LL | let _ = true as u16; | ^^^^^^^^^^^ help: try: `u16::from(true)` -error: casting `bool` to `u32` is more cleanly stated with `u32::from(_)` +warning: casting `bool` to `u32` is more cleanly stated with `u32::from(_)` --> $DIR/cast_lossless_bool.rs:10:13 | LL | let _ = true as u32; | ^^^^^^^^^^^ help: try: `u32::from(true)` -error: casting `bool` to `u64` is more cleanly stated with `u64::from(_)` +warning: casting `bool` to `u64` is more cleanly stated with `u64::from(_)` --> $DIR/cast_lossless_bool.rs:11:13 | LL | let _ = true as u64; | ^^^^^^^^^^^ help: try: `u64::from(true)` -error: casting `bool` to `u128` is more cleanly stated with `u128::from(_)` +warning: casting `bool` to `u128` is more cleanly stated with `u128::from(_)` --> $DIR/cast_lossless_bool.rs:12:13 | LL | let _ = true as u128; | ^^^^^^^^^^^^ help: try: `u128::from(true)` -error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)` +warning: casting `bool` to `usize` is more cleanly stated with `usize::from(_)` --> $DIR/cast_lossless_bool.rs:13:13 | LL | let _ = true as usize; | ^^^^^^^^^^^^^ help: try: `usize::from(true)` -error: casting `bool` to `i8` is more cleanly stated with `i8::from(_)` +warning: casting `bool` to `i8` is more cleanly stated with `i8::from(_)` --> $DIR/cast_lossless_bool.rs:15:13 | LL | let _ = true as i8; | ^^^^^^^^^^ help: try: `i8::from(true)` -error: casting `bool` to `i16` is more cleanly stated with `i16::from(_)` +warning: casting `bool` to `i16` is more cleanly stated with `i16::from(_)` --> $DIR/cast_lossless_bool.rs:16:13 | LL | let _ = true as i16; | ^^^^^^^^^^^ help: try: `i16::from(true)` -error: casting `bool` to `i32` is more cleanly stated with `i32::from(_)` +warning: casting `bool` to `i32` is more cleanly stated with `i32::from(_)` --> $DIR/cast_lossless_bool.rs:17:13 | LL | let _ = true as i32; | ^^^^^^^^^^^ help: try: `i32::from(true)` -error: casting `bool` to `i64` is more cleanly stated with `i64::from(_)` +warning: casting `bool` to `i64` is more cleanly stated with `i64::from(_)` --> $DIR/cast_lossless_bool.rs:18:13 | LL | let _ = true as i64; | ^^^^^^^^^^^ help: try: `i64::from(true)` -error: casting `bool` to `i128` is more cleanly stated with `i128::from(_)` +warning: casting `bool` to `i128` is more cleanly stated with `i128::from(_)` --> $DIR/cast_lossless_bool.rs:19:13 | LL | let _ = true as i128; | ^^^^^^^^^^^^ help: try: `i128::from(true)` -error: casting `bool` to `isize` is more cleanly stated with `isize::from(_)` +warning: casting `bool` to `isize` is more cleanly stated with `isize::from(_)` --> $DIR/cast_lossless_bool.rs:20:13 | LL | let _ = true as isize; | ^^^^^^^^^^^^^ help: try: `isize::from(true)` -error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` +warning: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` --> $DIR/cast_lossless_bool.rs:23:13 | LL | let _ = (true | false) as u16; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)` -error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` +warning: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` --> $DIR/cast_lossless_bool.rs:51:13 | LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/cast_lossless_float.fixed b/tests/ui/cast_lossless_float.fixed index 32a9c1c4ae1a..e72a0096acce 100644 --- a/tests/ui/cast_lossless_float.fixed +++ b/tests/ui/cast_lossless_float.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs index 6f5ddcfe09c8..dbcbaa9b8150 100644 --- a/tests/ui/cast_lossless_float.rs +++ b/tests/ui/cast_lossless_float.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 8326d40be716..0a388f2f05cb 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,70 +1,74 @@ -error: casting `i8` to `f32` may become silently lossy if you later change the type +warning: casting `i8` to `f32` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:9:13 | LL | let _ = x0 as f32; | ^^^^^^^^^ help: try: `f32::from(x0)` | - = note: `-D clippy::cast-lossless` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_lossless_float.rs:4:9 + | +LL | #![warn(clippy::cast_lossless)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: casting `i8` to `f64` may become silently lossy if you later change the type +warning: casting `i8` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:10:13 | LL | let _ = x0 as f64; | ^^^^^^^^^ help: try: `f64::from(x0)` -error: casting `u8` to `f32` may become silently lossy if you later change the type +warning: casting `u8` to `f32` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:12:13 | LL | let _ = x1 as f32; | ^^^^^^^^^ help: try: `f32::from(x1)` -error: casting `u8` to `f64` may become silently lossy if you later change the type +warning: casting `u8` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:13:13 | LL | let _ = x1 as f64; | ^^^^^^^^^ help: try: `f64::from(x1)` -error: casting `i16` to `f32` may become silently lossy if you later change the type +warning: casting `i16` to `f32` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:15:13 | LL | let _ = x2 as f32; | ^^^^^^^^^ help: try: `f32::from(x2)` -error: casting `i16` to `f64` may become silently lossy if you later change the type +warning: casting `i16` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:16:13 | LL | let _ = x2 as f64; | ^^^^^^^^^ help: try: `f64::from(x2)` -error: casting `u16` to `f32` may become silently lossy if you later change the type +warning: casting `u16` to `f32` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:18:13 | LL | let _ = x3 as f32; | ^^^^^^^^^ help: try: `f32::from(x3)` -error: casting `u16` to `f64` may become silently lossy if you later change the type +warning: casting `u16` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:19:13 | LL | let _ = x3 as f64; | ^^^^^^^^^ help: try: `f64::from(x3)` -error: casting `i32` to `f64` may become silently lossy if you later change the type +warning: casting `i32` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:21:13 | LL | let _ = x4 as f64; | ^^^^^^^^^ help: try: `f64::from(x4)` -error: casting `u32` to `f64` may become silently lossy if you later change the type +warning: casting `u32` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:23:13 | LL | let _ = x5 as f64; | ^^^^^^^^^ help: try: `f64::from(x5)` -error: casting `f32` to `f64` may become silently lossy if you later change the type +warning: casting `f32` to `f64` may become silently lossy if you later change the type --> $DIR/cast_lossless_float.rs:26:13 | LL | let _ = 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/cast_lossless_integer.fixed b/tests/ui/cast_lossless_integer.fixed index 925cbf25368f..7dab02084fc9 100644 --- a/tests/ui/cast_lossless_integer.fixed +++ b/tests/ui/cast_lossless_integer.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs index c82bd9108d23..c24f73960b03 100644 --- a/tests/ui/cast_lossless_integer.rs +++ b/tests/ui/cast_lossless_integer.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::no_effect, clippy::unnecessary_operation, dead_code)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 721b94876cb2..bf99b5dddad0 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,118 +1,122 @@ -error: casting `i8` to `i16` may become silently lossy if you later change the type +warning: casting `i8` to `i16` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:8:13 | LL | let _ = 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` | - = note: `-D clippy::cast-lossless` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_lossless_integer.rs:4:9 + | +LL | #![warn(clippy::cast_lossless)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: casting `i8` to `i32` may become silently lossy if you later change the type +warning: casting `i8` to `i32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:9:13 | LL | let _ = 1i8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1i8)` -error: casting `i8` to `i64` may become silently lossy if you later change the type +warning: casting `i8` to `i64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:10:13 | LL | let _ = 1i8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1i8)` -error: casting `u8` to `i16` may become silently lossy if you later change the type +warning: casting `u8` to `i16` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:11:13 | LL | let _ = 1u8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1u8)` -error: casting `u8` to `i32` may become silently lossy if you later change the type +warning: casting `u8` to `i32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:12:13 | LL | let _ = 1u8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1u8)` -error: casting `u8` to `i64` may become silently lossy if you later change the type +warning: casting `u8` to `i64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:13:13 | LL | let _ = 1u8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1u8)` -error: casting `u8` to `u16` may become silently lossy if you later change the type +warning: casting `u8` to `u16` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:14:13 | LL | let _ = 1u8 as u16; | ^^^^^^^^^^ help: try: `u16::from(1u8)` -error: casting `u8` to `u32` may become silently lossy if you later change the type +warning: casting `u8` to `u32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:15:13 | LL | let _ = 1u8 as u32; | ^^^^^^^^^^ help: try: `u32::from(1u8)` -error: casting `u8` to `u64` may become silently lossy if you later change the type +warning: casting `u8` to `u64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:16:13 | LL | let _ = 1u8 as u64; | ^^^^^^^^^^ help: try: `u64::from(1u8)` -error: casting `i16` to `i32` may become silently lossy if you later change the type +warning: casting `i16` to `i32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:17:13 | LL | let _ = 1i16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1i16)` -error: casting `i16` to `i64` may become silently lossy if you later change the type +warning: casting `i16` to `i64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:18:13 | LL | let _ = 1i16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i16)` -error: casting `u16` to `i32` may become silently lossy if you later change the type +warning: casting `u16` to `i32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:19:13 | LL | let _ = 1u16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1u16)` -error: casting `u16` to `i64` may become silently lossy if you later change the type +warning: casting `u16` to `i64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:20:13 | LL | let _ = 1u16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u16)` -error: casting `u16` to `u32` may become silently lossy if you later change the type +warning: casting `u16` to `u32` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:21:13 | LL | let _ = 1u16 as u32; | ^^^^^^^^^^^ help: try: `u32::from(1u16)` -error: casting `u16` to `u64` may become silently lossy if you later change the type +warning: casting `u16` to `u64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:22:13 | LL | let _ = 1u16 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u16)` -error: casting `i32` to `i64` may become silently lossy if you later change the type +warning: casting `i32` to `i64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:23:13 | LL | let _ = 1i32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i32)` -error: casting `u32` to `i64` may become silently lossy if you later change the type +warning: casting `u32` to `i64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:24:13 | LL | let _ = 1u32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u32)` -error: casting `u32` to `u64` may become silently lossy if you later change the type +warning: casting `u32` to `u64` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:25:13 | LL | let _ = 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` -error: casting `u8` to `u16` may become silently lossy if you later change the type +warning: casting `u8` to `u16` may become silently lossy if you later change the type --> $DIR/cast_lossless_integer.rs:28:13 | LL | let _ = (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/cast_nan_to_int.stderr b/tests/ui/cast_nan_to_int.stderr index 3539be75a19d..e7e2cbdef4dd 100644 --- a/tests/ui/cast_nan_to_int.stderr +++ b/tests/ui/cast_nan_to_int.stderr @@ -1,13 +1,17 @@ -error: casting a known NaN to usize +warning: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:5:13 | LL | let _ = (0.0_f32 / -0.0) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this always evaluates to 0 - = note: `-D clippy::cast-nan-to-int` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_nan_to_int.rs:1:9 + | +LL | #![warn(clippy::cast_nan_to_int)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: casting a known NaN to usize +warning: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:6:13 | LL | let _ = (f64::INFINITY * -0.0) as usize; @@ -15,7 +19,7 @@ LL | let _ = (f64::INFINITY * -0.0) as usize; | = note: this always evaluates to 0 -error: casting a known NaN to usize +warning: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:7:13 | LL | let _ = (0.0 * f32::INFINITY) as usize; @@ -23,7 +27,7 @@ LL | let _ = (0.0 * f32::INFINITY) as usize; | = note: this always evaluates to 0 -error: casting a known NaN to usize +warning: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:9:13 | LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; @@ -31,7 +35,7 @@ LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; | = note: this always evaluates to 0 -error: casting a known NaN to usize +warning: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:10:13 | LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; @@ -39,7 +43,7 @@ LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; | = note: this always evaluates to 0 -error: casting a known NaN to usize +warning: casting a known NaN to usize --> $DIR/cast_nan_to_int.rs:11:13 | LL | let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize; @@ -47,5 +51,5 @@ LL | let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize; | = note: this always evaluates to 0 -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/cast_raw_slice_pointer_cast.fixed b/tests/ui/cast_raw_slice_pointer_cast.fixed index b70c19129511..9b6fee270ee9 100644 --- a/tests/ui/cast_raw_slice_pointer_cast.fixed +++ b/tests/ui/cast_raw_slice_pointer_cast.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::cast_slice_from_raw_parts)] #[allow(unused_imports, unused_unsafe)] diff --git a/tests/ui/cast_raw_slice_pointer_cast.rs b/tests/ui/cast_raw_slice_pointer_cast.rs index c1b316765c96..c0bb81379905 100644 --- a/tests/ui/cast_raw_slice_pointer_cast.rs +++ b/tests/ui/cast_raw_slice_pointer_cast.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::cast_slice_from_raw_parts)] #[allow(unused_imports, unused_unsafe)] diff --git a/tests/ui/cast_raw_slice_pointer_cast.stderr b/tests/ui/cast_raw_slice_pointer_cast.stderr index f07801c197cc..99651879621f 100644 --- a/tests/ui/cast_raw_slice_pointer_cast.stderr +++ b/tests/ui/cast_raw_slice_pointer_cast.stderr @@ -1,46 +1,50 @@ -error: casting the result of `from_raw_parts` to *const [u8] +warning: casting the result of `from_raw_parts` to *const [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:9:35 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) as *const [u8] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` | - = note: `-D clippy::cast-slice-from-raw-parts` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_raw_slice_pointer_cast.rs:2:9 + | +LL | #![warn(clippy::cast_slice_from_raw_parts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting the result of `from_raw_parts_mut` to *mut [u8] +warning: casting the result of `from_raw_parts_mut` to *mut [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:10:35 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts_mut(mptr, 1) as *mut [u8] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts_mut(mptr, 1)` -error: casting the result of `from_raw_parts` to *const [u8] +warning: casting the result of `from_raw_parts` to *const [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:11:26 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` -error: casting the result of `from_raw_parts` to *const [u8] +warning: casting the result of `from_raw_parts` to *const [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:14:30 | LL | let _: *const [u8] = unsafe { slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` -error: casting the result of `from_raw_parts` to *const [u8] +warning: casting the result of `from_raw_parts` to *const [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:16:30 | LL | let _: *const [u8] = unsafe { one::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` -error: casting the result of `from_raw_parts` to *const [u8] +warning: casting the result of `from_raw_parts` to *const [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:20:30 | LL | let _: *const [u8] = unsafe { slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` -error: casting the result of `from_raw_parts` to *const [u8] +warning: casting the result of `from_raw_parts` to *const [u8] --> $DIR/cast_raw_slice_pointer_cast.rs:22:30 | LL | let _: *const [u8] = unsafe { one::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/cast_ref_to_mut.stderr b/tests/ui/cast_ref_to_mut.stderr index aacd99437d9f..4cf699711287 100644 --- a/tests/ui/cast_ref_to_mut.stderr +++ b/tests/ui/cast_ref_to_mut.stderr @@ -1,22 +1,26 @@ -error: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell` +warning: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell` --> $DIR/cast_ref_to_mut.rs:18:9 | LL | (*(a as *const _ as *mut String)).push_str(" world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::cast-ref-to-mut` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_ref_to_mut.rs:1:9 + | +LL | #![warn(clippy::cast_ref_to_mut)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell` +warning: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell` --> $DIR/cast_ref_to_mut.rs:19:9 | LL | *(a as *const _ as *mut _) = String::from("Replaced"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell` +warning: casting `&T` to `&mut T` may cause undefined behavior, consider instead using an `UnsafeCell` --> $DIR/cast_ref_to_mut.rs:20:9 | LL | *(a as *const _ as *mut String) += " world"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/cast_size.rs b/tests/ui/cast_size.rs index 595109be46bb..cd2184aea382 100644 --- a/tests/ui/cast_size.rs +++ b/tests/ui/cast_size.rs @@ -1,4 +1,4 @@ -// ignore-32bit +//@ignore-32bit #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index 6d2d49d9ed20..74cc127aaa4a 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -1,43 +1,51 @@ -error: casting `isize` to `i8` may truncate the value +warning: casting `isize` to `i8` may truncate the value --> $DIR/cast_size.rs:12:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ | = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... - = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_size.rs:4:5 + | +LL | clippy::cast_possible_truncation, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ... or use `try_from` and handle the error accordingly | LL | i8::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~ -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) +warning: 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_size.rs:15:5 | LL | x0 as f64; | ^^^^^^^^^ | - = note: `-D clippy::cast-precision-loss` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_size.rs:3:5 + | +LL | clippy::cast_precision_loss, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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) +warning: 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_size.rs:16:5 | LL | x1 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) +warning: 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_size.rs:17:5 | LL | x0 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) +warning: 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_size.rs:18:5 | LL | x1 as f32; | ^^^^^^^^^ -error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers +warning: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:19:5 | LL | 1isize as i32; @@ -49,7 +57,7 @@ help: ... or use `try_from` and handle the error accordingly LL | i32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers +warning: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:20:5 | LL | 1isize as u32; @@ -61,7 +69,7 @@ help: ... or use `try_from` and handle the error accordingly LL | u32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers +warning: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:21:5 | LL | 1usize as u32; @@ -73,7 +81,7 @@ help: ... or use `try_from` and handle the error accordingly LL | u32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers +warning: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:22:5 | LL | 1usize as i32; @@ -85,15 +93,19 @@ help: ... or use `try_from` and handle the error accordingly LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers +warning: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:22:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ | - = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_size.rs:6:5 + | +LL | clippy::cast_possible_wrap, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers +warning: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:24:5 | LL | 1i64 as isize; @@ -105,7 +117,7 @@ help: ... or use `try_from` and handle the error accordingly LL | isize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers +warning: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:25:5 | LL | 1i64 as usize; @@ -117,7 +129,7 @@ help: ... or use `try_from` and handle the error accordingly LL | usize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers +warning: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:26:5 | LL | 1u64 as isize; @@ -129,13 +141,13 @@ help: ... or use `try_from` and handle the error accordingly LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers +warning: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers --> $DIR/cast_size.rs:26:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ -error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers +warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:27:5 | LL | 1u64 as usize; @@ -147,23 +159,23 @@ help: ... or use `try_from` and handle the error accordingly LL | usize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers +warning: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast_size.rs:28:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ -error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +warning: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> $DIR/cast_size.rs:33:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ -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) +warning: 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_size.rs:34:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/cast_size_32bit.rs b/tests/ui/cast_size_32bit.rs index 99aac6deca32..7ca20d3ca4a7 100644 --- a/tests/ui/cast_size_32bit.rs +++ b/tests/ui/cast_size_32bit.rs @@ -1,4 +1,4 @@ -// ignore-64bit +//@ignore-64bit #[warn( clippy::cast_precision_loss, clippy::cast_possible_truncation, diff --git a/tests/ui/cast_size_32bit.stderr b/tests/ui/cast_size_32bit.stderr index 8990c3ba739b..2a67f1be1999 100644 --- a/tests/ui/cast_size_32bit.stderr +++ b/tests/ui/cast_size_32bit.stderr @@ -1,118 +1,183 @@ -error: casting `isize` to `i8` may truncate the value +warning: casting `isize` to `i8` may truncate the value --> $DIR/cast_size_32bit.rs:12:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ | - = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +note: the lint level is defined here + --> $DIR/cast_size_32bit.rs:4:5 + | +LL | clippy::cast_possible_truncation, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: ... or use `try_from` and handle the error accordingly + | +LL | i8::try_from(1isize); + | ~~~~~~~~~~~~~~~~~~~~ -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) +warning: 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_size_32bit.rs:15:5 | LL | x0 as f64; | ^^^^^^^^^ | - = note: `-D clippy::cast-precision-loss` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_size_32bit.rs:3:5 + | +LL | clippy::cast_precision_loss, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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) +warning: 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_size_32bit.rs:16:5 | LL | x1 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) +warning: 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_size_32bit.rs:17:5 | LL | x0 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) +warning: 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_size_32bit.rs:18:5 | LL | x1 as f32; | ^^^^^^^^^ -error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers +warning: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size_32bit.rs:19:5 | LL | 1isize as i32; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | i32::try_from(1isize); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers +warning: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size_32bit.rs:20:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | u32::try_from(1isize); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers +warning: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size_32bit.rs:21:5 | LL | 1usize as u32; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | u32::try_from(1usize); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers +warning: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast_size_32bit.rs:22:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | i32::try_from(1usize); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers +warning: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast_size_32bit.rs:22:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ | - = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cast_size_32bit.rs:6:5 + | +LL | clippy::cast_possible_wrap, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers +warning: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size_32bit.rs:24:5 | LL | 1i64 as isize; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | isize::try_from(1i64); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers +warning: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size_32bit.rs:25:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | usize::try_from(1i64); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers +warning: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size_32bit.rs:26:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | isize::try_from(1u64); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers +warning: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers --> $DIR/cast_size_32bit.rs:26:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ -error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers +warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers --> $DIR/cast_size_32bit.rs:27:5 | LL | 1u64 as usize; | ^^^^^^^^^^^^^ + | + = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... +help: ... or use `try_from` and handle the error accordingly + | +LL | usize::try_from(1u64); + | ~~~~~~~~~~~~~~~~~~~~~ -error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers +warning: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast_size_32bit.rs:28:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ -error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) +warning: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) --> $DIR/cast_size_32bit.rs:33:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ -error: casting integer literal to `f64` is unnecessary +warning: casting integer literal to `f64` is unnecessary --> $DIR/cast_size_32bit.rs:34:5 | LL | 3_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `3_999_999_999_f64` | - = note: `-D clippy::unnecessary-cast` implied by `-D warnings` + = note: `#[warn(clippy::unnecessary_cast)]` on by default -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/cast_slice_different_sizes.rs b/tests/ui/cast_slice_different_sizes.rs index 24d7eb28a197..bf3e8950a4dc 100644 --- a/tests/ui/cast_slice_different_sizes.rs +++ b/tests/ui/cast_slice_different_sizes.rs @@ -1,4 +1,5 @@ #![allow(clippy::let_unit_value)] +#![warn(clippy::cast_slice_different_sizes)] fn main() { let x: [i32; 3] = [1_i32, 2, 3]; diff --git a/tests/ui/cast_slice_different_sizes.stderr b/tests/ui/cast_slice_different_sizes.stderr index 40721dcd05d5..addd19e3dd80 100644 --- a/tests/ui/cast_slice_different_sizes.stderr +++ b/tests/ui/cast_slice_different_sizes.stderr @@ -1,31 +1,35 @@ -error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:9:13 +warning: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:10:13 | LL | let b = a as *const [u8]; | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(a as *const u8, ..)` | - = note: `#[deny(clippy::cast_slice_different_sizes)]` on by default +note: the lint level is defined here + --> $DIR/cast_slice_different_sizes.rs:2:9 + | +LL | #![warn(clippy::cast_slice_different_sizes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting between raw pointers to `[u8]` (element size 1) and `[u32]` (element size 4) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:10:13 +warning: casting between raw pointers to `[u8]` (element size 1) and `[u32]` (element size 4) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:11:13 | LL | let c = b as *const [u32]; | ^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(b as *const u32, ..)` -error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:13:16 +warning: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:14:16 | LL | let loss = r_x as *const [i32] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` -error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:20:24 +warning: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:21:24 | LL | let loss_block_1 = { r_x as *const [i32] } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts({ r_x as *const [i32] } as *const u8, ..)` -error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:21:24 +warning: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:22:24 | LL | let loss_block_2 = { | ________________________^ @@ -42,14 +46,14 @@ LL + r_x as *const [i32] LL ~ } as *const u8, ..); | -error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:38:27 +warning: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:39:27 | LL | let long_chain_loss = r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:53:36 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:54:36 | LL | fn bar(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -57,8 +61,8 @@ LL | | x as *mut [u8] LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:57:36 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:58:36 | LL | fn uwu(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -66,8 +70,8 @@ LL | | x as *mut _ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:61:37 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:62:37 | LL | fn bar2(x: *mut [u16]) -> *mut [u8] { | _____________________________________^ @@ -75,8 +79,8 @@ LL | | x as _ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:66:39 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:67:39 | LL | fn bar3(x: *mut [u16]) -> *const [u8] { | _______________________________________^ @@ -84,8 +88,8 @@ LL | | x as _ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(x as *const u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:71:39 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:72:39 | LL | fn bar4(x: *const [u16]) -> *mut [u8] { | _______________________________________^ @@ -93,8 +97,8 @@ LL | | x as _ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:76:39 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:77:39 | LL | fn blocks(x: *mut [u16]) -> *mut [u8] { | _______________________________________^ @@ -102,8 +106,8 @@ LL | | ({ x }) as _ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:80:44 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:81:44 | LL | fn more_blocks(x: *mut [u16]) -> *mut [u8] { | ____________________________________________^ @@ -111,11 +115,11 @@ LL | | { ({ x }) as _ } LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` -error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:81:5 +warning: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count + --> $DIR/cast_slice_different_sizes.rs:82:5 | LL | { ({ x }) as _ } | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/cfg_attr_rustfmt.fixed b/tests/ui/cfg_attr_rustfmt.fixed index b970b1209b65..13aadb7d3308 100644 --- a/tests/ui/cfg_attr_rustfmt.fixed +++ b/tests/ui/cfg_attr_rustfmt.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(stmt_expr_attributes)] #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/cfg_attr_rustfmt.rs b/tests/ui/cfg_attr_rustfmt.rs index 0a8e6a89d8a0..769c5d22b9da 100644 --- a/tests/ui/cfg_attr_rustfmt.rs +++ b/tests/ui/cfg_attr_rustfmt.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(stmt_expr_attributes)] #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/cfg_attr_rustfmt.stderr b/tests/ui/cfg_attr_rustfmt.stderr index 524a2bf72484..a4c08802ea07 100644 --- a/tests/ui/cfg_attr_rustfmt.stderr +++ b/tests/ui/cfg_attr_rustfmt.stderr @@ -1,22 +1,26 @@ -error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes +warning: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes --> $DIR/cfg_attr_rustfmt.rs:18:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` | - = note: `-D clippy::deprecated-cfg-attr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cfg_attr_rustfmt.rs:5:9 + | +LL | #![warn(clippy::deprecated_cfg_attr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes +warning: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes --> $DIR/cfg_attr_rustfmt.rs:22:1 | LL | #[cfg_attr(rustfmt, rustfmt_skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` -error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes +warning: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes --> $DIR/cfg_attr_rustfmt.rs:41:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index 39fc9d6dda67..cf11c0f15c34 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -1,11 +1,15 @@ -error: casting a character literal to `u8` truncates +warning: casting a character literal to `u8` truncates --> $DIR/char_lit_as_u8.rs:4:13 | LL | let _ = '❤' as u8; // no suggestion, since a byte literal won't work. | ^^^^^^^^^ | = note: `char` is four bytes wide, but `u8` is a single byte - = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/char_lit_as_u8.rs:1:9 + | +LL | #![warn(clippy::char_lit_as_u8)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/char_lit_as_u8_suggestions.fixed b/tests/ui/char_lit_as_u8_suggestions.fixed index 3dc3cb4e7573..ce2f149dc05e 100644 --- a/tests/ui/char_lit_as_u8_suggestions.fixed +++ b/tests/ui/char_lit_as_u8_suggestions.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::char_lit_as_u8)] diff --git a/tests/ui/char_lit_as_u8_suggestions.rs b/tests/ui/char_lit_as_u8_suggestions.rs index d379a0234942..ffad12fc6f95 100644 --- a/tests/ui/char_lit_as_u8_suggestions.rs +++ b/tests/ui/char_lit_as_u8_suggestions.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::char_lit_as_u8)] diff --git a/tests/ui/char_lit_as_u8_suggestions.stderr b/tests/ui/char_lit_as_u8_suggestions.stderr index 586174c50882..364f12702c6c 100644 --- a/tests/ui/char_lit_as_u8_suggestions.stderr +++ b/tests/ui/char_lit_as_u8_suggestions.stderr @@ -1,35 +1,39 @@ -error: casting a character literal to `u8` truncates +warning: casting a character literal to `u8` truncates --> $DIR/char_lit_as_u8_suggestions.rs:6:13 | LL | let _ = 'a' as u8; | ^^^^^^^^^ help: use a byte literal instead: `b'a'` | = note: `char` is four bytes wide, but `u8` is a single byte - = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/char_lit_as_u8_suggestions.rs:3:9 + | +LL | #![warn(clippy::char_lit_as_u8)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: casting a character literal to `u8` truncates +warning: casting a character literal to `u8` truncates --> $DIR/char_lit_as_u8_suggestions.rs:7:13 | -LL | let _ = '/n' as u8; - | ^^^^^^^^^^ help: use a byte literal instead: `b'/n'` +LL | let _ = '\n' as u8; + | ^^^^^^^^^^ help: use a byte literal instead: `b'\n'` | = note: `char` is four bytes wide, but `u8` is a single byte -error: casting a character literal to `u8` truncates +warning: casting a character literal to `u8` truncates --> $DIR/char_lit_as_u8_suggestions.rs:8:13 | -LL | let _ = '/0' as u8; - | ^^^^^^^^^^ help: use a byte literal instead: `b'/0'` +LL | let _ = '\0' as u8; + | ^^^^^^^^^^ help: use a byte literal instead: `b'\0'` | = note: `char` is four bytes wide, but `u8` is a single byte -error: casting a character literal to `u8` truncates +warning: casting a character literal to `u8` truncates --> $DIR/char_lit_as_u8_suggestions.rs:9:13 | -LL | let _ = '/x01' as u8; - | ^^^^^^^^^^^^ help: use a byte literal instead: `b'/x01'` +LL | let _ = '\x01' as u8; + | ^^^^^^^^^^^^ help: use a byte literal instead: `b'\x01'` | = note: `char` is four bytes wide, but `u8` is a single byte -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/checked_conversions.fixed b/tests/ui/checked_conversions.fixed index e279ba3147bb..188e6d975952 100644 --- a/tests/ui/checked_conversions.fixed +++ b/tests/ui/checked_conversions.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( clippy::cast_lossless, diff --git a/tests/ui/checked_conversions.rs b/tests/ui/checked_conversions.rs index 9d7a40995c37..70f0f0975acd 100644 --- a/tests/ui/checked_conversions.rs +++ b/tests/ui/checked_conversions.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( clippy::cast_lossless, diff --git a/tests/ui/checked_conversions.stderr b/tests/ui/checked_conversions.stderr index 273ead73bda5..f4fde6713de7 100644 --- a/tests/ui/checked_conversions.stderr +++ b/tests/ui/checked_conversions.stderr @@ -1,106 +1,110 @@ -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:16:13 | LL | let _ = value <= (u32::max_value() as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` | - = note: `-D clippy::checked-conversions` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/checked_conversions.rs:9:9 + | +LL | #![warn(clippy::checked_conversions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:17:13 | LL | let _ = value <= (u32::MAX as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:21:13 | LL | let _ = value <= i64::from(u16::max_value()) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:22:13 | LL | let _ = value <= i64::from(u16::MAX) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:26:13 | LL | let _ = value <= (u8::max_value() as isize) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:27:13 | LL | let _ = value <= (u8::MAX as isize) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:33:13 | LL | let _ = value <= (i32::max_value() as i64) && value >= (i32::min_value() as i64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:34:13 | LL | let _ = value <= (i32::MAX as i64) && value >= (i32::MIN as i64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:38:13 | LL | let _ = value <= i64::from(i16::max_value()) && value >= i64::from(i16::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:39:13 | LL | let _ = value <= i64::from(i16::MAX) && value >= i64::from(i16::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:45:13 | LL | let _ = value <= i32::max_value() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:46:13 | LL | let _ = value <= i32::MAX as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:50:13 | LL | let _ = value <= isize::max_value() as usize && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:51:13 | LL | let _ = value <= isize::MAX as usize && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:55:13 | LL | let _ = value <= u16::max_value() as u32 && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:56:13 | LL | let _ = value <= u16::MAX as u32 && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` -error: checked cast can be simplified +warning: checked cast can be simplified --> $DIR/checked_conversions.rs:89:13 | LL | let _ = value <= (u32::MAX as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/checked_unwrap/complex_conditionals.rs b/tests/ui/checked_unwrap/complex_conditionals.rs index ec082c73b44c..add56fed9a95 100644 --- a/tests/ui/checked_unwrap/complex_conditionals.rs +++ b/tests/ui/checked_unwrap/complex_conditionals.rs @@ -1,4 +1,4 @@ -#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +#![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] #![allow(clippy::if_same_then_else, clippy::branches_sharing_code)] fn test_complex_conditions() { diff --git a/tests/ui/checked_unwrap/complex_conditionals.stderr b/tests/ui/checked_unwrap/complex_conditionals.stderr index d44d5072e485..95ae9ae945c8 100644 --- a/tests/ui/checked_unwrap/complex_conditionals.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals.stderr @@ -1,4 +1,4 @@ -error: called `unwrap` on `x` after checking its variant with `is_ok` +warning: called `unwrap` on `x` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:8:9 | LL | if x.is_ok() && y.is_err() { @@ -10,10 +10,10 @@ LL | x.unwrap(); // unnecessary note: the lint level is defined here --> $DIR/complex_conditionals.rs:1:35 | -LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `unwrap_err()` will always panic +warning: this call to `unwrap_err()` will always panic --> $DIR/complex_conditionals.rs:9:9 | LL | if x.is_ok() && y.is_err() { @@ -25,10 +25,10 @@ LL | x.unwrap_err(); // will panic note: the lint level is defined here --> $DIR/complex_conditionals.rs:1:9 | -LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals.rs:10:9 | LL | if x.is_ok() && y.is_err() { @@ -37,7 +37,7 @@ LL | if x.is_ok() && y.is_err() { LL | y.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `y` after checking its variant with `is_err` +warning: called `unwrap_err` on `y` after checking its variant with `is_err` --> $DIR/complex_conditionals.rs:11:9 | LL | if x.is_ok() && y.is_err() { @@ -48,7 +48,7 @@ LL | y.unwrap_err(); // unnecessary | = help: try using `if let` or `match` -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals.rs:25:9 | LL | if x.is_ok() || y.is_ok() { @@ -57,7 +57,7 @@ LL | if x.is_ok() || y.is_ok() { LL | x.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `x` after checking its variant with `is_ok` +warning: called `unwrap_err` on `x` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:26:9 | LL | if x.is_ok() || y.is_ok() { @@ -68,7 +68,7 @@ LL | x.unwrap_err(); // unnecessary | = help: try using `if let` or `match` -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals.rs:27:9 | LL | if x.is_ok() || y.is_ok() { @@ -77,7 +77,7 @@ LL | if x.is_ok() || y.is_ok() { LL | y.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `y` after checking its variant with `is_ok` +warning: called `unwrap_err` on `y` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:28:9 | LL | if x.is_ok() || y.is_ok() { @@ -88,7 +88,7 @@ LL | y.unwrap_err(); // unnecessary | = help: try using `if let` or `match` -error: called `unwrap` on `x` after checking its variant with `is_ok` +warning: called `unwrap` on `x` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:32:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -98,7 +98,7 @@ LL | x.unwrap(); // unnecessary | = help: try using `if let` or `match` -error: this call to `unwrap_err()` will always panic +warning: this call to `unwrap_err()` will always panic --> $DIR/complex_conditionals.rs:33:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -107,7 +107,7 @@ LL | x.unwrap(); // unnecessary LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals.rs:34:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -116,7 +116,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { LL | y.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `y` after checking its variant with `is_ok` +warning: called `unwrap_err` on `y` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:35:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -127,7 +127,7 @@ LL | y.unwrap_err(); // unnecessary | = help: try using `if let` or `match` -error: called `unwrap` on `z` after checking its variant with `is_err` +warning: called `unwrap` on `z` after checking its variant with `is_err` --> $DIR/complex_conditionals.rs:36:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -138,7 +138,7 @@ LL | z.unwrap(); // unnecessary | = help: try using `if let` or `match` -error: this call to `unwrap_err()` will always panic +warning: this call to `unwrap_err()` will always panic --> $DIR/complex_conditionals.rs:37:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -147,7 +147,7 @@ LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { LL | z.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals.rs:45:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { @@ -156,7 +156,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { LL | x.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `x` after checking its variant with `is_ok` +warning: called `unwrap_err` on `x` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:46:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { @@ -167,7 +167,7 @@ LL | x.unwrap_err(); // unnecessary | = help: try using `if let` or `match` -error: called `unwrap` on `y` after checking its variant with `is_ok` +warning: called `unwrap` on `y` after checking its variant with `is_ok` --> $DIR/complex_conditionals.rs:47:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { @@ -178,7 +178,7 @@ LL | y.unwrap(); // unnecessary | = help: try using `if let` or `match` -error: this call to `unwrap_err()` will always panic +warning: this call to `unwrap_err()` will always panic --> $DIR/complex_conditionals.rs:48:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { @@ -187,7 +187,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { LL | y.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals.rs:49:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { @@ -196,7 +196,7 @@ LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { LL | z.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `z` after checking its variant with `is_err` +warning: called `unwrap_err` on `z` after checking its variant with `is_err` --> $DIR/complex_conditionals.rs:50:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { @@ -207,5 +207,5 @@ LL | z.unwrap_err(); // unnecessary | = help: try using `if let` or `match` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/checked_unwrap/complex_conditionals_nested.rs b/tests/ui/checked_unwrap/complex_conditionals_nested.rs index 043ea4148dc5..0d5ee94e7cf5 100644 --- a/tests/ui/checked_unwrap/complex_conditionals_nested.rs +++ b/tests/ui/checked_unwrap/complex_conditionals_nested.rs @@ -1,4 +1,4 @@ -#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +#![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] #![allow(clippy::if_same_then_else, clippy::branches_sharing_code)] fn test_nested() { diff --git a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr index 542ab53300c0..a01d10ab21b7 100644 --- a/tests/ui/checked_unwrap/complex_conditionals_nested.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals_nested.stderr @@ -1,4 +1,4 @@ -error: called `unwrap` on `x` after checking its variant with `is_some` +warning: called `unwrap` on `x` after checking its variant with `is_some` --> $DIR/complex_conditionals_nested.rs:8:13 | LL | if x.is_some() { @@ -9,10 +9,10 @@ LL | x.unwrap(); // unnecessary note: the lint level is defined here --> $DIR/complex_conditionals_nested.rs:1:35 | -LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/complex_conditionals_nested.rs:10:13 | LL | if x.is_some() { @@ -24,8 +24,8 @@ LL | x.unwrap(); // will panic note: the lint level is defined here --> $DIR/complex_conditionals_nested.rs:1:9 | -LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/checked_unwrap/simple_conditionals.rs b/tests/ui/checked_unwrap/simple_conditionals.rs index 82dce81979fd..6552f74d2701 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.rs +++ b/tests/ui/checked_unwrap/simple_conditionals.rs @@ -1,5 +1,5 @@ #![feature(lint_reasons)] -#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +#![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] #![allow(clippy::if_same_then_else, clippy::branches_sharing_code)] macro_rules! m { diff --git a/tests/ui/checked_unwrap/simple_conditionals.stderr b/tests/ui/checked_unwrap/simple_conditionals.stderr index ef6882742223..a012c1cebcd7 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -1,4 +1,4 @@ -error: called `unwrap` on `x` after checking its variant with `is_some` +warning: called `unwrap` on `x` after checking its variant with `is_some` --> $DIR/simple_conditionals.rs:40:9 | LL | if x.is_some() { @@ -9,10 +9,10 @@ LL | x.unwrap(); // unnecessary note: the lint level is defined here --> $DIR/simple_conditionals.rs:2:35 | -LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `expect` on `x` after checking its variant with `is_some` +warning: called `expect` on `x` after checking its variant with `is_some` --> $DIR/simple_conditionals.rs:41:9 | LL | if x.is_some() { @@ -21,7 +21,7 @@ LL | x.unwrap(); // unnecessary LL | x.expect("an error message"); // unnecessary | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/simple_conditionals.rs:43:9 | LL | if x.is_some() { @@ -33,10 +33,10 @@ LL | x.unwrap(); // will panic note: the lint level is defined here --> $DIR/simple_conditionals.rs:2:9 | -LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +LL | #![warn(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `expect()` will always panic +warning: this call to `expect()` will always panic --> $DIR/simple_conditionals.rs:44:9 | LL | if x.is_some() { @@ -45,7 +45,7 @@ LL | if x.is_some() { LL | x.expect("an error message"); // will panic | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/simple_conditionals.rs:47:9 | LL | if x.is_none() { @@ -53,7 +53,7 @@ LL | if x.is_none() { LL | x.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap` on `x` after checking its variant with `is_none` +warning: called `unwrap` on `x` after checking its variant with `is_none` --> $DIR/simple_conditionals.rs:49:9 | LL | if x.is_none() { @@ -62,7 +62,7 @@ LL | if x.is_none() { LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ -error: called `unwrap` on `x` after checking its variant with `is_some` +warning: called `unwrap` on `x` after checking its variant with `is_some` --> $DIR/simple_conditionals.rs:8:13 | LL | if $a.is_some() { @@ -73,9 +73,9 @@ LL | $a.unwrap(); // unnecessary LL | m!(x); | ----- in this macro invocation | - = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: called `unwrap` on `x` after checking its variant with `is_ok` +warning: called `unwrap` on `x` after checking its variant with `is_ok` --> $DIR/simple_conditionals.rs:57:9 | LL | if x.is_ok() { @@ -83,7 +83,7 @@ LL | if x.is_ok() { LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ -error: called `expect` on `x` after checking its variant with `is_ok` +warning: called `expect` on `x` after checking its variant with `is_ok` --> $DIR/simple_conditionals.rs:58:9 | LL | if x.is_ok() { @@ -92,7 +92,7 @@ LL | x.unwrap(); // unnecessary LL | x.expect("an error message"); // unnecessary | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `unwrap_err()` will always panic +warning: this call to `unwrap_err()` will always panic --> $DIR/simple_conditionals.rs:59:9 | LL | if x.is_ok() { @@ -101,7 +101,7 @@ LL | if x.is_ok() { LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/simple_conditionals.rs:61:9 | LL | if x.is_ok() { @@ -110,7 +110,7 @@ LL | if x.is_ok() { LL | x.unwrap(); // will panic | ^^^^^^^^^^ -error: this call to `expect()` will always panic +warning: this call to `expect()` will always panic --> $DIR/simple_conditionals.rs:62:9 | LL | if x.is_ok() { @@ -119,7 +119,7 @@ LL | if x.is_ok() { LL | x.expect("an error message"); // will panic | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `unwrap_err` on `x` after checking its variant with `is_ok` +warning: called `unwrap_err` on `x` after checking its variant with `is_ok` --> $DIR/simple_conditionals.rs:63:9 | LL | if x.is_ok() { @@ -128,7 +128,7 @@ LL | if x.is_ok() { LL | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ -error: this call to `unwrap()` will always panic +warning: this call to `unwrap()` will always panic --> $DIR/simple_conditionals.rs:66:9 | LL | if x.is_err() { @@ -136,7 +136,7 @@ LL | if x.is_err() { LL | x.unwrap(); // will panic | ^^^^^^^^^^ -error: called `unwrap_err` on `x` after checking its variant with `is_err` +warning: called `unwrap_err` on `x` after checking its variant with `is_err` --> $DIR/simple_conditionals.rs:67:9 | LL | if x.is_err() { @@ -145,7 +145,7 @@ LL | x.unwrap(); // will panic LL | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ -error: called `unwrap` on `x` after checking its variant with `is_err` +warning: called `unwrap` on `x` after checking its variant with `is_err` --> $DIR/simple_conditionals.rs:69:9 | LL | if x.is_err() { @@ -154,7 +154,7 @@ LL | if x.is_err() { LL | x.unwrap(); // unnecessary | ^^^^^^^^^^ -error: this call to `unwrap_err()` will always panic +warning: this call to `unwrap_err()` will always panic --> $DIR/simple_conditionals.rs:70:9 | LL | if x.is_err() { @@ -163,5 +163,5 @@ LL | if x.is_err() { LL | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/clone_on_copy.fixed b/tests/ui/clone_on_copy.fixed index 72b122270981..a720711585bb 100644 --- a/tests/ui/clone_on_copy.fixed +++ b/tests/ui/clone_on_copy.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( unused, diff --git a/tests/ui/clone_on_copy.rs b/tests/ui/clone_on_copy.rs index 03e210ebad98..2c5fac8faf56 100644 --- a/tests/ui/clone_on_copy.rs +++ b/tests/ui/clone_on_copy.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( unused, diff --git a/tests/ui/clone_on_copy.stderr b/tests/ui/clone_on_copy.stderr index 862234d204be..554ed39ca1e6 100644 --- a/tests/ui/clone_on_copy.stderr +++ b/tests/ui/clone_on_copy.stderr @@ -1,58 +1,58 @@ -error: using `clone` on type `i32` which implements the `Copy` trait +warning: using `clone` on type `i32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:25:5 | LL | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | - = note: `-D clippy::clone-on-copy` implied by `-D warnings` + = note: `#[warn(clippy::clone_on_copy)]` on by default -error: using `clone` on type `i32` which implements the `Copy` trait +warning: using `clone` on type `i32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:29:5 | LL | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` -error: using `clone` on type `i32` which implements the `Copy` trait +warning: using `clone` on type `i32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:32:5 | LL | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` -error: using `clone` on type `u32` which implements the `Copy` trait +warning: using `clone` on type `u32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:35:5 | LL | x.clone().rotate_left(1); | ^^^^^^^^^ help: try removing the `clone` call: `x` -error: using `clone` on type `i32` which implements the `Copy` trait +warning: using `clone` on type `i32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:49:5 | LL | m!(42).clone(); | ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)` -error: using `clone` on type `[u32; 2]` which implements the `Copy` trait +warning: using `clone` on type `[u32; 2]` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:59:5 | LL | x.clone()[0]; | ^^^^^^^^^ help: try dereferencing it: `(*x)` -error: using `clone` on type `char` which implements the `Copy` trait +warning: using `clone` on type `char` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:69:14 | LL | is_ascii('z'.clone()); | ^^^^^^^^^^^ help: try removing the `clone` call: `'z'` -error: using `clone` on type `i32` which implements the `Copy` trait +warning: using `clone` on type `i32` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:73:14 | LL | vec.push(42.clone()); | ^^^^^^^^^^ help: try removing the `clone` call: `42` -error: using `clone` on type `Option` which implements the `Copy` trait +warning: using `clone` on type `Option` which implements the `Copy` trait --> $DIR/clone_on_copy.rs:77:17 | LL | let value = opt.clone()?; // operator precedence needed (*opt)? | ^^^^^^^^^^^ help: try dereferencing it: `(*opt)` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/cloned_instead_of_copied.fixed b/tests/ui/cloned_instead_of_copied.fixed index ecbfc1feedf6..b6e09ab31908 100644 --- a/tests/ui/cloned_instead_of_copied.fixed +++ b/tests/ui/cloned_instead_of_copied.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::cloned_instead_of_copied)] #![allow(unused)] diff --git a/tests/ui/cloned_instead_of_copied.rs b/tests/ui/cloned_instead_of_copied.rs index 163dc3dddce6..fa9e1a996139 100644 --- a/tests/ui/cloned_instead_of_copied.rs +++ b/tests/ui/cloned_instead_of_copied.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::cloned_instead_of_copied)] #![allow(unused)] diff --git a/tests/ui/cloned_instead_of_copied.stderr b/tests/ui/cloned_instead_of_copied.stderr index e0361acd9560..b75d721e8e5a 100644 --- a/tests/ui/cloned_instead_of_copied.stderr +++ b/tests/ui/cloned_instead_of_copied.stderr @@ -1,52 +1,56 @@ -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:8:24 | LL | let _ = [1].iter().cloned(); | ^^^^^^ help: try: `copied` | - = note: `-D clippy::cloned-instead-of-copied` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cloned_instead_of_copied.rs:3:9 + | +LL | #![warn(clippy::cloned_instead_of_copied)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:9:31 | LL | let _ = vec!["hi"].iter().cloned(); | ^^^^^^ help: try: `copied` -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:10:22 | LL | let _ = Some(&1).cloned(); | ^^^^^^ help: try: `copied` -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:11:34 | LL | let _ = Box::new([1].iter()).cloned(); | ^^^^^^ help: try: `copied` -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:12:32 | LL | let _ = Box::new(Some(&1)).cloned(); | ^^^^^^ help: try: `copied` -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:28:22 | LL | let _ = Some(&1).cloned(); // Option::copied needs 1.35 | ^^^^^^ help: try: `copied` -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:33:24 | LL | let _ = [1].iter().cloned(); // Iterator::copied needs 1.36 | ^^^^^^ help: try: `copied` -error: used `cloned` where `copied` could be used instead +warning: used `cloned` where `copied` could be used instead --> $DIR/cloned_instead_of_copied.rs:34:22 | LL | let _ = Some(&1).cloned(); | ^^^^^^ help: try: `copied` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index 867516661a53..6d4d1464998a 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -1,148 +1,152 @@ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:8:5 | LL | x == f32::NAN; | ^^^^^^^^^^^^^ | - = note: `-D clippy::cmp-nan` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cmp_nan.rs:4:8 + | +LL | #[warn(clippy::cmp_nan)] + | ^^^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:9:5 | LL | x != f32::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:10:5 | LL | x < f32::NAN; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:11:5 | LL | x > f32::NAN; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:12:5 | LL | x <= f32::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:13:5 | LL | x >= f32::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:14:5 | LL | x == NAN_F32; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:15:5 | LL | x != NAN_F32; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:16:5 | LL | x < NAN_F32; | ^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:17:5 | LL | x > NAN_F32; | ^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:18:5 | LL | x <= NAN_F32; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:19:5 | LL | x >= NAN_F32; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:22:5 | LL | y == f64::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:23:5 | LL | y != f64::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:24:5 | LL | y < f64::NAN; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:25:5 | LL | y > f64::NAN; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:26:5 | LL | y <= f64::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:27:5 | LL | y >= f64::NAN; | ^^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:28:5 | LL | y == NAN_F64; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:29:5 | LL | y != NAN_F64; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:30:5 | LL | y < NAN_F64; | ^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:31:5 | LL | y > NAN_F64; | ^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:32:5 | LL | y <= NAN_F64; | ^^^^^^^^^^^^ -error: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead +warning: doomed comparison with `NAN`, use `{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:33:5 | LL | y >= NAN_F64; | ^^^^^^^^^^^^ -error: aborting due to 24 previous errors +warning: 24 warnings emitted diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index a1f4c70fb278..d8640f1a93fd 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,16 +1,20 @@ -error: comparing with null is better expressed by the `.is_null()` method +warning: comparing with null is better expressed by the `.is_null()` method --> $DIR/cmp_null.rs:9:8 | LL | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::cmp-null` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cmp_null.rs:1:9 + | +LL | #![warn(clippy::cmp_null)] + | ^^^^^^^^^^^^^^^^ -error: comparing with null is better expressed by the `.is_null()` method +warning: comparing with null is better expressed by the `.is_null()` method --> $DIR/cmp_null.rs:14:8 | LL | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/cmp_owned/asymmetric_partial_eq.fixed b/tests/ui/cmp_owned/asymmetric_partial_eq.fixed index abd059c23080..3bf3deb9b918 100644 --- a/tests/ui/cmp_owned/asymmetric_partial_eq.fixed +++ b/tests/ui/cmp_owned/asymmetric_partial_eq.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::redundant_clone, clippy::derive_partial_eq_without_eq)] // See #5700 // Define the types in each module to avoid trait impls leaking between modules. diff --git a/tests/ui/cmp_owned/asymmetric_partial_eq.rs b/tests/ui/cmp_owned/asymmetric_partial_eq.rs index 020ef5f840bd..10107dc8f86d 100644 --- a/tests/ui/cmp_owned/asymmetric_partial_eq.rs +++ b/tests/ui/cmp_owned/asymmetric_partial_eq.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::redundant_clone, clippy::derive_partial_eq_without_eq)] // See #5700 // Define the types in each module to avoid trait impls leaking between modules. diff --git a/tests/ui/cmp_owned/asymmetric_partial_eq.stderr b/tests/ui/cmp_owned/asymmetric_partial_eq.stderr index 43bf8851fc62..2b98bed9957d 100644 --- a/tests/ui/cmp_owned/asymmetric_partial_eq.stderr +++ b/tests/ui/cmp_owned/asymmetric_partial_eq.stderr @@ -1,12 +1,12 @@ -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:42:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` | - = note: `-D clippy::cmp-owned` implied by `-D warnings` + = note: `#[warn(clippy::cmp_owned)]` on by default -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:43:21 | LL | if owned == borrowed.to_owned() {} @@ -14,13 +14,13 @@ LL | if owned == borrowed.to_owned() {} | | | help: try: `borrowed == owned` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:61:21 | LL | if owned == borrowed.to_owned() {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:62:12 | LL | if borrowed.to_owned() == owned {} @@ -28,7 +28,7 @@ LL | if borrowed.to_owned() == owned {} | | | help: try: `owned == borrowed` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:88:20 | LL | if "Hi" == borrowed.to_string() {} @@ -36,11 +36,11 @@ LL | if "Hi" == borrowed.to_string() {} | | | help: try: `borrowed == "Hi"` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/asymmetric_partial_eq.rs:89:12 | LL | if borrowed.to_string() == "Hi" {} | ^^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/cmp_owned/comparison_flip.fixed b/tests/ui/cmp_owned/comparison_flip.fixed index 44e41bdd1148..b1133f2a59f7 100644 --- a/tests/ui/cmp_owned/comparison_flip.fixed +++ b/tests/ui/cmp_owned/comparison_flip.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use std::fmt::{self, Display}; diff --git a/tests/ui/cmp_owned/comparison_flip.rs b/tests/ui/cmp_owned/comparison_flip.rs index 662673abb62d..091a9aa65c0a 100644 --- a/tests/ui/cmp_owned/comparison_flip.rs +++ b/tests/ui/cmp_owned/comparison_flip.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use std::fmt::{self, Display}; diff --git a/tests/ui/cmp_owned/comparison_flip.stderr b/tests/ui/cmp_owned/comparison_flip.stderr index e4d0d822bb1e..d50969810dc4 100644 --- a/tests/ui/cmp_owned/comparison_flip.stderr +++ b/tests/ui/cmp_owned/comparison_flip.stderr @@ -1,12 +1,12 @@ -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/comparison_flip.rs:8:8 | LL | if a.to_string() != "bar" { | ^^^^^^^^^^^^^ help: try: `a` | - = note: `-D clippy::cmp-owned` implied by `-D warnings` + = note: `#[warn(clippy::cmp_owned)]` on by default -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/comparison_flip.rs:12:17 | LL | if "bar" != a.to_string() { @@ -14,5 +14,5 @@ LL | if "bar" != a.to_string() { | | | help: try: `a != "bar"` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/cmp_owned/with_suggestion.fixed b/tests/ui/cmp_owned/with_suggestion.fixed index b28c4378e33c..bf1a58588a85 100644 --- a/tests/ui/cmp_owned/with_suggestion.fixed +++ b/tests/ui/cmp_owned/with_suggestion.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[warn(clippy::cmp_owned)] #[allow(clippy::unnecessary_operation, clippy::no_effect, unused_must_use, clippy::eq_op)] @@ -31,7 +31,7 @@ struct Foo; impl PartialEq for Foo { // Allow this here, because it emits the lint // without a suggestion. This is tested in - // `tests/ui/cmp_owned/without_suggestion.rs` + // `$DIR/without_suggestion.rs` #[allow(clippy::cmp_owned)] fn eq(&self, other: &Self) -> bool { self.to_owned() == *other diff --git a/tests/ui/cmp_owned/with_suggestion.rs b/tests/ui/cmp_owned/with_suggestion.rs index c1089010fe10..f3f663670eb1 100644 --- a/tests/ui/cmp_owned/with_suggestion.rs +++ b/tests/ui/cmp_owned/with_suggestion.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[warn(clippy::cmp_owned)] #[allow(clippy::unnecessary_operation, clippy::no_effect, unused_must_use, clippy::eq_op)] diff --git a/tests/ui/cmp_owned/with_suggestion.stderr b/tests/ui/cmp_owned/with_suggestion.stderr index 2f333e6ea8ec..27f4b913631c 100644 --- a/tests/ui/cmp_owned/with_suggestion.stderr +++ b/tests/ui/cmp_owned/with_suggestion.stderr @@ -1,40 +1,44 @@ -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:7:14 | LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` | - = note: `-D clippy::cmp-owned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/with_suggestion.rs:3:8 + | +LL | #[warn(clippy::cmp_owned)] + | ^^^^^^^^^^^^^^^^^ -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:9:9 | LL | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:16:10 | LL | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:18:10 | LL | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:22:5 | LL | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/with_suggestion.rs:24:30 | LL | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/cmp_owned/without_suggestion.stderr b/tests/ui/cmp_owned/without_suggestion.stderr index d2dd14d8edbb..0d55ffc03527 100644 --- a/tests/ui/cmp_owned/without_suggestion.stderr +++ b/tests/ui/cmp_owned/without_suggestion.stderr @@ -1,22 +1,22 @@ -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/without_suggestion.rs:7:5 | LL | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating | - = note: `-D clippy::cmp-owned` implied by `-D warnings` + = note: `#[warn(clippy::cmp_owned)]` on by default -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/without_suggestion.rs:11:5 | LL | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating -error: this creates an owned instance just for comparison +warning: this creates an owned instance just for comparison --> $DIR/without_suggestion.rs:22:9 | LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/cognitive_complexity.stderr b/tests/ui/cognitive_complexity.stderr index 5824631fa83b..1064c81aa35e 100644 --- a/tests/ui/cognitive_complexity.stderr +++ b/tests/ui/cognitive_complexity.stderr @@ -1,13 +1,17 @@ -error: the function has a cognitive complexity of (28/25) +warning: the function has a cognitive complexity of (28/25) --> $DIR/cognitive_complexity.rs:6:4 | LL | fn main() { | ^^^^ | = help: you could split it up into multiple smaller functions - = note: `-D clippy::cognitive-complexity` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cognitive_complexity.rs:2:9 + | +LL | #![warn(clippy::cognitive_complexity)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the function has a cognitive complexity of (7/1) +warning: the function has a cognitive complexity of (7/1) --> $DIR/cognitive_complexity.rs:91:4 | LL | fn kaboom() { @@ -15,7 +19,7 @@ LL | fn kaboom() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:149:4 | LL | fn baa() { @@ -23,7 +27,7 @@ LL | fn baa() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:150:13 | LL | let x = || match 99 { @@ -31,7 +35,7 @@ LL | let x = || match 99 { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:167:4 | LL | fn bar() { @@ -39,7 +43,7 @@ LL | fn bar() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:186:4 | LL | fn barr() { @@ -47,7 +51,7 @@ LL | fn barr() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (3/1) +warning: the function has a cognitive complexity of (3/1) --> $DIR/cognitive_complexity.rs:196:4 | LL | fn barr2() { @@ -55,7 +59,7 @@ LL | fn barr2() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:212:4 | LL | fn barrr() { @@ -63,7 +67,7 @@ LL | fn barrr() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (3/1) +warning: the function has a cognitive complexity of (3/1) --> $DIR/cognitive_complexity.rs:222:4 | LL | fn barrr2() { @@ -71,7 +75,7 @@ LL | fn barrr2() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:238:4 | LL | fn barrrr() { @@ -79,7 +83,7 @@ LL | fn barrrr() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (3/1) +warning: the function has a cognitive complexity of (3/1) --> $DIR/cognitive_complexity.rs:248:4 | LL | fn barrrr2() { @@ -87,7 +91,7 @@ LL | fn barrrr2() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:264:4 | LL | fn cake() { @@ -95,7 +99,7 @@ LL | fn cake() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (4/1) +warning: the function has a cognitive complexity of (4/1) --> $DIR/cognitive_complexity.rs:274:8 | LL | pub fn read_file(input_path: &str) -> String { @@ -103,7 +107,7 @@ LL | pub fn read_file(input_path: &str) -> String { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:305:4 | LL | fn void(void: Void) { @@ -111,7 +115,7 @@ LL | fn void(void: Void) { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (8/1) +warning: the function has a cognitive complexity of (8/1) --> $DIR/cognitive_complexity.rs:356:4 | LL | fn early_ret() -> i32 { @@ -119,7 +123,7 @@ LL | fn early_ret() -> i32 { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:377:13 | LL | let x = |a: i32, b: i32| -> i32 { @@ -127,7 +131,7 @@ LL | let x = |a: i32, b: i32| -> i32 { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:390:8 | LL | fn moo(&self) { @@ -135,7 +139,7 @@ LL | fn moo(&self) { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:399:14 | LL | async fn a() { @@ -143,7 +147,7 @@ LL | async fn a() { | = help: you could split it up into multiple smaller functions -error: the function has a cognitive complexity of (2/1) +warning: the function has a cognitive complexity of (2/1) --> $DIR/cognitive_complexity.rs:406:22 | LL | pub async fn async_method() { @@ -151,5 +155,5 @@ LL | pub async fn async_method() { | = help: you could split it up into multiple smaller functions -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/cognitive_complexity_attr_used.stderr b/tests/ui/cognitive_complexity_attr_used.stderr index bb48f3297486..70d278a49a6c 100644 --- a/tests/ui/cognitive_complexity_attr_used.stderr +++ b/tests/ui/cognitive_complexity_attr_used.stderr @@ -1,11 +1,15 @@ -error: the function has a cognitive complexity of (3/0) +warning: the function has a cognitive complexity of (3/0) --> $DIR/cognitive_complexity_attr_used.rs:9:4 | LL | fn kaboom() { | ^^^^^^ | = help: you could split it up into multiple smaller functions - = note: `-D clippy::cognitive-complexity` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/cognitive_complexity_attr_used.rs:1:17 + | +LL | #![warn(unused, clippy::cognitive_complexity)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/collapsible_else_if.fixed b/tests/ui/collapsible_else_if.fixed index d6a5a7850679..8302cec45e78 100644 --- a/tests/ui/collapsible_else_if.fixed +++ b/tests/ui/collapsible_else_if.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::assertions_on_constants, clippy::equatable_if_let)] #[rustfmt::skip] diff --git a/tests/ui/collapsible_else_if.rs b/tests/ui/collapsible_else_if.rs index 4399fc8b2bd1..5913dcf41caf 100644 --- a/tests/ui/collapsible_else_if.rs +++ b/tests/ui/collapsible_else_if.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::assertions_on_constants, clippy::equatable_if_let)] #[rustfmt::skip] diff --git a/tests/ui/collapsible_else_if.stderr b/tests/ui/collapsible_else_if.stderr index 45b2094c9948..08361a1f3623 100644 --- a/tests/ui/collapsible_else_if.stderr +++ b/tests/ui/collapsible_else_if.stderr @@ -1,4 +1,4 @@ -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:14:12 | LL | } else { @@ -9,7 +9,11 @@ LL | | } LL | | } | |_____^ | - = note: `-D clippy::collapsible-else-if` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/collapsible_else_if.rs:6:8 + | +LL | #[warn(clippy::collapsible_else_if)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: collapse nested if block | LL ~ } else if y == "world" { @@ -17,7 +21,7 @@ LL + println!("world!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:22:12 | LL | } else { @@ -35,7 +39,7 @@ LL + println!("world!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:30:12 | LL | } else { @@ -58,7 +62,7 @@ LL + println!("!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:41:12 | LL | } else { @@ -81,7 +85,7 @@ LL + println!("!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:52:12 | LL | } else { @@ -104,7 +108,7 @@ LL + println!("!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:63:12 | LL | } else { @@ -127,7 +131,7 @@ LL + println!("!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:74:12 | LL | } else { @@ -150,7 +154,7 @@ LL + println!("!") LL + } | -error: this `else { if .. }` block can be collapsed +warning: this `else { if .. }` block can be collapsed --> $DIR/collapsible_else_if.rs:97:10 | LL | }else{ @@ -158,6 +162,8 @@ LL | }else{ LL | | if false {} LL | | } | |_____^ help: collapse nested if block: `if false {}` + | + = note: `#[warn(clippy::collapsible_else_if)]` on by default -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/collapsible_if.fixed b/tests/ui/collapsible_if.fixed index 6bb7682bae95..d2aba2ac59b8 100644 --- a/tests/ui/collapsible_if.fixed +++ b/tests/ui/collapsible_if.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::assertions_on_constants, clippy::equatable_if_let)] #[rustfmt::skip] diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index e216a9ee54c9..e0bef7f9c970 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::assertions_on_constants, clippy::equatable_if_let)] #[rustfmt::skip] diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 6327444df21d..22548a5f42b2 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,4 +1,4 @@ -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:9:5 | LL | / if x == "hello" { @@ -8,7 +8,11 @@ LL | | } LL | | } | |_____^ | - = note: `-D clippy::collapsible-if` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/collapsible_if.rs:5:8 + | +LL | #[warn(clippy::collapsible_if)] + | ^^^^^^^^^^^^^^^^^^^^^^ help: collapse nested if block | LL ~ if x == "hello" && y == "world" { @@ -16,7 +20,7 @@ LL + println!("Hello world!"); LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:15:5 | LL | / if x == "hello" || x == "world" { @@ -33,7 +37,7 @@ LL + println!("Hello world!"); LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:21:5 | LL | / if x == "hello" && x == "world" { @@ -50,7 +54,7 @@ LL + println!("Hello world!"); LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:27:5 | LL | / if x == "hello" || x == "world" { @@ -67,7 +71,7 @@ LL + println!("Hello world!"); LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:33:5 | LL | / if x == "hello" && x == "world" { @@ -84,7 +88,7 @@ LL + println!("Hello world!"); LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:39:5 | LL | / if 42 == 1337 { @@ -101,7 +105,7 @@ LL + println!("world!") LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:95:5 | LL | / if x == "hello" { @@ -118,7 +122,7 @@ LL + println!("Hello world!"); LL + } | -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:154:5 | LL | / if matches!(true, true) { @@ -126,7 +130,7 @@ LL | | if matches!(true, true) {} LL | | } | |_____^ help: collapse nested if block: `if matches!(true, true) && matches!(true, true) {}` -error: this `if` statement can be collapsed +warning: this `if` statement can be collapsed --> $DIR/collapsible_if.rs:159:5 | LL | / if matches!(true, true) && truth() { @@ -134,5 +138,5 @@ LL | | if matches!(true, true) {} LL | | } | |_____^ help: collapse nested if block: `if matches!(true, true) && truth() && matches!(true, true) {}` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/collapsible_match.stderr b/tests/ui/collapsible_match.stderr index 0294be60b43f..4053a949f046 100644 --- a/tests/ui/collapsible_match.stderr +++ b/tests/ui/collapsible_match.stderr @@ -1,4 +1,4 @@ -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:13:20 | LL | Ok(val) => match val { @@ -15,9 +15,13 @@ LL | Ok(val) => match val { | ^^^ replace this binding LL | Some(n) => foo(n), | ^^^^^^^ with this pattern - = note: `-D clippy::collapsible-match` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/collapsible_match.rs:1:9 + | +LL | #![warn(clippy::collapsible_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:22:20 | LL | Ok(val) => match val { @@ -35,7 +39,7 @@ LL | Ok(val) => match val { LL | Some(n) => foo(n), | ^^^^^^^ with this pattern -error: this `if let` can be collapsed into the outer `if let` +warning: this `if let` can be collapsed into the outer `if let` --> $DIR/collapsible_match.rs:31:9 | LL | / if let Some(n) = val { @@ -51,7 +55,7 @@ LL | if let Ok(val) = res_opt { LL | if let Some(n) = val { | ^^^^^^^ with this pattern -error: this `if let` can be collapsed into the outer `if let` +warning: this `if let` can be collapsed into the outer `if let` --> $DIR/collapsible_match.rs:38:9 | LL | / if let Some(n) = val { @@ -69,7 +73,7 @@ LL | if let Ok(val) = res_opt { LL | if let Some(n) = val { | ^^^^^^^ with this pattern -error: this `match` can be collapsed into the outer `if let` +warning: this `match` can be collapsed into the outer `if let` --> $DIR/collapsible_match.rs:49:9 | LL | / match val { @@ -87,7 +91,7 @@ LL | match val { LL | Some(n) => foo(n), | ^^^^^^^ with this pattern -error: this `if let` can be collapsed into the outer `match` +warning: this `if let` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:58:13 | LL | / if let Some(n) = val { @@ -103,7 +107,7 @@ LL | Ok(val) => { LL | if let Some(n) = val { | ^^^^^^^ with this pattern -error: this `match` can be collapsed into the outer `if let` +warning: this `match` can be collapsed into the outer `if let` --> $DIR/collapsible_match.rs:67:9 | LL | / match val { @@ -121,7 +125,7 @@ LL | match val { LL | Some(n) => foo(n), | ^^^^^^^ with this pattern -error: this `if let` can be collapsed into the outer `match` +warning: this `if let` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:78:13 | LL | / if let Some(n) = val { @@ -139,7 +143,7 @@ LL | Ok(val) => { LL | if let Some(n) = val { | ^^^^^^^ with this pattern -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:89:20 | LL | Ok(val) => match val { @@ -157,7 +161,7 @@ LL | Ok(val) => match val { LL | Some(n) => foo(n), | ^^^^^^^ with this pattern -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match.rs:98:22 | LL | Some(val) => match val { @@ -175,7 +179,7 @@ LL | Some(val) => match val { LL | Some(n) => foo(n), | ^^^^^^^ with this pattern -error: this `if let` can be collapsed into the outer `if let` +warning: this `if let` can be collapsed into the outer `if let` --> $DIR/collapsible_match.rs:263:9 | LL | / if let Some(u) = a { @@ -191,7 +195,7 @@ LL | if let Issue9647::A { a, .. } = x { LL | if let Some(u) = a { | ^^^^^^^ with this pattern, prefixed by a: -error: this `if let` can be collapsed into the outer `if let` +warning: this `if let` can be collapsed into the outer `if let` --> $DIR/collapsible_match.rs:271:9 | LL | / if let Some(u) = a { @@ -207,5 +211,5 @@ LL | if let Issue9647::A { a: Some(a), .. } = x { LL | if let Some(u) = a { | ^^^^^^^ with this pattern -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/collapsible_match2.stderr b/tests/ui/collapsible_match2.stderr index 144dbe40a7ad..b0f6b35f1ca7 100644 --- a/tests/ui/collapsible_match2.stderr +++ b/tests/ui/collapsible_match2.stderr @@ -1,4 +1,4 @@ -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match2.rs:13:34 | LL | Ok(val) if make() => match val { @@ -15,9 +15,13 @@ LL | Ok(val) if make() => match val { | ^^^ replace this binding LL | Some(n) => foo(n), | ^^^^^^^ with this pattern - = note: `-D clippy::collapsible-match` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/collapsible_match2.rs:1:9 + | +LL | #![warn(clippy::collapsible_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match2.rs:20:24 | LL | Ok(val) => match val { @@ -35,7 +39,7 @@ LL | Ok(val) => match val { LL | Some(n) => foo(n), | ^^^^^^^ with this pattern -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match2.rs:34:29 | LL | $pat => match $e { @@ -55,9 +59,9 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ^^^ ^^^^^^^ with this pattern | | | replace this binding - = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match2.rs:51:20 | LL | Some(s) => match *s { @@ -75,7 +79,7 @@ LL | Some(s) => match *s { LL | [n] => foo(n), | ^^^ with this pattern -error: this `match` can be collapsed into the outer `match` +warning: this `match` can be collapsed into the outer `match` --> $DIR/collapsible_match2.rs:60:24 | LL | Some(ref s) => match s { @@ -93,5 +97,5 @@ LL | Some(ref s) => match s { LL | [n] => foo(n), | ^^^ with this pattern -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/collapsible_str_replace.fixed b/tests/ui/collapsible_str_replace.fixed index 9792ae9ed6b8..ba6c1769a9a3 100644 --- a/tests/ui/collapsible_str_replace.fixed +++ b/tests/ui/collapsible_str_replace.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::collapsible_str_replace)] diff --git a/tests/ui/collapsible_str_replace.rs b/tests/ui/collapsible_str_replace.rs index baee185b79ea..f5871be65be1 100644 --- a/tests/ui/collapsible_str_replace.rs +++ b/tests/ui/collapsible_str_replace.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::collapsible_str_replace)] diff --git a/tests/ui/collapsible_str_replace.stderr b/tests/ui/collapsible_str_replace.stderr index 223358cf53f3..704ea7c6b5b2 100644 --- a/tests/ui/collapsible_str_replace.stderr +++ b/tests/ui/collapsible_str_replace.stderr @@ -1,24 +1,28 @@ -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:20:27 | LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` | - = note: `-D clippy::collapsible-str-replace` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/collapsible_str_replace.rs:4:9 + | +LL | #![warn(clippy::collapsible_str_replace)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:22:27 | LL | let _ = "hesuo worpd".replace('s', l).replace('u', l); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], l)` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:24:27 | LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u', 'p'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:27:10 | LL | .replace('s', "l") @@ -28,65 +32,65 @@ LL | | .replace('p', "l") LL | | .replace('d', "l"); | |__________________________^ help: replace with: `replace(['s', 'u', 'p', 'd'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:32:27 | LL | let _ = "hesuo world".replace(s, "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, 'u'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:34:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, 'u', 'p'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:36:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, u, 'p'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:38:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace(p, "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, u, p], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:40:27 | LL | let _ = "hesuo worlp".replace('s', "l").replace('u', "l").replace('p', "d"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:42:45 | LL | let _ = "hesuo worpd".replace('s', "x").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['u', 'p'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:45:47 | LL | let _ = "hesudo worpd".replace("su", "l").replace('d', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['d', 'p'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:47:28 | LL | let _ = "hesudo worpd".replace(d, "l").replace('p', "l").replace("su", "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([d, 'p'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:49:27 | LL | let _ = "hesuo world".replace(get_filter(), "l").replace('s', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([get_filter(), 's'], "l")` -error: used consecutive `str::replace` call +warning: used consecutive `str::replace` call --> $DIR/collapsible_str_replace.rs:86:16 | LL | let _ = "".replace('a', "1.58").replace('b', "1.58"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['a', 'b'], "1.58")` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/comparison_chain.stderr b/tests/ui/comparison_chain.stderr index 2eeb50202cd4..d5c0e4909d3e 100644 --- a/tests/ui/comparison_chain.stderr +++ b/tests/ui/comparison_chain.stderr @@ -1,4 +1,4 @@ -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:14:5 | LL | / if x > y { @@ -9,9 +9,13 @@ LL | | } | |_____^ | = help: consider rewriting the `if` chain to use `cmp` and `match` - = note: `-D clippy::comparison-chain` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/comparison_chain.rs:2:9 + | +LL | #![warn(clippy::comparison_chain)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:27:5 | LL | / if x > y { @@ -25,7 +29,7 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:35:5 | LL | / if x > y { @@ -39,7 +43,7 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:43:5 | LL | / if x > 1 { @@ -53,7 +57,7 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:117:5 | LL | / if x > y { @@ -65,7 +69,7 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:123:5 | LL | / if x > y { @@ -79,7 +83,7 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` -error: `if` chain can be rewritten with `match` +warning: `if` chain can be rewritten with `match` --> $DIR/comparison_chain.rs:131:5 | LL | / if x > y { @@ -93,5 +97,5 @@ LL | | } | = help: consider rewriting the `if` chain to use `cmp` and `match` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/comparison_to_empty.fixed b/tests/ui/comparison_to_empty.fixed index 261024caca76..dd2615ab25cf 100644 --- a/tests/ui/comparison_to_empty.fixed +++ b/tests/ui/comparison_to_empty.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::comparison_to_empty)] diff --git a/tests/ui/comparison_to_empty.rs b/tests/ui/comparison_to_empty.rs index 98ddd9749516..5462784c6ac8 100644 --- a/tests/ui/comparison_to_empty.rs +++ b/tests/ui/comparison_to_empty.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::comparison_to_empty)] diff --git a/tests/ui/comparison_to_empty.stderr b/tests/ui/comparison_to_empty.stderr index f69d6bd5255d..922c921db234 100644 --- a/tests/ui/comparison_to_empty.stderr +++ b/tests/ui/comparison_to_empty.stderr @@ -1,28 +1,32 @@ -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/comparison_to_empty.rs:8:13 | LL | let _ = s == ""; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` | - = note: `-D clippy::comparison-to-empty` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/comparison_to_empty.rs:3:9 + | +LL | #![warn(clippy::comparison_to_empty)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/comparison_to_empty.rs:9:13 | LL | let _ = s != ""; | ^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!s.is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/comparison_to_empty.rs:12:13 | LL | let _ = v == []; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `v.is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/comparison_to_empty.rs:13:13 | LL | let _ = v != []; | ^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!v.is_empty()` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index 6bc6fd6b6fa8..7ed071d546df 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,4 +1,4 @@ -error: you are implementing `Iterator` on a `Copy` type +warning: you are implementing `Iterator` on a `Copy` type --> $DIR/copy_iterator.rs:6:1 | LL | / impl Iterator for Countdown { @@ -11,7 +11,11 @@ LL | | } | |_^ | = note: consider implementing `IntoIterator` instead - = note: `-D clippy::copy-iterator` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/copy_iterator.rs:1:9 + | +LL | #![warn(clippy::copy_iterator)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/auxiliary/proc_macro_crash.rs b/tests/ui/crashes/auxiliary/proc_macro_crash.rs index 5ff2af7cd825..e2e5986ff38a 100644 --- a/tests/ui/crashes/auxiliary/proc_macro_crash.rs +++ b/tests/ui/crashes/auxiliary/proc_macro_crash.rs @@ -1,10 +1,3 @@ -// compile-flags: --emit=link -// no-prefer-dynamic -// ^ compiletest by default builds all aux files as dylibs, but we don't want that for proc-macro -// crates. If we don't set this, compiletest will override the `crate_type` attribute below and -// compile this as dylib. Removing this then causes the test to fail because a `dylib` crate can't -// contain a proc-macro. - #![feature(repr128)] #![allow(incomplete_features)] #![crate_type = "proc-macro"] diff --git a/tests/ui/crashes/ice-2774.stderr b/tests/ui/crashes/ice-2774.stderr index c5ea0b16d1be..fc6e7646962b 100644 --- a/tests/ui/crashes/ice-2774.stderr +++ b/tests/ui/crashes/ice-2774.stderr @@ -1,15 +1,15 @@ -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/ice-2774.rs:15:1 | LL | pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::needless-lifetimes` implied by `-D warnings` + = note: `#[warn(clippy::needless_lifetimes)]` on by default help: elide the lifetimes | LL - pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { LL + pub fn add_barfoos_to_foos(bars: &HashSet<&Bar>) { | -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-360.stderr b/tests/ui/crashes/ice-360.stderr index a2e2ab8fd192..1c0b0ad16df2 100644 --- a/tests/ui/crashes/ice-360.stderr +++ b/tests/ui/crashes/ice-360.stderr @@ -1,4 +1,4 @@ -error: this loop could be written as a `while let` loop +warning: this loop could be written as a `while let` loop --> $DIR/ice-360.rs:5:5 | LL | / loop { @@ -10,16 +10,16 @@ LL | | loop {} LL | | } | |_____^ help: try: `while let Some(ele) = iter.next() { .. }` | - = note: `-D clippy::while-let-loop` implied by `-D warnings` + = note: `#[warn(clippy::while_let_loop)]` on by default -error: empty `loop {}` wastes CPU cycles +warning: empty `loop {}` wastes CPU cycles --> $DIR/ice-360.rs:10:9 | LL | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body - = note: `-D clippy::empty-loop` implied by `-D warnings` + = note: `#[warn(clippy::empty_loop)]` on by default -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/crashes/ice-3717.rs b/tests/ui/crashes/ice-3717.rs index f50714643fd2..88c91451ea45 100644 --- a/tests/ui/crashes/ice-3717.rs +++ b/tests/ui/crashes/ice-3717.rs @@ -5,6 +5,7 @@ use std::collections::HashSet; fn main() {} pub fn ice_3717(_: &HashSet) { + //~^ ERROR: should be generalized let _ = [0u8; 0]; let _: HashSet = HashSet::new(); } diff --git a/tests/ui/crashes/ice-3741.rs b/tests/ui/crashes/ice-3741.rs index 1253ddcfaeb3..268c5ba0ad0f 100644 --- a/tests/ui/crashes/ice-3741.rs +++ b/tests/ui/crashes/ice-3741.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_crash.rs +//@aux-build:proc_macro_crash.rs:proc-macro #![warn(clippy::suspicious_else_formatting)] diff --git a/tests/ui/crashes/ice-3891.rs b/tests/ui/crashes/ice-3891.rs index 05c5134c8457..1471fa5cc55b 100644 --- a/tests/ui/crashes/ice-3891.rs +++ b/tests/ui/crashes/ice-3891.rs @@ -1,3 +1,3 @@ fn main() { - 1x; + 1x; //~ ERROR: invalid suffix } diff --git a/tests/ui/crashes/ice-3969.stderr b/tests/ui/crashes/ice-3969.stderr index 79018080886c..56c4a461a04d 100644 --- a/tests/ui/crashes/ice-3969.stderr +++ b/tests/ui/crashes/ice-3969.stderr @@ -1,34 +1,34 @@ -error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters +warning: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/ice-3969.rs:20:10 | LL | str: Sized; | ^^^^^ | - = note: `-D trivial-bounds` implied by `-D warnings` + = note: `#[warn(trivial_bounds)]` on by default -error: trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters +warning: trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/ice-3969.rs:24:30 | LL | for<'a> Dst: Sized, | ^^^^^ -error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters +warning: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/ice-3969.rs:31:10 | LL | str: Sized, | ^^^^^ -error: trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters +warning: trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters --> $DIR/ice-3969.rs:38:13 | LL | String: ::std::ops::Neg, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters +warning: trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters --> $DIR/ice-3969.rs:45:10 | LL | i32: Iterator, | ^^^^^^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/crashes/ice-4968.rs b/tests/ui/crashes/ice-4968.rs index e0510d942c20..ac724ac93e3f 100644 --- a/tests/ui/crashes/ice-4968.rs +++ b/tests/ui/crashes/ice-4968.rs @@ -1,4 +1,4 @@ -// check-pass +//@check-pass // Test for https://github.com/rust-lang/rust-clippy/issues/4968 diff --git a/tests/ui/crashes/ice-5497.rs b/tests/ui/crashes/ice-5497.rs index 0769bce5fc80..f77f691c1927 100644 --- a/tests/ui/crashes/ice-5497.rs +++ b/tests/ui/crashes/ice-5497.rs @@ -7,5 +7,5 @@ pub trait Foo { impl Foo for Vec { const OOB: i32 = [1][1] + T::OOB; - //~^ ERROR operation will panic + //~^ ERROR: operation will panic } diff --git a/tests/ui/crashes/ice-5835.stderr b/tests/ui/crashes/ice-5835.stderr index c972bcb60a0c..09376c84b02c 100644 --- a/tests/ui/crashes/ice-5835.stderr +++ b/tests/ui/crashes/ice-5835.stderr @@ -1,10 +1,10 @@ -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/ice-5835.rs:3:10 | LL | /// 位 | ^^^^ help: consider using four spaces per tab | - = note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings` + = note: `#[warn(clippy::tabs_in_doc_comments)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-5872.stderr b/tests/ui/crashes/ice-5872.stderr index a60ca345cf78..24bc06049073 100644 --- a/tests/ui/crashes/ice-5872.stderr +++ b/tests/ui/crashes/ice-5872.stderr @@ -1,10 +1,14 @@ -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/ice-5872.rs:4:39 | LL | let _ = vec![1, 2, 3].into_iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` | - = note: `-D clippy::needless-collect` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ice-5872.rs:1:9 + | +LL | #![warn(clippy::needless_collect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-6250.rs b/tests/ui/crashes/ice-6250.rs index c33580ff6ab6..ebcf35190dd5 100644 --- a/tests/ui/crashes/ice-6250.rs +++ b/tests/ui/crashes/ice-6250.rs @@ -10,7 +10,11 @@ pub fn list_data(cache: &Cache, key: usize) { if /* let */ Some(reference) = cache.data.get(key) { + //~^ ERROR: mismatched types + //~| ERROR: mismatched types unimplemented!() } } } + +fn main() {} diff --git a/tests/ui/crashes/ice-6250.stderr b/tests/ui/crashes/ice-6250.stderr index 4506d1550bd4..b72037b7d4a6 100644 --- a/tests/ui/crashes/ice-6250.stderr +++ b/tests/ui/crashes/ice-6250.stderr @@ -1,9 +1,3 @@ -error[E0601]: `main` function not found in crate `ice_6250` - --> $DIR/ice-6250.rs:16:2 - | -LL | } - | ^ consider adding a `main` function to `$DIR/ice-6250.rs` - error[E0308]: mismatched types --> $DIR/ice-6250.rs:12:14 | @@ -29,7 +23,6 @@ help: consider adding `let` LL | let Some(reference) = cache.data.get(key) { | +++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0308, E0601. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/crashes/ice-6251.rs b/tests/ui/crashes/ice-6251.rs index 6aa779aaeb3b..dad645d7187f 100644 --- a/tests/ui/crashes/ice-6251.rs +++ b/tests/ui/crashes/ice-6251.rs @@ -2,5 +2,10 @@ // assertion failed: `(left == right) ; different DefIds fn bug() -> impl Iterator { + //~^ ERROR: cannot be known at compilation time + //~| ERROR: cannot be known at compilation time + //~| ERROR: mismatched types std::iter::empty() } + +fn main() {} diff --git a/tests/ui/crashes/ice-6251.stderr b/tests/ui/crashes/ice-6251.stderr index 8da2965c6351..68a5766c90c0 100644 --- a/tests/ui/crashes/ice-6251.stderr +++ b/tests/ui/crashes/ice-6251.stderr @@ -1,9 +1,3 @@ -error[E0601]: `main` function not found in crate `ice_6251` - --> $DIR/ice-6251.rs:6:2 - | -LL | } - | ^ consider adding a `main` function to `$DIR/ice-6251.rs` - error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/ice-6251.rs:4:45 | @@ -35,7 +29,7 @@ LL | fn bug() -> impl Iterator { = note: expected type `usize` found closure `[closure@$DIR/ice-6251.rs:4:44: 4:53]` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0277, E0308, E0601. +Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/crashes/ice-6252.rs b/tests/ui/crashes/ice-6252.rs index 0ccf0aae9d74..f22e4951b948 100644 --- a/tests/ui/crashes/ice-6252.rs +++ b/tests/ui/crashes/ice-6252.rs @@ -5,9 +5,11 @@ trait TypeVal { } struct Five; struct Multiply { - _n: PhantomData, + _n: PhantomData, //~ ERROR: cannot find type } impl TypeVal for Multiply where N: TypeVal {} +//~^ ERROR: cannot find type +//~| ERROR: not all trait items implemented fn main() { [1; >::VAL]; diff --git a/tests/ui/crashes/ice-6254.stderr b/tests/ui/crashes/ice-6254.stderr index 22d82a30c6aa..eb01b1215cc5 100644 --- a/tests/ui/crashes/ice-6254.stderr +++ b/tests/ui/crashes/ice-6254.stderr @@ -1,4 +1,4 @@ -error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` +warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/ice-6254.rs:13:9 | LL | FOO_REF_REF => {}, @@ -6,7 +6,7 @@ LL | FOO_REF_REF => {}, | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 - = note: `-D indirect-structural-match` implied by `-D warnings` + = note: `#[warn(indirect_structural_match)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-6255.rs b/tests/ui/crashes/ice-6255.rs index ccde6aa2b0f7..b6555ac5c407 100644 --- a/tests/ui/crashes/ice-6255.rs +++ b/tests/ui/crashes/ice-6255.rs @@ -4,7 +4,6 @@ macro_rules! define_other_core { ( ) => { extern crate std as core; - //~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern` }; } @@ -13,3 +12,4 @@ fn main() { } define_other_core!(); +//~^ ERROR: macro-expanded `extern crate` items cannot shadow names passed with `--extern` diff --git a/tests/ui/crashes/ice-6256.rs b/tests/ui/crashes/ice-6256.rs index f9ee3e058c11..1d336b3cdc0c 100644 --- a/tests/ui/crashes/ice-6256.rs +++ b/tests/ui/crashes/ice-6256.rs @@ -10,6 +10,6 @@ impl dyn TT { #[rustfmt::skip] fn main() { - let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types - //[nll]~^ ERROR: borrowed data escapes outside of closure + let f = |x: &dyn TT| x.func(); + //~^ ERROR: borrowed data escapes outside of closure } diff --git a/tests/ui/crashes/ice-6256.stderr b/tests/ui/crashes/ice-6256.stderr index 9cfcccf1e3cd..671933157c80 100644 --- a/tests/ui/crashes/ice-6256.stderr +++ b/tests/ui/crashes/ice-6256.stderr @@ -1,7 +1,7 @@ error[E0521]: borrowed data escapes outside of closure --> $DIR/ice-6256.rs:13:26 | -LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types +LL | let f = |x: &dyn TT| x.func(); | - - ^^^^^^^^ | | | | | | | `x` escapes the closure body here diff --git a/tests/ui/crashes/ice-7169.stderr b/tests/ui/crashes/ice-7169.stderr index 5a9cd32380a1..0b0ef8d7d270 100644 --- a/tests/ui/crashes/ice-7169.stderr +++ b/tests/ui/crashes/ice-7169.stderr @@ -1,10 +1,10 @@ -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/ice-7169.rs:8:12 | LL | if let Ok(_) = Ok::<_, ()>(A::::default()) {} | -------^^^^^-------------------------------------- help: try this: `if Ok::<_, ()>(A::::default()).is_ok()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = note: `#[warn(clippy::redundant_pattern_matching)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-7272.rs b/tests/ui/crashes/ice-7272.rs index 57ab6ca14f86..e949038c8d0b 100644 --- a/tests/ui/crashes/ice-7272.rs +++ b/tests/ui/crashes/ice-7272.rs @@ -1,4 +1,4 @@ -// aux-build:ice-7272-aux.rs +//@aux-build:ice-7272-aux.rs #![allow(clippy::no_effect)] diff --git a/tests/ui/crashes/ice-7410.rs b/tests/ui/crashes/ice-7410.rs index 85fa42103219..9e364edd8f02 100644 --- a/tests/ui/crashes/ice-7410.rs +++ b/tests/ui/crashes/ice-7410.rs @@ -1,6 +1,6 @@ -// compile-flags: -Clink-arg=-nostartfiles -// ignore-macos -// ignore-windows +//@compile-flags: -Clink-arg=-nostartfiles +//@ignore-target-apple +//@ignore-target-windows #![feature(lang_items, start, libc)] #![no_std] diff --git a/tests/ui/crashes/ice-7868.stderr b/tests/ui/crashes/ice-7868.stderr index 1d8314e889fa..0caa3530d31c 100644 --- a/tests/ui/crashes/ice-7868.stderr +++ b/tests/ui/crashes/ice-7868.stderr @@ -1,11 +1,15 @@ -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/auxiliary/ice-7868-aux.rs:2:5 | LL | unsafe { 0 }; | ^^^^^^^^^^^^ | = help: consider adding a safety comment on the preceding line - = note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ice-7868.rs:1:9 + | +LL | #![warn(clippy::undocumented_unsafe_blocks)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-7869.stderr b/tests/ui/crashes/ice-7869.stderr index 35d1e8fd2957..492518b4f45a 100644 --- a/tests/ui/crashes/ice-7869.stderr +++ b/tests/ui/crashes/ice-7869.stderr @@ -1,4 +1,4 @@ -error: all variants have the same prefix: `Työ` +warning: all variants have the same prefix: `Työ` --> $DIR/ice-7869.rs:1:1 | LL | / enum Tila { @@ -9,7 +9,7 @@ LL | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports - = note: `-D clippy::enum-variant-names` implied by `-D warnings` + = note: `#[warn(clippy::enum_variant_names)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-8250.stderr b/tests/ui/crashes/ice-8250.stderr index 8ed8f3b3a064..e8ed373a0399 100644 --- a/tests/ui/crashes/ice-8250.stderr +++ b/tests/ui/crashes/ice-8250.stderr @@ -1,10 +1,10 @@ -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/ice-8250.rs:2:13 | LL | let _ = s[1..].splitn(2, '.').next()?; | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s[1..].split('.')` | - = note: `-D clippy::needless-splitn` implied by `-D warnings` + = note: `#[warn(clippy::needless_splitn)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-8681.rs b/tests/ui/crashes/ice-8681.rs index ee14f011f631..607b9caa3249 100644 --- a/tests/ui/crashes/ice-8681.rs +++ b/tests/ui/crashes/ice-8681.rs @@ -1,4 +1,4 @@ -// aux-build: ice-8681-aux.rs +//@aux-build: ice-8681-aux.rs #![warn(clippy::undocumented_unsafe_blocks)] diff --git a/tests/ui/crashes/ice-8821.stderr b/tests/ui/crashes/ice-8821.stderr index 486096e0a06d..ccf2e31adc4a 100644 --- a/tests/ui/crashes/ice-8821.stderr +++ b/tests/ui/crashes/ice-8821.stderr @@ -1,10 +1,14 @@ -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/ice-8821.rs:7:5 | LL | let _: () = FN(); | ^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `FN();` | - = note: `-D clippy::let-unit-value` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ice-8821.rs:1:9 + | +LL | #![warn(clippy::let_unit_value)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-8850.stderr b/tests/ui/crashes/ice-8850.stderr index 620fd1edaf79..0e86a7bb6c8c 100644 --- a/tests/ui/crashes/ice-8850.stderr +++ b/tests/ui/crashes/ice-8850.stderr @@ -1,4 +1,4 @@ -error: returning the result of a `let` binding from a block +warning: returning the result of a `let` binding from a block --> $DIR/ice-8850.rs:4:5 | LL | let res = FN() + 1; @@ -6,14 +6,14 @@ LL | let res = FN() + 1; LL | res | ^^^ | - = note: `-D clippy::let-and-return` implied by `-D warnings` + = note: `#[warn(clippy::let_and_return)]` on by default help: return the expression directly | LL ~ LL ~ FN() + 1 | -error: returning the result of a `let` binding from a block +warning: returning the result of a `let` binding from a block --> $DIR/ice-8850.rs:10:5 | LL | let res = FN() + 1; @@ -27,7 +27,7 @@ LL ~ LL ~ FN() + 1 | -error: returning the result of a `let` binding from a block +warning: returning the result of a `let` binding from a block --> $DIR/ice-8850.rs:24:5 | LL | let res = FN() + 1; @@ -41,5 +41,5 @@ LL ~ LL ~ FN() + 1 | -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/crashes/ice-9041.stderr b/tests/ui/crashes/ice-9041.stderr index f5038f0a8484..2c76c1300274 100644 --- a/tests/ui/crashes/ice-9041.stderr +++ b/tests/ui/crashes/ice-9041.stderr @@ -1,10 +1,10 @@ -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/ice-9041.rs:5:19 | LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|p| is_thing_ready(&p))` | - = note: `-D clippy::search-is-some` implied by `-D warnings` + = note: `#[warn(clippy::search_is_some)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crashes/ice-9405.stderr b/tests/ui/crashes/ice-9405.stderr index 9a6e410f21ea..56649a2bdfcb 100644 --- a/tests/ui/crashes/ice-9405.stderr +++ b/tests/ui/crashes/ice-9405.stderr @@ -1,7 +1,7 @@ warning: multiple lines skipped by escaped newline --> $DIR/ice-9405.rs:6:10 | -LL | "/ +LL | "\ | __________^ LL | | LL | | {}", diff --git a/tests/ui/crashes/ice-9463.rs b/tests/ui/crashes/ice-9463.rs index 9564e77c24b1..e6f0e4ec0d4c 100644 --- a/tests/ui/crashes/ice-9463.rs +++ b/tests/ui/crashes/ice-9463.rs @@ -1,5 +1,7 @@ #![deny(arithmetic_overflow)] fn main() { - let _x = -1_i32 >> -1; + let _x = -1_i32 >> -1; //~ ERROR: overflow let _y = 1u32 >> 10000000000000u32; + //~^ ERROR: overflow + //~| ERROR: literal out of range } diff --git a/tests/ui/crashes/ice-96721.rs b/tests/ui/crashes/ice-96721.rs index 4b3fb7640108..ca68ba3d03a5 100644 --- a/tests/ui/crashes/ice-96721.rs +++ b/tests/ui/crashes/ice-96721.rs @@ -4,7 +4,7 @@ macro_rules! foo { }; } -#[path = foo!()] //~ ERROR malformed `path` attribute +#[path = foo!()] //~ ERROR: malformed `path` attribute mod abc {} fn main() {} diff --git a/tests/ui/crashes/ice-96721.stderr b/tests/ui/crashes/ice-96721.stderr index 78c567b8e772..712bd14c685f 100644 --- a/tests/ui/crashes/ice-96721.stderr +++ b/tests/ui/crashes/ice-96721.stderr @@ -1,7 +1,7 @@ error: malformed `path` attribute input --> $DIR/ice-96721.rs:7:1 | -LL | #[path = foo!()] //~ ERROR malformed `path` attribute +LL | #[path = foo!()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` error: aborting due to previous error diff --git a/tests/ui/crashes/needless_lifetimes_impl_trait.rs b/tests/ui/crashes/needless_lifetimes_impl_trait.rs index 376ff97ba603..06e84c66a93f 100644 --- a/tests/ui/crashes/needless_lifetimes_impl_trait.rs +++ b/tests/ui/crashes/needless_lifetimes_impl_trait.rs @@ -13,6 +13,7 @@ impl<'a> Foo for Baz<'a> {} impl Bar { fn baz<'a>(&'a self) -> impl Foo + 'a { + //~^ ERROR: could be elided: 'a Baz { bar: self } } } diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr index 7a0a648974fc..f8f66bcd9ca9 100644 --- a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr +++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr @@ -1,4 +1,4 @@ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value-w-late-bound.rs:7:12 | LL | fn test(x: Foo<'_>) {} @@ -9,7 +9,11 @@ help: consider marking this type as `Copy` | LL | struct Foo<'a>(&'a [(); 100]); | ^^^^^^^^^^^^^^ - = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_pass_by_value-w-late-bound.rs:3:9 + | +LL | #![warn(clippy::needless_pass_by_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crate_in_macro_def.fixed b/tests/ui/crate_in_macro_def.fixed index 9fc594be311e..12a7b9470b31 100644 --- a/tests/ui/crate_in_macro_def.fixed +++ b/tests/ui/crate_in_macro_def.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::crate_in_macro_def)] mod hygienic { diff --git a/tests/ui/crate_in_macro_def.rs b/tests/ui/crate_in_macro_def.rs index ac456108e4ab..a1a9eabf639b 100644 --- a/tests/ui/crate_in_macro_def.rs +++ b/tests/ui/crate_in_macro_def.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::crate_in_macro_def)] mod hygienic { diff --git a/tests/ui/crate_in_macro_def.stderr b/tests/ui/crate_in_macro_def.stderr index 9ac5937dcc06..b326c32c1299 100644 --- a/tests/ui/crate_in_macro_def.stderr +++ b/tests/ui/crate_in_macro_def.stderr @@ -1,10 +1,14 @@ -error: `crate` references the macro call's crate +warning: `crate` references the macro call's crate --> $DIR/crate_in_macro_def.rs:19:28 | LL | println!("{}", crate::unhygienic::MESSAGE); | ^^^^^ help: to reference the macro definition's crate, use: `$crate` | - = note: `-D clippy::crate-in-macro-def` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/crate_in_macro_def.rs:2:9 + | +LL | #![warn(clippy::crate_in_macro_def)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crate_level_checks/entrypoint_recursion.rs b/tests/ui/crate_level_checks/entrypoint_recursion.rs index 1b3bcece6f1e..aa76688d8010 100644 --- a/tests/ui/crate_level_checks/entrypoint_recursion.rs +++ b/tests/ui/crate_level_checks/entrypoint_recursion.rs @@ -1,4 +1,4 @@ -// ignore-macos +//@ignore-target-apple #![feature(rustc_attrs)] diff --git a/tests/ui/crate_level_checks/entrypoint_recursion.stderr b/tests/ui/crate_level_checks/entrypoint_recursion.stderr index 3d79a115cb30..510e52ae25b5 100644 --- a/tests/ui/crate_level_checks/entrypoint_recursion.stderr +++ b/tests/ui/crate_level_checks/entrypoint_recursion.stderr @@ -1,11 +1,15 @@ -error: recursing into entrypoint `a` +warning: recursing into entrypoint `a` --> $DIR/entrypoint_recursion.rs:10:5 | LL | a(); | ^ | = help: consider using another function for this recursion - = note: `-D clippy::main-recursion` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/entrypoint_recursion.rs:5:8 + | +LL | #[warn(clippy::main_recursion)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crate_level_checks/no_std_main_recursion.rs b/tests/ui/crate_level_checks/no_std_main_recursion.rs index e1c9fe30a9df..32eba9695920 100644 --- a/tests/ui/crate_level_checks/no_std_main_recursion.rs +++ b/tests/ui/crate_level_checks/no_std_main_recursion.rs @@ -1,5 +1,5 @@ -// compile-flags: -Clink-arg=-nostartfiles -// ignore-macos +//@compile-flags: -Clink-arg=-nostartfiles +//@ignore-target-apple #![feature(lang_items, start, libc)] #![no_std] diff --git a/tests/ui/crate_level_checks/no_std_swap.stderr b/tests/ui/crate_level_checks/no_std_swap.stderr index 7d8ea3f76b0f..2ba3ab59df34 100644 --- a/tests/ui/crate_level_checks/no_std_swap.stderr +++ b/tests/ui/crate_level_checks/no_std_swap.stderr @@ -1,4 +1,4 @@ -error: this looks like you are trying to swap `a` and `b` +warning: this looks like you are trying to swap `a` and `b` --> $DIR/no_std_swap.rs:12:5 | LL | / a = b; @@ -6,7 +6,12 @@ LL | | b = a; | |_________^ help: try: `core::mem::swap(&mut a, &mut b)` | = note: or maybe you should use `core::mem::replace`? - = note: `-D clippy::almost-swapped` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/no_std_swap.rs:7:8 + | +LL | #[warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::almost_swapped)]` implied by `#[warn(clippy::all)]` -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/crate_level_checks/std_main_recursion.stderr b/tests/ui/crate_level_checks/std_main_recursion.stderr index 82c68bd1cfef..0b599a36cb23 100644 --- a/tests/ui/crate_level_checks/std_main_recursion.stderr +++ b/tests/ui/crate_level_checks/std_main_recursion.stderr @@ -1,11 +1,15 @@ -error: recursing into entrypoint `main` +warning: recursing into entrypoint `main` --> $DIR/std_main_recursion.rs:5:5 | LL | main(); | ^^^^ | = help: consider using another function for this recursion - = note: `-D clippy::main-recursion` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/std_main_recursion.rs:1:8 + | +LL | #[warn(clippy::main_recursion)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/create_dir.fixed b/tests/ui/create_dir.fixed index 8ed53a56ac04..d375bfb4a688 100644 --- a/tests/ui/create_dir.fixed +++ b/tests/ui/create_dir.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_must_use)] #![warn(clippy::create_dir)] @@ -8,8 +8,8 @@ fn create_dir() {} fn main() { // Should be warned - create_dir_all("foo"); - create_dir_all("bar").unwrap(); + std::fs::create_dir("foo"); + std::fs::create_dir("bar").unwrap(); // Shouldn't be warned create_dir(); diff --git a/tests/ui/create_dir.rs b/tests/ui/create_dir.rs index 19c8fc24ba23..d375bfb4a688 100644 --- a/tests/ui/create_dir.rs +++ b/tests/ui/create_dir.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_must_use)] #![warn(clippy::create_dir)] diff --git a/tests/ui/create_dir.stderr b/tests/ui/create_dir.stderr index 67298fc47095..1dd48825e562 100644 --- a/tests/ui/create_dir.stderr +++ b/tests/ui/create_dir.stderr @@ -1,16 +1,20 @@ -error: calling `std::fs::create_dir` where there may be a better way +warning: calling `std::fs::create_dir` where there may be a better way --> $DIR/create_dir.rs:11:5 | LL | std::fs::create_dir("foo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("foo")` | - = note: `-D clippy::create-dir` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/create_dir.rs:3:9 + | +LL | #![warn(clippy::create_dir)] + | ^^^^^^^^^^^^^^^^^^ -error: calling `std::fs::create_dir` where there may be a better way +warning: calling `std::fs::create_dir` where there may be a better way --> $DIR/create_dir.rs:12:5 | LL | std::fs::create_dir("bar").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("bar")` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/dbg_macro.rs b/tests/ui/dbg_macro.rs index 25294e8c766f..8701e3cd29f4 100644 --- a/tests/ui/dbg_macro.rs +++ b/tests/ui/dbg_macro.rs @@ -1,4 +1,4 @@ -// compile-flags: --test +//@compile-flags: --test #![warn(clippy::dbg_macro)] fn foo(n: u32) -> u32 { diff --git a/tests/ui/dbg_macro.stderr b/tests/ui/dbg_macro.stderr index ddb5f1342e99..45980447faa9 100644 --- a/tests/ui/dbg_macro.stderr +++ b/tests/ui/dbg_macro.stderr @@ -1,16 +1,20 @@ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:5:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::dbg-macro` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/dbg_macro.rs:2:9 + | +LL | #![warn(clippy::dbg_macro)] + | ^^^^^^^^^^^^^^^^^ help: remove the invocation before committing it to a version control system | LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:9:8 | LL | if dbg!(n <= 1) { @@ -21,7 +25,7 @@ help: remove the invocation before committing it to a version control system LL | if n <= 1 { | ~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:10:9 | LL | dbg!(1) @@ -32,7 +36,7 @@ help: remove the invocation before committing it to a version control system LL | 1 | -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:12:9 | LL | dbg!(n * factorial(n - 1)) @@ -43,7 +47,7 @@ help: remove the invocation before committing it to a version control system LL | n * factorial(n - 1) | -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:17:5 | LL | dbg!(42); @@ -54,7 +58,7 @@ help: remove the invocation before committing it to a version control system LL | 42; | ~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:18:5 | LL | dbg!(dbg!(dbg!(42))); @@ -65,7 +69,7 @@ help: remove the invocation before committing it to a version control system LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:19:14 | LL | foo(3) + dbg!(factorial(4)); @@ -76,7 +80,7 @@ help: remove the invocation before committing it to a version control system LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:20:5 | LL | dbg!(1, 2, dbg!(3, 4)); @@ -87,7 +91,7 @@ help: remove the invocation before committing it to a version control system LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:21:5 | LL | dbg!(1, 2, 3, 4, 5); @@ -98,7 +102,7 @@ help: remove the invocation before committing it to a version control system LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:41:9 | LL | dbg!(2); @@ -109,7 +113,7 @@ help: remove the invocation before committing it to a version control system LL | 2; | ~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:47:5 | LL | dbg!(1); @@ -120,7 +124,7 @@ help: remove the invocation before committing it to a version control system LL | 1; | ~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:52:5 | LL | dbg!(1); @@ -131,7 +135,7 @@ help: remove the invocation before committing it to a version control system LL | 1; | ~ -error: the `dbg!` macro is intended as a debugging tool +warning: the `dbg!` macro is intended as a debugging tool --> $DIR/dbg_macro.rs:58:9 | LL | dbg!(1); @@ -142,5 +146,5 @@ help: remove the invocation before committing it to a version control system LL | 1; | ~ -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/debug_assert_with_mut_call.stderr b/tests/ui/debug_assert_with_mut_call.stderr index a2ca71b57a6f..303aa6ed7152 100644 --- a/tests/ui/debug_assert_with_mut_call.stderr +++ b/tests/ui/debug_assert_with_mut_call.stderr @@ -1,172 +1,176 @@ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:42:19 | LL | debug_assert!(bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::debug-assert-with-mut-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/debug_assert_with_mut_call.rs:3:9 + | +LL | #![warn(clippy::debug_assert_with_mut_call)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:43:20 | LL | debug_assert!(!bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:45:25 | LL | debug_assert_eq!(0, u32_mut(&mut 3)); | ^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:46:22 | LL | debug_assert_eq!(u32_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:48:25 | LL | debug_assert_ne!(1, u32_mut(&mut 3)); | ^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:49:22 | LL | debug_assert_ne!(u32_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:64:19 | LL | debug_assert!(S.bool_self_mut()); | ^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:65:20 | LL | debug_assert!(!S.bool_self_mut()); | ^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:66:19 | LL | debug_assert!(S.bool_self_ref_arg_mut(&mut 3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:67:19 | LL | debug_assert!(S.bool_self_mut_arg_ref(&3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:68:19 | LL | debug_assert!(S.bool_self_mut_arg_mut(&mut 3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:70:22 | LL | debug_assert_eq!(S.u32_self_mut(), 0); | ^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:71:22 | LL | debug_assert_eq!(S.u32_self_mut_arg_ref(&3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:72:22 | LL | debug_assert_eq!(S.u32_self_ref_arg_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:73:22 | LL | debug_assert_eq!(S.u32_self_mut_arg_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:75:22 | LL | debug_assert_ne!(S.u32_self_mut(), 1); | ^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:76:22 | LL | debug_assert_ne!(S.u32_self_mut_arg_ref(&3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:77:22 | LL | debug_assert_ne!(S.u32_self_ref_arg_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:78:22 | LL | debug_assert_ne!(S.u32_self_mut_arg_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:86:22 | LL | debug_assert_eq!(v.pop(), Some(1)); | ^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_ne!` +warning: do not call a function with mutable arguments inside of `debug_assert_ne!` --> $DIR/debug_assert_with_mut_call.rs:87:31 | LL | debug_assert_ne!(Some(3), v.pop()); | ^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:90:19 | LL | debug_assert!(bool_mut(a)); | ^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:93:31 | LL | debug_assert!(!(bool_ref(&u32_mut(&mut 3)))); | ^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert_eq!` +warning: do not call a function with mutable arguments inside of `debug_assert_eq!` --> $DIR/debug_assert_with_mut_call.rs:96:22 | LL | debug_assert_eq!(v.pop().unwrap(), 3); | ^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:100:19 | LL | debug_assert!(bool_mut(&mut 3), "w/o format"); | ^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:102:19 | LL | debug_assert!(bool_mut(&mut 3), "{} format", "w/"); | ^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:107:9 | LL | bool_mut(&mut x); | ^^^^^^^^^^^^^^^^ -error: do not call a function with mutable arguments inside of `debug_assert!` +warning: do not call a function with mutable arguments inside of `debug_assert!` --> $DIR/debug_assert_with_mut_call.rs:114:9 | LL | bool_mut(&mut x); | ^^^^^^^^^^^^^^^^ -error: aborting due to 28 previous errors +warning: 28 warnings emitted diff --git a/tests/ui/decimal_literal_representation.fixed b/tests/ui/decimal_literal_representation.fixed index de391465125c..a6eb8c214578 100644 --- a/tests/ui/decimal_literal_representation.fixed +++ b/tests/ui/decimal_literal_representation.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[warn(clippy::decimal_literal_representation)] #[allow(unused_variables)] diff --git a/tests/ui/decimal_literal_representation.rs b/tests/ui/decimal_literal_representation.rs index 55d07698e7e5..7c666d6d7a69 100644 --- a/tests/ui/decimal_literal_representation.rs +++ b/tests/ui/decimal_literal_representation.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[warn(clippy::decimal_literal_representation)] #[allow(unused_variables)] diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index 8d50c8f83db4..a371bb7adf0f 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,46 +1,50 @@ -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:18:9 | LL | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | - = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/decimal_literal_representation.rs:3:8 + | +LL | #[warn(clippy::decimal_literal_representation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:19:9 | LL | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:20:9 | LL | 2_131_750_927, // 0x7F0F_F00F | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:21:9 | LL | 2_147_483_647, // 0x7FFF_FFFF | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:23:9 | LL | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:24:9 | LL | 32_773usize, // 0x8005_usize | ^^^^^^^^^^^ help: consider: `0x8005_usize` -error: integer literal has a better hexadecimal representation +warning: integer literal has a better hexadecimal representation --> $DIR/decimal_literal_representation.rs:25:9 | LL | 2_131_750_927isize, // 0x7F0F_F00F_isize | ^^^^^^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F_isize` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/declare_interior_mutable_const/enums.rs b/tests/ui/declare_interior_mutable_const/enums.rs index f44518694b89..34f2e02267ae 100644 --- a/tests/ui/declare_interior_mutable_const/enums.rs +++ b/tests/ui/declare_interior_mutable_const/enums.rs @@ -1,4 +1,4 @@ -#![warn(clippy::declare_interior_mutable_const)] +#![deny(clippy::declare_interior_mutable_const)] use std::cell::Cell; use std::sync::atomic::AtomicUsize; @@ -9,7 +9,7 @@ enum OptionalCell { } // a constant with enums should be linted only when the used variant is unfrozen (#3962). -const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); //~ ERROR interior mutable +const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); //~ ERROR: interior mutable const FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen; const fn unfrozen_variant() -> OptionalCell { @@ -20,7 +20,7 @@ const fn frozen_variant() -> OptionalCell { OptionalCell::Frozen } -const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); //~ ERROR interior mutable +const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); //~ ERROR: interior mutable const FROZEN_VARIANT_FROM_FN: OptionalCell = frozen_variant(); enum NestedInnermost { @@ -43,10 +43,11 @@ struct NestedOutermost { // a constant with enums should be linted according to its value, no matter how structs involve. const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { + //~^ ERROR: interior mutable outer: NestedOuter::NestedInner(NestedInner { inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)), }), -}; //~ ERROR interior mutable +}; const NESTED_FROZEN_VARIANT: NestedOutermost = NestedOutermost { outer: NestedOuter::NestedInner(NestedInner { inner: NestedInnermost::Frozen, @@ -56,11 +57,11 @@ const NESTED_FROZEN_VARIANT: NestedOutermost = NestedOutermost { trait AssocConsts { // When there's no default value, lint it only according to its type. // Further details are on the corresponding code (`NonCopyConst::check_trait_item`). - const TO_BE_UNFROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable - const TO_BE_FROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable + const TO_BE_UNFROZEN_VARIANT: OptionalCell; //~ ERROR: interior mutable + const TO_BE_FROZEN_VARIANT: OptionalCell; //~ ERROR: interior mutable // Lint default values accordingly. - const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); //~ ERROR interior mutable + const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); //~ ERROR: interior mutable const DEFAULTED_ON_FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen; } @@ -86,7 +87,7 @@ trait AssocTypes { impl AssocTypes for u64 { type ToBeUnfrozen = AtomicUsize; - const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR interior mutable + const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR: interior mutable const TO_BE_FROZEN_VARIANT: Option = None; } @@ -98,25 +99,25 @@ enum BothOfCellAndGeneric { } impl BothOfCellAndGeneric { - const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable + const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR: interior mutable // This is a false positive. The argument about this is on `is_value_unfrozen_raw` - const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable + const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR: interior mutable const FROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Frozen(5); // This is what is likely to be a false negative when one tries to fix // the `GENERIC_VARIANT` false positive. - const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); //~ ERROR interior mutable + const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); //~ ERROR: interior mutable } // associated types here is basically the same as the one above. trait BothOfCellAndGenericWithAssocType { type AssocType; - const UNFROZEN_VARIANT: BothOfCellAndGeneric = - BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable - const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable + const UNFROZEN_VARIANT: BothOfCellAndGeneric = //~ ERROR: interior mutable + BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); + const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR: interior mutable const FROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Frozen(5); } diff --git a/tests/ui/declare_interior_mutable_const/enums.stderr b/tests/ui/declare_interior_mutable_const/enums.stderr index 84198d546157..67efa09f43d4 100644 --- a/tests/ui/declare_interior_mutable_const/enums.stderr +++ b/tests/ui/declare_interior_mutable_const/enums.stderr @@ -1,17 +1,21 @@ error: a `const` item should never be interior mutable --> $DIR/enums.rs:12:1 | -LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); //~ ERROR interior mutable +LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | make this a static item (maybe with lazy_static) | - = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/enums.rs:1:9 + | +LL | #![deny(clippy::declare_interior_mutable_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/enums.rs:23:1 | -LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); //~ ERROR interior mutable +LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | make this a static item (maybe with lazy_static) @@ -24,65 +28,66 @@ LL | const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { | | | _make this a static item (maybe with lazy_static) | | +LL | | LL | | outer: NestedOuter::NestedInner(NestedInner { LL | | inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)), LL | | }), -LL | | }; //~ ERROR interior mutable +LL | | }; | |__^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:59:5 + --> $DIR/enums.rs:60:5 | -LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable +LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:60:5 + --> $DIR/enums.rs:61:5 | -LL | const TO_BE_FROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable +LL | const TO_BE_FROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:63:5 + --> $DIR/enums.rs:64:5 | -LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); //~ ERROR interior mutable +LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:89:5 + --> $DIR/enums.rs:90:5 | -LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR interior mutable +LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:101:5 + --> $DIR/enums.rs:102:5 | -LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mut... +LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:104:5 + --> $DIR/enums.rs:105:5 | -LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable +LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:110:5 + --> $DIR/enums.rs:111:5 | -LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); //~ ERROR interior mutable +LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:117:5 + --> $DIR/enums.rs:118:5 | LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric = -LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable +LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | |____________________________________________________________________^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:119:5 + --> $DIR/enums.rs:120:5 | -LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mu... +LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/declare_interior_mutable_const/others.rs b/tests/ui/declare_interior_mutable_const/others.rs index 896596b56792..6c9fc3f0377f 100644 --- a/tests/ui/declare_interior_mutable_const/others.rs +++ b/tests/ui/declare_interior_mutable_const/others.rs @@ -1,4 +1,4 @@ -#![warn(clippy::declare_interior_mutable_const)] +#![deny(clippy::declare_interior_mutable_const)] use std::borrow::Cow; use std::cell::Cell; @@ -6,17 +6,17 @@ use std::fmt::Display; use std::sync::atomic::AtomicUsize; use std::sync::Once; -const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable -const CELL: Cell = Cell::new(6); //~ ERROR interior mutable +const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR: interior mutable +const CELL: Cell = Cell::new(6); //~ ERROR: interior mutable const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); -//~^ ERROR interior mutable +//~^ ERROR: interior mutable macro_rules! declare_const { ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; } -declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable +declare_const!(_ONCE: Once = Once::new()); //~ ERROR: interior mutable // const ATOMIC_REF: &AtomicUsize = &AtomicUsize::new(7); // This will simply trigger E0492. @@ -40,7 +40,7 @@ mod issue_8493 { macro_rules! issue_8493 { () => { - const _BAZ: Cell = Cell::new(0); //~ ERROR interior mutable + const _BAZ: Cell = Cell::new(0); static _FOOBAR: () = { thread_local! { static _VAR: Cell = const { Cell::new(0) }; @@ -49,7 +49,7 @@ mod issue_8493 { }; } - issue_8493!(); + issue_8493!(); //~ ERROR: interior mutable } fn main() {} diff --git a/tests/ui/declare_interior_mutable_const/others.stderr b/tests/ui/declare_interior_mutable_const/others.stderr index 1fd6d7322a76..2ae3d376ae52 100644 --- a/tests/ui/declare_interior_mutable_const/others.stderr +++ b/tests/ui/declare_interior_mutable_const/others.stderr @@ -1,17 +1,21 @@ error: a `const` item should never be interior mutable --> $DIR/others.rs:9:1 | -LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable +LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | make this a static item (maybe with lazy_static) | - = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/others.rs:1:9 + | +LL | #![deny(clippy::declare_interior_mutable_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/others.rs:10:1 | -LL | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable +LL | const CELL: Cell = Cell::new(6); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | make this a static item (maybe with lazy_static) @@ -30,7 +34,7 @@ error: a `const` item should never be interior mutable LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ ... -LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable +LL | declare_const!(_ONCE: Once = Once::new()); | ----------------------------------------- in this macro invocation | = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -38,7 +42,7 @@ LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable error: a `const` item should never be interior mutable --> $DIR/others.rs:43:13 | -LL | const _BAZ: Cell = Cell::new(0); //~ ERROR interior mutable +LL | const _BAZ: Cell = Cell::new(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | issue_8493!(); diff --git a/tests/ui/declare_interior_mutable_const/traits.rs b/tests/ui/declare_interior_mutable_const/traits.rs index 256a336db821..8e053b1315d7 100644 --- a/tests/ui/declare_interior_mutable_const/traits.rs +++ b/tests/ui/declare_interior_mutable_const/traits.rs @@ -1,4 +1,4 @@ -#![warn(clippy::declare_interior_mutable_const)] +#![deny(clippy::declare_interior_mutable_const)] use std::borrow::Cow; use std::cell::Cell; @@ -12,10 +12,10 @@ macro_rules! declare_const { // a constant whose type is a concrete type should be linted at the definition site. trait ConcreteTypes { - const ATOMIC: AtomicUsize; //~ ERROR interior mutable + const ATOMIC: AtomicUsize; //~ ERROR: interior mutable const INTEGER: u64; const STRING: String; - declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR interior mutable + declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR: interior mutable } impl ConcreteTypes for u64 { @@ -40,7 +40,7 @@ trait GenericTypes { impl GenericTypes for u64 { const TO_REMAIN_GENERIC: T = T::DEFAULT; - const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); //~ ERROR interior mutable + const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); //~ ERROR: interior mutable } // a helper type used below @@ -65,8 +65,8 @@ impl AssocTypes for Vec { type ToBeGenericParam = T; const TO_BE_FROZEN: Self::ToBeFrozen = 12; - const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); //~ ERROR interior mutable - const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); //~ ERROR interior mutable + const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); //~ ERROR: interior mutable + const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); //~ ERROR: interior mutable const WRAPPED_TO_BE_GENERIC_PARAM: Wrapper = Wrapper(T::DEFAULT); } @@ -85,7 +85,7 @@ where T: AssocTypesHelper, { const NOT_BOUNDED: T::NotToBeBounded; - const BOUNDED: T::ToBeBounded; //~ ERROR interior mutable + const BOUNDED: T::ToBeBounded; //~ ERROR: interior mutable } impl AssocTypesFromGenericParam for u64 @@ -113,8 +113,8 @@ impl SelfType for u64 { impl SelfType for AtomicUsize { // this (interior mutable `Self` const) exists in `parking_lot`. // `const_trait_impl` will replace it in the future, hopefully. - const SELF: Self = AtomicUsize::new(17); //~ ERROR interior mutable - const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); //~ ERROR interior mutable + const SELF: Self = AtomicUsize::new(17); //~ ERROR: interior mutable + const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); //~ ERROR: interior mutable } // Even though a constant contains a generic type, if it also have an interior mutable type, @@ -122,7 +122,7 @@ impl SelfType for AtomicUsize { trait BothOfCellAndGeneric { // this is a false negative in the current implementation. const DIRECT: Cell; - const INDIRECT: Cell<*const T>; //~ ERROR interior mutable + const INDIRECT: Cell<*const T>; //~ ERROR: interior mutable } impl BothOfCellAndGeneric for u64 { @@ -138,13 +138,13 @@ impl Local where T: ConstDefault + AssocTypesHelper, { - const ATOMIC: AtomicUsize = AtomicUsize::new(18); //~ ERROR interior mutable + const ATOMIC: AtomicUsize = AtomicUsize::new(18); //~ ERROR: interior mutable const COW: Cow<'static, str> = Cow::Borrowed("tuvwxy"); const GENERIC_TYPE: T = T::DEFAULT; const ASSOC_TYPE: T::NotToBeBounded = T::NOT_TO_BE_BOUNDED; - const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); //~ ERROR interior mutable + const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); //~ ERROR: interior mutable } fn main() {} diff --git a/tests/ui/declare_interior_mutable_const/traits.stderr b/tests/ui/declare_interior_mutable_const/traits.stderr index 7debe059ff4e..76bdddbdee77 100644 --- a/tests/ui/declare_interior_mutable_const/traits.stderr +++ b/tests/ui/declare_interior_mutable_const/traits.stderr @@ -1,10 +1,14 @@ error: a `const` item should never be interior mutable --> $DIR/traits.rs:15:5 | -LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable +LL | const ATOMIC: AtomicUsize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/traits.rs:1:9 + | +LL | #![deny(clippy::declare_interior_mutable_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:9:9 @@ -12,7 +16,7 @@ error: a `const` item should never be interior mutable LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ ... -LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR interior mutable +LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); | ---------------------------------------------------------- in this macro invocation | = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -20,55 +24,55 @@ LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR i error: a `const` item should never be interior mutable --> $DIR/traits.rs:43:5 | -LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); //~ ERROR interior mutable +LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:68:5 | -LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); //~ ERROR interior mutable +LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:69:5 | -LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); //~ ERROR interior mutable +LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:88:5 | -LL | const BOUNDED: T::ToBeBounded; //~ ERROR interior mutable +LL | const BOUNDED: T::ToBeBounded; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:116:5 | -LL | const SELF: Self = AtomicUsize::new(17); //~ ERROR interior mutable +LL | const SELF: Self = AtomicUsize::new(17); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:117:5 | -LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); //~ ERROR interior mutable +LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:125:5 | -LL | const INDIRECT: Cell<*const T>; //~ ERROR interior mutable +LL | const INDIRECT: Cell<*const T>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:141:5 | -LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); //~ ERROR interior mutable +LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable --> $DIR/traits.rs:147:5 | -LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); //~ ERROR interior mutable +LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/tests/ui/def_id_nocore.rs b/tests/ui/def_id_nocore.rs index 1af77d1a25b2..da0816830b85 100644 --- a/tests/ui/def_id_nocore.rs +++ b/tests/ui/def_id_nocore.rs @@ -1,4 +1,4 @@ -// ignore-macos +//@ignore-target-apple #![feature(no_core, lang_items, start)] #![no_core] diff --git a/tests/ui/def_id_nocore.stderr b/tests/ui/def_id_nocore.stderr index f8fc17e872bd..270a3d515f12 100644 --- a/tests/ui/def_id_nocore.stderr +++ b/tests/ui/def_id_nocore.stderr @@ -1,11 +1,11 @@ -error: methods called `as_*` usually take `self` by reference or `self` by mutable reference +warning: methods called `as_*` usually take `self` by reference or `self` by mutable reference --> $DIR/def_id_nocore.rs:27:19 | LL | pub fn as_ref(self) -> &'static str { | ^^^^ | = help: consider choosing a less ambiguous name - = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = note: `#[warn(clippy::wrong_self_convention)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/default_instead_of_iter_empty.fixed b/tests/ui/default_instead_of_iter_empty.fixed index f1abfdcd6ce6..f44d34576f68 100644 --- a/tests/ui/default_instead_of_iter_empty.fixed +++ b/tests/ui/default_instead_of_iter_empty.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::default_instead_of_iter_empty)] #![allow(dead_code)] use std::collections::HashMap; diff --git a/tests/ui/default_instead_of_iter_empty.rs b/tests/ui/default_instead_of_iter_empty.rs index 2630519c46da..1c649df253cc 100644 --- a/tests/ui/default_instead_of_iter_empty.rs +++ b/tests/ui/default_instead_of_iter_empty.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::default_instead_of_iter_empty)] #![allow(dead_code)] use std::collections::HashMap; diff --git a/tests/ui/default_instead_of_iter_empty.stderr b/tests/ui/default_instead_of_iter_empty.stderr index 460fc84def8a..0dae290427df 100644 --- a/tests/ui/default_instead_of_iter_empty.stderr +++ b/tests/ui/default_instead_of_iter_empty.stderr @@ -1,22 +1,26 @@ -error: `std::iter::empty()` is the more idiomatic way +warning: `std::iter::empty()` is the more idiomatic way --> $DIR/default_instead_of_iter_empty.rs:13:13 | LL | let _ = std::iter::Empty::::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::()` | - = note: `-D clippy::default-instead-of-iter-empty` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/default_instead_of_iter_empty.rs:2:9 + | +LL | #![warn(clippy::default_instead_of_iter_empty)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `std::iter::empty()` is the more idiomatic way +warning: `std::iter::empty()` is the more idiomatic way --> $DIR/default_instead_of_iter_empty.rs:14:13 | LL | let _ = std::iter::Empty::>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::>()` -error: `std::iter::empty()` is the more idiomatic way +warning: `std::iter::empty()` is the more idiomatic way --> $DIR/default_instead_of_iter_empty.rs:15:41 | LL | let _foo: std::iter::Empty = std::iter::Empty::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/default_numeric_fallback_f64.fixed b/tests/ui/default_numeric_fallback_f64.fixed index a370ccc76962..cec7efd7a3b7 100644 --- a/tests/ui/default_numeric_fallback_f64.fixed +++ b/tests/ui/default_numeric_fallback_f64.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::default_numeric_fallback)] #![allow( @@ -18,11 +18,11 @@ extern crate macro_rules; mod basic_expr { fn test() { // Should lint unsuffixed literals typed `f64`. - let x = 0.12_f64; - let x = [1.0_f64, 2.0_f64, 3.0_f64]; - let x = if true { (1.0_f64, 2.0_f64) } else { (3.0_f64, 4.0_f64) }; - let x = match 1.0_f64 { - _ => 1.0_f64, + let x = 0.12; + let x = [1., 2., 3.]; + let x = if true { (1., 2.) } else { (3., 4.) }; + let x = match 1. { + _ => 1., }; // Should NOT lint suffixed literals. @@ -41,7 +41,7 @@ mod nested_local { fn test() { let x: _ = { // Should lint this because this literal is not bound to any types. - let y = 1.0_f64; + let y = 1.; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 1. @@ -49,13 +49,13 @@ mod nested_local { let x: _ = if true { // Should lint this because this literal is not bound to any types. - let y = 1.0_f64; + let y = 1.; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 1. } else { // Should lint this because this literal is not bound to any types. - let y = 1.0_f64; + let y = 1.; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 2. @@ -63,7 +63,7 @@ mod nested_local { const X: f32 = { // Should lint this because this literal is not bound to any types. - let y = 1.0_f64; + let y = 1.; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 1. @@ -75,17 +75,17 @@ mod function_def { fn ret_f64() -> f64 { // Even though the output type is specified, // this unsuffixed literal is linted to reduce heuristics and keep codebase simple. - 1.0_f64 + 1. } fn test() { // Should lint this because return type is inferred to `f64` and NOT bound to a concrete // type. - let f = || -> _ { 1.0_f64 }; + let f = || -> _ { 1. }; // Even though the output type is specified, // this unsuffixed literal is linted to reduce heuristics and keep codebase simple. - let f = || -> f64 { 1.0_f64 }; + let f = || -> f64 { 1. }; } } @@ -99,10 +99,10 @@ mod function_calls { concrete_arg(1.); // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type. - generic_arg(1.0_f64); + generic_arg(1.); // Should lint this because the argument type is inferred to `f64` and NOT bound to a concrete type. - let x: _ = generic_arg(1.0_f64); + let x: _ = generic_arg(1.); } } @@ -120,10 +120,10 @@ mod struct_ctor { ConcreteStruct { x: 1. }; // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type. - GenericStruct { x: 1.0_f64 }; + GenericStruct { x: 1. }; // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type. - let _ = GenericStruct { x: 1.0_f64 }; + let _ = GenericStruct { x: 1. }; } } @@ -141,7 +141,7 @@ mod enum_ctor { ConcreteEnum::X(1.); // Should lint this because the field type is inferred to `f64` and NOT bound to a concrete type. - GenericEnum::X(1.0_f64); + GenericEnum::X(1.); } } @@ -161,14 +161,14 @@ mod method_calls { s.concrete_arg(1.); // Should lint this because the argument type is bound to a concrete type. - s.generic_arg(1.0_f64); + s.generic_arg(1.); } } mod in_macro { macro_rules! internal_macro { () => { - let x = 22.0_f64; + let x = 22.; }; } diff --git a/tests/ui/default_numeric_fallback_f64.rs b/tests/ui/default_numeric_fallback_f64.rs index 2476fe95141d..cec7efd7a3b7 100644 --- a/tests/ui/default_numeric_fallback_f64.rs +++ b/tests/ui/default_numeric_fallback_f64.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::default_numeric_fallback)] #![allow( diff --git a/tests/ui/default_numeric_fallback_f64.stderr b/tests/ui/default_numeric_fallback_f64.stderr index 5df2f642388d..a0bd124318c3 100644 --- a/tests/ui/default_numeric_fallback_f64.stderr +++ b/tests/ui/default_numeric_fallback_f64.stderr @@ -1,144 +1,148 @@ -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:21:17 | LL | let x = 0.12; | ^^^^ help: consider adding suffix: `0.12_f64` | - = note: `-D clippy::default-numeric-fallback` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/default_numeric_fallback_f64.rs:4:9 + | +LL | #![warn(clippy::default_numeric_fallback)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:22:18 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:22:22 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `2.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:22:26 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `3.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:23:28 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:23:32 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `2.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:23:46 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `3.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:23:50 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `4.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:24:23 | LL | let x = match 1. { | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:25:18 | LL | _ => 1., | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:44:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:52:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:58:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:66:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:78:9 | LL | 1. | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:84:27 | LL | let f = || -> _ { 1. }; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:88:29 | LL | let f = || -> f64 { 1. }; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:102:21 | LL | generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:105:32 | LL | let x: _ = generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:123:28 | LL | GenericStruct { x: 1. }; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:126:36 | LL | let _ = GenericStruct { x: 1. }; | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:144:24 | LL | GenericEnum::X(1.); | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:164:23 | LL | s.generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_f64.rs:171:21 | LL | let x = 22.; @@ -147,7 +151,7 @@ LL | let x = 22.; LL | internal_macro!(); | ----------------- in this macro invocation | - = note: this error originates in the macro `internal_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `internal_macro` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 24 previous errors +warning: 24 warnings emitted diff --git a/tests/ui/default_numeric_fallback_i32.fixed b/tests/ui/default_numeric_fallback_i32.fixed index 3f4994f0453b..5f060ca54687 100644 --- a/tests/ui/default_numeric_fallback_i32.fixed +++ b/tests/ui/default_numeric_fallback_i32.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![feature(lint_reasons)] #![warn(clippy::default_numeric_fallback)] @@ -18,12 +18,12 @@ extern crate macro_rules; mod basic_expr { fn test() { // Should lint unsuffixed literals typed `i32`. - let x = 22_i32; - let x = [1_i32, 2_i32, 3_i32]; - let x = if true { (1_i32, 2_i32) } else { (3_i32, 4_i32) }; - let x = match 1_i32 { - 1_i32 => 1_i32, - _ => 2_i32, + let x = 22; + let x = [1, 2, 3]; + let x = if true { (1, 2) } else { (3, 4) }; + let x = match 1 { + 1 => 1, + _ => 2, }; // Should NOT lint suffixed literals. @@ -42,7 +42,7 @@ mod nested_local { fn test() { let x: _ = { // Should lint this because this literal is not bound to any types. - let y = 1_i32; + let y = 1; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 1 @@ -50,13 +50,13 @@ mod nested_local { let x: _ = if true { // Should lint this because this literal is not bound to any types. - let y = 1_i32; + let y = 1; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 1 } else { // Should lint this because this literal is not bound to any types. - let y = 1_i32; + let y = 1; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 2 @@ -64,7 +64,7 @@ mod nested_local { const CONST_X: i32 = { // Should lint this because this literal is not bound to any types. - let y = 1_i32; + let y = 1; // Should NOT lint this because this literal is bound to `_` of outer `Local`. 1 @@ -76,17 +76,17 @@ mod function_def { fn ret_i32() -> i32 { // Even though the output type is specified, // this unsuffixed literal is linted to reduce heuristics and keep codebase simple. - 1_i32 + 1 } fn test() { // Should lint this because return type is inferred to `i32` and NOT bound to a concrete // type. - let f = || -> _ { 1_i32 }; + let f = || -> _ { 1 }; // Even though the output type is specified, // this unsuffixed literal is linted to reduce heuristics and keep codebase simple. - let f = || -> i32 { 1_i32 }; + let f = || -> i32 { 1 }; } } @@ -100,10 +100,10 @@ mod function_calls { concrete_arg(1); // Should lint this because the argument type is inferred to `i32` and NOT bound to a concrete type. - generic_arg(1_i32); + generic_arg(1); // Should lint this because the argument type is inferred to `i32` and NOT bound to a concrete type. - let x: _ = generic_arg(1_i32); + let x: _ = generic_arg(1); } } @@ -121,10 +121,10 @@ mod struct_ctor { ConcreteStruct { x: 1 }; // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type. - GenericStruct { x: 1_i32 }; + GenericStruct { x: 1 }; // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type. - let _ = GenericStruct { x: 1_i32 }; + let _ = GenericStruct { x: 1 }; } } @@ -142,7 +142,7 @@ mod enum_ctor { ConcreteEnum::X(1); // Should lint this because the field type is inferred to `i32` and NOT bound to a concrete type. - GenericEnum::X(1_i32); + GenericEnum::X(1); } } @@ -162,14 +162,14 @@ mod method_calls { s.concrete_arg(1); // Should lint this because the argument type is bound to a concrete type. - s.generic_arg(1_i32); + s.generic_arg(1); } } mod in_macro { macro_rules! internal_macro { () => { - let x = 22_i32; + let x = 22; }; } diff --git a/tests/ui/default_numeric_fallback_i32.rs b/tests/ui/default_numeric_fallback_i32.rs index 2df0e09787f9..5f060ca54687 100644 --- a/tests/ui/default_numeric_fallback_i32.rs +++ b/tests/ui/default_numeric_fallback_i32.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![feature(lint_reasons)] #![warn(clippy::default_numeric_fallback)] diff --git a/tests/ui/default_numeric_fallback_i32.stderr b/tests/ui/default_numeric_fallback_i32.stderr index 6f219c3fc2b0..0755e2c1d44f 100644 --- a/tests/ui/default_numeric_fallback_i32.stderr +++ b/tests/ui/default_numeric_fallback_i32.stderr @@ -1,156 +1,160 @@ -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:21:17 | LL | let x = 22; | ^^ help: consider adding suffix: `22_i32` | - = note: `-D clippy::default-numeric-fallback` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/default_numeric_fallback_i32.rs:5:9 + | +LL | #![warn(clippy::default_numeric_fallback)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:22:18 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:22:21 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `2_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:22:24 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `3_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:23:28 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:23:31 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `2_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:23:44 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `3_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:23:47 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `4_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:24:23 | LL | let x = match 1 { | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:25:13 | LL | 1 => 1, | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:25:18 | LL | 1 => 1, | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:26:18 | LL | _ => 2, | ^ help: consider adding suffix: `2_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:45:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:53:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:59:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:67:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:79:9 | LL | 1 | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:85:27 | LL | let f = || -> _ { 1 }; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:89:29 | LL | let f = || -> i32 { 1 }; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:103:21 | LL | generic_arg(1); | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:106:32 | LL | let x: _ = generic_arg(1); | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:124:28 | LL | GenericStruct { x: 1 }; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:127:36 | LL | let _ = GenericStruct { x: 1 }; | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:145:24 | LL | GenericEnum::X(1); | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:165:23 | LL | s.generic_arg(1); | ^ help: consider adding suffix: `1_i32` -error: default numeric fallback might occur +warning: default numeric fallback might occur --> $DIR/default_numeric_fallback_i32.rs:172:21 | LL | let x = 22; @@ -159,7 +163,7 @@ LL | let x = 22; LL | internal_macro!(); | ----------------- in this macro invocation | - = note: this error originates in the macro `internal_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `internal_macro` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 26 previous errors +warning: 26 warnings emitted diff --git a/tests/ui/default_trait_access.fixed b/tests/ui/default_trait_access.fixed index 5640599d48ae..2a048284b123 100644 --- a/tests/ui/default_trait_access.fixed +++ b/tests/ui/default_trait_access.fixed @@ -1,6 +1,6 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs -#![deny(clippy::default_trait_access)] +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro +#![warn(clippy::default_trait_access)] #![allow(dead_code, unused_imports)] #![allow(clippy::uninlined_format_args)] @@ -12,17 +12,17 @@ use std::default::Default as D2; use std::string; fn main() { - let s1: String = String::default(); + let s1: String = Default::default(); let s2 = String::default(); - let s3: String = String::default(); + let s3: String = D2::default(); - let s4: String = String::default(); + let s4: String = std::default::Default::default(); let s5 = string::String::default(); - let s6: String = String::default(); + let s6: String = default::Default::default(); let s7 = std::string::String::default(); @@ -32,19 +32,19 @@ fn main() { let s10 = DerivedDefault::default(); - let s11: GenericDerivedDefault = GenericDerivedDefault::default(); + let s11: GenericDerivedDefault = Default::default(); let s12 = GenericDerivedDefault::::default(); let s13 = TupleDerivedDefault::default(); - let s14: TupleDerivedDefault = TupleDerivedDefault::default(); + let s14: TupleDerivedDefault = Default::default(); - let s15: ArrayDerivedDefault = ArrayDerivedDefault::default(); + let s15: ArrayDerivedDefault = Default::default(); let s16 = ArrayDerivedDefault::default(); - let s17: TupleStructDerivedDefault = TupleStructDerivedDefault::default(); + let s17: TupleStructDerivedDefault = Default::default(); let s18 = TupleStructDerivedDefault::default(); diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index 11d4bc5c5f02..2a048284b123 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -1,6 +1,6 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs -#![deny(clippy::default_trait_access)] +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro +#![warn(clippy::default_trait_access)] #![allow(dead_code, unused_imports)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index e4f73c08d190..f7eb594f6ac2 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,4 +1,4 @@ -error: calling `String::default()` is more clear than this expression +warning: calling `String::default()` is more clear than this expression --> $DIR/default_trait_access.rs:15:22 | LL | let s1: String = Default::default(); @@ -7,50 +7,50 @@ LL | let s1: String = Default::default(); note: the lint level is defined here --> $DIR/default_trait_access.rs:3:9 | -LL | #![deny(clippy::default_trait_access)] +LL | #![warn(clippy::default_trait_access)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `String::default()` is more clear than this expression +warning: calling `String::default()` is more clear than this expression --> $DIR/default_trait_access.rs:19:22 | LL | let s3: String = D2::default(); | ^^^^^^^^^^^^^ help: try: `String::default()` -error: calling `String::default()` is more clear than this expression +warning: calling `String::default()` is more clear than this expression --> $DIR/default_trait_access.rs:21:22 | LL | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()` -error: calling `String::default()` is more clear than this expression +warning: calling `String::default()` is more clear than this expression --> $DIR/default_trait_access.rs:25:22 | LL | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()` -error: calling `GenericDerivedDefault::default()` is more clear than this expression +warning: calling `GenericDerivedDefault::default()` is more clear than this expression --> $DIR/default_trait_access.rs:35:46 | LL | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` -error: calling `TupleDerivedDefault::default()` is more clear than this expression +warning: calling `TupleDerivedDefault::default()` is more clear than this expression --> $DIR/default_trait_access.rs:41:36 | LL | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` -error: calling `ArrayDerivedDefault::default()` is more clear than this expression +warning: calling `ArrayDerivedDefault::default()` is more clear than this expression --> $DIR/default_trait_access.rs:43:36 | LL | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` -error: calling `TupleStructDerivedDefault::default()` is more clear than this expression +warning: calling `TupleStructDerivedDefault::default()` is more clear than this expression --> $DIR/default_trait_access.rs:47:42 | LL | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/default_union_representation.stderr b/tests/ui/default_union_representation.stderr index 8b7ed94cbc61..ee16032349e8 100644 --- a/tests/ui/default_union_representation.stderr +++ b/tests/ui/default_union_representation.stderr @@ -1,4 +1,4 @@ -error: this union has the default representation +warning: this union has the default representation --> $DIR/default_union_representation.rs:4:1 | LL | / union NoAttribute { @@ -8,9 +8,13 @@ LL | | } | |_^ | = help: consider annotating `NoAttribute` with `#[repr(C)]` to explicitly specify memory layout - = note: `-D clippy::default-union-representation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/default_union_representation.rs:2:9 + | +LL | #![warn(clippy::default_union_representation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this union has the default representation +warning: this union has the default representation --> $DIR/default_union_representation.rs:16:1 | LL | / union ReprPacked { @@ -21,7 +25,7 @@ LL | | } | = help: consider annotating `ReprPacked` with `#[repr(C)]` to explicitly specify memory layout -error: this union has the default representation +warning: this union has the default representation --> $DIR/default_union_representation.rs:34:1 | LL | / union ReprAlign { @@ -32,7 +36,7 @@ LL | | } | = help: consider annotating `ReprAlign` with `#[repr(C)]` to explicitly specify memory layout -error: this union has the default representation +warning: this union has the default representation --> $DIR/default_union_representation.rs:54:1 | LL | / union ZSTAndTwoFields { @@ -44,5 +48,5 @@ LL | | } | = help: consider annotating `ZSTAndTwoFields` with `#[repr(C)]` to explicitly specify memory layout -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index 0e142ac8f20e..1eee655b291b 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -1,100 +1,100 @@ -error: lint `clippy::should_assert_eq` has been removed: `assert!()` will be more flexible with RFC 2011 +warning: lint `clippy::should_assert_eq` has been removed: `assert!()` will be more flexible with RFC 2011 --> $DIR/deprecated.rs:5:9 | LL | #![warn(clippy::should_assert_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D renamed-and-removed-lints` implied by `-D warnings` + = note: `#[warn(renamed_and_removed_lints)]` on by default -error: lint `clippy::extend_from_slice` has been removed: `.extend_from_slice(_)` is a faster way to extend a Vec by a slice +warning: lint `clippy::extend_from_slice` has been removed: `.extend_from_slice(_)` is a faster way to extend a Vec by a slice --> $DIR/deprecated.rs:6:9 | LL | #![warn(clippy::extend_from_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::range_step_by_zero` has been removed: `iterator.step_by(0)` panics nowadays +warning: lint `clippy::range_step_by_zero` has been removed: `iterator.step_by(0)` panics nowadays --> $DIR/deprecated.rs:7:9 | LL | #![warn(clippy::range_step_by_zero)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 +warning: lint `clippy::unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 --> $DIR/deprecated.rs:8:9 | LL | #![warn(clippy::unstable_as_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 +warning: lint `clippy::unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 --> $DIR/deprecated.rs:9:9 | LL | #![warn(clippy::unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr +warning: lint `clippy::misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr --> $DIR/deprecated.rs:10:9 | LL | #![warn(clippy::misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::assign_ops` has been removed: using compound assignment operators (e.g., `+=`) is harmless +warning: lint `clippy::assign_ops` has been removed: using compound assignment operators (e.g., `+=`) is harmless --> $DIR/deprecated.rs:11:9 | LL | #![warn(clippy::assign_ops)] | ^^^^^^^^^^^^^^^^^^ -error: lint `clippy::if_let_redundant_pattern_matching` has been removed: this lint has been changed to redundant_pattern_matching +warning: lint `clippy::if_let_redundant_pattern_matching` has been removed: this lint has been changed to redundant_pattern_matching --> $DIR/deprecated.rs:12:9 | LL | #![warn(clippy::if_let_redundant_pattern_matching)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::unsafe_vector_initialization` has been removed: the replacement suggested by this lint had substantially different behavior +warning: lint `clippy::unsafe_vector_initialization` has been removed: the replacement suggested by this lint had substantially different behavior --> $DIR/deprecated.rs:13:9 | LL | #![warn(clippy::unsafe_vector_initialization)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::unused_collect` has been removed: `collect` has been marked as #[must_use] in rustc and that covers all cases of this lint +warning: lint `clippy::unused_collect` has been removed: `collect` has been marked as #[must_use] in rustc and that covers all cases of this lint --> $DIR/deprecated.rs:14:9 | LL | #![warn(clippy::unused_collect)] | ^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::replace_consts` has been removed: associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants +warning: lint `clippy::replace_consts` has been removed: associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants --> $DIR/deprecated.rs:15:9 | LL | #![warn(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::regex_macro` has been removed: the regex! macro has been removed from the regex crate in 2018 +warning: lint `clippy::regex_macro` has been removed: the regex! macro has been removed from the regex crate in 2018 --> $DIR/deprecated.rs:16:9 | LL | #![warn(clippy::regex_macro)] | ^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint +warning: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint --> $DIR/deprecated.rs:17:9 | LL | #![warn(clippy::find_map)] | ^^^^^^^^^^^^^^^^ -error: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint +warning: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint --> $DIR/deprecated.rs:18:9 | LL | #![warn(clippy::filter_map)] | ^^^^^^^^^^^^^^^^^^ -error: lint `clippy::pub_enum_variant_names` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items +warning: lint `clippy::pub_enum_variant_names` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items --> $DIR/deprecated.rs:19:9 | LL | #![warn(clippy::pub_enum_variant_names)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items +warning: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items --> $DIR/deprecated.rs:20:9 | LL | #![warn(clippy::wrong_pub_self_convention)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/deprecated_old.stderr b/tests/ui/deprecated_old.stderr index 8043ab0058a5..fc4c1604c68b 100644 --- a/tests/ui/deprecated_old.stderr +++ b/tests/ui/deprecated_old.stderr @@ -1,22 +1,22 @@ -error: lint `unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 +warning: lint `unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 --> $DIR/deprecated_old.rs:1:8 | LL | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ | - = note: `-D renamed-and-removed-lints` implied by `-D warnings` + = note: `#[warn(renamed_and_removed_lints)]` on by default -error: lint `unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 +warning: lint `unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 --> $DIR/deprecated_old.rs:2:8 | LL | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ -error: lint `misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr +warning: lint `misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr --> $DIR/deprecated_old.rs:3:8 | LL | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/deref_addrof.fixed b/tests/ui/deref_addrof.fixed index 2f489deb1ee1..196fe302822d 100644 --- a/tests/ui/deref_addrof.fixed +++ b/tests/ui/deref_addrof.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::return_self_not_must_use)] #![warn(clippy::deref_addrof)] @@ -44,14 +44,14 @@ fn main() { #[rustfmt::skip] macro_rules! m { ($visitor: expr) => { - $visitor + *& $visitor }; } #[rustfmt::skip] macro_rules! m_mut { ($visitor: expr) => { - $visitor + *& mut $visitor }; } diff --git a/tests/ui/deref_addrof.rs b/tests/ui/deref_addrof.rs index 49f360b9a7f9..627fefd3250a 100644 --- a/tests/ui/deref_addrof.rs +++ b/tests/ui/deref_addrof.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::return_self_not_must_use)] #![warn(clippy::deref_addrof)] diff --git a/tests/ui/deref_addrof.stderr b/tests/ui/deref_addrof.stderr index 75371fcdb967..71c4017471f5 100644 --- a/tests/ui/deref_addrof.stderr +++ b/tests/ui/deref_addrof.stderr @@ -1,54 +1,58 @@ -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:19:13 | LL | let b = *&a; | ^^^ help: try this: `a` | - = note: `-D clippy::deref-addrof` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/deref_addrof.rs:3:9 + | +LL | #![warn(clippy::deref_addrof)] + | ^^^^^^^^^^^^^^^^^^^^ -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:21:13 | LL | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try this: `get_number()` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:26:13 | LL | let b = *&bytes[1..2][0]; | ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:30:13 | LL | let b = *&(a); | ^^^^^ help: try this: `(a)` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:32:13 | LL | let b = *(&a); | ^^^^^ help: try this: `a` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:35:13 | LL | let b = *((&a)); | ^^^^^^^ help: try this: `a` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:37:13 | LL | let b = *&&a; | ^^^^ help: try this: `&a` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:39:14 | LL | let b = **&aref; | ^^^^^^ help: try this: `aref` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:47:9 | LL | *& $visitor @@ -57,9 +61,9 @@ LL | *& $visitor LL | m!(self) | -------- in this macro invocation | - = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof.rs:54:9 | LL | *& mut $visitor @@ -68,7 +72,7 @@ LL | *& mut $visitor LL | m_mut!(self) | ------------ in this macro invocation | - = note: this error originates in the macro `m_mut` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `m_mut` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/deref_addrof_double_trigger.stderr b/tests/ui/deref_addrof_double_trigger.stderr index 2c55a4ed6acd..ad6273f7ec9d 100644 --- a/tests/ui/deref_addrof_double_trigger.stderr +++ b/tests/ui/deref_addrof_double_trigger.stderr @@ -1,22 +1,26 @@ -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof_double_trigger.rs:10:14 | LL | let b = **&&a; | ^^^^ help: try this: `&a` | - = note: `-D clippy::deref-addrof` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/deref_addrof_double_trigger.rs:3:8 + | +LL | #[warn(clippy::deref_addrof)] + | ^^^^^^^^^^^^^^^^^^^^ -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof_double_trigger.rs:14:17 | LL | let y = *&mut x; | ^^^^^^^ help: try this: `x` -error: immediately dereferencing a reference +warning: immediately dereferencing a reference --> $DIR/deref_addrof_double_trigger.rs:21:18 | LL | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/deref_by_slicing.fixed b/tests/ui/deref_by_slicing.fixed index 257393e56ff0..f91a425c65da 100644 --- a/tests/ui/deref_by_slicing.fixed +++ b/tests/ui/deref_by_slicing.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::deref_by_slicing)] #![allow(clippy::borrow_deref_ref)] diff --git a/tests/ui/deref_by_slicing.rs b/tests/ui/deref_by_slicing.rs index e288046f927f..1bfdd0a981ba 100644 --- a/tests/ui/deref_by_slicing.rs +++ b/tests/ui/deref_by_slicing.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::deref_by_slicing)] #![allow(clippy::borrow_deref_ref)] diff --git a/tests/ui/deref_by_slicing.stderr b/tests/ui/deref_by_slicing.stderr index 8f042ef47ebe..b9458b2d8774 100644 --- a/tests/ui/deref_by_slicing.stderr +++ b/tests/ui/deref_by_slicing.stderr @@ -1,58 +1,62 @@ -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:10:13 | LL | let _ = &vec[..]; | ^^^^^^^^ help: dereference the original value instead: `&*vec` | - = note: `-D clippy::deref-by-slicing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/deref_by_slicing.rs:3:9 + | +LL | #![warn(clippy::deref_by_slicing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:11:13 | LL | let _ = &mut vec[..]; | ^^^^^^^^^^^^ help: dereference the original value instead: `&mut *vec` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:14:13 | LL | let _ = &ref_vec[..]; | ^^^^^^^^^^^^ help: dereference the original value instead: `&**ref_vec` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:15:21 | LL | let mut_slice = &mut ref_vec[..]; | ^^^^^^^^^^^^^^^^ help: dereference the original value instead: `&mut **ref_vec` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:16:13 | LL | let _ = &mut mut_slice[..]; // Err, re-borrows slice | ^^^^^^^^^^^^^^^^^^ help: reborrow the original value instead: `&mut *mut_slice` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:19:13 | LL | let _ = &s[..]; | ^^^^^^ help: dereference the original value instead: `&*s` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:22:18 | LL | let _ = &mut &S[..]; // Err, re-borrows slice | ^^^^^^ help: reborrow the original value instead: `&*S` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:26:13 | LL | let _ = &slice_ref[..]; // Err, derefs slice | ^^^^^^^^^^^^^^ help: dereference the original value instead: `*slice_ref` -error: slicing when dereferencing would work +warning: slicing when dereferencing would work --> $DIR/deref_by_slicing.rs:29:13 | LL | let _ = (&bytes[..]).read_to_end(&mut vec![]).unwrap(); // Err, re-borrows slice | ^^^^^^^^^^^^ help: reborrow the original value instead: `(&*bytes)` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/derivable_impls.fixed b/tests/ui/derivable_impls.fixed index 89ec33a0d8f7..aa0efb85c297 100644 --- a/tests/ui/derivable_impls.fixed +++ b/tests/ui/derivable_impls.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] diff --git a/tests/ui/derivable_impls.rs b/tests/ui/derivable_impls.rs index def6e41162f1..8dc999ad5860 100644 --- a/tests/ui/derivable_impls.rs +++ b/tests/ui/derivable_impls.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] diff --git a/tests/ui/derivable_impls.stderr b/tests/ui/derivable_impls.stderr index 81963c3be5b5..2145815f7f3b 100644 --- a/tests/ui/derivable_impls.stderr +++ b/tests/ui/derivable_impls.stderr @@ -1,4 +1,4 @@ -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:22:1 | LL | / impl std::default::Default for FooDefault<'_> { @@ -10,14 +10,14 @@ LL | | } LL | | } | |_^ | - = note: `-D clippy::derivable-impls` implied by `-D warnings` + = note: `#[warn(clippy::derivable_impls)]` on by default = help: remove the manual implementation... help: ...and instead derive it | LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:43:1 | LL | / impl std::default::Default for TupleDefault { @@ -33,7 +33,7 @@ help: ...and instead derive it LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:95:1 | LL | / impl Default for StrDefault<'_> { @@ -49,7 +49,7 @@ help: ...and instead derive it LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:121:1 | LL | / impl Default for Y { @@ -65,7 +65,7 @@ help: ...and instead derive it LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:160:1 | LL | / impl Default for WithoutSelfCurly { @@ -81,7 +81,7 @@ help: ...and instead derive it LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:168:1 | LL | / impl Default for WithoutSelfParan { @@ -97,7 +97,7 @@ help: ...and instead derive it LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:218:1 | LL | / impl Default for RepeatDefault1 { @@ -113,7 +113,7 @@ help: ...and instead derive it LL | #[derive(Default)] | -error: this `impl` can be derived +warning: this `impl` can be derived --> $DIR/derivable_impls.rs:252:1 | LL | / impl Default for SimpleEnum { @@ -134,5 +134,5 @@ LL ~ #[default] LL ~ Bar, | -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index d37f7fa73319..1a74bfda2285 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -1,4 +1,4 @@ -error: you are implementing `Clone` explicitly on a `Copy` type +warning: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:7:1 | LL | / impl Clone for Qux { @@ -17,9 +17,13 @@ LL | | Qux LL | | } LL | | } | |_^ - = note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/derive.rs:2:9 + | +LL | #![warn(clippy::expl_impl_clone_on_copy)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you are implementing `Clone` explicitly on a `Copy` type +warning: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:31:1 | LL | / impl<'a> Clone for Lt<'a> { @@ -39,7 +43,7 @@ LL | | } LL | | } | |_^ -error: you are implementing `Clone` explicitly on a `Copy` type +warning: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:42:1 | LL | / impl Clone for BigArray { @@ -59,7 +63,7 @@ LL | | } LL | | } | |_^ -error: you are implementing `Clone` explicitly on a `Copy` type +warning: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:53:1 | LL | / impl Clone for FnPtr { @@ -79,7 +83,7 @@ LL | | } LL | | } | |_^ -error: you are implementing `Clone` explicitly on a `Copy` type +warning: you are implementing `Clone` explicitly on a `Copy` type --> $DIR/derive.rs:73:1 | LL | / impl Clone for Generic2 { @@ -99,5 +103,5 @@ LL | | } LL | | } | |_^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/derive_ord_xor_partial_ord.stderr b/tests/ui/derive_ord_xor_partial_ord.stderr index 58efbb8541f6..1af679a469b5 100644 --- a/tests/ui/derive_ord_xor_partial_ord.stderr +++ b/tests/ui/derive_ord_xor_partial_ord.stderr @@ -1,4 +1,4 @@ -error: you are deriving `Ord` but have implemented `PartialOrd` explicitly +warning: you are deriving `Ord` but have implemented `PartialOrd` explicitly --> $DIR/derive_ord_xor_partial_ord.rs:21:10 | LL | #[derive(Ord, PartialEq, Eq)] @@ -9,10 +9,14 @@ note: `PartialOrd` implemented here | LL | impl PartialOrd for DeriveOrd { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::derive-ord-xor-partial-ord` implied by `-D warnings` - = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) +note: the lint level is defined here + --> $DIR/derive_ord_xor_partial_ord.rs:1:9 + | +LL | #![warn(clippy::derive_ord_xor_partial_ord)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this warning originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) -error: you are deriving `Ord` but have implemented `PartialOrd` explicitly +warning: you are deriving `Ord` but have implemented `PartialOrd` explicitly --> $DIR/derive_ord_xor_partial_ord.rs:30:10 | LL | #[derive(Ord, PartialEq, Eq)] @@ -23,9 +27,9 @@ note: `PartialOrd` implemented here | LL | impl PartialOrd for DeriveOrdWithExplicitTypeVariable { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) -error: you are implementing `Ord` explicitly but have derived `PartialOrd` +warning: you are implementing `Ord` explicitly but have derived `PartialOrd` --> $DIR/derive_ord_xor_partial_ord.rs:42:1 | LL | / impl std::cmp::Ord for DerivePartialOrd { @@ -40,9 +44,9 @@ note: `PartialOrd` implemented here | LL | #[derive(PartialOrd, PartialEq, Eq)] | ^^^^^^^^^^ - = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) -error: you are implementing `Ord` explicitly but have derived `PartialOrd` +warning: you are implementing `Ord` explicitly but have derived `PartialOrd` --> $DIR/derive_ord_xor_partial_ord.rs:62:5 | LL | / impl Ord for DerivePartialOrdInUseOrd { @@ -57,7 +61,7 @@ note: `PartialOrd` implemented here | LL | #[derive(PartialOrd, PartialEq, Eq)] | ^^^^^^^^^^ - = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/derive_partial_eq_without_eq.fixed b/tests/ui/derive_partial_eq_without_eq.fixed index bbbe467590f9..a1f29430c30f 100644 --- a/tests/ui/derive_partial_eq_without_eq.fixed +++ b/tests/ui/derive_partial_eq_without_eq.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::derive_partial_eq_without_eq)] diff --git a/tests/ui/derive_partial_eq_without_eq.rs b/tests/ui/derive_partial_eq_without_eq.rs index 88d6fbd1af7e..ff4d888559b7 100644 --- a/tests/ui/derive_partial_eq_without_eq.rs +++ b/tests/ui/derive_partial_eq_without_eq.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::derive_partial_eq_without_eq)] diff --git a/tests/ui/derive_partial_eq_without_eq.stderr b/tests/ui/derive_partial_eq_without_eq.stderr index 794c5dab8445..389ddc654c1f 100644 --- a/tests/ui/derive_partial_eq_without_eq.stderr +++ b/tests/ui/derive_partial_eq_without_eq.stderr @@ -1,70 +1,74 @@ -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:13:17 | LL | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` | - = note: `-D clippy::derive-partial-eq-without-eq` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/derive_partial_eq_without_eq.rs:4:9 + | +LL | #![warn(clippy::derive_partial_eq_without_eq)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:55:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:61:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:67:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:70:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:76:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:82:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:95:17 | LL | #[derive(Debug, PartialEq, Clone)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:98:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:105:14 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: you are deriving `PartialEq` and can implement `Eq` +warning: you are deriving `PartialEq` and can implement `Eq` --> $DIR/derive_partial_eq_without_eq.rs:108:14 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/derived_hash_with_manual_eq.rs b/tests/ui/derived_hash_with_manual_eq.rs index 8ad09a8de43d..9e5857acca99 100644 --- a/tests/ui/derived_hash_with_manual_eq.rs +++ b/tests/ui/derived_hash_with_manual_eq.rs @@ -9,7 +9,7 @@ impl PartialEq for Foo { } } -#[derive(Hash)] +#[derive(Hash)] //~ ERROR: deriving `Hash` but have implemented `PartialEq` struct Bar; impl PartialEq for Bar { @@ -18,7 +18,7 @@ impl PartialEq for Bar { } } -#[derive(Hash)] +#[derive(Hash)] //~ ERROR: deriving `Hash` but have implemented `PartialEq` struct Baz; impl PartialEq for Baz { diff --git a/tests/ui/disallowed_names.stderr b/tests/ui/disallowed_names.stderr index 78cb55096ff0..2d1e9ea927f5 100644 --- a/tests/ui/disallowed_names.stderr +++ b/tests/ui/disallowed_names.stderr @@ -1,88 +1,92 @@ -error: use of a disallowed/placeholder name `foo` +warning: use of a disallowed/placeholder name `foo` --> $DIR/disallowed_names.rs:11:9 | LL | fn test(foo: ()) {} | ^^^ | - = note: `-D clippy::disallowed-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/disallowed_names.rs:9:9 + | +LL | #![warn(clippy::disallowed_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of a disallowed/placeholder name `foo` +warning: use of a disallowed/placeholder name `foo` --> $DIR/disallowed_names.rs:14:9 | LL | let foo = 42; | ^^^ -error: use of a disallowed/placeholder name `baz` +warning: use of a disallowed/placeholder name `baz` --> $DIR/disallowed_names.rs:15:9 | LL | let baz = 42; | ^^^ -error: use of a disallowed/placeholder name `quux` +warning: use of a disallowed/placeholder name `quux` --> $DIR/disallowed_names.rs:16:9 | LL | let quux = 42; | ^^^^ -error: use of a disallowed/placeholder name `foo` +warning: use of a disallowed/placeholder name `foo` --> $DIR/disallowed_names.rs:27:10 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ -error: use of a disallowed/placeholder name `baz` +warning: use of a disallowed/placeholder name `baz` --> $DIR/disallowed_names.rs:27:20 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ -error: use of a disallowed/placeholder name `quux` +warning: use of a disallowed/placeholder name `quux` --> $DIR/disallowed_names.rs:27:26 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^^ -error: use of a disallowed/placeholder name `foo` +warning: use of a disallowed/placeholder name `foo` --> $DIR/disallowed_names.rs:32:19 | LL | fn issue_1647(mut foo: u8) { | ^^^ -error: use of a disallowed/placeholder name `baz` +warning: use of a disallowed/placeholder name `baz` --> $DIR/disallowed_names.rs:33:13 | LL | let mut baz = 0; | ^^^ -error: use of a disallowed/placeholder name `quux` +warning: use of a disallowed/placeholder name `quux` --> $DIR/disallowed_names.rs:34:21 | LL | if let Some(mut quux) = Some(42) {} | ^^^^ -error: use of a disallowed/placeholder name `baz` +warning: use of a disallowed/placeholder name `baz` --> $DIR/disallowed_names.rs:38:13 | LL | let ref baz = 0; | ^^^ -error: use of a disallowed/placeholder name `quux` +warning: use of a disallowed/placeholder name `quux` --> $DIR/disallowed_names.rs:39:21 | LL | if let Some(ref quux) = Some(42) {} | ^^^^ -error: use of a disallowed/placeholder name `baz` +warning: use of a disallowed/placeholder name `baz` --> $DIR/disallowed_names.rs:43:17 | LL | let ref mut baz = 0; | ^^^ -error: use of a disallowed/placeholder name `quux` +warning: use of a disallowed/placeholder name `quux` --> $DIR/disallowed_names.rs:44:25 | LL | if let Some(ref mut quux) = Some(42) {} | ^^^^ -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/disallowed_script_idents.rs b/tests/ui/disallowed_script_idents.rs index cfdda35971fb..304316e17f41 100644 --- a/tests/ui/disallowed_script_idents.rs +++ b/tests/ui/disallowed_script_idents.rs @@ -1,4 +1,4 @@ -#![deny(clippy::disallowed_script_idents)] +#![warn(clippy::disallowed_script_idents)] #![allow(dead_code)] fn main() { diff --git a/tests/ui/disallowed_script_idents.stderr b/tests/ui/disallowed_script_idents.stderr index cc84dc1d43c5..c1a4339f792f 100644 --- a/tests/ui/disallowed_script_idents.stderr +++ b/tests/ui/disallowed_script_idents.stderr @@ -1,4 +1,4 @@ -error: identifier `счётчик` has a Unicode script that is not allowed by configuration: Cyrillic +warning: identifier `счётчик` has a Unicode script that is not allowed by configuration: Cyrillic --> $DIR/disallowed_script_idents.rs:8:9 | LL | let счётчик = 10; // Cyrillic is not allowed by default. @@ -7,14 +7,14 @@ LL | let счётчик = 10; // Cyrillic is not allowed by default. note: the lint level is defined here --> $DIR/disallowed_script_idents.rs:1:9 | -LL | #![deny(clippy::disallowed_script_idents)] +LL | #![warn(clippy::disallowed_script_idents)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana +warning: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana --> $DIR/disallowed_script_idents.rs:9:9 | LL | let カウンタ = 10; // Same for japanese. | ^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 9c91d935716d..d6198aa3fc1d 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -1,48 +1,52 @@ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:19:10 | LL | b || diverge(); | ^^^^^^^^^ | - = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/diverging_sub_expression.rs:1:9 + | +LL | #![warn(clippy::diverging_sub_expression)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:20:10 | LL | b || A.foo(); | ^^^^^^^ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:29:26 | LL | 6 => true || return, | ^^^^^^ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:30:26 | LL | 7 => true || continue, | ^^^^^^^^ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:33:26 | LL | 3 => true || diverge(), | ^^^^^^^^^ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:36:30 | LL | _ => true || panic!("boo"), | ^^^^^^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/diverging_sub_expression.rs:38:26 | LL | _ => true || break, | ^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/doc/doc-fixable.fixed b/tests/ui/doc/doc-fixable.fixed index ecb0bf3644ee..d3aa2816cb6d 100644 --- a/tests/ui/doc/doc-fixable.fixed +++ b/tests/ui/doc/doc-fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix //! This file tests for the `DOC_MARKDOWN` lint. #![allow(dead_code, incomplete_features)] diff --git a/tests/ui/doc/doc-fixable.rs b/tests/ui/doc/doc-fixable.rs index 11c48dd103d6..d1e7d8017d7d 100644 --- a/tests/ui/doc/doc-fixable.rs +++ b/tests/ui/doc/doc-fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix //! This file tests for the `DOC_MARKDOWN` lint. #![allow(dead_code, incomplete_features)] diff --git a/tests/ui/doc/doc-fixable.stderr b/tests/ui/doc/doc-fixable.stderr index 6c67c903c750..28d02dbba2f0 100644 --- a/tests/ui/doc/doc-fixable.stderr +++ b/tests/ui/doc/doc-fixable.stderr @@ -1,16 +1,20 @@ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:9:9 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^ | - = note: `-D clippy::doc-markdown` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/doc-fixable.rs:5:9 + | +LL | #![warn(clippy::doc_markdown)] + | ^^^^^^^^^^^^^^^^^^^^ help: try | LL | /// The `foo_bar` function does _nothing_. See also foo::bar. (note the dot there) | ~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:9:51 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) @@ -21,18 +25,18 @@ help: try LL | /// The foo_bar function does _nothing_. See also `foo::bar`. (note the dot there) | ~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:10:83 | -LL | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun +LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun | ^^^^^^^^^^^^^ | help: try | -LL | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not `Foo::some_fun` +LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not `Foo::some_fun` | ~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:12:13 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. @@ -43,7 +47,7 @@ help: try LL | /// Here be `::a::global:path`, and _::another::global::path_. :: is not a path though. | ~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:12:36 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. @@ -54,7 +58,7 @@ help: try LL | /// Here be ::a::global:path, and _`::another::global::path`_. :: is not a path though. | ~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:13:25 | LL | /// Import an item from ::awesome::global::blob:: (Intended postfix) @@ -65,7 +69,7 @@ help: try LL | /// Import an item from `::awesome::global::blob::` (Intended postfix) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:14:31 | LL | /// These are the options for ::Cat: (Intended trailing single colon, shouldn't be linted) @@ -76,7 +80,7 @@ help: try LL | /// These are the options for `::Cat`: (Intended trailing single colon, shouldn't be linted) | ~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:15:22 | LL | /// That's not code ~NotInCodeBlock~. @@ -87,7 +91,7 @@ help: try LL | /// That's not code ~`NotInCodeBlock`~. | ~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:16:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -98,7 +102,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:30:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -109,7 +113,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:37:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -120,7 +124,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:51:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -131,7 +135,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:74:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -142,7 +146,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:91:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -153,7 +157,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:99:8 | LL | /// ## CamelCaseThing @@ -164,7 +168,7 @@ help: try LL | /// ## `CamelCaseThing` | ~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:102:7 | LL | /// # CamelCaseThing @@ -175,7 +179,7 @@ help: try LL | /// # `CamelCaseThing` | ~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:104:22 | LL | /// Not a title #897 CamelCaseThing @@ -186,7 +190,7 @@ help: try LL | /// Not a title #897 `CamelCaseThing` | ~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:105:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -197,7 +201,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:112:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -208,7 +212,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:125:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -219,7 +223,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:136:43 | LL | /** E.g., serialization of an empty list: FooBar @@ -230,7 +234,7 @@ help: try LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:141:5 | LL | And BarQuz too. @@ -241,7 +245,7 @@ help: try LL | And `BarQuz` too. | ~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:142:1 | LL | be_sure_we_got_to_the_end_of_it @@ -252,7 +256,7 @@ help: try LL | `be_sure_we_got_to_the_end_of_it` | -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:147:43 | LL | /** E.g., serialization of an empty list: FooBar @@ -263,7 +267,7 @@ help: try LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:152:5 | LL | And BarQuz too. @@ -274,7 +278,7 @@ help: try LL | And `BarQuz` too. | ~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:153:1 | LL | be_sure_we_got_to_the_end_of_it @@ -285,7 +289,7 @@ help: try LL | `be_sure_we_got_to_the_end_of_it` | -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:164:5 | LL | /// be_sure_we_got_to_the_end_of_it @@ -296,7 +300,7 @@ help: try LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/doc-fixable.rs:183:22 | LL | /// An iterator over mycrate::Collection's values. @@ -307,5 +311,5 @@ help: try LL | /// An iterator over `mycrate::Collection`'s values. | ~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 28 previous errors +warning: 28 warnings emitted diff --git a/tests/ui/doc/unbalanced_ticks.stderr b/tests/ui/doc/unbalanced_ticks.stderr index f2ac6bc3269a..213a0bb43500 100644 --- a/tests/ui/doc/unbalanced_ticks.stderr +++ b/tests/ui/doc/unbalanced_ticks.stderr @@ -1,4 +1,4 @@ -error: backticks are unbalanced +warning: backticks are unbalanced --> $DIR/unbalanced_ticks.rs:7:1 | LL | / /// This is a doc comment with `unbalanced_tick marks and several words that @@ -8,9 +8,13 @@ LL | | /// very `confusing_and_misleading`. | |____________________________________^ | = help: a backtick may be missing a pair - = note: `-D clippy::doc-markdown` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unbalanced_ticks.rs:5:9 + | +LL | #![warn(clippy::doc_markdown)] + | ^^^^^^^^^^^^^^^^^^^^ -error: backticks are unbalanced +warning: backticks are unbalanced --> $DIR/unbalanced_ticks.rs:13:1 | LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. @@ -18,7 +22,7 @@ LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. | = help: a backtick may be missing a pair -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/unbalanced_ticks.rs:15:32 | LL | /// This paragraph is fine and should_be linted normally. @@ -29,7 +33,7 @@ help: try LL | /// This paragraph is fine and `should_be` linted normally. | ~~~~~~~~~~~ -error: backticks are unbalanced +warning: backticks are unbalanced --> $DIR/unbalanced_ticks.rs:17:1 | LL | /// Double unbalanced backtick from ``here to here` should lint. @@ -37,7 +41,7 @@ LL | /// Double unbalanced backtick from ``here to here` should lint. | = help: a backtick may be missing a pair -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/unbalanced_ticks.rs:30:8 | LL | /// ## not_fine @@ -48,7 +52,7 @@ help: try LL | /// ## `not_fine` | ~~~~~~~~~~ -error: backticks are unbalanced +warning: backticks are unbalanced --> $DIR/unbalanced_ticks.rs:32:1 | LL | /// ### `unbalanced @@ -56,7 +60,7 @@ LL | /// ### `unbalanced | = help: a backtick may be missing a pair -error: backticks are unbalanced +warning: backticks are unbalanced --> $DIR/unbalanced_ticks.rs:34:1 | LL | /// - This `item has unbalanced tick marks @@ -64,7 +68,7 @@ LL | /// - This `item has unbalanced tick marks | = help: a backtick may be missing a pair -error: item in documentation is missing backticks +warning: item in documentation is missing backticks --> $DIR/unbalanced_ticks.rs:35:23 | LL | /// - This item needs backticks_here @@ -75,5 +79,5 @@ help: try LL | /// - This item needs `backticks_here` | ~~~~~~~~~~~~~~~~ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/doc_errors.stderr b/tests/ui/doc_errors.stderr index d74f2dbfe1ba..1ca49c759f16 100644 --- a/tests/ui/doc_errors.stderr +++ b/tests/ui/doc_errors.stderr @@ -1,46 +1,50 @@ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:7:1 | LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::missing-errors-doc` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/doc_errors.rs:1:9 + | +LL | #![warn(clippy::missing_errors_doc)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:11:1 | LL | pub async fn async_pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:16:1 | LL | pub fn pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:21:1 | LL | pub async fn async_pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:51:5 | LL | pub fn pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:56:5 | LL | pub async fn async_pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function returning `Result` missing `# Errors` section +warning: docs for function returning `Result` missing `# Errors` section --> $DIR/doc_errors.rs:85:5 | LL | fn trait_method_missing_errors_header() -> Result<(), ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/doc_link_with_quotes.stderr b/tests/ui/doc_link_with_quotes.stderr index ea730e667d65..a6a5b1511125 100644 --- a/tests/ui/doc_link_with_quotes.stderr +++ b/tests/ui/doc_link_with_quotes.stderr @@ -1,10 +1,14 @@ -error: possible intra-doc link using quotes instead of backticks +warning: possible intra-doc link using quotes instead of backticks --> $DIR/doc_link_with_quotes.rs:7:12 | LL | /// Calls ['bar'] uselessly | ^^^^^ | - = note: `-D clippy::doc-link-with-quotes` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/doc_link_with_quotes.rs:1:9 + | +LL | #![warn(clippy::doc_link_with_quotes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/doc_unsafe.rs b/tests/ui/doc_unsafe.rs index b91f7aa0dd8d..fa4fab03119f 100644 --- a/tests/ui/doc_unsafe.rs +++ b/tests/ui/doc_unsafe.rs @@ -1,4 +1,4 @@ -// aux-build:doc_unsafe_macros.rs +//@aux-build:doc_unsafe_macros.rs #![allow(clippy::let_unit_value)] diff --git a/tests/ui/doc_unsafe.stderr b/tests/ui/doc_unsafe.stderr index a86e191370e3..a851c635dfe0 100644 --- a/tests/ui/doc_unsafe.stderr +++ b/tests/ui/doc_unsafe.stderr @@ -1,36 +1,36 @@ -error: unsafe function's docs miss `# Safety` section +warning: unsafe function's docs miss `# Safety` section --> $DIR/doc_unsafe.rs:9:1 | LL | pub unsafe fn destroy_the_planet() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::missing-safety-doc` implied by `-D warnings` + = note: `#[warn(clippy::missing_safety_doc)]` on by default -error: unsafe function's docs miss `# Safety` section +warning: unsafe function's docs miss `# Safety` section --> $DIR/doc_unsafe.rs:32:5 | LL | pub unsafe fn republished() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsafe function's docs miss `# Safety` section +warning: unsafe function's docs miss `# Safety` section --> $DIR/doc_unsafe.rs:40:5 | LL | unsafe fn woefully_underdocumented(self); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for unsafe trait missing `# Safety` section +warning: docs for unsafe trait missing `# Safety` section --> $DIR/doc_unsafe.rs:46:1 | LL | pub unsafe trait UnsafeTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsafe function's docs miss `# Safety` section +warning: unsafe function's docs miss `# Safety` section --> $DIR/doc_unsafe.rs:76:5 | LL | pub unsafe fn more_undocumented_unsafe() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsafe function's docs miss `# Safety` section +warning: unsafe function's docs miss `# Safety` section --> $DIR/doc_unsafe.rs:92:9 | LL | pub unsafe fn whee() { @@ -39,7 +39,7 @@ LL | pub unsafe fn whee() { LL | very_unsafe!(); | -------------- in this macro invocation | - = note: this error originates in the macro `very_unsafe` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `very_unsafe` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/double_comparison.fixed b/tests/ui/double_comparison.fixed index bb6cdaa667d4..c80ff671a5db 100644 --- a/tests/ui/double_comparison.fixed +++ b/tests/ui/double_comparison.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix fn main() { let x = 1; diff --git a/tests/ui/double_comparison.rs b/tests/ui/double_comparison.rs index 9a2a9068a28d..bc78694aa680 100644 --- a/tests/ui/double_comparison.rs +++ b/tests/ui/double_comparison.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix fn main() { let x = 1; diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index 05ef4e25f7f8..24005b56bcc9 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -1,52 +1,52 @@ -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:6:8 | LL | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` | - = note: `-D clippy::double-comparisons` implied by `-D warnings` + = note: `#[warn(clippy::double_comparisons)]` on by default -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:9:8 | LL | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:12:8 | LL | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:15:8 | LL | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:18:8 | LL | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:21:8 | LL | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:24:8 | LL | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` -error: this binary expression can be simplified +warning: this binary expression can be simplified --> $DIR/double_comparison.rs:27:8 | LL | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/double_must_use.stderr b/tests/ui/double_must_use.stderr index 3d34557a881b..6dfb209bdf6a 100644 --- a/tests/ui/double_must_use.stderr +++ b/tests/ui/double_must_use.stderr @@ -1,13 +1,17 @@ -error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` +warning: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` --> $DIR/double_must_use.rs:5:1 | LL | pub fn must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: either add some descriptive text or remove the attribute - = note: `-D clippy::double-must-use` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/double_must_use.rs:1:9 + | +LL | #![warn(clippy::double_must_use)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` +warning: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` --> $DIR/double_must_use.rs:10:1 | LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { @@ -15,7 +19,7 @@ LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { | = help: either add some descriptive text or remove the attribute -error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` +warning: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` --> $DIR/double_must_use.rs:15:1 | LL | pub fn must_use_array() -> [Result<(), ()>; 1] { @@ -23,5 +27,5 @@ LL | pub fn must_use_array() -> [Result<(), ()>; 1] { | = help: either add some descriptive text or remove the attribute -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index 7cdb040b6873..5291a22633c3 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,10 +1,14 @@ -error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op +warning: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op --> $DIR/double_neg.rs:7:5 | LL | --x; | ^^^ | - = note: `-D clippy::double-neg` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/double_neg.rs:1:8 + | +LL | #[warn(clippy::double_neg)] + | ^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index 40fcad2ab1d4..8f051a6233b5 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -1,40 +1,44 @@ -error: consider removing unnecessary double parentheses +warning: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:15:5 | LL | ((0)) | ^^^^^ | - = note: `-D clippy::double-parens` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/double_parens.rs:1:9 + | +LL | #![warn(clippy::double_parens)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: consider removing unnecessary double parentheses +warning: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:19:14 | LL | dummy_fn((0)); | ^^^ -error: consider removing unnecessary double parentheses +warning: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:23:20 | LL | x.dummy_method((0)); | ^^^ -error: consider removing unnecessary double parentheses +warning: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:27:5 | LL | ((1, 2)) | ^^^^^^^^ -error: consider removing unnecessary double parentheses +warning: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:31:5 | LL | (()) | ^^^^ -error: consider removing unnecessary double parentheses +warning: consider removing unnecessary double parentheses --> $DIR/double_parens.rs:53:16 | LL | assert_eq!(((1, 2)), (1, 2), "Error"); | ^^^^^^^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index 90bef1c3c439..f94becb9767c 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -1,4 +1,4 @@ -error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact +warning: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact --> $DIR/drop_forget_copy.rs:33:5 | LL | drop(s1); @@ -9,9 +9,13 @@ note: argument has type `SomeStruct` | LL | drop(s1); | ^^ - = note: `-D clippy::drop-copy` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/drop_forget_copy.rs:1:9 + | +LL | #![warn(clippy::drop_copy, clippy::forget_copy)] + | ^^^^^^^^^^^^^^^^^ -error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact +warning: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact --> $DIR/drop_forget_copy.rs:34:5 | LL | drop(s2); @@ -23,7 +27,7 @@ note: argument has type `SomeStruct` LL | drop(s2); | ^^ -error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact +warning: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact --> $DIR/drop_forget_copy.rs:36:5 | LL | drop(s4); @@ -35,7 +39,7 @@ note: argument has type `SomeStruct` LL | drop(s4); | ^^ -error: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact +warning: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact --> $DIR/drop_forget_copy.rs:39:5 | LL | forget(s1); @@ -46,9 +50,13 @@ note: argument has type `SomeStruct` | LL | forget(s1); | ^^ - = note: `-D clippy::forget-copy` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/drop_forget_copy.rs:1:28 + | +LL | #![warn(clippy::drop_copy, clippy::forget_copy)] + | ^^^^^^^^^^^^^^^^^^^ -error: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact +warning: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact --> $DIR/drop_forget_copy.rs:40:5 | LL | forget(s2); @@ -60,7 +68,7 @@ note: argument has type `SomeStruct` LL | forget(s2); | ^^ -error: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact +warning: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact --> $DIR/drop_forget_copy.rs:42:5 | LL | forget(s4); @@ -72,7 +80,7 @@ note: argument has type `SomeStruct` LL | forget(s4); | ^^ -error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact +warning: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact --> $DIR/drop_forget_copy.rs:80:13 | LL | drop(println_and(13)); // Lint, even if we only care about the side-effect, it's already in a block @@ -84,7 +92,7 @@ note: argument has type `i32` LL | drop(println_and(13)); // Lint, even if we only care about the side-effect, it's already in a block | ^^^^^^^^^^^^^^^ -error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact +warning: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact --> $DIR/drop_forget_copy.rs:82:14 | LL | 3 if drop(println_and(14)) == () => (), // Lint, idiomatic use is only in body of `Arm` @@ -96,7 +104,7 @@ note: argument has type `i32` LL | 3 if drop(println_and(14)) == () => (), // Lint, idiomatic use is only in body of `Arm` | ^^^^^^^^^^^^^^^ -error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact +warning: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact --> $DIR/drop_forget_copy.rs:83:14 | LL | 4 => drop(2), // Lint, not a fn/method call @@ -108,5 +116,5 @@ note: argument has type `i32` LL | 4 => drop(2), // Lint, not a fn/method call | ^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/drop_non_drop.stderr b/tests/ui/drop_non_drop.stderr index b86057c0c321..fcb7e3159cec 100644 --- a/tests/ui/drop_non_drop.stderr +++ b/tests/ui/drop_non_drop.stderr @@ -1,4 +1,4 @@ -error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes +warning: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes --> $DIR/drop_non_drop.rs:22:5 | LL | drop(Foo); @@ -9,9 +9,13 @@ note: argument has type `main::Foo` | LL | drop(Foo); | ^^^ - = note: `-D clippy::drop-non-drop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/drop_non_drop.rs:1:9 + | +LL | #![warn(clippy::drop_non_drop)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes +warning: call to `std::mem::drop` with a value that does not implement `Drop`. Dropping such a type only extends its contained lifetimes --> $DIR/drop_non_drop.rs:37:5 | LL | drop(Baz(Foo)); @@ -23,5 +27,5 @@ note: argument has type `main::Baz` LL | drop(Baz(Foo)); | ^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/drop_ref.stderr b/tests/ui/drop_ref.stderr index 293b9f6de832..d23d3f1f92f3 100644 --- a/tests/ui/drop_ref.stderr +++ b/tests/ui/drop_ref.stderr @@ -1,4 +1,4 @@ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:11:5 | LL | drop(&SomeStruct); @@ -9,9 +9,13 @@ note: argument has type `&SomeStruct` | LL | drop(&SomeStruct); | ^^^^^^^^^^^ - = note: `-D clippy::drop-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/drop_ref.rs:1:9 + | +LL | #![warn(clippy::drop_ref)] + | ^^^^^^^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:14:5 | LL | drop(&owned1); @@ -23,7 +27,7 @@ note: argument has type `&SomeStruct` LL | drop(&owned1); | ^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:15:5 | LL | drop(&&owned1); @@ -35,7 +39,7 @@ note: argument has type `&&SomeStruct` LL | drop(&&owned1); | ^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:16:5 | LL | drop(&mut owned1); @@ -47,7 +51,7 @@ note: argument has type `&mut SomeStruct` LL | drop(&mut owned1); | ^^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:20:5 | LL | drop(reference1); @@ -59,7 +63,7 @@ note: argument has type `&SomeStruct` LL | drop(reference1); | ^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:23:5 | LL | drop(reference2); @@ -71,7 +75,7 @@ note: argument has type `&mut SomeStruct` LL | drop(reference2); | ^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:26:5 | LL | drop(reference3); @@ -83,7 +87,7 @@ note: argument has type `&SomeStruct` LL | drop(reference3); | ^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:31:5 | LL | drop(&val); @@ -95,7 +99,7 @@ note: argument has type `&T` LL | drop(&val); | ^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:39:5 | LL | std::mem::drop(&SomeStruct); @@ -107,7 +111,7 @@ note: argument has type `&SomeStruct` LL | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:91:13 | LL | drop(println_and(&13)); // Lint, even if we only care about the side-effect, it's already in a block @@ -119,7 +123,7 @@ note: argument has type `&i32` LL | drop(println_and(&13)); // Lint, even if we only care about the side-effect, it's already in a block | ^^^^^^^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:93:14 | LL | 3 if drop(println_and(&14)) == () => (), // Lint, idiomatic use is only in body of `Arm` @@ -131,7 +135,7 @@ note: argument has type `&i32` LL | 3 if drop(println_and(&14)) == () => (), // Lint, idiomatic use is only in body of `Arm` | ^^^^^^^^^^^^^^^^ -error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing +warning: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing --> $DIR/drop_ref.rs:94:14 | LL | 4 => drop(&2), // Lint, not a fn/method call @@ -143,5 +147,5 @@ note: argument has type `&i32` LL | 4 => drop(&2), // Lint, not a fn/method call | ^^ -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index f71614a5fd16..9a27c084e7e2 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -1,10 +1,14 @@ -error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult +warning: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult --> $DIR/duplicate_underscore_argument.rs:4:23 | LL | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | - = note: `-D clippy::duplicate-underscore-argument` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/duplicate_underscore_argument.rs:1:9 + | +LL | #![warn(clippy::duplicate_underscore_argument)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/duration_subsec.fixed b/tests/ui/duration_subsec.fixed index d92b8998e880..bfd30f0042d5 100644 --- a/tests/ui/duration_subsec.fixed +++ b/tests/ui/duration_subsec.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::needless_borrow)] #![warn(clippy::duration_subsec)] diff --git a/tests/ui/duration_subsec.rs b/tests/ui/duration_subsec.rs index 08da804996d1..860233f084f3 100644 --- a/tests/ui/duration_subsec.rs +++ b/tests/ui/duration_subsec.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::needless_borrow)] #![warn(clippy::duration_subsec)] diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index cdbeff6a0378..216af18d1943 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,34 +1,38 @@ -error: calling `subsec_millis()` is more concise than this calculation +warning: calling `subsec_millis()` is more concise than this calculation --> $DIR/duration_subsec.rs:10:24 | LL | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` | - = note: `-D clippy::duration-subsec` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/duration_subsec.rs:3:9 + | +LL | #![warn(clippy::duration_subsec)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `subsec_millis()` is more concise than this calculation +warning: calling `subsec_millis()` is more concise than this calculation --> $DIR/duration_subsec.rs:11:24 | LL | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` -error: calling `subsec_micros()` is more concise than this calculation +warning: calling `subsec_micros()` is more concise than this calculation --> $DIR/duration_subsec.rs:16:22 | LL | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` -error: calling `subsec_micros()` is more concise than this calculation +warning: calling `subsec_micros()` is more concise than this calculation --> $DIR/duration_subsec.rs:21:13 | LL | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` -error: calling `subsec_micros()` is more concise than this calculation +warning: calling `subsec_micros()` is more concise than this calculation --> $DIR/duration_subsec.rs:25:13 | LL | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/else_if_without_else.rs b/tests/ui/else_if_without_else.rs index 879b3ac398e4..c5c751811bf8 100644 --- a/tests/ui/else_if_without_else.rs +++ b/tests/ui/else_if_without_else.rs @@ -1,5 +1,5 @@ #![warn(clippy::all)] -#![warn(clippy::else_if_without_else)] +#![deny(clippy::else_if_without_else)] fn bla1() -> bool { unimplemented!() @@ -43,7 +43,7 @@ fn main() { if bla1() { println!("if"); } else if bla2() { - //~ ERROR else if without else + //~^ ERROR: `if` expression with an `else if`, but without a final `else` println!("else if"); } @@ -52,7 +52,7 @@ fn main() { } else if bla2() { println!("else if 1"); } else if bla3() { - //~ ERROR else if without else + //~^ ERROR: `if` expression with an `else if`, but without a final `else` println!("else if 2"); } } diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index 90ccfb4fad64..d2f01bc3f423 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -3,20 +3,24 @@ error: `if` expression with an `else if`, but without a final `else` | LL | } else if bla2() { | ____________^ -LL | | //~ ERROR else if without else +LL | | LL | | println!("else if"); LL | | } | |_____^ | = help: add an `else` block here - = note: `-D clippy::else-if-without-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/else_if_without_else.rs:2:9 + | +LL | #![deny(clippy::else_if_without_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `if` expression with an `else if`, but without a final `else` --> $DIR/else_if_without_else.rs:54:12 | LL | } else if bla3() { | ____________^ -LL | | //~ ERROR else if without else +LL | | LL | | println!("else if 2"); LL | | } | |_____^ diff --git a/tests/ui/empty_drop.fixed b/tests/ui/empty_drop.fixed index 2e1b768461ab..6c15cb933027 100644 --- a/tests/ui/empty_drop.fixed +++ b/tests/ui/empty_drop.fixed @@ -1,11 +1,13 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::empty_drop)] #![allow(unused)] // should cause an error struct Foo; - +impl Drop for Foo { + fn drop(&mut self) {} +} // shouldn't cause an error struct Bar; @@ -19,6 +21,10 @@ impl Drop for Bar { // should error struct Baz; - +impl Drop for Baz { + fn drop(&mut self) { + {} + } +} fn main() {} diff --git a/tests/ui/empty_drop.rs b/tests/ui/empty_drop.rs index 75232b0334df..6c15cb933027 100644 --- a/tests/ui/empty_drop.rs +++ b/tests/ui/empty_drop.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::empty_drop)] #![allow(unused)] diff --git a/tests/ui/empty_drop.stderr b/tests/ui/empty_drop.stderr index 70f7880d0360..77ac21f91564 100644 --- a/tests/ui/empty_drop.stderr +++ b/tests/ui/empty_drop.stderr @@ -1,4 +1,4 @@ -error: empty drop implementation +warning: empty drop implementation --> $DIR/empty_drop.rs:8:1 | LL | / impl Drop for Foo { @@ -6,9 +6,13 @@ LL | | fn drop(&mut self) {} LL | | } | |_^ help: try removing this impl | - = note: `-D clippy::empty-drop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/empty_drop.rs:2:9 + | +LL | #![warn(clippy::empty_drop)] + | ^^^^^^^^^^^^^^^^^^ -error: empty drop implementation +warning: empty drop implementation --> $DIR/empty_drop.rs:24:1 | LL | / impl Drop for Baz { @@ -18,5 +22,5 @@ LL | | } LL | | } | |_^ help: try removing this impl -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index 0d9aa5818e28..eb9ff68d647f 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,11 +1,15 @@ -error: enum with no variants +warning: enum with no variants --> $DIR/empty_enum.rs:5:1 | LL | enum Empty {} | ^^^^^^^^^^^^^ | = help: consider using the uninhabited type `!` (never type) or a wrapper around it to introduce a type which can't be instantiated - = note: `-D clippy::empty-enum` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/empty_enum.rs:2:9 + | +LL | #![warn(clippy::empty_enum)] + | ^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/empty_line_after_outer_attribute.rs b/tests/ui/empty_line_after_outer_attribute.rs index 697412c00275..b2d7ddae4274 100644 --- a/tests/ui/empty_line_after_outer_attribute.rs +++ b/tests/ui/empty_line_after_outer_attribute.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_attr.rs +//@aux-build:proc_macro_attr.rs:proc-macro #![warn(clippy::empty_line_after_outer_attr)] #![allow(clippy::assertions_on_constants)] #![feature(custom_inner_attributes)] diff --git a/tests/ui/empty_line_after_outer_attribute.stderr b/tests/ui/empty_line_after_outer_attribute.stderr index 594fca44a321..d145a4577a39 100644 --- a/tests/ui/empty_line_after_outer_attribute.stderr +++ b/tests/ui/empty_line_after_outer_attribute.stderr @@ -1,4 +1,4 @@ -error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? +warning: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:11:1 | LL | / #[crate_type = "lib"] @@ -7,9 +7,13 @@ LL | | /// some comment LL | | fn with_one_newline_and_comment() { assert!(true) } | |_ | - = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/empty_line_after_outer_attribute.rs:2:9 + | +LL | #![warn(clippy::empty_line_after_outer_attr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? +warning: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:23:1 | LL | / #[crate_type = "lib"] @@ -17,7 +21,7 @@ LL | | LL | | fn with_one_newline() { assert!(true) } | |_ -error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? +warning: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:28:1 | LL | / #[crate_type = "lib"] @@ -26,7 +30,7 @@ LL | | LL | | fn with_two_newlines() { assert!(true) } | |_ -error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? +warning: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:35:1 | LL | / #[crate_type = "lib"] @@ -34,7 +38,7 @@ LL | | LL | | enum Baz { | |_ -error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? +warning: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:43:1 | LL | / #[crate_type = "lib"] @@ -42,7 +46,7 @@ LL | | LL | | struct Foo { | |_ -error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? +warning: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? --> $DIR/empty_line_after_outer_attribute.rs:51:1 | LL | / #[crate_type = "lib"] @@ -50,5 +54,5 @@ LL | | LL | | mod foo { | |_ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/empty_loop.rs b/tests/ui/empty_loop.rs index 8fd7697eb3b2..82485ef8067f 100644 --- a/tests/ui/empty_loop.rs +++ b/tests/ui/empty_loop.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::empty_loop)] diff --git a/tests/ui/empty_loop.stderr b/tests/ui/empty_loop.stderr index 7602412334bb..91a1a3fddbaa 100644 --- a/tests/ui/empty_loop.stderr +++ b/tests/ui/empty_loop.stderr @@ -1,13 +1,17 @@ -error: empty `loop {}` wastes CPU cycles +warning: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop.rs:9:5 | LL | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body - = note: `-D clippy::empty-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/empty_loop.rs:3:9 + | +LL | #![warn(clippy::empty_loop)] + | ^^^^^^^^^^^^^^^^^^ -error: empty `loop {}` wastes CPU cycles +warning: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop.rs:11:9 | LL | loop {} @@ -15,7 +19,7 @@ LL | loop {} | = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body -error: empty `loop {}` wastes CPU cycles +warning: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop.rs:15:9 | LL | 'inner: loop {} @@ -23,5 +27,5 @@ LL | 'inner: loop {} | = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/empty_loop_no_std.rs b/tests/ui/empty_loop_no_std.rs index e742b396fcde..f9ab443dfd94 100644 --- a/tests/ui/empty_loop_no_std.rs +++ b/tests/ui/empty_loop_no_std.rs @@ -1,5 +1,5 @@ -// compile-flags: -Clink-arg=-nostartfiles -// ignore-macos +//@compile-flags: -Clink-arg=-nostartfiles +//@ignore-target-apple #![warn(clippy::empty_loop)] #![feature(lang_items, start, libc)] diff --git a/tests/ui/empty_loop_no_std.stderr b/tests/ui/empty_loop_no_std.stderr index 71af64f49d52..f903f51b269f 100644 --- a/tests/ui/empty_loop_no_std.stderr +++ b/tests/ui/empty_loop_no_std.stderr @@ -1,13 +1,17 @@ -error: empty `loop {}` wastes CPU cycles +warning: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop_no_std.rs:13:5 | LL | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body - = note: `-D clippy::empty-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/empty_loop_no_std.rs:4:9 + | +LL | #![warn(clippy::empty_loop)] + | ^^^^^^^^^^^^^^^^^^ -error: empty `loop {}` wastes CPU cycles +warning: empty `loop {}` wastes CPU cycles --> $DIR/empty_loop_no_std.rs:25:5 | LL | loop {} @@ -15,5 +19,5 @@ LL | loop {} | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/empty_structs_with_brackets.fixed b/tests/ui/empty_structs_with_brackets.fixed index 80f07603b8d4..0caa3c49cd66 100644 --- a/tests/ui/empty_structs_with_brackets.fixed +++ b/tests/ui/empty_structs_with_brackets.fixed @@ -1,9 +1,9 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::empty_structs_with_brackets)] #![allow(dead_code)] -pub struct MyEmptyStruct; // should trigger lint -struct MyEmptyTupleStruct; // should trigger lint +pub struct MyEmptyStruct {} // should trigger lint +struct MyEmptyTupleStruct(); // should trigger lint // should not trigger lint struct MyCfgStruct { diff --git a/tests/ui/empty_structs_with_brackets.rs b/tests/ui/empty_structs_with_brackets.rs index 1d1ed4c76902..0caa3c49cd66 100644 --- a/tests/ui/empty_structs_with_brackets.rs +++ b/tests/ui/empty_structs_with_brackets.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::empty_structs_with_brackets)] #![allow(dead_code)] diff --git a/tests/ui/empty_structs_with_brackets.stderr b/tests/ui/empty_structs_with_brackets.stderr index 0308cb5571af..7b24d001db8c 100644 --- a/tests/ui/empty_structs_with_brackets.stderr +++ b/tests/ui/empty_structs_with_brackets.stderr @@ -1,13 +1,17 @@ -error: found empty brackets on struct declaration +warning: found empty brackets on struct declaration --> $DIR/empty_structs_with_brackets.rs:5:25 | LL | pub struct MyEmptyStruct {} // should trigger lint | ^^^ | - = note: `-D clippy::empty-structs-with-brackets` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/empty_structs_with_brackets.rs:2:9 + | +LL | #![warn(clippy::empty_structs_with_brackets)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: remove the brackets -error: found empty brackets on struct declaration +warning: found empty brackets on struct declaration --> $DIR/empty_structs_with_brackets.rs:6:26 | LL | struct MyEmptyTupleStruct(); // should trigger lint @@ -15,5 +19,5 @@ LL | struct MyEmptyTupleStruct(); // should trigger lint | = help: remove the brackets -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/entry.fixed b/tests/ui/entry.fixed index dbe09e0ff3c6..7e82390605cc 100644 --- a/tests/ui/entry.fixed +++ b/tests/ui/entry.fixed @@ -1,5 +1,5 @@ -// needs-asm-support -// run-rustfix +//@needs-asm-support +//@run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index 30fed34fc5de..742c93225357 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -1,5 +1,5 @@ -// needs-asm-support -// run-rustfix +//@needs-asm-support +//@run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 2c4c49d2522c..37205cc24bb6 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,4 +1,4 @@ -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:25:5 | LL | / if !m.contains_key(&k) { @@ -6,9 +6,13 @@ LL | | m.insert(k, v); LL | | } | |_____^ help: try this: `m.entry(k).or_insert(v);` | - = note: `-D clippy::map-entry` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/entry.rs:5:9 + | +LL | #![warn(clippy::map_entry)] + | ^^^^^^^^^^^^^^^^^ -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:30:5 | LL | / if !m.contains_key(&k) { @@ -31,7 +35,7 @@ LL + } LL + }); | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:39:5 | LL | / if !m.contains_key(&k) { @@ -54,7 +58,7 @@ LL + } LL + }); | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:48:5 | LL | / if !m.contains_key(&k) { @@ -78,7 +82,7 @@ LL + } LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:58:5 | LL | / if !m.contains_key(&k) { @@ -95,7 +99,7 @@ LL + v LL + }); | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:64:5 | LL | / if !m.contains_key(&k) { @@ -121,7 +125,7 @@ LL + } LL + }); | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:76:5 | LL | / if !m.contains_key(&k) { @@ -145,7 +149,7 @@ LL + }; LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:86:5 | LL | / if !m.contains_key(&k) { @@ -186,7 +190,7 @@ LL + } LL + }); | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:120:5 | LL | / if !m.contains_key(&m!(k)) { @@ -194,7 +198,7 @@ LL | | m.insert(m!(k), m!(v)); LL | | } | |_____^ help: try this: `m.entry(m!(k)).or_insert_with(|| m!(v));` -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry.rs:152:5 | LL | / if !m.contains_key(&k) { @@ -213,5 +217,5 @@ LL + v LL + }); | -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/entry_btree.fixed b/tests/ui/entry_btree.fixed index 94979104556b..3baaacffd20d 100644 --- a/tests/ui/entry_btree.fixed +++ b/tests/ui/entry_btree.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_entry)] #![allow(dead_code)] diff --git a/tests/ui/entry_btree.rs b/tests/ui/entry_btree.rs index 080c1d959e89..770e8e91da23 100644 --- a/tests/ui/entry_btree.rs +++ b/tests/ui/entry_btree.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_entry)] #![allow(dead_code)] diff --git a/tests/ui/entry_btree.stderr b/tests/ui/entry_btree.stderr index 5c6fcdf1a28c..922951ede2af 100644 --- a/tests/ui/entry_btree.stderr +++ b/tests/ui/entry_btree.stderr @@ -1,4 +1,4 @@ -error: usage of `contains_key` followed by `insert` on a `BTreeMap` +warning: usage of `contains_key` followed by `insert` on a `BTreeMap` --> $DIR/entry_btree.rs:12:5 | LL | / if !m.contains_key(&k) { @@ -7,7 +7,11 @@ LL | | foo(); LL | | } | |_____^ | - = note: `-D clippy::map-entry` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/entry_btree.rs:3:9 + | +LL | #![warn(clippy::map_entry)] + | ^^^^^^^^^^^^^^^^^ help: try this | LL ~ if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) { @@ -16,5 +20,5 @@ LL + foo(); LL + } | -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/entry_with_else.fixed b/tests/ui/entry_with_else.fixed index 2332fa6313ff..71fe04fd6484 100644 --- a/tests/ui/entry_with_else.fixed +++ b/tests/ui/entry_with_else.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] diff --git a/tests/ui/entry_with_else.rs b/tests/ui/entry_with_else.rs index 2ff0c038efe2..80f74649a603 100644 --- a/tests/ui/entry_with_else.rs +++ b/tests/ui/entry_with_else.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)] #![warn(clippy::map_entry)] diff --git a/tests/ui/entry_with_else.stderr b/tests/ui/entry_with_else.stderr index e0f6671b460e..2efff7e5eb21 100644 --- a/tests/ui/entry_with_else.stderr +++ b/tests/ui/entry_with_else.stderr @@ -1,4 +1,4 @@ -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:16:5 | LL | / if !m.contains_key(&k) { @@ -8,7 +8,11 @@ LL | | m.insert(k, v2); LL | | } | |_____^ | - = note: `-D clippy::map-entry` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/entry_with_else.rs:4:9 + | +LL | #![warn(clippy::map_entry)] + | ^^^^^^^^^^^^^^^^^ help: try this | LL ~ match m.entry(k) { @@ -21,7 +25,7 @@ LL + } LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:22:5 | LL | / if m.contains_key(&k) { @@ -43,7 +47,7 @@ LL + } LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:28:5 | LL | / if !m.contains_key(&k) { @@ -62,7 +66,7 @@ LL + foo(); LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:34:5 | LL | / if !m.contains_key(&k) { @@ -81,7 +85,7 @@ LL + foo(); LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:40:5 | LL | / if !m.contains_key(&k) { @@ -103,7 +107,7 @@ LL + } LL + } | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:46:5 | LL | / if m.contains_key(&k) { @@ -126,7 +130,7 @@ LL + } LL ~ }; | -error: usage of `contains_key` followed by `insert` on a `HashMap` +warning: usage of `contains_key` followed by `insert` on a `HashMap` --> $DIR/entry_with_else.rs:52:5 | LL | / if m.contains_key(&k) { @@ -147,5 +151,5 @@ LL + None LL ~ }; | -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/enum_clike_unportable_variant.rs b/tests/ui/enum_clike_unportable_variant.rs index 7d6842f5b542..abe42a2305f5 100644 --- a/tests/ui/enum_clike_unportable_variant.rs +++ b/tests/ui/enum_clike_unportable_variant.rs @@ -1,4 +1,4 @@ -// ignore-x86 +//@ignore-target-x86 #![warn(clippy::enum_clike_unportable_variant)] #![allow(unused, non_upper_case_globals)] diff --git a/tests/ui/enum_clike_unportable_variant.stderr b/tests/ui/enum_clike_unportable_variant.stderr index 5935eea5e036..8248d1e24bc6 100644 --- a/tests/ui/enum_clike_unportable_variant.stderr +++ b/tests/ui/enum_clike_unportable_variant.stderr @@ -1,58 +1,62 @@ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:8:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/enum_clike_unportable_variant.rs:3:9 + | +LL | #![warn(clippy::enum_clike_unportable_variant)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:15:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:18:5 | LL | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:25:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:26:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:28:5 | LL | C = (i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:34:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:35:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ -error: C-like enum variant discriminant is not portable to 32-bit targets +warning: C-like enum variant discriminant is not portable to 32-bit targets --> $DIR/enum_clike_unportable_variant.rs:40:5 | LL | X = ::Number, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/enum_glob_use.fixed b/tests/ui/enum_glob_use.fixed index a98216758bb9..419370ffb1d2 100644 --- a/tests/ui/enum_glob_use.fixed +++ b/tests/ui/enum_glob_use.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::enum_glob_use)] #![allow(unused)] diff --git a/tests/ui/enum_glob_use.rs b/tests/ui/enum_glob_use.rs index 5d929c9731d3..645ed98325c9 100644 --- a/tests/ui/enum_glob_use.rs +++ b/tests/ui/enum_glob_use.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::enum_glob_use)] #![allow(unused)] diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 69531aed39bd..dee849f7a031 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,22 +1,26 @@ -error: usage of wildcard import for enum variants +warning: usage of wildcard import for enum variants --> $DIR/enum_glob_use.rs:7:5 | LL | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::cmp::Ordering::Less` | - = note: `-D clippy::enum-glob-use` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/enum_glob_use.rs:3:9 + | +LL | #![warn(clippy::enum_glob_use)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: usage of wildcard import for enum variants +warning: usage of wildcard import for enum variants --> $DIR/enum_glob_use.rs:13:5 | LL | use self::Enum::*; | ^^^^^^^^^^^^^ help: try: `self::Enum::Foo` -error: usage of wildcard import for enum variants +warning: usage of wildcard import for enum variants --> $DIR/enum_glob_use.rs:17:13 | LL | use crate::Enum::*; | ^^^^^^^^^^^^^^ help: try: `crate::Enum::Foo` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 7342aff80f01..c5a617afaf6c 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,12 +1,16 @@ -error: variant name ends with the enum's name +warning: variant name ends with the enum's name --> $DIR/enum_variants.rs:15:5 | LL | cFoo, | ^^^^ | - = note: `-D clippy::enum-variant-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/enum_variants.rs:1:9 + | +LL | #![warn(clippy::enum_variant_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: all variants have the same prefix: `c` +warning: all variants have the same prefix: `c` --> $DIR/enum_variants.rs:14:1 | LL | / enum Foo { @@ -18,25 +22,25 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: variant name starts with the enum's name +warning: variant name starts with the enum's name --> $DIR/enum_variants.rs:26:5 | LL | FoodGood, | ^^^^^^^^ -error: variant name starts with the enum's name +warning: variant name starts with the enum's name --> $DIR/enum_variants.rs:27:5 | LL | FoodMiddle, | ^^^^^^^^^^ -error: variant name starts with the enum's name +warning: variant name starts with the enum's name --> $DIR/enum_variants.rs:28:5 | LL | FoodBad, | ^^^^^^^ -error: all variants have the same prefix: `Food` +warning: all variants have the same prefix: `Food` --> $DIR/enum_variants.rs:25:1 | LL | / enum Food { @@ -48,7 +52,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: all variants have the same prefix: `CallType` +warning: all variants have the same prefix: `CallType` --> $DIR/enum_variants.rs:35:1 | LL | / enum BadCallType { @@ -60,7 +64,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: all variants have the same prefix: `Constant` +warning: all variants have the same prefix: `Constant` --> $DIR/enum_variants.rs:47:1 | LL | / enum Consts { @@ -72,7 +76,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: all variants have the same prefix: `C` +warning: all variants have the same prefix: `C` --> $DIR/enum_variants.rs:59:1 | LL | / enum Something { @@ -84,7 +88,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: all variants have the same prefix: `WithOut` +warning: all variants have the same prefix: `WithOut` --> $DIR/enum_variants.rs:81:1 | LL | / enum Seallll { @@ -96,7 +100,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: all variants have the same postfix: `IData` +warning: all variants have the same postfix: `IData` --> $DIR/enum_variants.rs:136:1 | LL | / enum IDataRequest { @@ -108,7 +112,7 @@ LL | | } | = help: remove the postfixes and use full paths to the variants instead of glob imports -error: all variants have the same postfix: `HIData` +warning: all variants have the same postfix: `HIData` --> $DIR/enum_variants.rs:142:1 | LL | / enum HIDataRequest { @@ -120,7 +124,7 @@ LL | | } | = help: remove the postfixes and use full paths to the variants instead of glob imports -error: all variants have the same prefix: `_Type` +warning: all variants have the same prefix: `_Type` --> $DIR/enum_variants.rs:162:5 | LL | / enum DoLint { @@ -133,7 +137,7 @@ LL | | } | = help: remove the prefixes and use full paths to the variants instead of glob imports -error: all variants have the same postfix: `Type` +warning: all variants have the same postfix: `Type` --> $DIR/enum_variants.rs:169:5 | LL | / enum DoLintToo { @@ -145,5 +149,5 @@ LL | | } | = help: remove the postfixes and use full paths to the variants instead of glob imports -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/eprint_with_newline.rs b/tests/ui/eprint_with_newline.rs index de5e121be877..eb90a06dd7f6 100644 --- a/tests/ui/eprint_with_newline.rs +++ b/tests/ui/eprint_with_newline.rs @@ -1,12 +1,12 @@ #![allow(clippy::print_literal)] -#![warn(clippy::print_with_newline)] +#![deny(clippy::print_with_newline)] fn main() { - eprint!("Hello\n"); - eprint!("Hello {}\n", "world"); - eprint!("Hello {} {}\n", "world", "#2"); - eprint!("{}\n", 1265); - eprint!("\n"); + eprint!("Hello\n"); //~ ERROR: using `eprint!()` with a format string that ends in a single newline + eprint!("Hello {}\n", "world"); //~ ERROR: using `eprint!()` with a format string that ends in a single newline + eprint!("Hello {} {}\n", "world", "#2"); //~ ERROR: using `eprint!()` with a format string that ends in a single newline + eprint!("{}\n", 1265); //~ ERROR: using `eprint!()` with a format string that ends in a single newline + eprint!("\n"); //~ ERROR: using `eprint!()` with a format string that ends in a single newline // these are all fine eprint!(""); @@ -25,7 +25,7 @@ fn main() { // Escaping eprint!("\\n"); // #3514 - eprint!("\\\n"); // should fail + eprint!("\\\n"); //~ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("\\\\n"); // Raw strings @@ -33,10 +33,12 @@ fn main() { // Literal newlines should also fail eprint!( + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline " " ); eprint!( + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline r" " ); @@ -44,7 +46,7 @@ fn main() { // Don't warn on CRLF (#4208) eprint!("\r\n"); eprint!("foo\r\n"); - eprint!("\\r\n"); //~ ERROR + eprint!("\\r\n"); //~ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("foo\rbar\n"); // Ignore expanded format strings diff --git a/tests/ui/eprint_with_newline.stderr b/tests/ui/eprint_with_newline.stderr index 0eefb9f0ca97..1506ce9c6985 100644 --- a/tests/ui/eprint_with_newline.stderr +++ b/tests/ui/eprint_with_newline.stderr @@ -1,80 +1,85 @@ error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:5:5 | -LL | eprint!("Hello/n"); +LL | eprint!("Hello\n"); | ^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::print-with-newline` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/eprint_with_newline.rs:2:9 + | +LL | #![deny(clippy::print_with_newline)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `eprintln!` instead | -LL - eprint!("Hello/n"); +LL - eprint!("Hello\n"); LL + eprintln!("Hello"); | error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:6:5 | -LL | eprint!("Hello {}/n", "world"); +LL | eprint!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `eprintln!` instead | -LL - eprint!("Hello {}/n", "world"); +LL - eprint!("Hello {}\n", "world"); LL + eprintln!("Hello {}", "world"); | error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:7:5 | -LL | eprint!("Hello {} {}/n", "world", "#2"); +LL | eprint!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `eprintln!` instead | -LL - eprint!("Hello {} {}/n", "world", "#2"); +LL - eprint!("Hello {} {}\n", "world", "#2"); LL + eprintln!("Hello {} {}", "world", "#2"); | error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:8:5 | -LL | eprint!("{}/n", 1265); +LL | eprint!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^ | help: use `eprintln!` instead | -LL - eprint!("{}/n", 1265); +LL - eprint!("{}\n", 1265); LL + eprintln!("{}", 1265); | error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:9:5 | -LL | eprint!("/n"); +LL | eprint!("\n"); | ^^^^^^^^^^^^^ | help: use `eprintln!` instead | -LL - eprint!("/n"); +LL - eprint!("\n"); LL + eprintln!(); | error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:28:5 | -LL | eprint!("//n"); // should fail +LL | eprint!("\\\n"); | ^^^^^^^^^^^^^^^ | help: use `eprintln!` instead | -LL - eprint!("//n"); // should fail -LL + eprintln!("/"); // should fail +LL - eprint!("\\\n"); +LL + eprintln!("\\"); | error: using `eprint!()` with a format string that ends in a single newline --> $DIR/eprint_with_newline.rs:35:5 | LL | / eprint!( +LL | | LL | | " LL | | " LL | | ); @@ -83,13 +88,15 @@ LL | | ); help: use `eprintln!` instead | LL ~ eprintln!( +LL | LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:39:5 + --> $DIR/eprint_with_newline.rs:40:5 | LL | / eprint!( +LL | | LL | | r" LL | | " LL | | ); @@ -98,19 +105,20 @@ LL | | ); help: use `eprintln!` instead | LL ~ eprintln!( +LL | LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:47:5 + --> $DIR/eprint_with_newline.rs:49:5 | -LL | eprint!("/r/n"); //~ ERROR +LL | eprint!("\\r\n"); | ^^^^^^^^^^^^^^^^ | help: use `eprintln!` instead | -LL - eprint!("/r/n"); //~ ERROR -LL + eprintln!("/r"); //~ ERROR +LL - eprint!("\\r\n"); +LL + eprintln!("\\r"); | error: aborting due to 9 previous errors diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index e73795502652..cdd33ebe582f 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -1,4 +1,4 @@ -// compile-flags: --test +//@compile-flags: --test #![warn(clippy::eq_op)] #![allow(clippy::double_parens, clippy::identity_op, clippy::nonminimal_bool)] diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index d365ab27edc2..dc2f3e069f37 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -1,172 +1,176 @@ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:9:13 | LL | let _ = 1 == 1; | ^^^^^^ | - = note: `-D clippy::eq-op` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/eq_op.rs:3:9 + | +LL | #![warn(clippy::eq_op)] + | ^^^^^^^^^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:10:13 | LL | let _ = "no" == "no"; | ^^^^^^^^^^^^ -error: equal expressions as operands to `!=` +warning: equal expressions as operands to `!=` --> $DIR/eq_op.rs:12:13 | LL | let _ = false != false; | ^^^^^^^^^^^^^^ -error: equal expressions as operands to `<` +warning: equal expressions as operands to `<` --> $DIR/eq_op.rs:13:13 | LL | let _ = 1.5 < 1.5; | ^^^^^^^^^ -error: equal expressions as operands to `>=` +warning: equal expressions as operands to `>=` --> $DIR/eq_op.rs:14:13 | LL | let _ = 1u64 >= 1u64; | ^^^^^^^^^^^^ -error: equal expressions as operands to `&` +warning: equal expressions as operands to `&` --> $DIR/eq_op.rs:17:13 | LL | let _ = (1u32 as u64) & (1u32 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `^` +warning: equal expressions as operands to `^` --> $DIR/eq_op.rs:20:17 | LL | let _ = 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `<` +warning: equal expressions as operands to `<` --> $DIR/eq_op.rs:24:13 | LL | let _ = (-(2) < -(2)); | ^^^^^^^^^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:25:13 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `&` +warning: equal expressions as operands to `&` --> $DIR/eq_op.rs:25:14 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `&` +warning: equal expressions as operands to `&` --> $DIR/eq_op.rs:25:35 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:26:13 | LL | let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `!=` +warning: equal expressions as operands to `!=` --> $DIR/eq_op.rs:29:13 | LL | let _ = ([1] != [1]); | ^^^^^^^^^^^^ -error: equal expressions as operands to `!=` +warning: equal expressions as operands to `!=` --> $DIR/eq_op.rs:30:13 | LL | let _ = ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:34:13 | LL | let _ = 1 + 1 == 2; | ^^^^^^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:35:13 | LL | let _ = 1 - 1 == 0; | ^^^^^^^^^^ -error: equal expressions as operands to `-` +warning: equal expressions as operands to `-` --> $DIR/eq_op.rs:35:13 | LL | let _ = 1 - 1 == 0; | ^^^^^ -error: equal expressions as operands to `-` +warning: equal expressions as operands to `-` --> $DIR/eq_op.rs:37:13 | LL | let _ = 1 - 1; | ^^^^^ -error: equal expressions as operands to `/` +warning: equal expressions as operands to `/` --> $DIR/eq_op.rs:38:13 | LL | let _ = 1 / 1; | ^^^^^ -error: equal expressions as operands to `&&` +warning: equal expressions as operands to `&&` --> $DIR/eq_op.rs:39:13 | LL | let _ = true && true; | ^^^^^^^^^^^^ -error: equal expressions as operands to `||` +warning: equal expressions as operands to `||` --> $DIR/eq_op.rs:41:13 | LL | let _ = true || true; | ^^^^^^^^^^^^ -error: equal expressions as operands to `&&` +warning: equal expressions as operands to `&&` --> $DIR/eq_op.rs:46:13 | LL | let _ = a == b && b == a; | ^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `&&` +warning: equal expressions as operands to `&&` --> $DIR/eq_op.rs:47:13 | LL | let _ = a != b && b != a; | ^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `&&` +warning: equal expressions as operands to `&&` --> $DIR/eq_op.rs:48:13 | LL | let _ = a < b && b > a; | ^^^^^^^^^^^^^^ -error: equal expressions as operands to `&&` +warning: equal expressions as operands to `&&` --> $DIR/eq_op.rs:49:13 | LL | let _ = a <= b && b >= a; | ^^^^^^^^^^^^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:52:13 | LL | let _ = a == a; | ^^^^^^ -error: equal expressions as operands to `/` +warning: equal expressions as operands to `/` --> $DIR/eq_op.rs:62:20 | LL | const D: u32 = A / A; | ^^^^^ -error: equal expressions as operands to `==` +warning: equal expressions as operands to `==` --> $DIR/eq_op.rs:93:5 | LL | (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 28 previous errors +warning: 28 warnings emitted diff --git a/tests/ui/eq_op_macros.stderr b/tests/ui/eq_op_macros.stderr index cd9f1826e59b..1ec018f5e4ad 100644 --- a/tests/ui/eq_op_macros.stderr +++ b/tests/ui/eq_op_macros.stderr @@ -1,4 +1,4 @@ -error: identical args used in this `assert_eq!` macro call +warning: identical args used in this `assert_eq!` macro call --> $DIR/eq_op_macros.rs:7:20 | LL | assert_eq!(a, a); @@ -7,10 +7,14 @@ LL | assert_eq!(a, a); LL | assert_in_macro_def!(); | ---------------------- in this macro invocation | - = note: `-D clippy::eq-op` implied by `-D warnings` - = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) +note: the lint level is defined here + --> $DIR/eq_op_macros.rs:1:9 + | +LL | #![warn(clippy::eq_op)] + | ^^^^^^^^^^^^^ + = note: this warning originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) -error: identical args used in this `assert_ne!` macro call +warning: identical args used in this `assert_ne!` macro call --> $DIR/eq_op_macros.rs:8:20 | LL | assert_ne!(a, a); @@ -19,9 +23,9 @@ LL | assert_ne!(a, a); LL | assert_in_macro_def!(); | ---------------------- in this macro invocation | - = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) -error: identical args used in this `debug_assert_eq!` macro call +warning: identical args used in this `debug_assert_eq!` macro call --> $DIR/eq_op_macros.rs:9:26 | LL | debug_assert_eq!(a, a); @@ -30,9 +34,9 @@ LL | debug_assert_eq!(a, a); LL | assert_in_macro_def!(); | ---------------------- in this macro invocation | - = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) -error: identical args used in this `debug_assert_ne!` macro call +warning: identical args used in this `debug_assert_ne!` macro call --> $DIR/eq_op_macros.rs:10:26 | LL | debug_assert_ne!(a, a); @@ -41,55 +45,55 @@ LL | debug_assert_ne!(a, a); LL | assert_in_macro_def!(); | ---------------------- in this macro invocation | - = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info) -error: identical args used in this `assert_eq!` macro call +warning: identical args used in this `assert_eq!` macro call --> $DIR/eq_op_macros.rs:22:16 | LL | assert_eq!(a, a); | ^^^^ -error: identical args used in this `assert_eq!` macro call +warning: identical args used in this `assert_eq!` macro call --> $DIR/eq_op_macros.rs:23:16 | LL | assert_eq!(a + 1, a + 1); | ^^^^^^^^^^^^ -error: identical args used in this `assert_ne!` macro call +warning: identical args used in this `assert_ne!` macro call --> $DIR/eq_op_macros.rs:30:16 | LL | assert_ne!(a, a); | ^^^^ -error: identical args used in this `assert_ne!` macro call +warning: identical args used in this `assert_ne!` macro call --> $DIR/eq_op_macros.rs:31:16 | LL | assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ -error: identical args used in this `debug_assert_eq!` macro call +warning: identical args used in this `debug_assert_eq!` macro call --> $DIR/eq_op_macros.rs:38:22 | LL | debug_assert_eq!(a, a); | ^^^^ -error: identical args used in this `debug_assert_eq!` macro call +warning: identical args used in this `debug_assert_eq!` macro call --> $DIR/eq_op_macros.rs:39:22 | LL | debug_assert_eq!(a + 1, a + 1); | ^^^^^^^^^^^^ -error: identical args used in this `debug_assert_ne!` macro call +warning: identical args used in this `debug_assert_ne!` macro call --> $DIR/eq_op_macros.rs:46:22 | LL | debug_assert_ne!(a, a); | ^^^^ -error: identical args used in this `debug_assert_ne!` macro call +warning: identical args used in this `debug_assert_ne!` macro call --> $DIR/eq_op_macros.rs:47:22 | LL | debug_assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/equatable_if_let.fixed b/tests/ui/equatable_if_let.fixed index 9af2ba962720..5219c4f11d83 100644 --- a/tests/ui/equatable_if_let.fixed +++ b/tests/ui/equatable_if_let.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![allow(unused_variables, dead_code, clippy::derive_partial_eq_without_eq)] #![warn(clippy::equatable_if_let)] diff --git a/tests/ui/equatable_if_let.rs b/tests/ui/equatable_if_let.rs index c3626c081dd5..625b7a12f3f9 100644 --- a/tests/ui/equatable_if_let.rs +++ b/tests/ui/equatable_if_let.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![allow(unused_variables, dead_code, clippy::derive_partial_eq_without_eq)] #![warn(clippy::equatable_if_let)] diff --git a/tests/ui/equatable_if_let.stderr b/tests/ui/equatable_if_let.stderr index 40ca75b8da22..8e37e1994146 100644 --- a/tests/ui/equatable_if_let.stderr +++ b/tests/ui/equatable_if_let.stderr @@ -1,88 +1,92 @@ -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:59:8 | LL | if let 2 = a {} | ^^^^^^^^^ help: try: `a == 2` | - = note: `-D clippy::equatable-if-let` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/equatable_if_let.rs:5:9 + | +LL | #![warn(clippy::equatable_if_let)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:60:8 | LL | if let Ordering::Greater = a.cmp(&b) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.cmp(&b) == Ordering::Greater` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:61:8 | LL | if let Some(2) = c {} | ^^^^^^^^^^^^^^^ help: try: `c == Some(2)` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:62:8 | LL | if let Struct { a: 2, b: false } = d {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d == (Struct { a: 2, b: false })` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:63:8 | LL | if let Enum::TupleVariant(32, 64) = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::TupleVariant(32, 64)` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:64:8 | LL | if let Enum::RecordVariant { a: 64, b: 32 } = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == (Enum::RecordVariant { a: 64, b: 32 })` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:65:8 | LL | if let Enum::UnitVariant = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::UnitVariant` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:66:8 | LL | if let (Enum::UnitVariant, &Struct { a: 2, b: false }) = (e, &d) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(e, &d) == (Enum::UnitVariant, &Struct { a: 2, b: false })` -error: this pattern matching can be expressed using `matches!` +warning: this pattern matching can be expressed using `matches!` --> $DIR/equatable_if_let.rs:75:8 | LL | if let NotPartialEq::A = f {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(f, NotPartialEq::A)` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:76:8 | LL | if let NotStructuralEq::A = g {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `g == NotStructuralEq::A` -error: this pattern matching can be expressed using `matches!` +warning: this pattern matching can be expressed using `matches!` --> $DIR/equatable_if_let.rs:77:8 | LL | if let Some(NotPartialEq::A) = Some(f) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(Some(f), Some(NotPartialEq::A))` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:78:8 | LL | if let Some(NotStructuralEq::A) = Some(g) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(g) == Some(NotStructuralEq::A)` -error: this pattern matching can be expressed using `matches!` +warning: this pattern matching can be expressed using `matches!` --> $DIR/equatable_if_let.rs:79:8 | LL | if let NoPartialEqStruct { a: 2, b: false } = h {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(h, NoPartialEqStruct { a: 2, b: false })` -error: this pattern matching can be expressed using equality +warning: this pattern matching can be expressed using equality --> $DIR/equatable_if_let.rs:86:8 | LL | if let m1!(x) = "abc" { | ^^^^^^^^^^^^^^^^^^ help: try: `"abc" == m1!(x)` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 165ed9bfe58b..e8d95b45e5a1 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,34 +1,38 @@ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:37:5 | LL | x * 0; | ^^^^^ | - = note: `-D clippy::erasing-op` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/erasing_op.rs:33:8 + | +LL | #[warn(clippy::erasing_op)] + | ^^^^^^^^^^^^^^^^^^ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:38:5 | LL | 0 & x; | ^^^^^ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:39:5 | LL | 0 / x; | ^^^^^ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:41:5 | LL | 0 * Vec1 { x: 5 }; | ^^^^^^^^^^^^^^^^^ -error: this operation will always return zero. This is likely not the intended outcome +warning: this operation will always return zero. This is likely not the intended outcome --> $DIR/erasing_op.rs:42:5 | LL | Vec1 { x: 5 } * 0; | ^^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/err_expect.fixed b/tests/ui/err_expect.fixed index b63cbd8a8e6b..6ade6f546891 100644 --- a/tests/ui/err_expect.fixed +++ b/tests/ui/err_expect.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] diff --git a/tests/ui/err_expect.rs b/tests/ui/err_expect.rs index c081a745fb40..a93fb59493fe 100644 --- a/tests/ui/err_expect.rs +++ b/tests/ui/err_expect.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] diff --git a/tests/ui/err_expect.stderr b/tests/ui/err_expect.stderr index 82c0754cfb00..87b7551c027d 100644 --- a/tests/ui/err_expect.stderr +++ b/tests/ui/err_expect.stderr @@ -1,16 +1,16 @@ -error: called `.err().expect()` on a `Result` value +warning: called `.err().expect()` on a `Result` value --> $DIR/err_expect.rs:12:16 | LL | test_debug.err().expect("Testing debug type"); | ^^^^^^^^^^^^ help: try: `expect_err` | - = note: `-D clippy::err-expect` implied by `-D warnings` + = note: `#[warn(clippy::err_expect)]` on by default -error: called `.err().expect()` on a `Result` value +warning: called `.err().expect()` on a `Result` value --> $DIR/err_expect.rs:27:7 | LL | x.err().expect("17"); | ^^^^^^^^^^^^ help: try: `expect_err` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed index dc129591eac4..b1baf462c0f8 100644 --- a/tests/ui/eta.fixed +++ b/tests/ui/eta.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)] #![allow(unused)] #![allow( diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index 025fd6a0b7af..e113c3d6cd6b 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)] #![allow(unused)] #![allow( diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index a521fb868607..48ead3215f9c 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,162 +1,170 @@ -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:28:27 | LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: replace the closure with the function itself: `foo` | - = note: `-D clippy::redundant-closure` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/eta.rs:2:9 + | +LL | #![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:32:40 | LL | let _: Option> = true.then(|| vec![]); // special case vec! | ^^^^^^^^^ help: replace the closure with `Vec::new`: `std::vec::Vec::new` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:33:35 | LL | let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? | ^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo2` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:34:26 | LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:41:27 | LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:87:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo` | - = note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/eta.rs:2:36 + | +LL | #![warn(clippy::redundant_closure, clippy::redundant_closure_for_method_calls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:88:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:90:42 | LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear()); | ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:94:29 | LL | let e = Some("str").map(|s| s.to_string()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:95:27 | LL | let e = Some('a').map(|s| s.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:97:65 | LL | let e: std::vec::Vec = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:160:22 | LL | requires_fn_once(|| x()); | ^^^^^^ help: replace the closure with the function itself: `x` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:167:27 | LL | let a = Some(1u8).map(|a| foo_ptr(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:172:27 | LL | let a = Some(1u8).map(|a| closure(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:204:28 | LL | x.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:205:28 | LL | y.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:206:28 | LL | z.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:213:21 | LL | Some(1).map(|n| closure(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:217:21 | LL | Some(1).map(|n| in_loop(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `in_loop` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:310:18 | LL | takes_fn_mut(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:313:19 | LL | takes_fn_once(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:317:26 | LL | move || takes_fn_mut(|| f_used_once()) | ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:329:19 | LL | array_opt.map(|a| a.as_slice()); | ^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8; 3]>::as_slice` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:332:19 | LL | slice_opt.map(|s| s.len()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8]>::len` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:335:17 | LL | ptr_opt.map(|p| p.is_null()); | ^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<*const usize>::is_null` -error: redundant closure +warning: redundant closure --> $DIR/eta.rs:339:17 | LL | dyn_opt.map(|d| d.method_on_dyn()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `::method_on_dyn` -error: aborting due to 26 previous errors +warning: 26 warnings emitted diff --git a/tests/ui/excessive_precision.fixed b/tests/ui/excessive_precision.fixed index b74bda182be9..0a07957386c2 100644 --- a/tests/ui/excessive_precision.fixed +++ b/tests/ui/excessive_precision.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::excessive_precision)] #![allow(dead_code, unused_variables, clippy::print_literal)] diff --git a/tests/ui/excessive_precision.rs b/tests/ui/excessive_precision.rs index 6e84a71f24cb..62a832caa67b 100644 --- a/tests/ui/excessive_precision.rs +++ b/tests/ui/excessive_precision.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::excessive_precision)] #![allow(dead_code, unused_variables, clippy::print_literal)] diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 42d9d4de193c..bbb314e2f86c 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -1,94 +1,98 @@ -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:15:26 | LL | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79_f32` | - = note: `-D clippy::excessive-precision` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/excessive_precision.rs:2:9 + | +LL | #![warn(clippy::excessive_precision)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:16:26 | LL | const BAD32_2: f32 = 0.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:17:26 | LL | const BAD32_3: f32 = 0.100_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:18:29 | LL | const BAD32_EDGE: f32 = 1.000_000_9; | ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:22:26 | LL | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:25:22 | LL | println!("{:?}", 8.888_888_888_888_888_888_888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:36:22 | LL | let bad32: f32 = 1.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:37:26 | LL | let bad32_suf: f32 = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:38:21 | LL | let bad32_inf = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:48:36 | LL | let bad_vec32: Vec = vec![0.123_456_789]; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:49:36 | LL | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:53:24 | LL | let bad_e32: f32 = 1.123_456_788_888e-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:56:27 | LL | let bad_bige32: f32 = 1.123_456_788_888E-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:65:13 | LL | let _ = 2.225_073_858_507_201_1e-308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-308_f64` -error: float has excessive precision +warning: float has excessive precision --> $DIR/excessive_precision.rs:68:13 | LL | let _ = 1.000_000_000_000_001e-324_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0_f64` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/exhaustive_items.fixed b/tests/ui/exhaustive_items.fixed index c209f5b4b727..2ca677e05f54 100644 --- a/tests/ui/exhaustive_items.fixed +++ b/tests/ui/exhaustive_items.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] +#![warn(clippy::exhaustive_enums, clippy::exhaustive_structs)] #![allow(unused)] fn main() { @@ -8,7 +8,6 @@ fn main() { } pub mod enums { - #[non_exhaustive] pub enum Exhaustive { Foo, Bar, @@ -18,7 +17,6 @@ pub mod enums { /// Some docs #[repr(C)] - #[non_exhaustive] pub enum ExhaustiveWithAttrs { Foo, Bar, @@ -54,7 +52,6 @@ pub mod enums { } pub mod structs { - #[non_exhaustive] pub struct Exhaustive { pub foo: u8, pub bar: String, diff --git a/tests/ui/exhaustive_items.rs b/tests/ui/exhaustive_items.rs index 6f59dbf2da59..2ca677e05f54 100644 --- a/tests/ui/exhaustive_items.rs +++ b/tests/ui/exhaustive_items.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] +#![warn(clippy::exhaustive_enums, clippy::exhaustive_structs)] #![allow(unused)] fn main() { diff --git a/tests/ui/exhaustive_items.stderr b/tests/ui/exhaustive_items.stderr index f46ebd477b8f..5f618543e8fc 100644 --- a/tests/ui/exhaustive_items.stderr +++ b/tests/ui/exhaustive_items.stderr @@ -1,4 +1,4 @@ -error: exported enums should not be exhaustive +warning: exported enums should not be exhaustive --> $DIR/exhaustive_items.rs:11:5 | LL | / pub enum Exhaustive { @@ -12,7 +12,7 @@ LL | | } note: the lint level is defined here --> $DIR/exhaustive_items.rs:3:9 | -LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] +LL | #![warn(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding #[non_exhaustive] | @@ -20,7 +20,7 @@ LL ~ #[non_exhaustive] LL ~ pub enum Exhaustive { | -error: exported enums should not be exhaustive +warning: exported enums should not be exhaustive --> $DIR/exhaustive_items.rs:20:5 | LL | / pub enum ExhaustiveWithAttrs { @@ -37,7 +37,7 @@ LL ~ #[non_exhaustive] LL ~ pub enum ExhaustiveWithAttrs { | -error: exported structs should not be exhaustive +warning: exported structs should not be exhaustive --> $DIR/exhaustive_items.rs:55:5 | LL | / pub struct Exhaustive { @@ -49,7 +49,7 @@ LL | | } note: the lint level is defined here --> $DIR/exhaustive_items.rs:3:35 | -LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] +LL | #![warn(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding #[non_exhaustive] | @@ -57,5 +57,5 @@ LL ~ #[non_exhaustive] LL ~ pub struct Exhaustive { | -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/exit1.stderr b/tests/ui/exit1.stderr index a8d3956aa27a..252d5375d36e 100644 --- a/tests/ui/exit1.stderr +++ b/tests/ui/exit1.stderr @@ -1,10 +1,14 @@ -error: usage of `process::exit` +warning: usage of `process::exit` --> $DIR/exit1.rs:5:9 | LL | std::process::exit(4); | ^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::exit` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/exit1.rs:1:8 + | +LL | #[warn(clippy::exit)] + | ^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/exit2.stderr b/tests/ui/exit2.stderr index 7263e156a9d2..82acd7ed3902 100644 --- a/tests/ui/exit2.stderr +++ b/tests/ui/exit2.stderr @@ -1,10 +1,14 @@ -error: usage of `process::exit` +warning: usage of `process::exit` --> $DIR/exit2.rs:4:5 | LL | std::process::exit(3); | ^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::exit` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/exit2.rs:1:8 + | +LL | #[warn(clippy::exit)] + | ^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/expect.stderr b/tests/ui/expect.stderr index c08e0dbbf744..3a9042977caf 100644 --- a/tests/ui/expect.stderr +++ b/tests/ui/expect.stderr @@ -1,13 +1,17 @@ -error: used `expect()` on an `Option` value +warning: used `expect()` on an `Option` value --> $DIR/expect.rs:5:13 | LL | let _ = opt.expect(""); | ^^^^^^^^^^^^^^ | = help: if this value is `None`, it will panic - = note: `-D clippy::expect-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/expect.rs:1:9 + | +LL | #![warn(clippy::expect_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: used `expect()` on a `Result` value +warning: used `expect()` on a `Result` value --> $DIR/expect.rs:10:13 | LL | let _ = res.expect(""); @@ -15,7 +19,7 @@ LL | let _ = res.expect(""); | = help: if this value is an `Err`, it will panic -error: used `expect_err()` on a `Result` value +warning: used `expect_err()` on a `Result` value --> $DIR/expect.rs:11:13 | LL | let _ = res.expect_err(""); @@ -23,5 +27,5 @@ LL | let _ = res.expect_err(""); | = help: if this value is an `Ok`, it will panic -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/expect_fun_call.fixed b/tests/ui/expect_fun_call.fixed index 15172ae345c2..8e97054fb6bc 100644 --- a/tests/ui/expect_fun_call.fixed +++ b/tests/ui/expect_fun_call.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::expect_fun_call)] #![allow(clippy::to_string_in_format_args, clippy::uninlined_format_args)] diff --git a/tests/ui/expect_fun_call.rs b/tests/ui/expect_fun_call.rs index 0f448d004174..31e6bcc7ff64 100644 --- a/tests/ui/expect_fun_call.rs +++ b/tests/ui/expect_fun_call.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::expect_fun_call)] #![allow(clippy::to_string_in_format_args, clippy::uninlined_format_args)] diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr index cb55e32aee02..1c1c65a892c7 100644 --- a/tests/ui/expect_fun_call.stderr +++ b/tests/ui/expect_fun_call.stderr @@ -1,94 +1,98 @@ -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:34:26 | LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` | - = note: `-D clippy::expect-fun-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/expect_fun_call.rs:2:9 + | +LL | #![warn(clippy::expect_fun_call)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:37:26 | LL | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:40:37 | LL | with_none_and_format_with_macro.expect(format!("Error {}: fake error", one!()).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", one!()))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:50:25 | LL | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:53:25 | LL | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:65:17 | LL | Some("foo").expect(format!("{} {}", 1, 2).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{} {}", 1, 2))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:86:21 | LL | Some("foo").expect(&get_string()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:87:21 | LL | Some("foo").expect(get_string().as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:88:21 | LL | Some("foo").expect(get_string().as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:90:21 | LL | Some("foo").expect(get_static_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_static_str()) })` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:91:21 | LL | Some("foo").expect(get_non_static_str(&0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:95:16 | LL | Some(true).expect(&format!("key {}, {}", 1, 2)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:101:17 | LL | opt_ref.expect(&format!("{:?}", opt_ref)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{:?}", opt_ref))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:105:20 | LL | format_capture.expect(&format!("{error_code}")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{error_code}"))` -error: use of `expect` followed by a function call +warning: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:108:30 | LL | format_capture_and_value.expect(&format!("{error_code}, {}", 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{error_code}, {}", 1))` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/expect_tool_lint_rfc_2383.rs b/tests/ui/expect_tool_lint_rfc_2383.rs index 018f875d60bf..e778eec119a1 100644 --- a/tests/ui/expect_tool_lint_rfc_2383.rs +++ b/tests/ui/expect_tool_lint_rfc_2383.rs @@ -1,4 +1,4 @@ -// check-pass +//@check-pass #![feature(lint_reasons)] //! This file tests the `#[expect]` attribute implementation for tool lints. The same //! file is used to test clippy and rustdoc. Any changes to this file should be synced diff --git a/tests/ui/expect_tool_lint_rfc_2383.stderr b/tests/ui/expect_tool_lint_rfc_2383.stderr index 7ce9e855b5e0..176aa9d4e69b 100644 --- a/tests/ui/expect_tool_lint_rfc_2383.stderr +++ b/tests/ui/expect_tool_lint_rfc_2383.stderr @@ -1,40 +1,40 @@ -error: this lint expectation is unfulfilled +warning: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:35:14 | LL | #[expect(dead_code)] | ^^^^^^^^^ | - = note: `-D unfulfilled-lint-expectations` implied by `-D warnings` + = note: `#[warn(unfulfilled_lint_expectations)]` on by default -error: this lint expectation is unfulfilled +warning: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:39:18 | LL | #[expect(illegal_floating_point_literal_pattern)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this lint expectation is unfulfilled +warning: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:113:14 | LL | #[expect(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^ -error: this lint expectation is unfulfilled +warning: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:120:14 | LL | #[expect(clippy::bytes_nth)] | ^^^^^^^^^^^^^^^^^ -error: this lint expectation is unfulfilled +warning: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:125:14 | LL | #[expect(clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this lint expectation is unfulfilled +warning: this lint expectation is unfulfilled --> $DIR/expect_tool_lint_rfc_2383.rs:130:14 | LL | #[expect(clippy::overly_complex_bool_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/explicit_auto_deref.fixed b/tests/ui/explicit_auto_deref.fixed index 5d40c850424f..71a5ed96d5c4 100644 --- a/tests/ui/explicit_auto_deref.fixed +++ b/tests/ui/explicit_auto_deref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(closure_lifetime_binder)] #![warn(clippy::explicit_auto_deref)] diff --git a/tests/ui/explicit_auto_deref.rs b/tests/ui/explicit_auto_deref.rs index 79e03f4d76c1..9d0cafa150f6 100644 --- a/tests/ui/explicit_auto_deref.rs +++ b/tests/ui/explicit_auto_deref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(closure_lifetime_binder)] #![warn(clippy::explicit_auto_deref)] diff --git a/tests/ui/explicit_auto_deref.stderr b/tests/ui/explicit_auto_deref.stderr index 91863abcc5d2..38de7363f0e0 100644 --- a/tests/ui/explicit_auto_deref.stderr +++ b/tests/ui/explicit_auto_deref.stderr @@ -1,238 +1,242 @@ -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:70:19 | LL | let _: &str = &*s; | ^^^ help: try this: `&s` | - = note: `-D clippy::explicit-auto-deref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/explicit_auto_deref.rs:4:9 + | +LL | #![warn(clippy::explicit_auto_deref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:71:19 | LL | let _: &str = &*{ String::new() }; | ^^^^^^^^^^^^^^^^^^^ help: try this: `&{ String::new() }` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:72:19 | LL | let _: &str = &mut *{ String::new() }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut { String::new() }` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:76:11 | LL | f_str(&*s); | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:80:13 | LL | f_str_t(&*s, &*s); // Don't lint second param. | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:83:24 | LL | let _: &Box = &**b; | ^^^^ help: try this: `&b` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:89:7 | LL | c(&*s); | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:95:9 | LL | &**x | ^^^^ help: try this: `x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:99:11 | LL | { &**x } | ^^^^ help: try this: `x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:103:9 | LL | &**{ x } | ^^^^^^^^ help: try this: `{ x }` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:107:9 | LL | &***x | ^^^^^ help: try this: `x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:124:12 | LL | f1(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:125:12 | LL | f2(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:126:12 | LL | f3(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:127:27 | LL | f4.callable_str()(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:128:12 | LL | f5(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:129:12 | LL | f6(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:130:27 | LL | f7.callable_str()(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:131:25 | LL | f8.callable_t()(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:132:12 | LL | f9(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:133:13 | LL | f10(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:134:26 | LL | f11.callable_t()(&*x); | ^^^ help: try this: `&x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:138:16 | LL | let _ = S1(&*s); | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:143:21 | LL | let _ = S2 { s: &*s }; | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:159:30 | LL | let _ = Self::S1(&**s); | ^^^^ help: try this: `s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:160:35 | LL | let _ = Self::S2 { s: &**s }; | ^^^^ help: try this: `s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:163:20 | LL | let _ = E1::S1(&*s); | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:164:25 | LL | let _ = E1::S2 { s: &*s }; | ^^^ help: try this: `&s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:182:13 | LL | let _ = (*b).foo; | ^^^^ help: try this: `b` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:183:13 | LL | let _ = (**b).foo; | ^^^^^ help: try this: `b` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:198:19 | LL | let _ = f_str(*ref_str); | ^^^^^^^^ help: try this: `ref_str` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:200:19 | LL | let _ = f_str(**ref_ref_str); | ^^^^^^^^^^^^^ help: try this: `ref_ref_str` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:210:13 | LL | f_str(&&*ref_str); // `needless_borrow` will suggest removing both references | ^^^^^^^^ help: try this: `ref_str` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:211:12 | LL | f_str(&&**ref_str); // `needless_borrow` will suggest removing only one reference | ^^^^^^^^^^ help: try this: `ref_str` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:220:41 | LL | let _ = || -> &'static str { return *s }; | ^^ help: try this: `s` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:239:9 | LL | &**x | ^^^^ help: try this: `x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:262:8 | LL | c1(*x); | ^^ help: try this: `x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:265:20 | LL | return *x; | ^^ help: try this: `x` -error: deref which would be done by auto-deref +warning: deref which would be done by auto-deref --> $DIR/explicit_auto_deref.rs:267:9 | LL | *x | ^^ help: try this: `x` -error: aborting due to 39 previous errors +warning: 39 warnings emitted diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index d3f3c626bbdf..1e2351551244 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -1,54 +1,58 @@ -error: the variable `_index` is used as a loop counter +warning: the variable `_index` is used as a loop counter --> $DIR/explicit_counter_loop.rs:7:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` | - = note: `-D clippy::explicit-counter-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/explicit_counter_loop.rs:1:9 + | +LL | #![warn(clippy::explicit_counter_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the variable `_index` is used as a loop counter +warning: the variable `_index` is used as a loop counter --> $DIR/explicit_counter_loop.rs:13:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` -error: the variable `_index` is used as a loop counter +warning: the variable `_index` is used as a loop counter --> $DIR/explicit_counter_loop.rs:18:5 | LL | for _v in &mut vec { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter_mut().enumerate()` -error: the variable `_index` is used as a loop counter +warning: the variable `_index` is used as a loop counter --> $DIR/explicit_counter_loop.rs:23:5 | LL | for _v in vec { | ^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.into_iter().enumerate()` -error: the variable `count` is used as a loop counter +warning: the variable `count` is used as a loop counter --> $DIR/explicit_counter_loop.rs:62:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` -error: the variable `count` is used as a loop counter +warning: the variable `count` is used as a loop counter --> $DIR/explicit_counter_loop.rs:73:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` -error: the variable `count` is used as a loop counter +warning: the variable `count` is used as a loop counter --> $DIR/explicit_counter_loop.rs:131:9 | LL | for _i in 3..10 { | ^^^^^^^^^^^^^^^ help: consider using: `for (count, _i) in (3..10).enumerate()` -error: the variable `idx_usize` is used as a loop counter +warning: the variable `idx_usize` is used as a loop counter --> $DIR/explicit_counter_loop.rs:171:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_usize, _item) in slice.iter().enumerate()` -error: the variable `idx_u32` is used as a loop counter +warning: the variable `idx_u32` is used as a loop counter --> $DIR/explicit_counter_loop.rs:183:9 | LL | for _item in slice { @@ -56,5 +60,5 @@ LL | for _item in slice { | = note: `idx_u32` is of type `u32`, making it ineligible for `Iterator::enumerate` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/explicit_deref_methods.fixed b/tests/ui/explicit_deref_methods.fixed index 6d32bbece1e5..77e9f5fc1fdf 100644 --- a/tests/ui/explicit_deref_methods.fixed +++ b/tests/ui/explicit_deref_methods.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::explicit_deref_methods)] #![allow(unused_variables)] #![allow( diff --git a/tests/ui/explicit_deref_methods.rs b/tests/ui/explicit_deref_methods.rs index 779909e42380..0c2cc7c2c3a6 100644 --- a/tests/ui/explicit_deref_methods.rs +++ b/tests/ui/explicit_deref_methods.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::explicit_deref_methods)] #![allow(unused_variables)] #![allow( diff --git a/tests/ui/explicit_deref_methods.stderr b/tests/ui/explicit_deref_methods.stderr index 4b10ed1377b0..797973e11fe5 100644 --- a/tests/ui/explicit_deref_methods.stderr +++ b/tests/ui/explicit_deref_methods.stderr @@ -1,76 +1,80 @@ -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:36:19 | LL | let b: &str = a.deref(); | ^^^^^^^^^ help: try this: `&*a` | - = note: `-D clippy::explicit-deref-methods` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/explicit_deref_methods.rs:2:9 + | +LL | #![warn(clippy::explicit_deref_methods)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: explicit `deref_mut` method call +warning: explicit `deref_mut` method call --> $DIR/explicit_deref_methods.rs:38:23 | LL | let b: &mut str = a.deref_mut(); | ^^^^^^^^^^^^^ help: try this: `&mut **a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:41:39 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try this: `&*a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:41:50 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try this: `&*a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:43:20 | LL | println!("{}", a.deref()); | ^^^^^^^^^ help: try this: `&*a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:46:11 | LL | match a.deref() { | ^^^^^^^^^ help: try this: `&*a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:50:28 | LL | let b: String = concat(a.deref()); | ^^^^^^^^^ help: try this: `&*a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:52:13 | LL | let b = just_return(a).deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `just_return(a)` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:54:28 | LL | let b: String = concat(just_return(a).deref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `just_return(a)` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:56:19 | LL | let b: &str = a.deref().deref(); | ^^^^^^^^^^^^^^^^^ help: try this: `&**a` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:59:13 | LL | let b = opt_a.unwrap().deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&*opt_a.unwrap()` -error: explicit `deref` method call +warning: explicit `deref` method call --> $DIR/explicit_deref_methods.rs:85:31 | LL | let b: &str = expr_deref!(a.deref()); | ^^^^^^^^^ help: try this: `&*a` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/explicit_write.fixed b/tests/ui/explicit_write.fixed index 862c3fea9ee8..213485bc221b 100644 --- a/tests/ui/explicit_write.fixed +++ b/tests/ui/explicit_write.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::explicit_write)] #![allow(unused_imports)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/explicit_write.rs b/tests/ui/explicit_write.rs index 41d7c2255738..64acd7108bfa 100644 --- a/tests/ui/explicit_write.rs +++ b/tests/ui/explicit_write.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::explicit_write)] #![allow(unused_imports)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index 457e9c627180..9409b1cc14e3 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,82 +1,86 @@ -error: use of `write!(stdout(), ...).unwrap()` +warning: use of `write!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:24:9 | LL | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")` | - = note: `-D clippy::explicit-write` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/explicit_write.rs:2:9 + | +LL | #![warn(clippy::explicit_write)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: use of `write!(stderr(), ...).unwrap()` +warning: use of `write!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:25:9 | LL | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")` -error: use of `writeln!(stdout(), ...).unwrap()` +warning: use of `writeln!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:26:9 | LL | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test")` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:27:9 | LL | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test")` -error: use of `stdout().write_fmt(...).unwrap()` +warning: use of `stdout().write_fmt(...).unwrap()` --> $DIR/explicit_write.rs:28:9 | LL | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `print!("test")` -error: use of `stderr().write_fmt(...).unwrap()` +warning: use of `stderr().write_fmt(...).unwrap()` --> $DIR/explicit_write.rs:29:9 | LL | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprint!("test")` -error: use of `writeln!(stdout(), ...).unwrap()` +warning: use of `writeln!(stdout(), ...).unwrap()` --> $DIR/explicit_write.rs:32:9 | -LL | writeln!(std::io::stdout(), "test/ntest").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test/ntest")` +LL | writeln!(std::io::stdout(), "test\ntest").unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `println!("test\ntest")` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:33:9 | -LL | writeln!(std::io::stderr(), "test/ntest").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test/ntest")` +LL | writeln!(std::io::stderr(), "test\ntest").unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("test\ntest")` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:36:9 | LL | writeln!(std::io::stderr(), "with {}", value).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {}", value)` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:37:9 | LL | writeln!(std::io::stderr(), "with {} {}", 2, value).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {} {}", 2, value)` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:38:9 | LL | writeln!(std::io::stderr(), "with {value}").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("with {value}")` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:39:9 | LL | writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("macro arg {}", one!())` -error: use of `writeln!(stderr(), ...).unwrap()` +warning: use of `writeln!(stderr(), ...).unwrap()` --> $DIR/explicit_write.rs:41:9 | LL | writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `eprintln!("{:w$}", value, w = width)` -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/extend_with_drain.fixed b/tests/ui/extend_with_drain.fixed index 71ebad24c16e..594f2f6d4135 100644 --- a/tests/ui/extend_with_drain.fixed +++ b/tests/ui/extend_with_drain.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::extend_with_drain)] #![allow(clippy::iter_with_drain)] use std::collections::BinaryHeap; diff --git a/tests/ui/extend_with_drain.rs b/tests/ui/extend_with_drain.rs index e9f011abb0e8..3e2ad02052d7 100644 --- a/tests/ui/extend_with_drain.rs +++ b/tests/ui/extend_with_drain.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::extend_with_drain)] #![allow(clippy::iter_with_drain)] use std::collections::BinaryHeap; diff --git a/tests/ui/extend_with_drain.stderr b/tests/ui/extend_with_drain.stderr index da14ddb25b37..3f9b055e711a 100644 --- a/tests/ui/extend_with_drain.stderr +++ b/tests/ui/extend_with_drain.stderr @@ -1,28 +1,32 @@ -error: use of `extend` instead of `append` for adding the full range of a second vector +warning: use of `extend` instead of `append` for adding the full range of a second vector --> $DIR/extend_with_drain.rs:9:5 | LL | vec2.extend(vec1.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec2.append(&mut vec1)` | - = note: `-D clippy::extend-with-drain` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/extend_with_drain.rs:2:9 + | +LL | #![warn(clippy::extend_with_drain)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `extend` instead of `append` for adding the full range of a second vector +warning: use of `extend` instead of `append` for adding the full range of a second vector --> $DIR/extend_with_drain.rs:14:5 | LL | vec4.extend(vec3.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec4.append(&mut vec3)` -error: use of `extend` instead of `append` for adding the full range of a second vector +warning: use of `extend` instead of `append` for adding the full range of a second vector --> $DIR/extend_with_drain.rs:18:5 | LL | vec11.extend(return_vector().drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec11.append(&mut return_vector())` -error: use of `extend` instead of `append` for adding the full range of a second vector +warning: use of `extend` instead of `append` for adding the full range of a second vector --> $DIR/extend_with_drain.rs:49:5 | LL | y.extend(ref_x.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `y.append(ref_x)` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/extra_unused_lifetimes.rs b/tests/ui/extra_unused_lifetimes.rs index d6631e012900..50abe89da893 100644 --- a/tests/ui/extra_unused_lifetimes.rs +++ b/tests/ui/extra_unused_lifetimes.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_derive.rs +//@aux-build:proc_macro_derive.rs:proc-macro #![allow( unused, diff --git a/tests/ui/extra_unused_lifetimes.stderr b/tests/ui/extra_unused_lifetimes.stderr index 26ebc3976dfc..f24bbdc60264 100644 --- a/tests/ui/extra_unused_lifetimes.stderr +++ b/tests/ui/extra_unused_lifetimes.stderr @@ -1,40 +1,44 @@ -error: this lifetime isn't used in the function definition +warning: this lifetime isn't used in the function definition --> $DIR/extra_unused_lifetimes.rs:19:14 | LL | fn unused_lt<'a>(x: u8) {} | ^^ | - = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/extra_unused_lifetimes.rs:10:9 + | +LL | #![warn(clippy::extra_unused_lifetimes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this lifetime isn't used in the function definition +warning: this lifetime isn't used in the function definition --> $DIR/extra_unused_lifetimes.rs:46:10 | LL | fn x<'a>(&self) {} | ^^ -error: this lifetime isn't used in the function definition +warning: this lifetime isn't used in the function definition --> $DIR/extra_unused_lifetimes.rs:72:22 | LL | fn unused_lt<'a>(x: u8) {} | ^^ -error: this lifetime isn't used in the impl +warning: this lifetime isn't used in the impl --> $DIR/extra_unused_lifetimes.rs:83:10 | LL | impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar { | ^^ -error: this lifetime isn't used in the impl +warning: this lifetime isn't used in the impl --> $DIR/extra_unused_lifetimes.rs:89:10 | LL | impl<'b> Scalar { | ^^ -error: this lifetime isn't used in the function definition +warning: this lifetime isn't used in the function definition --> $DIR/extra_unused_lifetimes.rs:90:26 | LL | pub fn something<'c>() -> Self { | ^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/extra_unused_type_parameters.stderr b/tests/ui/extra_unused_type_parameters.stderr index 86c88fc9bf00..d2d721dd5725 100644 --- a/tests/ui/extra_unused_type_parameters.stderr +++ b/tests/ui/extra_unused_type_parameters.stderr @@ -1,13 +1,17 @@ -error: type parameter goes unused in function definition +warning: type parameter goes unused in function definition --> $DIR/extra_unused_type_parameters.rs:4:13 | LL | fn unused_ty(x: u8) { | ^^^ | = help: consider removing the parameter - = note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/extra_unused_type_parameters.rs:2:9 + | +LL | #![warn(clippy::extra_unused_type_parameters)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type parameters go unused in function definition +warning: type parameters go unused in function definition --> $DIR/extra_unused_type_parameters.rs:8:16 | LL | fn unused_multi(x: u8) { @@ -15,7 +19,7 @@ LL | fn unused_multi(x: u8) { | = help: consider removing the parameters -error: type parameter goes unused in function definition +warning: type parameter goes unused in function definition --> $DIR/extra_unused_type_parameters.rs:12:23 | LL | fn unused_with_lt<'a, T>(x: &'a u8) { @@ -23,7 +27,7 @@ LL | fn unused_with_lt<'a, T>(x: &'a u8) { | = help: consider removing the parameter -error: type parameter goes unused in function definition +warning: type parameter goes unused in function definition --> $DIR/extra_unused_type_parameters.rs:24:19 | LL | fn unused_bounded(x: U) { @@ -31,7 +35,7 @@ LL | fn unused_bounded(x: U) { | = help: consider removing the parameter -error: type parameter goes unused in function definition +warning: type parameter goes unused in function definition --> $DIR/extra_unused_type_parameters.rs:28:24 | LL | fn unused_where_clause(x: U) @@ -39,7 +43,7 @@ LL | fn unused_where_clause(x: U) | = help: consider removing the parameter -error: type parameters go unused in function definition +warning: type parameters go unused in function definition --> $DIR/extra_unused_type_parameters.rs:35:16 | LL | fn some_unused, E>(b: B, c: C) { @@ -47,7 +51,7 @@ LL | fn some_unused, E>(b: B, c: C) { | = help: consider removing the parameters -error: type parameter goes unused in function definition +warning: type parameter goes unused in function definition --> $DIR/extra_unused_type_parameters.rs:60:22 | LL | fn unused_ty_impl(&self) { @@ -55,7 +59,7 @@ LL | fn unused_ty_impl(&self) { | = help: consider removing the parameter -error: type parameters go unused in function definition +warning: type parameters go unused in function definition --> $DIR/extra_unused_type_parameters.rs:82:17 | LL | fn unused_opaque(dummy: impl Default) { @@ -63,7 +67,7 @@ LL | fn unused_opaque(dummy: impl Default) { | = help: consider removing the parameters -error: type parameter goes unused in function definition +warning: type parameter goes unused in function definition --> $DIR/extra_unused_type_parameters.rs:95:58 | LL | fn unused_with_priv_trait_bound() { @@ -71,5 +75,5 @@ LL | fn unused_with_priv_trait_bound() { | = help: consider removing the parameter -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/fallible_impl_from.rs b/tests/ui/fallible_impl_from.rs index fb6e8ec706b1..8a7ee723aad1 100644 --- a/tests/ui/fallible_impl_from.rs +++ b/tests/ui/fallible_impl_from.rs @@ -1,4 +1,4 @@ -#![deny(clippy::fallible_impl_from)] +#![warn(clippy::fallible_impl_from)] #![allow(clippy::uninlined_format_args)] // docs example diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 21761484f8c4..a506ef4d98e7 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,4 +1,4 @@ -error: consider implementing `TryFrom` instead +warning: consider implementing `TryFrom` instead --> $DIR/fallible_impl_from.rs:6:1 | LL | / impl From for Foo { @@ -17,10 +17,10 @@ LL | Foo(s.parse().unwrap()) note: the lint level is defined here --> $DIR/fallible_impl_from.rs:1:9 | -LL | #![deny(clippy::fallible_impl_from)] +LL | #![warn(clippy::fallible_impl_from)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: consider implementing `TryFrom` instead +warning: consider implementing `TryFrom` instead --> $DIR/fallible_impl_from.rs:27:1 | LL | / impl From for Invalid { @@ -38,9 +38,9 @@ note: potential failure(s) | LL | panic!(); | ^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: consider implementing `TryFrom` instead +warning: consider implementing `TryFrom` instead --> $DIR/fallible_impl_from.rs:36:1 | LL | / impl From> for Invalid { @@ -65,9 +65,9 @@ LL | } else if s.parse::().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ LL | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: consider implementing `TryFrom` instead +warning: consider implementing `TryFrom` instead --> $DIR/fallible_impl_from.rs:54:1 | LL | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { @@ -87,7 +87,7 @@ LL | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/field_reassign_with_default.rs b/tests/ui/field_reassign_with_default.rs index 1f989bb12205..398733fbf8c9 100644 --- a/tests/ui/field_reassign_with_default.rs +++ b/tests/ui/field_reassign_with_default.rs @@ -1,5 +1,5 @@ -// aux-build:proc_macro_derive.rs -// aux-build:macro_rules.rs +//@aux-build:proc_macro_derive.rs:proc-macro +//@aux-build:macro_rules.rs #![warn(clippy::field_reassign_with_default)] diff --git a/tests/ui/field_reassign_with_default.stderr b/tests/ui/field_reassign_with_default.stderr index 710bb66a48a4..719cfd33d4f9 100644 --- a/tests/ui/field_reassign_with_default.stderr +++ b/tests/ui/field_reassign_with_default.stderr @@ -1,4 +1,4 @@ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:63:5 | LL | a.i = 42; @@ -9,9 +9,13 @@ note: consider initializing the variable with `main::A { i: 42, ..Default::defau | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::field-reassign-with-default` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/field_reassign_with_default.rs:4:9 + | +LL | #![warn(clippy::field_reassign_with_default)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:103:5 | LL | a.j = 43; @@ -23,7 +27,7 @@ note: consider initializing the variable with `main::A { j: 43, i: 42 }` and rem LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:108:5 | LL | a.i = 42; @@ -35,7 +39,7 @@ note: consider initializing the variable with `main::A { i: 42, j: 44 }` and rem LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:114:5 | LL | a.i = 42; @@ -47,7 +51,7 @@ note: consider initializing the variable with `main::A { i: 42, ..Default::defau LL | let mut a = A::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:124:5 | LL | a.i = Default::default(); @@ -59,7 +63,7 @@ note: consider initializing the variable with `main::A { i: Default::default(), LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:128:5 | LL | a.i = Default::default(); @@ -71,7 +75,7 @@ note: consider initializing the variable with `main::A { i: Default::default(), LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:150:5 | LL | a.i = vec![1]; @@ -83,7 +87,7 @@ note: consider initializing the variable with `C { i: vec![1], ..Default::defaul LL | let mut a: C = C::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:157:5 | LL | a.i = true; @@ -95,7 +99,7 @@ note: consider initializing the variable with `Wrapper:: { i: true }` and LL | let mut a: Wrapper = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:160:5 | LL | a.i = 42; @@ -107,7 +111,7 @@ note: consider initializing the variable with `WrapperMulti:: { i: 42, LL | let mut a: WrapperMulti = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:229:13 | LL | f.name = name.len(); @@ -119,7 +123,7 @@ note: consider initializing the variable with `issue6312::ImplDropAllCopy { name LL | let mut f = ImplDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: field assignment outside of initializer for an instance created with Default::default() +warning: field assignment outside of initializer for an instance created with Default::default() --> $DIR/field_reassign_with_default.rs:245:13 | LL | f.name = name.len(); @@ -131,5 +135,5 @@ note: consider initializing the variable with `issue6312::NoDropAllCopy { name: LL | let mut f = NoDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/filetype_is_file.stderr b/tests/ui/filetype_is_file.stderr index e51a90d6cfd2..11e64d3e7812 100644 --- a/tests/ui/filetype_is_file.stderr +++ b/tests/ui/filetype_is_file.stderr @@ -1,13 +1,17 @@ -error: `FileType::is_file()` only covers regular files +warning: `FileType::is_file()` only covers regular files --> $DIR/filetype_is_file.rs:8:8 | LL | if fs::metadata("foo.txt")?.file_type().is_file() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `!FileType::is_dir()` instead - = note: `-D clippy::filetype-is-file` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/filetype_is_file.rs:1:9 + | +LL | #![warn(clippy::filetype_is_file)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `!FileType::is_file()` only denies regular files +warning: `!FileType::is_file()` only denies regular files --> $DIR/filetype_is_file.rs:13:8 | LL | if !fs::metadata("foo.txt")?.file_type().is_file() { @@ -15,7 +19,7 @@ LL | if !fs::metadata("foo.txt")?.file_type().is_file() { | = help: use `FileType::is_dir()` instead -error: `FileType::is_file()` only covers regular files +warning: `FileType::is_file()` only covers regular files --> $DIR/filetype_is_file.rs:18:9 | LL | if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { @@ -23,5 +27,5 @@ LL | if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { | = help: use `!FileType::is_dir()` instead -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/filter_map_identity.fixed b/tests/ui/filter_map_identity.fixed index a5860aa49b3b..44665b451ada 100644 --- a/tests/ui/filter_map_identity.fixed +++ b/tests/ui/filter_map_identity.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_imports, clippy::needless_return)] #![warn(clippy::filter_map_identity)] diff --git a/tests/ui/filter_map_identity.rs b/tests/ui/filter_map_identity.rs index 7e998b9cdf70..9832acb013f8 100644 --- a/tests/ui/filter_map_identity.rs +++ b/tests/ui/filter_map_identity.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_imports, clippy::needless_return)] #![warn(clippy::filter_map_identity)] diff --git a/tests/ui/filter_map_identity.stderr b/tests/ui/filter_map_identity.stderr index 43c9fdca4fbe..c53768265e2c 100644 --- a/tests/ui/filter_map_identity.stderr +++ b/tests/ui/filter_map_identity.stderr @@ -1,28 +1,32 @@ -error: use of `filter_map` with an identity function +warning: use of `filter_map` with an identity function --> $DIR/filter_map_identity.rs:8:22 | LL | let _ = iterator.filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` | - = note: `-D clippy::filter-map-identity` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/filter_map_identity.rs:4:9 + | +LL | #![warn(clippy::filter_map_identity)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `filter_map` with an identity function +warning: use of `filter_map` with an identity function --> $DIR/filter_map_identity.rs:11:22 | LL | let _ = iterator.filter_map(std::convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` -error: use of `filter_map` with an identity function +warning: use of `filter_map` with an identity function --> $DIR/filter_map_identity.rs:15:22 | LL | let _ = iterator.filter_map(identity); | ^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` -error: use of `filter_map` with an identity function +warning: use of `filter_map` with an identity function --> $DIR/filter_map_identity.rs:18:22 | LL | let _ = iterator.filter_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/filter_map_next.stderr b/tests/ui/filter_map_next.stderr index ddc982c93fe6..17729b9dd353 100644 --- a/tests/ui/filter_map_next.stderr +++ b/tests/ui/filter_map_next.stderr @@ -1,4 +1,4 @@ -error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead +warning: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead --> $DIR/filter_map_next.rs:7:26 | LL | let _: Option = vec![1, 2, 3, 4, 5, 6] @@ -11,7 +11,12 @@ LL | | }) LL | | .next(); | |_______________^ | - = note: `-D clippy::filter-map-next` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/filter_map_next.rs:1:22 + | +LL | #![warn(clippy::all, clippy::pedantic)] + | ^^^^^^^^^^^^^^^^ + = note: `#[warn(clippy::filter_map_next)]` implied by `#[warn(clippy::pedantic)]` -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/filter_map_next_fixable.fixed b/tests/ui/filter_map_next_fixable.fixed index 462d46169fcb..efb37f8b1b73 100644 --- a/tests/ui/filter_map_next_fixable.fixed +++ b/tests/ui/filter_map_next_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all, clippy::pedantic)] #![allow(unused)] diff --git a/tests/ui/filter_map_next_fixable.rs b/tests/ui/filter_map_next_fixable.rs index 2ea00cf73072..b10e20d359ed 100644 --- a/tests/ui/filter_map_next_fixable.rs +++ b/tests/ui/filter_map_next_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all, clippy::pedantic)] #![allow(unused)] diff --git a/tests/ui/filter_map_next_fixable.stderr b/tests/ui/filter_map_next_fixable.stderr index a9fc6abe88fa..95a26f4ca4f0 100644 --- a/tests/ui/filter_map_next_fixable.stderr +++ b/tests/ui/filter_map_next_fixable.stderr @@ -1,16 +1,21 @@ -error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead +warning: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead --> $DIR/filter_map_next_fixable.rs:9:32 | LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `a.iter().find_map(|s| s.parse().ok())` | - = note: `-D clippy::filter-map-next` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/filter_map_next_fixable.rs:3:22 + | +LL | #![warn(clippy::all, clippy::pedantic)] + | ^^^^^^^^^^^^^^^^ + = note: `#[warn(clippy::filter_map_next)]` implied by `#[warn(clippy::pedantic)]` -error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead +warning: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead --> $DIR/filter_map_next_fixable.rs:22:26 | LL | let _: Option = a.iter().filter_map(|s| s.parse().ok()).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `a.iter().find_map(|s| s.parse().ok())` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/flat_map_identity.fixed b/tests/ui/flat_map_identity.fixed index 1f4b880ef5bc..97091d6f1a5b 100644 --- a/tests/ui/flat_map_identity.fixed +++ b/tests/ui/flat_map_identity.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_imports, clippy::needless_return)] #![warn(clippy::flat_map_identity)] diff --git a/tests/ui/flat_map_identity.rs b/tests/ui/flat_map_identity.rs index de14a06d4e6b..5607683a5d04 100644 --- a/tests/ui/flat_map_identity.rs +++ b/tests/ui/flat_map_identity.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_imports, clippy::needless_return)] #![warn(clippy::flat_map_identity)] diff --git a/tests/ui/flat_map_identity.stderr b/tests/ui/flat_map_identity.stderr index e776c9fdf512..14d9652e29b6 100644 --- a/tests/ui/flat_map_identity.stderr +++ b/tests/ui/flat_map_identity.stderr @@ -1,22 +1,26 @@ -error: use of `flat_map` with an identity function +warning: use of `flat_map` with an identity function --> $DIR/flat_map_identity.rs:10:22 | LL | let _ = iterator.flat_map(|x| x); | ^^^^^^^^^^^^^^^ help: try: `flatten()` | - = note: `-D clippy::flat-map-identity` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/flat_map_identity.rs:4:9 + | +LL | #![warn(clippy::flat_map_identity)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `flat_map` with an identity function +warning: use of `flat_map` with an identity function --> $DIR/flat_map_identity.rs:13:22 | LL | let _ = iterator.flat_map(convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` -error: use of `flat_map` with an identity function +warning: use of `flat_map` with an identity function --> $DIR/flat_map_identity.rs:16:22 | LL | let _ = iterator.flat_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/flat_map_option.fixed b/tests/ui/flat_map_option.fixed index 6a34f008995c..eeab864c42ff 100644 --- a/tests/ui/flat_map_option.fixed +++ b/tests/ui/flat_map_option.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::flat_map_option)] #![allow(clippy::redundant_closure, clippy::unnecessary_filter_map)] diff --git a/tests/ui/flat_map_option.rs b/tests/ui/flat_map_option.rs index 2479abddbf04..ebc389f7f029 100644 --- a/tests/ui/flat_map_option.rs +++ b/tests/ui/flat_map_option.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::flat_map_option)] #![allow(clippy::redundant_closure, clippy::unnecessary_filter_map)] diff --git a/tests/ui/flat_map_option.stderr b/tests/ui/flat_map_option.stderr index a9d8056dee97..75343a473bd1 100644 --- a/tests/ui/flat_map_option.stderr +++ b/tests/ui/flat_map_option.stderr @@ -1,16 +1,20 @@ -error: used `flat_map` where `filter_map` could be used instead +warning: used `flat_map` where `filter_map` could be used instead --> $DIR/flat_map_option.rs:8:24 | LL | let _ = [1].iter().flat_map(c); | ^^^^^^^^ help: try: `filter_map` | - = note: `-D clippy::flat-map-option` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/flat_map_option.rs:2:9 + | +LL | #![warn(clippy::flat_map_option)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: used `flat_map` where `filter_map` could be used instead +warning: used `flat_map` where `filter_map` could be used instead --> $DIR/flat_map_option.rs:9:24 | LL | let _ = [1].iter().flat_map(Some); | ^^^^^^^^ help: try: `filter_map` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/float_arithmetic.stderr b/tests/ui/float_arithmetic.stderr index 1ceffb35beed..53a701485bf0 100644 --- a/tests/ui/float_arithmetic.stderr +++ b/tests/ui/float_arithmetic.stderr @@ -1,106 +1,110 @@ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:15:5 | LL | f * 2.0; | ^^^^^^^ | - = note: `-D clippy::float-arithmetic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/float_arithmetic.rs:1:37 + | +LL | #![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:17:5 | LL | 1.0 + f; | ^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:18:5 | LL | f * 2.0; | ^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:19:5 | LL | f / 2.0; | ^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:20:5 | LL | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:21:5 | LL | -f; | ^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:23:5 | LL | f += 1.0; | ^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:24:5 | LL | f -= 1.0; | ^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:25:5 | LL | f *= 2.0; | ^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:26:5 | LL | f /= 2.0; | ^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:32:5 | LL | 3.1_f32 + &1.2_f32; | ^^^^^^^^^^^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:33:5 | LL | &3.4_f32 + 1.5_f32; | ^^^^^^^^^^^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:34:5 | LL | &3.5_f32 + &1.3_f32; | ^^^^^^^^^^^^^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:39:5 | LL | a + f | ^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:43:5 | LL | f1 + f2 | ^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:47:5 | LL | f1 + f2 | ^^^^^^^ -error: floating-point arithmetic detected +warning: floating-point arithmetic detected --> $DIR/float_arithmetic.rs:51:5 | LL | (&f1 + &f2) | ^^^^^^^^^^^ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index e3e9f3949fdf..206117f12da9 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,13 +1,17 @@ -error: strict comparison of `f32` or `f64` +warning: strict comparison of `f32` or `f64` --> $DIR/float_cmp.rs:57:5 | LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` - = note: `-D clippy::float-cmp` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/float_cmp.rs:1:9 + | +LL | #![warn(clippy::float_cmp)] + | ^^^^^^^^^^^^^^^^^ -error: strict comparison of `f32` or `f64` +warning: strict comparison of `f32` or `f64` --> $DIR/float_cmp.rs:62:5 | LL | x == 1.0; @@ -15,7 +19,7 @@ LL | x == 1.0; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` +warning: strict comparison of `f32` or `f64` --> $DIR/float_cmp.rs:65:5 | LL | twice(x) != twice(ONE as f64); @@ -23,7 +27,7 @@ LL | twice(x) != twice(ONE as f64); | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` +warning: strict comparison of `f32` or `f64` --> $DIR/float_cmp.rs:85:5 | LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; @@ -31,7 +35,7 @@ LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` arrays +warning: strict comparison of `f32` or `f64` arrays --> $DIR/float_cmp.rs:90:5 | LL | a1 == a2; @@ -39,7 +43,7 @@ LL | a1 == a2; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` +warning: strict comparison of `f32` or `f64` --> $DIR/float_cmp.rs:91:5 | LL | a1[0] == a2[0]; @@ -47,5 +51,5 @@ LL | a1[0] == a2[0]; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index 65c45648ab38..099bd5daaed6 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -1,13 +1,17 @@ -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:16:5 | LL | 1f32 == ONE; | ^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1f32 - ONE).abs() < error_margin` | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` - = note: `-D clippy::float-cmp-const` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/float_cmp_const.rs:3:9 + | +LL | #![warn(clippy::float_cmp_const)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:17:5 | LL | TWO == ONE; @@ -15,7 +19,7 @@ LL | TWO == ONE; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:18:5 | LL | TWO != ONE; @@ -23,7 +27,7 @@ LL | TWO != ONE; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:19:5 | LL | ONE + ONE == TWO; @@ -31,7 +35,7 @@ LL | ONE + ONE == TWO; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:21:5 | LL | x as f32 == ONE; @@ -39,7 +43,7 @@ LL | x as f32 == ONE; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:24:5 | LL | v == ONE; @@ -47,7 +51,7 @@ LL | v == ONE; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` constant +warning: strict comparison of `f32` or `f64` constant --> $DIR/float_cmp_const.rs:25:5 | LL | v != ONE; @@ -55,7 +59,7 @@ LL | v != ONE; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: strict comparison of `f32` or `f64` constant arrays +warning: strict comparison of `f32` or `f64` constant arrays --> $DIR/float_cmp_const.rs:57:5 | LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; @@ -63,5 +67,5 @@ LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; | = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/float_equality_without_abs.stderr b/tests/ui/float_equality_without_abs.stderr index b34c8159da04..4293fde258cf 100644 --- a/tests/ui/float_equality_without_abs.stderr +++ b/tests/ui/float_equality_without_abs.stderr @@ -1,4 +1,4 @@ -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:4:5 | LL | (a - b) < f32::EPSILON @@ -6,9 +6,13 @@ LL | (a - b) < f32::EPSILON | | | help: add `.abs()`: `(a - b).abs()` | - = note: `-D clippy::float-equality-without-abs` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/float_equality_without_abs.rs:1:9 + | +LL | #![warn(clippy::float_equality_without_abs)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:13:13 | LL | let _ = (a - b) < f32::EPSILON; @@ -16,7 +20,7 @@ LL | let _ = (a - b) < f32::EPSILON; | | | help: add `.abs()`: `(a - b).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:14:13 | LL | let _ = a - b < f32::EPSILON; @@ -24,7 +28,7 @@ LL | let _ = a - b < f32::EPSILON; | | | help: add `.abs()`: `(a - b).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:15:13 | LL | let _ = a - b.abs() < f32::EPSILON; @@ -32,7 +36,7 @@ LL | let _ = a - b.abs() < f32::EPSILON; | | | help: add `.abs()`: `(a - b.abs()).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:16:13 | LL | let _ = (a as f64 - b as f64) < f64::EPSILON; @@ -40,7 +44,7 @@ LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | | | help: add `.abs()`: `(a as f64 - b as f64).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:17:13 | LL | let _ = 1.0 - 2.0 < f32::EPSILON; @@ -48,7 +52,7 @@ LL | let _ = 1.0 - 2.0 < f32::EPSILON; | | | help: add `.abs()`: `(1.0 - 2.0).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:19:13 | LL | let _ = f32::EPSILON > (a - b); @@ -56,7 +60,7 @@ LL | let _ = f32::EPSILON > (a - b); | | | help: add `.abs()`: `(a - b).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:20:13 | LL | let _ = f32::EPSILON > a - b; @@ -64,7 +68,7 @@ LL | let _ = f32::EPSILON > a - b; | | | help: add `.abs()`: `(a - b).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:21:13 | LL | let _ = f32::EPSILON > a - b.abs(); @@ -72,7 +76,7 @@ LL | let _ = f32::EPSILON > a - b.abs(); | | | help: add `.abs()`: `(a - b.abs()).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:22:13 | LL | let _ = f64::EPSILON > (a as f64 - b as f64); @@ -80,7 +84,7 @@ LL | let _ = f64::EPSILON > (a as f64 - b as f64); | | | help: add `.abs()`: `(a as f64 - b as f64).abs()` -error: float equality check without `.abs()` +warning: float equality check without `.abs()` --> $DIR/float_equality_without_abs.rs:23:13 | LL | let _ = f32::EPSILON > 1.0 - 2.0; @@ -88,5 +92,5 @@ LL | let _ = f32::EPSILON > 1.0 - 2.0; | | | help: add `.abs()`: `(1.0 - 2.0).abs()` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/floating_point_abs.fixed b/tests/ui/floating_point_abs.fixed index ca747fefc646..0cc572822e77 100644 --- a/tests/ui/floating_point_abs.fixed +++ b/tests/ui/floating_point_abs.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(const_fn_floating_point_arithmetic)] #![warn(clippy::suboptimal_flops)] diff --git a/tests/ui/floating_point_abs.rs b/tests/ui/floating_point_abs.rs index e4b606574979..6c732d398f06 100644 --- a/tests/ui/floating_point_abs.rs +++ b/tests/ui/floating_point_abs.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(const_fn_floating_point_arithmetic)] #![warn(clippy::suboptimal_flops)] diff --git a/tests/ui/floating_point_abs.stderr b/tests/ui/floating_point_abs.stderr index db8290423ae0..af96a7fb5a2d 100644 --- a/tests/ui/floating_point_abs.stderr +++ b/tests/ui/floating_point_abs.stderr @@ -1,52 +1,56 @@ -error: manual implementation of `abs` method +warning: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:16:5 | LL | if num >= 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_abs.rs:3:9 + | +LL | #![warn(clippy::suboptimal_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `abs` method +warning: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:20:5 | LL | if 0.0 < num { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` -error: manual implementation of `abs` method +warning: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:24:5 | LL | if a.a > 0.0 { a.a } else { -a.a } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` -error: manual implementation of `abs` method +warning: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:28:5 | LL | if 0.0 >= num { -num } else { num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` -error: manual implementation of `abs` method +warning: manual implementation of `abs` method --> $DIR/floating_point_abs.rs:32:5 | LL | if a.a < 0.0 { -a.a } else { a.a } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` -error: manual implementation of negation of `abs` method +warning: manual implementation of negation of `abs` method --> $DIR/floating_point_abs.rs:36:5 | LL | if num < 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` -error: manual implementation of negation of `abs` method +warning: manual implementation of negation of `abs` method --> $DIR/floating_point_abs.rs:40:5 | LL | if 0.0 >= num { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` -error: manual implementation of negation of `abs` method +warning: manual implementation of negation of `abs` method --> $DIR/floating_point_abs.rs:45:12 | LL | a: if a.a >= 0.0 { -a.a } else { a.a }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/floating_point_exp.fixed b/tests/ui/floating_point_exp.fixed index b9e3d89c2b29..1a33b8153eca 100644 --- a/tests/ui/floating_point_exp.fixed +++ b/tests/ui/floating_point_exp.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::imprecise_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_exp.rs b/tests/ui/floating_point_exp.rs index ef008dd9be05..4f4a5ec81ac9 100644 --- a/tests/ui/floating_point_exp.rs +++ b/tests/ui/floating_point_exp.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::imprecise_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_exp.stderr b/tests/ui/floating_point_exp.stderr index b92fae56e421..554ea2886d1a 100644 --- a/tests/ui/floating_point_exp.stderr +++ b/tests/ui/floating_point_exp.stderr @@ -1,34 +1,38 @@ -error: (e.pow(x) - 1) can be computed more accurately +warning: (e.pow(x) - 1) can be computed more accurately --> $DIR/floating_point_exp.rs:7:13 | LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` | - = note: `-D clippy::imprecise-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_exp.rs:2:9 + | +LL | #![warn(clippy::imprecise_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: (e.pow(x) - 1) can be computed more accurately +warning: (e.pow(x) - 1) can be computed more accurately --> $DIR/floating_point_exp.rs:8:13 | LL | let _ = x.exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` -error: (e.pow(x) - 1) can be computed more accurately +warning: (e.pow(x) - 1) can be computed more accurately --> $DIR/floating_point_exp.rs:9:13 | LL | let _ = (x as f32).exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).exp_m1()` -error: (e.pow(x) - 1) can be computed more accurately +warning: (e.pow(x) - 1) can be computed more accurately --> $DIR/floating_point_exp.rs:15:13 | LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` -error: (e.pow(x) - 1) can be computed more accurately +warning: (e.pow(x) - 1) can be computed more accurately --> $DIR/floating_point_exp.rs:16:13 | LL | let _ = x.exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/floating_point_hypot.fixed b/tests/ui/floating_point_hypot.fixed index bbe411b3f488..431cb2709787 100644 --- a/tests/ui/floating_point_hypot.fixed +++ b/tests/ui/floating_point_hypot.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::imprecise_flops)] fn main() { diff --git a/tests/ui/floating_point_hypot.rs b/tests/ui/floating_point_hypot.rs index 586fd170ea14..e5506ed391c0 100644 --- a/tests/ui/floating_point_hypot.rs +++ b/tests/ui/floating_point_hypot.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::imprecise_flops)] fn main() { diff --git a/tests/ui/floating_point_hypot.stderr b/tests/ui/floating_point_hypot.stderr index 42069d9ee9ef..ea27f81b3539 100644 --- a/tests/ui/floating_point_hypot.stderr +++ b/tests/ui/floating_point_hypot.stderr @@ -1,22 +1,26 @@ -error: hypotenuse can be computed more accurately +warning: hypotenuse can be computed more accurately --> $DIR/floating_point_hypot.rs:7:13 | LL | let _ = (x * x + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` | - = note: `-D clippy::imprecise-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_hypot.rs:2:9 + | +LL | #![warn(clippy::imprecise_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: hypotenuse can be computed more accurately +warning: hypotenuse can be computed more accurately --> $DIR/floating_point_hypot.rs:8:13 | LL | let _ = ((x + 1f32) * (x + 1f32) + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 1f32).hypot(y)` -error: hypotenuse can be computed more accurately +warning: hypotenuse can be computed more accurately --> $DIR/floating_point_hypot.rs:9:13 | LL | let _ = (x.powi(2) + y.powi(2)).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/floating_point_log.fixed b/tests/ui/floating_point_log.fixed index ee5406461600..6582c0a0f6c8 100644 --- a/tests/ui/floating_point_log.fixed +++ b/tests/ui/floating_point_log.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)] #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] diff --git a/tests/ui/floating_point_log.rs b/tests/ui/floating_point_log.rs index 0590670a50bc..854d269fff59 100644 --- a/tests/ui/floating_point_log.rs +++ b/tests/ui/floating_point_log.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::double_parens, clippy::unnecessary_cast)] #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] diff --git a/tests/ui/floating_point_log.stderr b/tests/ui/floating_point_log.stderr index 89800a13a6ec..932644081d86 100644 --- a/tests/ui/floating_point_log.stderr +++ b/tests/ui/floating_point_log.stderr @@ -1,180 +1,188 @@ -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:10:13 | LL | let _ = x.log(2f32); | ^^^^^^^^^^^ help: consider using: `x.log2()` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_log.rs:3:9 + | +LL | #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:11:13 | LL | let _ = x.log(10f32); | ^^^^^^^^^^^^ help: consider using: `x.log10()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:12:13 | LL | let _ = x.log(std::f32::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:13:13 | LL | let _ = x.log(TWO); | ^^^^^^^^^^ help: consider using: `x.log2()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:14:13 | LL | let _ = x.log(E); | ^^^^^^^^ help: consider using: `x.ln()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:15:13 | LL | let _ = (x as f32).log(2f32); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log2()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:18:13 | LL | let _ = x.log(2f64); | ^^^^^^^^^^^ help: consider using: `x.log2()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:19:13 | LL | let _ = x.log(10f64); | ^^^^^^^^^^^^ help: consider using: `x.log10()` -error: logarithm for bases 2, 10 and e can be computed more accurately +warning: logarithm for bases 2, 10 and e can be computed more accurately --> $DIR/floating_point_log.rs:20:13 | LL | let _ = x.log(std::f64::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:25:13 | LL | let _ = (1f32 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` | - = note: `-D clippy::imprecise-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_log.rs:3:35 + | +LL | #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:26:13 | LL | let _ = (1f32 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:27:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:28:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:29:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:30:13 | LL | let _ = (1.0 + x.powi(3) / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(3) / 2.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:31:13 | LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(std::f32::consts::E - 1.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:32:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:33:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:34:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:35:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:43:13 | LL | let _ = (1f64 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:44:13 | LL | let _ = (1f64 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:45:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:46:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:47:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:48:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:49:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:50:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` -error: ln(1 + x) can be computed more accurately +warning: ln(1 + x) can be computed more accurately --> $DIR/floating_point_log.rs:51:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` -error: aborting due to 29 previous errors +warning: 29 warnings emitted diff --git a/tests/ui/floating_point_logbase.fixed b/tests/ui/floating_point_logbase.fixed index 7347bf72cbea..0783ecee1eec 100644 --- a/tests/ui/floating_point_logbase.fixed +++ b/tests/ui/floating_point_logbase.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suboptimal_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_logbase.rs b/tests/ui/floating_point_logbase.rs index ba5b8d406928..80fcfab68252 100644 --- a/tests/ui/floating_point_logbase.rs +++ b/tests/ui/floating_point_logbase.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suboptimal_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_logbase.stderr b/tests/ui/floating_point_logbase.stderr index 9d736b5e1a27..dd644c3f5830 100644 --- a/tests/ui/floating_point_logbase.stderr +++ b/tests/ui/floating_point_logbase.stderr @@ -1,34 +1,38 @@ -error: log base can be expressed more clearly +warning: log base can be expressed more clearly --> $DIR/floating_point_logbase.rs:8:13 | LL | let _ = x.ln() / y.ln(); | ^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_logbase.rs:2:9 + | +LL | #![warn(clippy::suboptimal_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: log base can be expressed more clearly +warning: log base can be expressed more clearly --> $DIR/floating_point_logbase.rs:9:13 | LL | let _ = (x as f32).ln() / y.ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log(y)` -error: log base can be expressed more clearly +warning: log base can be expressed more clearly --> $DIR/floating_point_logbase.rs:10:13 | LL | let _ = x.log2() / y.log2(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` -error: log base can be expressed more clearly +warning: log base can be expressed more clearly --> $DIR/floating_point_logbase.rs:11:13 | LL | let _ = x.log10() / y.log10(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` -error: log base can be expressed more clearly +warning: log base can be expressed more clearly --> $DIR/floating_point_logbase.rs:12:13 | LL | let _ = x.log(5f32) / y.log(5f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/floating_point_mul_add.fixed b/tests/ui/floating_point_mul_add.fixed index d3e536ba3500..8848981a11d8 100644 --- a/tests/ui/floating_point_mul_add.fixed +++ b/tests/ui/floating_point_mul_add.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(const_fn_floating_point_arithmetic)] #![warn(clippy::suboptimal_flops)] diff --git a/tests/ui/floating_point_mul_add.rs b/tests/ui/floating_point_mul_add.rs index 5d4a9e35cfc2..b0edf5cb210c 100644 --- a/tests/ui/floating_point_mul_add.rs +++ b/tests/ui/floating_point_mul_add.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(const_fn_floating_point_arithmetic)] #![warn(clippy::suboptimal_flops)] diff --git a/tests/ui/floating_point_mul_add.stderr b/tests/ui/floating_point_mul_add.stderr index a79ae94e8d43..4eee257d36ab 100644 --- a/tests/ui/floating_point_mul_add.stderr +++ b/tests/ui/floating_point_mul_add.stderr @@ -1,76 +1,80 @@ -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:21:13 | LL | let _ = a * b + c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_mul_add.rs:3:9 + | +LL | #![warn(clippy::suboptimal_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:22:13 | LL | let _ = a * b - c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, -c)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:23:13 | LL | let _ = c + a * b; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:24:13 | LL | let _ = c - a * b; | ^^^^^^^^^ help: consider using: `a.mul_add(-b, c)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:25:13 | LL | let _ = a + 2.0 * 4.0; | ^^^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4.0, a)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:26:13 | LL | let _ = a + 2. * 4.; | ^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4., a)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:28:13 | LL | let _ = (a * b) + c; | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:29:13 | LL | let _ = c + (a * b); | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:30:13 | LL | let _ = a * b * c + d; | ^^^^^^^^^^^^^ help: consider using: `(a * b).mul_add(c, d)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:32:13 | LL | let _ = a.mul_add(b, c) * a.mul_add(b, c) + a.mul_add(b, c) + c; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `a.mul_add(b, c).mul_add(a.mul_add(b, c), a.mul_add(b, c))` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:33:13 | LL | let _ = 1234.567_f64 * 45.67834_f64 + 0.0004_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1234.567_f64.mul_add(45.67834_f64, 0.0004_f64)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_mul_add.rs:35:13 | LL | let _ = (a * a + b).sqrt(); | ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/floating_point_powf.fixed b/tests/ui/floating_point_powf.fixed index f7f93de29577..1e660b140c58 100644 --- a/tests/ui/floating_point_powf.fixed +++ b/tests/ui/floating_point_powf.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_powf.rs b/tests/ui/floating_point_powf.rs index 499fc0e15e47..71c2f5292053 100644 --- a/tests/ui/floating_point_powf.rs +++ b/tests/ui/floating_point_powf.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_powf.stderr b/tests/ui/floating_point_powf.stderr index 7c9d50db2f78..7771709627fd 100644 --- a/tests/ui/floating_point_powf.stderr +++ b/tests/ui/floating_point_powf.stderr @@ -1,192 +1,200 @@ -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:7:13 | LL | let _ = 2f32.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_powf.rs:2:9 + | +LL | #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:8:13 | LL | let _ = 2f32.powf(3.1); | ^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp2()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:9:13 | LL | let _ = 2f32.powf(-3.1); | ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp2()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:10:13 | LL | let _ = std::f32::consts::E.powf(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:11:13 | LL | let _ = std::f32::consts::E.powf(3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:12:13 | LL | let _ = std::f32::consts::E.powf(-3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp()` -error: square-root of a number can be computed more efficiently and accurately +warning: square-root of a number can be computed more efficiently and accurately --> $DIR/floating_point_powf.rs:13:13 | LL | let _ = x.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` -error: cube-root of a number can be computed more accurately +warning: cube-root of a number can be computed more accurately --> $DIR/floating_point_powf.rs:14:13 | LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` | - = note: `-D clippy::imprecise-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_powf.rs:2:35 + | +LL | #![warn(clippy::suboptimal_flops, clippy::imprecise_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: cube-root of a number can be computed more accurately +warning: cube-root of a number can be computed more accurately --> $DIR/floating_point_powf.rs:15:13 | LL | let _ = (x as f32).powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).cbrt()` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:16:13 | LL | let _ = x.powf(3.0); | ^^^^^^^^^^^ help: consider using: `x.powi(3)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:17:13 | LL | let _ = x.powf(-2.0); | ^^^^^^^^^^^^ help: consider using: `x.powi(-2)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:18:13 | LL | let _ = x.powf(16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(16_777_215)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:19:13 | LL | let _ = x.powf(-16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-16_777_215)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:20:13 | LL | let _ = (x as f32).powf(-16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(-16_777_215)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:21:13 | LL | let _ = (x as f32).powf(3.0); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(3)` -error: cube-root of a number can be computed more accurately +warning: cube-root of a number can be computed more accurately --> $DIR/floating_point_powf.rs:22:13 | LL | let _ = (1.5_f32 + 1.0).powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(1.5_f32 + 1.0).cbrt()` -error: cube-root of a number can be computed more accurately +warning: cube-root of a number can be computed more accurately --> $DIR/floating_point_powf.rs:23:13 | LL | let _ = 1.5_f64.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.cbrt()` -error: square-root of a number can be computed more efficiently and accurately +warning: square-root of a number can be computed more efficiently and accurately --> $DIR/floating_point_powf.rs:24:13 | LL | let _ = 1.5_f64.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.sqrt()` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:25:13 | LL | let _ = 1.5_f64.powf(3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.powi(3)` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:34:13 | LL | let _ = 2f64.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:35:13 | LL | let _ = 2f64.powf(3.1); | ^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp2()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:36:13 | LL | let _ = 2f64.powf(-3.1); | ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp2()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:37:13 | LL | let _ = std::f64::consts::E.powf(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:38:13 | LL | let _ = std::f64::consts::E.powf(3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp()` -error: exponent for bases 2 and e can be computed more accurately +warning: exponent for bases 2 and e can be computed more accurately --> $DIR/floating_point_powf.rs:39:13 | LL | let _ = std::f64::consts::E.powf(-3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp()` -error: square-root of a number can be computed more efficiently and accurately +warning: square-root of a number can be computed more efficiently and accurately --> $DIR/floating_point_powf.rs:40:13 | LL | let _ = x.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` -error: cube-root of a number can be computed more accurately +warning: cube-root of a number can be computed more accurately --> $DIR/floating_point_powf.rs:41:13 | LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:42:13 | LL | let _ = x.powf(3.0); | ^^^^^^^^^^^ help: consider using: `x.powi(3)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:43:13 | LL | let _ = x.powf(-2.0); | ^^^^^^^^^^^^ help: consider using: `x.powi(-2)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:44:13 | LL | let _ = x.powf(-2_147_483_648.0); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-2_147_483_648)` -error: exponentiation with integer powers can be computed more efficiently +warning: exponentiation with integer powers can be computed more efficiently --> $DIR/floating_point_powf.rs:45:13 | LL | let _ = x.powf(2_147_483_647.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2_147_483_647)` -error: aborting due to 31 previous errors +warning: 31 warnings emitted diff --git a/tests/ui/floating_point_powi.fixed b/tests/ui/floating_point_powi.fixed index 8ffd4cc51379..41d5288d6e0c 100644 --- a/tests/ui/floating_point_powi.fixed +++ b/tests/ui/floating_point_powi.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suboptimal_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_powi.rs b/tests/ui/floating_point_powi.rs index 9ae3455a1346..7951aab31beb 100644 --- a/tests/ui/floating_point_powi.rs +++ b/tests/ui/floating_point_powi.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suboptimal_flops)] #![allow(clippy::unnecessary_cast)] diff --git a/tests/ui/floating_point_powi.stderr b/tests/ui/floating_point_powi.stderr index fdf6d088052e..fbacba194167 100644 --- a/tests/ui/floating_point_powi.stderr +++ b/tests/ui/floating_point_powi.stderr @@ -1,88 +1,92 @@ -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:10:13 | LL | let _ = x.powi(2) + y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_powi.rs:2:9 + | +LL | #![warn(clippy::suboptimal_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:11:13 | LL | let _ = x.powi(2) - y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, -y)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:12:13 | LL | let _ = x + y.powi(2); | ^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:13:13 | LL | let _ = x - y.powi(2); | ^^^^^^^^^^^^^ help: consider using: `y.mul_add(-y, x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:14:13 | LL | let _ = x + (y as f32).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y as f32).mul_add(y as f32, x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:15:13 | LL | let _ = (x.powi(2) + y).sqrt(); | ^^^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:16:13 | LL | let _ = (x + y.powi(2)).sqrt(); | ^^^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:18:13 | LL | let _ = (x - 1.0).powi(2) - y; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -y)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:19:13 | LL | let _ = (x - 1.0).powi(2) - y + 3.0; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -y)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:20:13 | LL | let _ = (x - 1.0).powi(2) - (y + 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -(y + 3.0))` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:21:13 | LL | let _ = x - (y + 1.0).powi(2); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0).mul_add(-(y + 1.0), x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:22:13 | LL | let _ = x - (3.0 * y).powi(2); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(3.0 * y).mul_add(-(3.0 * y), x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:23:13 | LL | let _ = x - (y + 1.0 + x).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0 + x).mul_add(-(y + 1.0 + x), x)` -error: multiply and add expressions can be calculated more efficiently and accurately +warning: multiply and add expressions can be calculated more efficiently and accurately --> $DIR/floating_point_powi.rs:24:13 | LL | let _ = x - (y + 1.0 + 2.0).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0 + 2.0).mul_add(-(y + 1.0 + 2.0), x)` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/floating_point_rad.fixed b/tests/ui/floating_point_rad.fixed index 27674b8a455b..af2364527128 100644 --- a/tests/ui/floating_point_rad.fixed +++ b/tests/ui/floating_point_rad.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(const_fn_floating_point_arithmetic)] #![warn(clippy::suboptimal_flops)] diff --git a/tests/ui/floating_point_rad.rs b/tests/ui/floating_point_rad.rs index f1ea73df3984..d7612c56a3e4 100644 --- a/tests/ui/floating_point_rad.rs +++ b/tests/ui/floating_point_rad.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(const_fn_floating_point_arithmetic)] #![warn(clippy::suboptimal_flops)] diff --git a/tests/ui/floating_point_rad.stderr b/tests/ui/floating_point_rad.stderr index 979442f2c24a..b169472301fe 100644 --- a/tests/ui/floating_point_rad.stderr +++ b/tests/ui/floating_point_rad.stderr @@ -1,52 +1,56 @@ -error: conversion to radians can be done more accurately +warning: conversion to radians can be done more accurately --> $DIR/floating_point_rad.rs:12:13 | LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()` | - = note: `-D clippy::suboptimal-flops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/floating_point_rad.rs:3:9 + | +LL | #![warn(clippy::suboptimal_flops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: conversion to degrees can be done more accurately +warning: conversion to degrees can be done more accurately --> $DIR/floating_point_rad.rs:13:13 | LL | let _ = degrees as f64 * 180.0 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_degrees()` -error: conversion to degrees can be done more accurately +warning: conversion to degrees can be done more accurately --> $DIR/floating_point_rad.rs:18:13 | LL | let _ = x * 180f32 / std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_degrees()` -error: conversion to degrees can be done more accurately +warning: conversion to degrees can be done more accurately --> $DIR/floating_point_rad.rs:19:13 | LL | let _ = 90. * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_degrees()` -error: conversion to degrees can be done more accurately +warning: conversion to degrees can be done more accurately --> $DIR/floating_point_rad.rs:20:13 | LL | let _ = 90.5 * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_degrees()` -error: conversion to radians can be done more accurately +warning: conversion to radians can be done more accurately --> $DIR/floating_point_rad.rs:21:13 | LL | let _ = x * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_radians()` -error: conversion to radians can be done more accurately +warning: conversion to radians can be done more accurately --> $DIR/floating_point_rad.rs:22:13 | LL | let _ = 90. * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_radians()` -error: conversion to radians can be done more accurately +warning: conversion to radians can be done more accurately --> $DIR/floating_point_rad.rs:23:13 | LL | let _ = 90.5 * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_radians()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/fn_address_comparisons.stderr b/tests/ui/fn_address_comparisons.stderr index 9c1b5419a431..202587ff93ab 100644 --- a/tests/ui/fn_address_comparisons.stderr +++ b/tests/ui/fn_address_comparisons.stderr @@ -1,16 +1,20 @@ -error: comparing with a non-unique address of a function item +warning: comparing with a non-unique address of a function item --> $DIR/fn_address_comparisons.rs:15:13 | LL | let _ = f == a; | ^^^^^^ | - = note: `-D clippy::fn-address-comparisons` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_address_comparisons.rs:8:8 + | +LL | #[warn(clippy::fn_address_comparisons)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: comparing with a non-unique address of a function item +warning: comparing with a non-unique address of a function item --> $DIR/fn_address_comparisons.rs:16:13 | LL | let _ = f != a; | ^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/fn_null_check.stderr b/tests/ui/fn_null_check.stderr index 660dd3239792..dd9acd0ce83f 100644 --- a/tests/ui/fn_null_check.stderr +++ b/tests/ui/fn_null_check.stderr @@ -1,13 +1,17 @@ -error: function pointer assumed to be nullable, even though it isn't +warning: function pointer assumed to be nullable, even though it isn't --> $DIR/fn_null_check.rs:13:8 | LL | if (fn_ptr as *mut ()).is_null() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try wrapping your function pointer type in `Option` instead, and using `is_none` to check for null pointer value - = note: `-D clippy::fn-null-check` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_null_check.rs:2:9 + | +LL | #![warn(clippy::fn_null_check)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: function pointer assumed to be nullable, even though it isn't +warning: function pointer assumed to be nullable, even though it isn't --> $DIR/fn_null_check.rs:14:8 | LL | if (fn_ptr as *const u8).is_null() {} @@ -15,7 +19,7 @@ LL | if (fn_ptr as *const u8).is_null() {} | = help: try wrapping your function pointer type in `Option` instead, and using `is_none` to check for null pointer value -error: function pointer assumed to be nullable, even though it isn't +warning: function pointer assumed to be nullable, even though it isn't --> $DIR/fn_null_check.rs:15:8 | LL | if (fn_ptr as *const ()) == std::ptr::null() {} @@ -23,7 +27,7 @@ LL | if (fn_ptr as *const ()) == std::ptr::null() {} | = help: try wrapping your function pointer type in `Option` instead, and using `is_none` to check for null pointer value -error: function pointer assumed to be nullable, even though it isn't +warning: function pointer assumed to be nullable, even though it isn't --> $DIR/fn_null_check.rs:16:8 | LL | if (fn_ptr as *const ()) == (0 as *const ()) {} @@ -31,7 +35,7 @@ LL | if (fn_ptr as *const ()) == (0 as *const ()) {} | = help: try wrapping your function pointer type in `Option` instead, and using `is_none` to check for null pointer value -error: function pointer assumed to be nullable, even though it isn't +warning: function pointer assumed to be nullable, even though it isn't --> $DIR/fn_null_check.rs:17:8 | LL | if (fn_ptr as *const ()) == ZPTR {} @@ -39,5 +43,5 @@ LL | if (fn_ptr as *const ()) == ZPTR {} | = help: try wrapping your function pointer type in `Option` instead, and using `is_none` to check for null pointer value -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/fn_params_excessive_bools.stderr b/tests/ui/fn_params_excessive_bools.stderr index 43363b46972c..cc92ae3863c6 100644 --- a/tests/ui/fn_params_excessive_bools.stderr +++ b/tests/ui/fn_params_excessive_bools.stderr @@ -1,13 +1,17 @@ -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:19:1 | LL | fn g(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider refactoring bools into two-variant enums - = note: `-D clippy::fn-params-excessive-bools` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_params_excessive_bools.rs:1:9 + | +LL | #![warn(clippy::fn_params_excessive_bools)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:22:1 | LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool) {} @@ -15,7 +19,7 @@ LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool | = help: consider refactoring bools into two-variant enums -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:27:5 | LL | fn f(_: bool, _: bool, _: bool, _: bool); @@ -23,7 +27,7 @@ LL | fn f(_: bool, _: bool, _: bool, _: bool); | = help: consider refactoring bools into two-variant enums -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:31:5 | LL | fn i(_: bool, _: bool, _: bool, _: bool) {} @@ -31,7 +35,7 @@ LL | fn i(_: bool, _: bool, _: bool, _: bool) {} | = help: consider refactoring bools into two-variant enums -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:35:5 | LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} @@ -39,7 +43,7 @@ LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} | = help: consider refactoring bools into two-variant enums -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:50:5 | LL | / fn n(_: bool, _: u32, _: bool, _: Box, _: bool, _: bool) { @@ -49,7 +53,7 @@ LL | | } | = help: consider refactoring bools into two-variant enums -error: more than 3 bools in function parameters +warning: more than 3 bools in function parameters --> $DIR/fn_params_excessive_bools.rs:51:9 | LL | fn nn(_: bool, _: bool, _: bool, _: bool) {} @@ -57,5 +61,5 @@ LL | fn nn(_: bool, _: bool, _: bool, _: bool) {} | = help: consider refactoring bools into two-variant enums -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/fn_to_numeric_cast.rs b/tests/ui/fn_to_numeric_cast.rs index a456c085c876..4f6af8708899 100644 --- a/tests/ui/fn_to_numeric_cast.rs +++ b/tests/ui/fn_to_numeric_cast.rs @@ -1,4 +1,4 @@ -// ignore-32bit +//@ignore-32bit #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] diff --git a/tests/ui/fn_to_numeric_cast.stderr b/tests/ui/fn_to_numeric_cast.stderr index e9549e157cd9..cad3f360e23a 100644 --- a/tests/ui/fn_to_numeric_cast.stderr +++ b/tests/ui/fn_to_numeric_cast.stderr @@ -1,144 +1,152 @@ -error: casting function pointer `foo` to `i8`, which truncates the value +warning: casting function pointer `foo` to `i8`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` | - = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_to_numeric_cast.rs:3:37 + | +LL | #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting function pointer `foo` to `i16`, which truncates the value +warning: casting function pointer `foo` to `i16`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `i32`, which truncates the value +warning: casting function pointer `foo` to `i32`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `i64` +warning: casting function pointer `foo` to `i64` --> $DIR/fn_to_numeric_cast.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` | - = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_to_numeric_cast.rs:3:9 + | +LL | #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting function pointer `foo` to `i128` +warning: casting function pointer `foo` to `i128` --> $DIR/fn_to_numeric_cast.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `isize` +warning: casting function pointer `foo` to `isize` --> $DIR/fn_to_numeric_cast.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u8`, which truncates the value +warning: casting function pointer `foo` to `u8`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u16`, which truncates the value +warning: casting function pointer `foo` to `u16`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u32`, which truncates the value +warning: casting function pointer `foo` to `u32`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u64` +warning: casting function pointer `foo` to `u64` --> $DIR/fn_to_numeric_cast.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u128` +warning: casting function pointer `foo` to `u128` --> $DIR/fn_to_numeric_cast.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `abc` to `i8`, which truncates the value +warning: casting function pointer `abc` to `i8`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i16`, which truncates the value +warning: casting function pointer `abc` to `i16`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i32`, which truncates the value +warning: casting function pointer `abc` to `i32`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i64` +warning: casting function pointer `abc` to `i64` --> $DIR/fn_to_numeric_cast.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i128` +warning: casting function pointer `abc` to `i128` --> $DIR/fn_to_numeric_cast.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `isize` +warning: casting function pointer `abc` to `isize` --> $DIR/fn_to_numeric_cast.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u8`, which truncates the value +warning: casting function pointer `abc` to `u8`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u16`, which truncates the value +warning: casting function pointer `abc` to `u16`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u32`, which truncates the value +warning: casting function pointer `abc` to `u32`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u64` +warning: casting function pointer `abc` to `u64` --> $DIR/fn_to_numeric_cast.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u128` +warning: casting function pointer `abc` to `u128` --> $DIR/fn_to_numeric_cast.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `f` to `i32`, which truncates the value +warning: casting function pointer `f` to `i32`, which truncates the value --> $DIR/fn_to_numeric_cast.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` -error: aborting due to 23 previous errors +warning: 23 warnings emitted diff --git a/tests/ui/fn_to_numeric_cast_32bit.rs b/tests/ui/fn_to_numeric_cast_32bit.rs index 04ee985c0863..62ce97f098d4 100644 --- a/tests/ui/fn_to_numeric_cast_32bit.rs +++ b/tests/ui/fn_to_numeric_cast_32bit.rs @@ -1,4 +1,4 @@ -// ignore-64bit +//@ignore-64bit #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] diff --git a/tests/ui/fn_to_numeric_cast_32bit.stderr b/tests/ui/fn_to_numeric_cast_32bit.stderr index 08dd611d6752..62718fe866ca 100644 --- a/tests/ui/fn_to_numeric_cast_32bit.stderr +++ b/tests/ui/fn_to_numeric_cast_32bit.stderr @@ -1,144 +1,152 @@ -error: casting function pointer `foo` to `i8`, which truncates the value +warning: casting function pointer `foo` to `i8`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` | - = note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_to_numeric_cast_32bit.rs:3:37 + | +LL | #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting function pointer `foo` to `i16`, which truncates the value +warning: casting function pointer `foo` to `i16`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `i32` +warning: casting function pointer `foo` to `i32`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` - | - = note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings` -error: casting function pointer `foo` to `i64` +warning: casting function pointer `foo` to `i64` --> $DIR/fn_to_numeric_cast_32bit.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` + | +note: the lint level is defined here + --> $DIR/fn_to_numeric_cast_32bit.rs:3:9 + | +LL | #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting function pointer `foo` to `i128` +warning: casting function pointer `foo` to `i128` --> $DIR/fn_to_numeric_cast_32bit.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `isize` +warning: casting function pointer `foo` to `isize` --> $DIR/fn_to_numeric_cast_32bit.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u8`, which truncates the value +warning: casting function pointer `foo` to `u8`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u16`, which truncates the value +warning: casting function pointer `foo` to `u16`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u32` +warning: casting function pointer `foo` to `u32`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u64` +warning: casting function pointer `foo` to `u64` --> $DIR/fn_to_numeric_cast_32bit.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `foo` to `u128` +warning: casting function pointer `foo` to `u128` --> $DIR/fn_to_numeric_cast_32bit.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` -error: casting function pointer `abc` to `i8`, which truncates the value +warning: casting function pointer `abc` to `i8`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i16`, which truncates the value +warning: casting function pointer `abc` to `i16`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i32` +warning: casting function pointer `abc` to `i32`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i64` +warning: casting function pointer `abc` to `i64` --> $DIR/fn_to_numeric_cast_32bit.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `i128` +warning: casting function pointer `abc` to `i128` --> $DIR/fn_to_numeric_cast_32bit.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `isize` +warning: casting function pointer `abc` to `isize` --> $DIR/fn_to_numeric_cast_32bit.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u8`, which truncates the value +warning: casting function pointer `abc` to `u8`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u16`, which truncates the value +warning: casting function pointer `abc` to `u16`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u32` +warning: casting function pointer `abc` to `u32`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u64` +warning: casting function pointer `abc` to `u64` --> $DIR/fn_to_numeric_cast_32bit.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `abc` to `u128` +warning: casting function pointer `abc` to `u128` --> $DIR/fn_to_numeric_cast_32bit.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` -error: casting function pointer `f` to `i32` +warning: casting function pointer `f` to `i32`, which truncates the value --> $DIR/fn_to_numeric_cast_32bit.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` -error: aborting due to 23 previous errors +warning: 23 warnings emitted diff --git a/tests/ui/fn_to_numeric_cast_any.stderr b/tests/ui/fn_to_numeric_cast_any.stderr index a6c4a77672f8..204f8e35819e 100644 --- a/tests/ui/fn_to_numeric_cast_any.stderr +++ b/tests/ui/fn_to_numeric_cast_any.stderr @@ -1,106 +1,110 @@ -error: casting function pointer `foo` to `i8` +warning: casting function pointer `foo` to `i8` --> $DIR/fn_to_numeric_cast_any.rs:23:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i8` | - = note: `-D clippy::fn-to-numeric-cast-any` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fn_to_numeric_cast_any.rs:1:9 + | +LL | #![warn(clippy::fn_to_numeric_cast_any)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting function pointer `foo` to `i16` +warning: casting function pointer `foo` to `i16` --> $DIR/fn_to_numeric_cast_any.rs:24:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i16` -error: casting function pointer `foo` to `i32` +warning: casting function pointer `foo` to `i32` --> $DIR/fn_to_numeric_cast_any.rs:25:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i32` -error: casting function pointer `foo` to `i64` +warning: casting function pointer `foo` to `i64` --> $DIR/fn_to_numeric_cast_any.rs:26:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i64` -error: casting function pointer `foo` to `i128` +warning: casting function pointer `foo` to `i128` --> $DIR/fn_to_numeric_cast_any.rs:27:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i128` -error: casting function pointer `foo` to `isize` +warning: casting function pointer `foo` to `isize` --> $DIR/fn_to_numeric_cast_any.rs:28:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as isize` -error: casting function pointer `foo` to `u8` +warning: casting function pointer `foo` to `u8` --> $DIR/fn_to_numeric_cast_any.rs:30:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u8` -error: casting function pointer `foo` to `u16` +warning: casting function pointer `foo` to `u16` --> $DIR/fn_to_numeric_cast_any.rs:31:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u16` -error: casting function pointer `foo` to `u32` +warning: casting function pointer `foo` to `u32` --> $DIR/fn_to_numeric_cast_any.rs:32:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u32` -error: casting function pointer `foo` to `u64` +warning: casting function pointer `foo` to `u64` --> $DIR/fn_to_numeric_cast_any.rs:33:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u64` -error: casting function pointer `foo` to `u128` +warning: casting function pointer `foo` to `u128` --> $DIR/fn_to_numeric_cast_any.rs:34:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u128` -error: casting function pointer `foo` to `usize` +warning: casting function pointer `foo` to `usize` --> $DIR/fn_to_numeric_cast_any.rs:35:13 | LL | let _ = foo as usize; | ^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as usize` -error: casting function pointer `Struct::static_method` to `usize` +warning: casting function pointer `Struct::static_method` to `usize` --> $DIR/fn_to_numeric_cast_any.rs:39:13 | LL | let _ = Struct::static_method as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `Struct::static_method() as usize` -error: casting function pointer `f` to `usize` +warning: casting function pointer `f` to `usize` --> $DIR/fn_to_numeric_cast_any.rs:43:5 | LL | f as usize | ^^^^^^^^^^ help: did you mean to invoke the function?: `f() as usize` -error: casting function pointer `T::static_method` to `usize` +warning: casting function pointer `T::static_method` to `usize` --> $DIR/fn_to_numeric_cast_any.rs:47:5 | LL | T::static_method as usize | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `T::static_method() as usize` -error: casting function pointer `(clos as fn(u32) -> u32)` to `usize` +warning: casting function pointer `(clos as fn(u32) -> u32)` to `usize` --> $DIR/fn_to_numeric_cast_any.rs:53:13 | LL | let _ = (clos as fn(u32) -> u32) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `(clos as fn(u32) -> u32)() as usize` -error: casting function pointer `foo` to `*const ()` +warning: casting function pointer `foo` to `*const ()` --> $DIR/fn_to_numeric_cast_any.rs:57:13 | LL | let _ = foo as *const (); | ^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as *const ()` -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/for_kv_map.stderr b/tests/ui/for_kv_map.stderr index e5cc7c1466ab..fcb3efb995f9 100644 --- a/tests/ui/for_kv_map.stderr +++ b/tests/ui/for_kv_map.stderr @@ -1,16 +1,20 @@ -error: you seem to want to iterate on a map's values +warning: you seem to want to iterate on a map's values --> $DIR/for_kv_map.rs:9:19 | LL | for (_, v) in &m { | ^^ | - = note: `-D clippy::for-kv-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/for_kv_map.rs:1:9 + | +LL | #![warn(clippy::for_kv_map)] + | ^^^^^^^^^^^^^^^^^^ help: use the corresponding method | LL | for v in m.values() { | ~ ~~~~~~~~~~ -error: you seem to want to iterate on a map's values +warning: you seem to want to iterate on a map's values --> $DIR/for_kv_map.rs:14:19 | LL | for (_, v) in &*m { @@ -21,7 +25,7 @@ help: use the corresponding method LL | for v in (*m).values() { | ~ ~~~~~~~~~~~~~ -error: you seem to want to iterate on a map's values +warning: you seem to want to iterate on a map's values --> $DIR/for_kv_map.rs:22:19 | LL | for (_, v) in &mut m { @@ -32,7 +36,7 @@ help: use the corresponding method LL | for v in m.values_mut() { | ~ ~~~~~~~~~~~~~~ -error: you seem to want to iterate on a map's values +warning: you seem to want to iterate on a map's values --> $DIR/for_kv_map.rs:27:19 | LL | for (_, v) in &mut *m { @@ -43,7 +47,7 @@ help: use the corresponding method LL | for v in (*m).values_mut() { | ~ ~~~~~~~~~~~~~~~~~ -error: you seem to want to iterate on a map's keys +warning: you seem to want to iterate on a map's keys --> $DIR/for_kv_map.rs:33:24 | LL | for (k, _value) in rm { @@ -54,5 +58,5 @@ help: use the corresponding method LL | for k in rm.keys() { | ~ ~~~~~~~~~ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/for_loop_fixable.fixed b/tests/ui/for_loop_fixable.fixed index e9dd38fe40e6..f578c98da153 100644 --- a/tests/ui/for_loop_fixable.fixed +++ b/tests/ui/for_loop_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/for_loop_fixable.rs b/tests/ui/for_loop_fixable.rs index 534fb4dd4ef2..42bc6de0c7dd 100644 --- a/tests/ui/for_loop_fixable.rs +++ b/tests/ui/for_loop_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/for_loop_fixable.stderr b/tests/ui/for_loop_fixable.stderr index ddfe66d675f9..9c8d2713f21c 100644 --- a/tests/ui/for_loop_fixable.stderr +++ b/tests/ui/for_loop_fixable.stderr @@ -1,96 +1,116 @@ -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:43:15 | LL | for _v in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | - = note: `-D clippy::explicit-iter-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/for_loop_fixable.rs:21:5 + | +LL | clippy::explicit_iter_loop, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:45:15 | LL | for _v in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` -error: it is more concise to loop over containers instead of using explicit iteration methods +warning: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:48:15 | LL | for _v in out_vec.into_iter() {} | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` | - = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/for_loop_fixable.rs:22:5 + | +LL | clippy::explicit_into_iter_loop, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:53:15 | LL | for _v in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:57:15 | LL | for _v in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:62:15 | LL | for _v in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:65:15 | LL | for _v in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:68:15 | LL | for _v in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:71:15 | LL | for _v in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:74:15 | LL | for _v in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:77:15 | LL | for _v in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:80:15 | LL | for _v in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` -error: it is more concise to loop over containers instead of using explicit iteration methods +warning: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:255:18 | LL | for i in iterator.into_iter() { | ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator` + | +note: the lint level is defined here + --> $DIR/for_loop_fixable.rs:249:8 + | +LL | #[warn(clippy::explicit_into_iter_loop, clippy::explicit_iter_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: it is more concise to loop over references to containers instead of using explicit iteration methods +warning: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:275:18 | LL | for _ in t.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t` + | +note: the lint level is defined here + --> $DIR/for_loop_fixable.rs:249:41 + | +LL | #[warn(clippy::explicit_into_iter_loop, clippy::explicit_iter_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: it is more concise to loop over containers instead of using explicit iteration methods +warning: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/for_loop_fixable.rs:277:18 | LL | for _ in r.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `r` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/for_loop_unfixable.stderr b/tests/ui/for_loop_unfixable.stderr index 50a86eaa68f7..10918727f44c 100644 --- a/tests/ui/for_loop_unfixable.stderr +++ b/tests/ui/for_loop_unfixable.stderr @@ -1,10 +1,14 @@ -error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want +warning: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want --> $DIR/for_loop_unfixable.rs:15:15 | LL | for _v in vec.iter().next() {} | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::iter-next-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/for_loop_unfixable.rs:7:5 + | +LL | clippy::iter_next_loop, + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/forget_non_drop.stderr b/tests/ui/forget_non_drop.stderr index 194e37c8b424..ca6ac6a7a42e 100644 --- a/tests/ui/forget_non_drop.stderr +++ b/tests/ui/forget_non_drop.stderr @@ -1,4 +1,4 @@ -error: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it +warning: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it --> $DIR/forget_non_drop.rs:13:5 | LL | forget(Foo); @@ -9,9 +9,13 @@ note: argument has type `main::Foo` | LL | forget(Foo); | ^^^ - = note: `-D clippy::forget-non-drop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/forget_non_drop.rs:1:9 + | +LL | #![warn(clippy::forget_non_drop)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it +warning: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it --> $DIR/forget_non_drop.rs:24:5 | LL | forget(Baz(Foo)); @@ -23,5 +27,5 @@ note: argument has type `main::Baz` LL | forget(Baz(Foo)); | ^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/forget_ref.stderr b/tests/ui/forget_ref.stderr index 011cdefc665f..48ebc6ddb8dc 100644 --- a/tests/ui/forget_ref.stderr +++ b/tests/ui/forget_ref.stderr @@ -1,4 +1,4 @@ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:11:5 | LL | forget(&SomeStruct); @@ -9,9 +9,13 @@ note: argument has type `&SomeStruct` | LL | forget(&SomeStruct); | ^^^^^^^^^^^ - = note: `-D clippy::forget-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/forget_ref.rs:1:9 + | +LL | #![warn(clippy::forget_ref)] + | ^^^^^^^^^^^^^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:14:5 | LL | forget(&owned); @@ -23,7 +27,7 @@ note: argument has type `&SomeStruct` LL | forget(&owned); | ^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:15:5 | LL | forget(&&owned); @@ -35,7 +39,7 @@ note: argument has type `&&SomeStruct` LL | forget(&&owned); | ^^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:16:5 | LL | forget(&mut owned); @@ -47,7 +51,7 @@ note: argument has type `&mut SomeStruct` LL | forget(&mut owned); | ^^^^^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:20:5 | LL | forget(&*reference1); @@ -59,7 +63,7 @@ note: argument has type `&SomeStruct` LL | forget(&*reference1); | ^^^^^^^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:23:5 | LL | forget(reference2); @@ -71,7 +75,7 @@ note: argument has type `&mut SomeStruct` LL | forget(reference2); | ^^^^^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:26:5 | LL | forget(reference3); @@ -83,7 +87,7 @@ note: argument has type `&SomeStruct` LL | forget(reference3); | ^^^^^^^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:31:5 | LL | forget(&val); @@ -95,7 +99,7 @@ note: argument has type `&T` LL | forget(&val); | ^^^^ -error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing +warning: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing --> $DIR/forget_ref.rs:39:5 | LL | std::mem::forget(&SomeStruct); @@ -107,5 +111,5 @@ note: argument has type `&SomeStruct` LL | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/format.fixed b/tests/ui/format.fixed index cd2f70ee8b02..4a62dfe9a7e3 100644 --- a/tests/ui/format.fixed +++ b/tests/ui/format.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::useless_format)] #![allow( unused_tuple_struct_fields, diff --git a/tests/ui/format.rs b/tests/ui/format.rs index c22345a79d43..879617aff426 100644 --- a/tests/ui/format.rs +++ b/tests/ui/format.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::useless_format)] #![allow( unused_tuple_struct_fields, diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index a0e5d5c8ad21..7546d8ea7113 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -1,24 +1,28 @@ -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:22:5 | LL | format!("foo"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` | - = note: `-D clippy::useless-format` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/format.rs:3:9 + | +LL | #![warn(clippy::useless_format)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:23:5 | LL | format!("{{}}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:24:5 | LL | format!("{{}} abc {{}}"); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:25:5 | LL | / format!( @@ -33,71 +37,71 @@ LL ~ r##"foo {} LL ~ " bar"##.to_string(); | -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:30:13 | LL | let _ = format!(""); | ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:32:5 | LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:40:5 | LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:70:5 | LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:72:5 | LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:76:18 | LL | let _ = Some(format!("{}", a + "bar")); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:80:22 | -LL | let _s: String = format!("{}", &*v.join("/n")); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("/n")).to_string()` +LL | let _s: String = format!("{}", &*v.join("\n")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("\n")).to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:86:13 | LL | let _ = format!("{x}"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:88:13 | LL | let _ = format!("{y}", y = x); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:92:13 | LL | let _ = format!("{abc}"); | ^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `abc.to_string()` -error: useless use of `format!` +warning: useless use of `format!` --> $DIR/format.rs:94:13 | LL | let _ = format!("{xx}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `xx.to_string()` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/format_args.fixed b/tests/ui/format_args.fixed index 825e122be5a5..ea3836861357 100644 --- a/tests/ui/format_args.fixed +++ b/tests/ui/format_args.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::to_string_in_format_args)] #![allow(unused)] #![allow( diff --git a/tests/ui/format_args.rs b/tests/ui/format_args.rs index a41e53389e52..bfb324492467 100644 --- a/tests/ui/format_args.rs +++ b/tests/ui/format_args.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::to_string_in_format_args)] #![allow(unused)] #![allow( diff --git a/tests/ui/format_args.stderr b/tests/ui/format_args.stderr index f1832b970198..f16db1a50337 100644 --- a/tests/ui/format_args.stderr +++ b/tests/ui/format_args.stderr @@ -1,154 +1,158 @@ -error: `to_string` applied to a type that implements `Display` in `format!` args +warning: `to_string` applied to a type that implements `Display` in `format!` args --> $DIR/format_args.rs:77:72 | LL | let _ = format!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this | - = note: `-D clippy::to-string-in-format-args` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/format_args.rs:2:9 + | +LL | #![warn(clippy::to_string_in_format_args)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `to_string` applied to a type that implements `Display` in `write!` args +warning: `to_string` applied to a type that implements `Display` in `write!` args --> $DIR/format_args.rs:81:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `writeln!` args +warning: `to_string` applied to a type that implements `Display` in `writeln!` args --> $DIR/format_args.rs:86:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `print!` args +warning: `to_string` applied to a type that implements `Display` in `print!` args --> $DIR/format_args.rs:88:63 | LL | print!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:89:65 | LL | println!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `eprint!` args +warning: `to_string` applied to a type that implements `Display` in `eprint!` args --> $DIR/format_args.rs:90:64 | LL | eprint!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `eprintln!` args +warning: `to_string` applied to a type that implements `Display` in `eprintln!` args --> $DIR/format_args.rs:91:66 | LL | eprintln!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `format_args!` args +warning: `to_string` applied to a type that implements `Display` in `format_args!` args --> $DIR/format_args.rs:92:77 | LL | let _ = format_args!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `assert!` args +warning: `to_string` applied to a type that implements `Display` in `assert!` args --> $DIR/format_args.rs:93:70 | LL | assert!(true, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `assert_eq!` args +warning: `to_string` applied to a type that implements `Display` in `assert_eq!` args --> $DIR/format_args.rs:94:73 | LL | assert_eq!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `assert_ne!` args +warning: `to_string` applied to a type that implements `Display` in `assert_ne!` args --> $DIR/format_args.rs:95:73 | LL | assert_ne!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `panic!` args +warning: `to_string` applied to a type that implements `Display` in `panic!` args --> $DIR/format_args.rs:96:63 | LL | panic!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:97:20 | LL | println!("{}", X(1).to_string()); | ^^^^^^^^^^^^^^^^ help: use this: `*X(1)` -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:98:20 | LL | println!("{}", Y(&X(1)).to_string()); | ^^^^^^^^^^^^^^^^^^^^ help: use this: `***Y(&X(1))` -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:99:24 | LL | println!("{}", Z(1).to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:100:20 | LL | println!("{}", x.to_string()); | ^^^^^^^^^^^^^ help: use this: `**x` -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:101:20 | LL | println!("{}", x_ref.to_string()); | ^^^^^^^^^^^^^^^^^ help: use this: `***x_ref` -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:103:39 | LL | println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:104:52 | LL | println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:105:39 | LL | println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:106:52 | LL | println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `print!` args +warning: `to_string` applied to a type that implements `Display` in `print!` args --> $DIR/format_args.rs:118:37 | LL | print!("{}", (Location::caller().to_string())); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `print!` args +warning: `to_string` applied to a type that implements `Display` in `print!` args --> $DIR/format_args.rs:119:39 | LL | print!("{}", ((Location::caller()).to_string())); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `format!` args +warning: `to_string` applied to a type that implements `Display` in `format!` args --> $DIR/format_args.rs:147:38 | LL | let x = format!("{} {}", a, b.to_string()); | ^^^^^^^^^^^^ help: remove this -error: `to_string` applied to a type that implements `Display` in `println!` args +warning: `to_string` applied to a type that implements `Display` in `println!` args --> $DIR/format_args.rs:161:24 | LL | println!("{}", original[..10].to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use this: `&original[..10]` -error: aborting due to 25 previous errors +warning: 25 warnings emitted diff --git a/tests/ui/format_args_unfixable.stderr b/tests/ui/format_args_unfixable.stderr index b291d475ad90..93ab5b5a92af 100644 --- a/tests/ui/format_args_unfixable.stderr +++ b/tests/ui/format_args_unfixable.stderr @@ -1,4 +1,4 @@ -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:25:5 | LL | println!("error: {}", format!("something failed at {}", Location::caller())); @@ -6,9 +6,13 @@ LL | println!("error: {}", format!("something failed at {}", Location::calle | = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` - = note: `-D clippy::format-in-format-args` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/format_args_unfixable.rs:1:9 + | +LL | #![warn(clippy::format_in_format_args, clippy::to_string_in_format_args)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:26:5 | LL | println!("{}: {}", error, format!("something failed at {}", Location::caller())); @@ -17,7 +21,7 @@ LL | println!("{}: {}", error, format!("something failed at {}", Location::c = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:27:5 | LL | println!("{:?}: {}", error, format!("something failed at {}", Location::caller())); @@ -26,7 +30,7 @@ LL | println!("{:?}: {}", error, format!("something failed at {}", Location: = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:28:5 | LL | println!("{{}}: {}", format!("something failed at {}", Location::caller())); @@ -35,7 +39,7 @@ LL | println!("{{}}: {}", format!("something failed at {}", Location::caller = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:29:5 | LL | println!(r#"error: "{}""#, format!("something failed at {}", Location::caller())); @@ -44,7 +48,7 @@ LL | println!(r#"error: "{}""#, format!("something failed at {}", Location:: = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:30:5 | LL | println!("error: {}", format!(r#"something failed at "{}""#, Location::caller())); @@ -53,7 +57,7 @@ LL | println!("error: {}", format!(r#"something failed at "{}""#, Location:: = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `println!` args +warning: `format!` in `println!` args --> $DIR/format_args_unfixable.rs:31:5 | LL | println!("error: {}", format!("something failed at {} {0}", Location::caller())); @@ -62,7 +66,7 @@ LL | println!("error: {}", format!("something failed at {} {0}", Location::c = help: combine the `format!(..)` arguments with the outer `println!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `format!` args +warning: `format!` in `format!` args --> $DIR/format_args_unfixable.rs:32:13 | LL | let _ = format!("error: {}", format!("something failed at {}", Location::caller())); @@ -71,7 +75,7 @@ LL | let _ = format!("error: {}", format!("something failed at {}", Location = help: combine the `format!(..)` arguments with the outer `format!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `write!` args +warning: `format!` in `write!` args --> $DIR/format_args_unfixable.rs:33:13 | LL | let _ = write!( @@ -85,7 +89,7 @@ LL | | ); = help: combine the `format!(..)` arguments with the outer `write!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `writeln!` args +warning: `format!` in `writeln!` args --> $DIR/format_args_unfixable.rs:38:13 | LL | let _ = writeln!( @@ -99,7 +103,7 @@ LL | | ); = help: combine the `format!(..)` arguments with the outer `writeln!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `print!` args +warning: `format!` in `print!` args --> $DIR/format_args_unfixable.rs:43:5 | LL | print!("error: {}", format!("something failed at {}", Location::caller())); @@ -108,7 +112,7 @@ LL | print!("error: {}", format!("something failed at {}", Location::caller( = help: combine the `format!(..)` arguments with the outer `print!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `eprint!` args +warning: `format!` in `eprint!` args --> $DIR/format_args_unfixable.rs:44:5 | LL | eprint!("error: {}", format!("something failed at {}", Location::caller())); @@ -117,7 +121,7 @@ LL | eprint!("error: {}", format!("something failed at {}", Location::caller = help: combine the `format!(..)` arguments with the outer `eprint!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `eprintln!` args +warning: `format!` in `eprintln!` args --> $DIR/format_args_unfixable.rs:45:5 | LL | eprintln!("error: {}", format!("something failed at {}", Location::caller())); @@ -126,7 +130,7 @@ LL | eprintln!("error: {}", format!("something failed at {}", Location::call = help: combine the `format!(..)` arguments with the outer `eprintln!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `format_args!` args +warning: `format!` in `format_args!` args --> $DIR/format_args_unfixable.rs:46:13 | LL | let _ = format_args!("error: {}", format!("something failed at {}", Location::caller())); @@ -135,7 +139,7 @@ LL | let _ = format_args!("error: {}", format!("something failed at {}", Loc = help: combine the `format!(..)` arguments with the outer `format_args!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `assert!` args +warning: `format!` in `assert!` args --> $DIR/format_args_unfixable.rs:47:5 | LL | assert!(true, "error: {}", format!("something failed at {}", Location::caller())); @@ -144,7 +148,7 @@ LL | assert!(true, "error: {}", format!("something failed at {}", Location:: = help: combine the `format!(..)` arguments with the outer `assert!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `assert_eq!` args +warning: `format!` in `assert_eq!` args --> $DIR/format_args_unfixable.rs:48:5 | LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); @@ -153,7 +157,7 @@ LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: combine the `format!(..)` arguments with the outer `assert_eq!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `assert_ne!` args +warning: `format!` in `assert_ne!` args --> $DIR/format_args_unfixable.rs:49:5 | LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); @@ -162,7 +166,7 @@ LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: combine the `format!(..)` arguments with the outer `assert_ne!(..)` call = help: or consider changing `format!` to `format_args!` -error: `format!` in `panic!` args +warning: `format!` in `panic!` args --> $DIR/format_args_unfixable.rs:50:5 | LL | panic!("error: {}", format!("something failed at {}", Location::caller())); @@ -171,5 +175,5 @@ LL | panic!("error: {}", format!("something failed at {}", Location::caller( = help: combine the `format!(..)` arguments with the outer `panic!(..)` call = help: or consider changing `format!` to `format_args!` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/format_push_string.stderr b/tests/ui/format_push_string.stderr index d7be9a5f206c..4178dc0bd33a 100644 --- a/tests/ui/format_push_string.stderr +++ b/tests/ui/format_push_string.stderr @@ -1,13 +1,17 @@ -error: `format!(..)` appended to existing `String` +warning: `format!(..)` appended to existing `String` --> $DIR/format_push_string.rs:5:5 | LL | string += &format!("{:?}", 1234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using `write!` to avoid the extra allocation - = note: `-D clippy::format-push-string` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/format_push_string.rs:1:9 + | +LL | #![warn(clippy::format_push_string)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `format!(..)` appended to existing `String` +warning: `format!(..)` appended to existing `String` --> $DIR/format_push_string.rs:6:5 | LL | string.push_str(&format!("{:?}", 5678)); @@ -15,5 +19,5 @@ LL | string.push_str(&format!("{:?}", 5678)); | = help: consider using `write!` to avoid the extra allocation -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index caccd5cba178..f7c7a22a7668 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,13 +1,18 @@ -error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` +warning: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` --> $DIR/formatting.rs:16:6 | LL | a =- 35; | ^^^^ | = note: to remove this lint, use either `-=` or `= -` - = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/formatting.rs:1:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::suspicious_assignment_formatting)]` implied by `#[warn(clippy::all)]` -error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` +warning: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` --> $DIR/formatting.rs:17:6 | LL | a =* &191; @@ -15,7 +20,7 @@ LL | a =* &191; | = note: to remove this lint, use either `*=` or `= *` -error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` +warning: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` --> $DIR/formatting.rs:20:6 | LL | b =! false; @@ -23,16 +28,16 @@ LL | b =! false; | = note: to remove this lint, use either `!=` or `= !` -error: possibly missing a comma here +warning: possibly missing a comma here --> $DIR/formatting.rs:29:19 | LL | -1, -2, -3 // <= no comma here | ^ | = note: to remove this lint, add a comma or write the expr in a single line - = note: `-D clippy::possible-missing-comma` implied by `-D warnings` + = note: `#[warn(clippy::possible_missing_comma)]` implied by `#[warn(clippy::all)]` -error: possibly missing a comma here +warning: possibly missing a comma here --> $DIR/formatting.rs:33:19 | LL | -1, -2, -3 // <= no comma here @@ -40,7 +45,7 @@ LL | -1, -2, -3 // <= no comma here | = note: to remove this lint, add a comma or write the expr in a single line -error: possibly missing a comma here +warning: possibly missing a comma here --> $DIR/formatting.rs:70:11 | LL | -1 @@ -48,5 +53,5 @@ LL | -1 | = note: to remove this lint, add a comma or write the expr in a single line -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/from_iter_instead_of_collect.fixed b/tests/ui/from_iter_instead_of_collect.fixed index 48f8093311cb..e926f8c529df 100644 --- a/tests/ui/from_iter_instead_of_collect.fixed +++ b/tests/ui/from_iter_instead_of_collect.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::from_iter_instead_of_collect)] #![allow(unused_imports, unused_tuple_struct_fields)] @@ -15,47 +15,47 @@ impl FromIterator for Foo { impl<'a> FromIterator<&'a bool> for Foo { fn from_iter>(iter: T) -> Self { - iter.into_iter().copied().collect::() + >::from_iter(iter.into_iter().copied()) } } fn main() { let iter_expr = std::iter::repeat(5).take(5); - let _ = iter_expr.collect::>(); + let _ = Vec::from_iter(iter_expr); - let _ = vec![5, 5, 5, 5].iter().enumerate().collect::>(); + let _ = HashMap::::from_iter(vec![5, 5, 5, 5].iter().enumerate()); Vec::from_iter(vec![42u32]); let a = vec![0, 1, 2]; - assert_eq!(a, (0..3).collect::>()); - assert_eq!(a, (0..3).collect::>()); + assert_eq!(a, Vec::from_iter(0..3)); + assert_eq!(a, Vec::::from_iter(0..3)); - let mut b = (0..3).collect::>(); + let mut b = VecDeque::from_iter(0..3); b.push_back(4); - let mut b = (0..3).collect::>(); + let mut b = VecDeque::::from_iter(0..3); b.push_back(4); { use std::collections; - let mut b = (0..3).collect::>(); + let mut b = collections::VecDeque::::from_iter(0..3); b.push_back(4); } let values = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd')]; - let bm = values.iter().cloned().collect::>(); - let mut bar = bm.range(0..2).collect::>(); + let bm = BTreeMap::from_iter(values.iter().cloned()); + let mut bar = BTreeMap::from_iter(bm.range(0..2)); bar.insert(&4, &'e'); - let mut bts = (0..3).collect::>(); + let mut bts = BTreeSet::from_iter(0..3); bts.insert(2); { use std::collections; - let _ = (0..3).collect::>(); - let _ = (0..3).collect::>(); + let _ = collections::BTreeSet::from_iter(0..3); + let _ = collections::BTreeSet::::from_iter(0..3); } - for _i in [1, 2, 3].iter().collect::>() {} - for _i in [1, 2, 3].iter().collect::>() {} + for _i in Vec::from_iter([1, 2, 3].iter()) {} + for _i in Vec::<&i32>::from_iter([1, 2, 3].iter()) {} } diff --git a/tests/ui/from_iter_instead_of_collect.rs b/tests/ui/from_iter_instead_of_collect.rs index ebe0ad278be3..e926f8c529df 100644 --- a/tests/ui/from_iter_instead_of_collect.rs +++ b/tests/ui/from_iter_instead_of_collect.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::from_iter_instead_of_collect)] #![allow(unused_imports, unused_tuple_struct_fields)] diff --git a/tests/ui/from_iter_instead_of_collect.stderr b/tests/ui/from_iter_instead_of_collect.stderr index 8aa3c3c01f81..83226597148a 100644 --- a/tests/ui/from_iter_instead_of_collect.stderr +++ b/tests/ui/from_iter_instead_of_collect.stderr @@ -1,94 +1,98 @@ -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:18:9 | LL | >::from_iter(iter.into_iter().copied()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter.into_iter().copied().collect::()` | - = note: `-D clippy::from-iter-instead-of-collect` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/from_iter_instead_of_collect.rs:3:9 + | +LL | #![warn(clippy::from_iter_instead_of_collect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:24:13 | LL | let _ = Vec::from_iter(iter_expr); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter_expr.collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:26:13 | LL | let _ = HashMap::::from_iter(vec![5, 5, 5, 5].iter().enumerate()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `vec![5, 5, 5, 5].iter().enumerate().collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:31:19 | LL | assert_eq!(a, Vec::from_iter(0..3)); | ^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:32:19 | LL | assert_eq!(a, Vec::::from_iter(0..3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:34:17 | LL | let mut b = VecDeque::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:37:17 | LL | let mut b = VecDeque::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:42:21 | LL | let mut b = collections::VecDeque::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:47:14 | LL | let bm = BTreeMap::from_iter(values.iter().cloned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `values.iter().cloned().collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:48:19 | LL | let mut bar = BTreeMap::from_iter(bm.range(0..2)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `bm.range(0..2).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:51:19 | LL | let mut bts = BTreeSet::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:55:17 | LL | let _ = collections::BTreeSet::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:56:17 | LL | let _ = collections::BTreeSet::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:59:15 | LL | for _i in Vec::from_iter([1, 2, 3].iter()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `[1, 2, 3].iter().collect::>()` -error: usage of `FromIterator::from_iter` +warning: usage of `FromIterator::from_iter` --> $DIR/from_iter_instead_of_collect.rs:60:15 | LL | for _i in Vec::<&i32>::from_iter([1, 2, 3].iter()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `[1, 2, 3].iter().collect::>()` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/from_over_into.fixed b/tests/ui/from_over_into.fixed index 72d635c2ccd6..fc6d937060dc 100644 --- a/tests/ui/from_over_into.fixed +++ b/tests/ui/from_over_into.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(type_alias_impl_trait)] #![warn(clippy::from_over_into)] diff --git a/tests/ui/from_over_into.rs b/tests/ui/from_over_into.rs index 965f4d5d7859..fe1ebee35f16 100644 --- a/tests/ui/from_over_into.rs +++ b/tests/ui/from_over_into.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(type_alias_impl_trait)] #![warn(clippy::from_over_into)] diff --git a/tests/ui/from_over_into.stderr b/tests/ui/from_over_into.stderr index 3c4d011d6fb4..7c739ba103da 100644 --- a/tests/ui/from_over_into.stderr +++ b/tests/ui/from_over_into.stderr @@ -1,10 +1,14 @@ -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into.rs:10:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::from-over-into` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/from_over_into.rs:4:9 + | +LL | #![warn(clippy::from_over_into)] + | ^^^^^^^^^^^^^^^^^^^^^^ help: replace the `Into` implentation with `From` | LL ~ impl From for StringWrapper { @@ -12,7 +16,7 @@ LL ~ fn from(val: String) -> Self { LL ~ StringWrapper(val) | -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into.rs:18:1 | LL | impl Into for String { @@ -25,7 +29,7 @@ LL ~ fn from(val: String) -> Self { LL ~ SelfType(String::new()) | -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into.rs:33:1 | LL | impl Into for X { @@ -40,7 +44,7 @@ LL ~ let _ = X::FOO; LL ~ let _: X = val; | -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into.rs:45:1 | LL | impl core::convert::Into for crate::ExplicitPaths { @@ -58,7 +62,7 @@ LL ~ val.0 = false; LL ~ val.0 | -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into.rs:78:5 | LL | impl Into> for Vec { @@ -71,5 +75,5 @@ LL ~ fn from(val: Vec) -> Self { LL ~ FromOverInto(val) | -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/from_over_into_unfixable.stderr b/tests/ui/from_over_into_unfixable.stderr index 6f6ce351921b..74d9a6ecbf95 100644 --- a/tests/ui/from_over_into_unfixable.stderr +++ b/tests/ui/from_over_into_unfixable.stderr @@ -1,13 +1,17 @@ -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into_unfixable.rs:11:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: replace the `Into` implentation with `From` - = note: `-D clippy::from-over-into` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/from_over_into_unfixable.rs:1:9 + | +LL | #![warn(clippy::from_over_into)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into_unfixable.rs:19:1 | LL | impl Into for &'static [u8] { @@ -15,7 +19,7 @@ LL | impl Into for &'static [u8] { | = help: replace the `Into` implentation with `From<&'static [u8]>` -error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true +warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> $DIR/from_over_into_unfixable.rs:28:1 | LL | impl Into for ContainsVal { @@ -25,5 +29,5 @@ LL | impl Into for ContainsVal { https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence = help: replace the `Into` implentation with `From` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/from_raw_with_void_ptr.stderr b/tests/ui/from_raw_with_void_ptr.stderr index 96e4af12ba38..4a433e9d48fe 100644 --- a/tests/ui/from_raw_with_void_ptr.stderr +++ b/tests/ui/from_raw_with_void_ptr.stderr @@ -1,4 +1,4 @@ -error: creating a `Box` from a void raw pointer +warning: creating a `Box` from a void raw pointer --> $DIR/from_raw_with_void_ptr.rs:10:22 | LL | let _ = unsafe { Box::from_raw(ptr) }; @@ -9,9 +9,13 @@ help: cast this to a pointer of the appropriate type | LL | let _ = unsafe { Box::from_raw(ptr) }; | ^^^ - = note: `-D clippy::from-raw-with-void-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/from_raw_with_void_ptr.rs:1:9 + | +LL | #![warn(clippy::from_raw_with_void_ptr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: creating a `Rc` from a void raw pointer +warning: creating a `Rc` from a void raw pointer --> $DIR/from_raw_with_void_ptr.rs:21:22 | LL | let _ = unsafe { Rc::from_raw(ptr) }; @@ -23,7 +27,7 @@ help: cast this to a pointer of the appropriate type LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^ -error: creating a `Arc` from a void raw pointer +warning: creating a `Arc` from a void raw pointer --> $DIR/from_raw_with_void_ptr.rs:25:22 | LL | let _ = unsafe { Arc::from_raw(ptr) }; @@ -35,7 +39,7 @@ help: cast this to a pointer of the appropriate type LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^ -error: creating a `Weak` from a void raw pointer +warning: creating a `Weak` from a void raw pointer --> $DIR/from_raw_with_void_ptr.rs:29:22 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; @@ -47,7 +51,7 @@ help: cast this to a pointer of the appropriate type LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^ -error: creating a `Weak` from a void raw pointer +warning: creating a `Weak` from a void raw pointer --> $DIR/from_raw_with_void_ptr.rs:33:22 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; @@ -59,5 +63,5 @@ help: cast this to a pointer of the appropriate type LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/from_str_radix_10.stderr b/tests/ui/from_str_radix_10.stderr index da5c16f8d01a..c1e39c87072e 100644 --- a/tests/ui/from_str_radix_10.stderr +++ b/tests/ui/from_str_radix_10.stderr @@ -1,52 +1,56 @@ -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:28:5 | LL | u32::from_str_radix("30", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"30".parse::()` | - = note: `-D clippy::from-str-radix-10` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/from_str_radix_10.rs:1:9 + | +LL | #![warn(clippy::from_str_radix_10)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:29:5 | LL | i64::from_str_radix("24", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"24".parse::()` -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:30:5 | LL | isize::from_str_radix("100", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"100".parse::()` -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:31:5 | LL | u8::from_str_radix("7", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"7".parse::()` -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:32:5 | LL | u16::from_str_radix(&("10".to_owned() + "5"), 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("10".to_owned() + "5").parse::()` -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:33:5 | LL | i128::from_str_radix(Test + Test, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(Test + Test).parse::()` -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:36:5 | LL | i32::from_str_radix(string, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.parse::()` -error: this call to `from_str_radix` can be replaced with a call to `str::parse` +warning: this call to `from_str_radix` can be replaced with a call to `str::parse` --> $DIR/from_str_radix_10.rs:39:5 | LL | i32::from_str_radix(&stringier, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `stringier.parse::()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 8ebd4997f4f6..367a8ee48b04 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -1,12 +1,17 @@ -error: this function has too many arguments (8/7) +warning: this function has too many arguments (8/7) --> $DIR/functions.rs:8:1 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::too-many-arguments` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/functions.rs:1:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::too_many_arguments)]` implied by `#[warn(clippy::all)]` -error: this function has too many arguments (8/7) +warning: this function has too many arguments (8/7) --> $DIR/functions.rs:11:1 | LL | / fn bad_multiline( @@ -18,91 +23,91 @@ LL | | eight: () LL | | ) { | |__^ -error: this function has too many arguments (8/7) +warning: this function has too many arguments (8/7) --> $DIR/functions.rs:45:5 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this function has too many arguments (8/7) +warning: this function has too many arguments (8/7) --> $DIR/functions.rs:54:5 | LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:63:34 | LL | println!("{}", unsafe { *p }); | ^ | - = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` + = note: `#[warn(clippy::not_unsafe_ptr_arg_deref)]` implied by `#[warn(clippy::all)]` -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:64:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:65:33 | LL | unsafe { std::ptr::read(p) }; | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:76:30 | LL | println!("{}", unsafe { *p }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:77:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:78:29 | LL | unsafe { std::ptr::read(p) }; | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:84:30 | LL | println!("{}", unsafe { *p }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:85:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:86:29 | LL | unsafe { std::ptr::read(p) }; | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:95:34 | LL | println!("{}", unsafe { *p }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:96:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ -error: this public function might dereference a raw pointer but is not marked `unsafe` +warning: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:97:33 | LL | unsafe { std::ptr::read(p) }; | ^ -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/functions_maxlines.stderr b/tests/ui/functions_maxlines.stderr index dc6c8ba2f154..5f04f88fdf3e 100644 --- a/tests/ui/functions_maxlines.stderr +++ b/tests/ui/functions_maxlines.stderr @@ -1,4 +1,4 @@ -error: this function has too many lines (102/100) +warning: this function has too many lines (102/100) --> $DIR/functions_maxlines.rs:58:1 | LL | / fn bad_lines() { @@ -10,7 +10,11 @@ LL | | println!("This is bad."); LL | | } | |_^ | - = note: `-D clippy::too-many-lines` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/functions_maxlines.rs:1:9 + | +LL | #![warn(clippy::too_many_lines)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/future_not_send.stderr b/tests/ui/future_not_send.stderr index 5b6858e4568b..2d6d8b6dc4a4 100644 --- a/tests/ui/future_not_send.stderr +++ b/tests/ui/future_not_send.stderr @@ -1,4 +1,4 @@ -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:7:62 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { @@ -24,9 +24,13 @@ LL | async { true }.await LL | } | - `cell` is later dropped here = note: `std::cell::Cell` doesn't implement `std::marker::Sync` - = note: `-D clippy::future-not-send` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/future_not_send.rs:1:9 + | +LL | #![warn(clippy::future_not_send)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:11:42 | LL | pub async fn public_future(rc: Rc<[u8]>) { @@ -43,7 +47,7 @@ LL | } | - `rc` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:19:63 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { @@ -62,7 +66,7 @@ LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^ has type `&std::cell::Cell` which is not `Send`, because `std::cell::Cell` is not `Sync` = note: `std::cell::Cell` doesn't implement `std::marker::Sync` -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:23:43 | LL | pub async fn public_future2(rc: Rc<[u8]>) {} @@ -75,7 +79,7 @@ LL | pub async fn public_future2(rc: Rc<[u8]>) {} | ^^ has type `std::rc::Rc<[u8]>` which is not `Send` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:34:39 | LL | async fn private_future(&self) -> usize { @@ -93,7 +97,7 @@ LL | } | - `&self` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:39:39 | LL | pub async fn public_future(&self) { @@ -110,7 +114,7 @@ LL | } | - `&self` is later dropped here = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:49:37 | LL | async fn generic_future(t: T) -> T @@ -128,7 +132,7 @@ LL | } | - `rt` is later dropped here = note: `T` doesn't implement `std::marker::Sync` -error: future cannot be sent between threads safely +warning: future cannot be sent between threads safely --> $DIR/future_not_send.rs:65:34 | LL | async fn unclear_future(t: T) {} @@ -141,5 +145,5 @@ LL | async fn unclear_future(t: T) {} | ^ has type `T` which is not `Send` = note: `T` doesn't implement `std::marker::Send` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/get_first.fixed b/tests/ui/get_first.fixed index def58afa4fbf..ef132b796117 100644 --- a/tests/ui/get_first.fixed +++ b/tests/ui/get_first.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::get_first)] use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/tests/ui/get_first.rs b/tests/ui/get_first.rs index 85a381854cd3..4d8722356144 100644 --- a/tests/ui/get_first.rs +++ b/tests/ui/get_first.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::get_first)] use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/tests/ui/get_first.stderr b/tests/ui/get_first.stderr index 466beff9c92d..de67040c5acc 100644 --- a/tests/ui/get_first.stderr +++ b/tests/ui/get_first.stderr @@ -1,22 +1,26 @@ -error: accessing first element with `x.get(0)` +warning: accessing first element with `x.get(0)` --> $DIR/get_first.rs:19:13 | LL | let _ = x.get(0); // Use x.first() | ^^^^^^^^ help: try: `x.first()` | - = note: `-D clippy::get-first` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/get_first.rs:2:9 + | +LL | #![warn(clippy::get_first)] + | ^^^^^^^^^^^^^^^^^ -error: accessing first element with `y.get(0)` +warning: accessing first element with `y.get(0)` --> $DIR/get_first.rs:24:13 | LL | let _ = y.get(0); // Use y.first() | ^^^^^^^^ help: try: `y.first()` -error: accessing first element with `z.get(0)` +warning: accessing first element with `z.get(0)` --> $DIR/get_first.rs:29:13 | LL | let _ = z.get(0); // Use z.first() | ^^^^^^^^ help: try: `z.first()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/get_last_with_len.fixed b/tests/ui/get_last_with_len.fixed index 1e90b37687a1..a58dfda79885 100644 --- a/tests/ui/get_last_with_len.fixed +++ b/tests/ui/get_last_with_len.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::get_last_with_len)] #![allow(unused)] diff --git a/tests/ui/get_last_with_len.rs b/tests/ui/get_last_with_len.rs index d63a731bd524..d626656c78f9 100644 --- a/tests/ui/get_last_with_len.rs +++ b/tests/ui/get_last_with_len.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::get_last_with_len)] #![allow(unused)] diff --git a/tests/ui/get_last_with_len.stderr b/tests/ui/get_last_with_len.stderr index ac8dd6c2e41a..fdaba7a1c481 100644 --- a/tests/ui/get_last_with_len.stderr +++ b/tests/ui/get_last_with_len.stderr @@ -1,40 +1,44 @@ -error: accessing last element with `x.get(x.len() - 1)` +warning: accessing last element with `x.get(x.len() - 1)` --> $DIR/get_last_with_len.rs:10:13 | LL | let _ = x.get(x.len() - 1); | ^^^^^^^^^^^^^^^^^^ help: try: `x.last()` | - = note: `-D clippy::get-last-with-len` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/get_last_with_len.rs:3:9 + | +LL | #![warn(clippy::get_last_with_len)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: accessing last element with `s.field.get(s.field.len() - 1)` +warning: accessing last element with `s.field.get(s.field.len() - 1)` --> $DIR/get_last_with_len.rs:34:13 | LL | let _ = s.field.get(s.field.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.field.last()` -error: accessing last element with `slice.get(slice.len() - 1)` +warning: accessing last element with `slice.get(slice.len() - 1)` --> $DIR/get_last_with_len.rs:39:13 | LL | let _ = slice.get(slice.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice.last()` -error: accessing last element with `array.get(array.len() - 1)` +warning: accessing last element with `array.get(array.len() - 1)` --> $DIR/get_last_with_len.rs:42:13 | LL | let _ = array.get(array.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array.last()` -error: accessing last element with `deq.get(deq.len() - 1)` +warning: accessing last element with `deq.get(deq.len() - 1)` --> $DIR/get_last_with_len.rs:45:13 | LL | let _ = deq.get(deq.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `deq.back()` -error: accessing last element with `nested[0].get(nested[0].len() - 1)` +warning: accessing last element with `nested[0].get(nested[0].len() - 1)` --> $DIR/get_last_with_len.rs:48:13 | LL | let _ = nested[0].get(nested[0].len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `nested[0].last()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/get_unwrap.fixed b/tests/ui/get_unwrap.fixed index 5827fc7d76e6..297763f2e776 100644 --- a/tests/ui/get_unwrap.fixed +++ b/tests/ui/get_unwrap.fixed @@ -1,8 +1,8 @@ -// run-rustfix +//@run-rustfix #![allow(unused_mut, clippy::from_iter_instead_of_collect, clippy::get_first)] #![warn(clippy::unwrap_used)] -#![deny(clippy::get_unwrap)] +#![warn(clippy::get_unwrap)] use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/tests/ui/get_unwrap.rs b/tests/ui/get_unwrap.rs index a2a323c14fb7..20b2bbe83182 100644 --- a/tests/ui/get_unwrap.rs +++ b/tests/ui/get_unwrap.rs @@ -1,8 +1,8 @@ -// run-rustfix +//@run-rustfix #![allow(unused_mut, clippy::from_iter_instead_of_collect, clippy::get_first)] #![warn(clippy::unwrap_used)] -#![deny(clippy::get_unwrap)] +#![warn(clippy::get_unwrap)] use std::collections::BTreeMap; use std::collections::HashMap; diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index 6dee4d5b4b62..cb28dfd322ec 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -1,4 +1,4 @@ -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:35:17 | LL | let _ = boxed_slice.get(1).unwrap(); @@ -7,25 +7,29 @@ LL | let _ = boxed_slice.get(1).unwrap(); note: the lint level is defined here --> $DIR/get_unwrap.rs:5:9 | -LL | #![deny(clippy::get_unwrap)] +LL | #![warn(clippy::get_unwrap)] | ^^^^^^^^^^^^^^^^^^ -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:35:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message - = note: `-D clippy::unwrap-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/get_unwrap.rs:4:9 + | +LL | #![warn(clippy::unwrap_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:36:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:36:17 | LL | let _ = some_slice.get(0).unwrap(); @@ -33,13 +37,13 @@ LL | let _ = some_slice.get(0).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:37:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:37:17 | LL | let _ = some_vec.get(0).unwrap(); @@ -47,13 +51,13 @@ LL | let _ = some_vec.get(0).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:38:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:38:17 | LL | let _ = some_vecdeque.get(0).unwrap(); @@ -61,13 +65,13 @@ LL | let _ = some_vecdeque.get(0).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:39:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:39:17 | LL | let _ = some_hashmap.get(&1).unwrap(); @@ -75,13 +79,13 @@ LL | let _ = some_hashmap.get(&1).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:40:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:40:17 | LL | let _ = some_btreemap.get(&1).unwrap(); @@ -89,13 +93,13 @@ LL | let _ = some_btreemap.get(&1).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:44:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:44:22 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); @@ -103,13 +107,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:49:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:49:10 | LL | *boxed_slice.get_mut(0).unwrap() = 1; @@ -117,13 +121,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:50:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:50:10 | LL | *some_slice.get_mut(0).unwrap() = 1; @@ -131,13 +135,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:51:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:51:10 | LL | *some_vec.get_mut(0).unwrap() = 1; @@ -145,13 +149,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:52:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:52:10 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; @@ -159,13 +163,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1; | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:64:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:64:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); @@ -173,13 +177,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise +warning: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise --> $DIR/get_unwrap.rs:65:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/get_unwrap.rs:65:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); @@ -187,5 +191,5 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message -error: aborting due to 26 previous errors +warning: 26 warnings emitted diff --git a/tests/ui/identity_op.fixed b/tests/ui/identity_op.fixed index cac69ef42c41..beb16000eca2 100644 --- a/tests/ui/identity_op.fixed +++ b/tests/ui/identity_op.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::identity_op)] #![allow(unused)] #![allow( diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index 33201aad4f64..072e00c00f0a 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::identity_op)] #![allow(unused)] #![allow( diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 3ba557d18b24..82950d5a7e16 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,244 +1,248 @@ -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:43:5 | LL | x + 0; | ^^^^^ help: consider reducing it to: `x` | - = note: `-D clippy::identity-op` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/identity_op.rs:2:9 + | +LL | #![warn(clippy::identity_op)] + | ^^^^^^^^^^^^^^^^^^^ -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:44:5 | LL | x + (1 - 1); | ^^^^^^^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:46:5 | LL | 0 + x; | ^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:49:5 | LL | x | (0); | ^^^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:52:5 | LL | x * 1; | ^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:53:5 | LL | 1 * x; | ^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:59:5 | LL | -1 & x; | ^^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:62:5 | LL | u & 255; | ^^^^^^^ help: consider reducing it to: `u` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:65:5 | LL | 42 << 0; | ^^^^^^^ help: consider reducing it to: `42` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:66:5 | LL | 1 >> 0; | ^^^^^^ help: consider reducing it to: `1` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:67:5 | LL | 42 >> 0; | ^^^^^^^ help: consider reducing it to: `42` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:68:5 | LL | &x >> 0; | ^^^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:69:5 | LL | x >> &0; | ^^^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:76:5 | LL | 2 % 3; | ^^^^^ help: consider reducing it to: `2` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:77:5 | LL | -2 % 3; | ^^^^^^ help: consider reducing it to: `-2` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:78:5 | LL | 2 % -3 + x; | ^^^^^^ help: consider reducing it to: `2` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:79:5 | LL | -2 % -3 + x; | ^^^^^^^ help: consider reducing it to: `-2` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:80:9 | LL | x + 1 % 3; | ^^^^^ help: consider reducing it to: `1` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:88:5 | LL | 0 + if b { 1 } else { 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:89:5 | LL | 0 + if b { 1 } else { 2 } + if b { 3 } else { 4 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:90:5 | LL | 0 + match a { 0 => 10, _ => 20 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:91:5 | LL | 0 + match a { 0 => 10, _ => 20 } + match a { 0 => 30, _ => 40 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:92:5 | LL | 0 + if b { 1 } else { 2 } + match a { 0 => 30, _ => 40 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:93:5 | LL | 0 + match a { 0 => 10, _ => 20 } + if b { 3 } else { 4 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:94:5 | LL | (if b { 1 } else { 2 }) + 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:96:5 | LL | 0 + { a } + 3; | ^^^^^^^^^ help: consider reducing it to: `({ a })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:97:5 | LL | 0 + { a } * 2; | ^^^^^^^^^^^^^ help: consider reducing it to: `({ a } * 2)` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:98:5 | LL | 0 + loop { let mut c = 0; if c == 10 { break c; } c += 1; } + { a * 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(loop { let mut c = 0; if c == 10 { break c; } c += 1; })` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:103:7 | LL | f(1 * a + { 8 * 5 }); | ^^^^^ help: consider reducing it to: `a` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:104:7 | LL | f(0 + if b { 1 } else { 2 } + 3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `if b { 1 } else { 2 }` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:105:20 | LL | const _: i32 = { 2 * 4 } + 0 + 3; | ^^^^^^^^^^^^^ help: consider reducing it to: `{ 2 * 4 }` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:106:20 | LL | const _: i32 = 0 + { 1 + 2 * 3 } + 3; | ^^^^^^^^^^^^^^^^^ help: consider reducing it to: `{ 1 + 2 * 3 }` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:108:5 | LL | 0 + a as usize; | ^^^^^^^^^^^^^^ help: consider reducing it to: `a as usize` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:109:13 | LL | let _ = 0 + a as usize; | ^^^^^^^^^^^^^^ help: consider reducing it to: `a as usize` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:110:5 | LL | 0 + { a } as usize; | ^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `({ a } as usize)` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:112:9 | LL | 2 * (0 + { a }); | ^^^^^^^^^^^ help: consider reducing it to: `{ a }` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:113:5 | LL | 1 * ({ a } + 4); | ^^^^^^^^^^^^^^^ help: consider reducing it to: `(({ a } + 4))` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:114:5 | LL | 1 * 1; | ^^^^^ help: consider reducing it to: `1` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:118:18 | LL | let _: i32 = &x + 0; | ^^^^^^ help: consider reducing it to: `x` -error: this operation has no effect +warning: this operation has no effect --> $DIR/identity_op.rs:122:5 | LL | 0 + if a { 1 } else { 2 } + if b { 3 } else { 5 } | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if a { 1 } else { 2 })` -error: aborting due to 40 previous errors +warning: 40 warnings emitted diff --git a/tests/ui/if_let_mutex.stderr b/tests/ui/if_let_mutex.stderr index da0cc25f0ab5..8a68e93a8390 100644 --- a/tests/ui/if_let_mutex.stderr +++ b/tests/ui/if_let_mutex.stderr @@ -1,4 +1,4 @@ -error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock +warning: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock --> $DIR/if_let_mutex.rs:10:5 | LL | if let Err(locked) = m.lock() { @@ -14,9 +14,13 @@ LL | | }; | |_____^ | = help: move the lock call outside of the `if let ...` expression - = note: `-D clippy::if-let-mutex` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/if_let_mutex.rs:1:9 + | +LL | #![warn(clippy::if_let_mutex)] + | ^^^^^^^^^^^^^^^^^^^^ -error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock +warning: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock --> $DIR/if_let_mutex.rs:22:5 | LL | if let Some(locked) = m.lock().unwrap().deref() { @@ -33,7 +37,7 @@ LL | | }; | = help: move the lock call outside of the `if let ...` expression -error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock +warning: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock --> $DIR/if_let_mutex.rs:43:5 | LL | if let Ok(i) = mutex.lock() { @@ -49,5 +53,5 @@ LL | | }; | = help: move the lock call outside of the `if let ...` expression -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index 46671c15274f..337ab9a882d5 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,4 +1,4 @@ -error: unnecessary boolean `not` operation +warning: unnecessary boolean `not` operation --> $DIR/if_not_else.rs:12:5 | LL | / if !bla() { @@ -9,9 +9,13 @@ LL | | } | |_____^ | = help: remove the `!` and swap the blocks of the `if`/`else` - = note: `-D clippy::if-not-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/if_not_else.rs:2:9 + | +LL | #![warn(clippy::if_not_else)] + | ^^^^^^^^^^^^^^^^^^^ -error: unnecessary `!=` operation +warning: unnecessary `!=` operation --> $DIR/if_not_else.rs:17:5 | LL | / if 4 != 5 { @@ -23,5 +27,5 @@ LL | | } | = help: change to `==` and swap the blocks of the `if`/`else` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/if_same_then_else.rs b/tests/ui/if_same_then_else.rs index 07d2002eb27f..189c26f9108e 100644 --- a/tests/ui/if_same_then_else.rs +++ b/tests/ui/if_same_then_else.rs @@ -1,4 +1,4 @@ -#![warn(clippy::if_same_then_else)] +#![deny(clippy::if_same_then_else)] #![allow( clippy::disallowed_names, clippy::eq_op, @@ -21,6 +21,7 @@ fn foo() -> bool { fn if_same_then_else() { if true { + //~^ ERROR: this `if` has identical blocks Foo { bar: 42 }; 0..10; ..; @@ -29,7 +30,6 @@ fn if_same_then_else() { 0..=10; foo(); } else { - //~ ERROR same body as `if` block Foo { bar: 42 }; 0..10; ..; @@ -65,16 +65,16 @@ fn if_same_then_else() { } let _ = if true { + //~^ ERROR: this `if` has identical blocks 0.0 } else { - //~ ERROR same body as `if` block 0.0 }; let _ = if true { + //~^ ERROR: this `if` has identical blocks -0.0 } else { - //~ ERROR same body as `if` block -0.0 }; @@ -88,13 +88,14 @@ fn if_same_then_else() { } let _ = if true { + //~^ ERROR: this `if` has identical blocks 42 } else { - //~ ERROR same body as `if` block 42 }; if true { + //~^ ERROR: this `if` has identical blocks let bar = if true { 42 } else { 43 }; while foo() { @@ -102,7 +103,6 @@ fn if_same_then_else() { } bar + 1; } else { - //~ ERROR same body as `if` block let bar = if true { 42 } else { 43 }; while foo() { diff --git a/tests/ui/if_same_then_else.stderr b/tests/ui/if_same_then_else.stderr index fb23b81d36d7..c3b5c0a3f60c 100644 --- a/tests/ui/if_same_then_else.stderr +++ b/tests/ui/if_same_then_else.stderr @@ -3,43 +3,47 @@ error: this `if` has identical blocks | LL | if true { | _____________^ +LL | | LL | | Foo { bar: 42 }; LL | | 0..10; -LL | | ..; ... | LL | | foo(); LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:31:12 + --> $DIR/if_same_then_else.rs:32:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | Foo { bar: 42 }; LL | | 0..10; +LL | | ..; ... | LL | | foo(); LL | | } | |_____^ - = note: `-D clippy::if-same-then-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/if_same_then_else.rs:1:9 + | +LL | #![deny(clippy::if_same_then_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has identical blocks --> $DIR/if_same_then_else.rs:67:21 | LL | let _ = if true { | _____________________^ +LL | | LL | | 0.0 LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:69:12 + --> $DIR/if_same_then_else.rs:70:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | 0.0 LL | | }; | |_____^ @@ -49,16 +53,16 @@ error: this `if` has identical blocks | LL | let _ = if true { | _____________________^ +LL | | LL | | -0.0 LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:76:12 + --> $DIR/if_same_then_else.rs:77:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | -0.0 LL | | }; | |_____^ @@ -68,16 +72,16 @@ error: this `if` has identical blocks | LL | let _ = if true { | _____________________^ +LL | | LL | | 42 LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:92:12 + --> $DIR/if_same_then_else.rs:93:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | 42 LL | | }; | |_____^ @@ -87,22 +91,22 @@ error: this `if` has identical blocks | LL | if true { | _____________^ +LL | | LL | | let bar = if true { 42 } else { 43 }; LL | | -LL | | while foo() { ... | LL | | bar + 1; LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:104:12 + --> $DIR/if_same_then_else.rs:105:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | let bar = if true { 42 } else { 43 }; LL | | +LL | | while foo() { ... | LL | | bar + 1; LL | | } diff --git a/tests/ui/if_same_then_else2.rs b/tests/ui/if_same_then_else2.rs index 58167f4446db..eb401d0b2fc1 100644 --- a/tests/ui/if_same_then_else2.rs +++ b/tests/ui/if_same_then_else2.rs @@ -1,4 +1,4 @@ -#![warn(clippy::if_same_then_else)] +#![deny(clippy::if_same_then_else)] #![allow( clippy::disallowed_names, clippy::collapsible_else_if, @@ -12,6 +12,7 @@ fn if_same_then_else2() -> Result<&'static str, ()> { if true { + //~^ ERROR: this `if` has identical blocks for _ in &[42] { let foo: &Option<_> = &Some::(42); if foo.is_some() { @@ -21,7 +22,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } } } else { - //~ ERROR same body as `if` block for _ in &[42] { let bar: &Option<_> = &Some::(42); if bar.is_some() { @@ -33,16 +33,16 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } if true { + //~^ ERROR: this `if` has identical blocks if let Some(a) = Some(42) {} } else { - //~ ERROR same body as `if` block if let Some(a) = Some(42) {} } if true { + //~^ ERROR: this `if` has identical blocks if let (1, .., 3) = (1, 2, 3) {} } else { - //~ ERROR same body as `if` block if let (1, .., 3) = (1, 2, 3) {} } @@ -90,16 +90,16 @@ fn if_same_then_else2() -> Result<&'static str, ()> { // Same NaNs let _ = if true { + //~^ ERROR: this `if` has identical blocks f32::NAN } else { - //~ ERROR same body as `if` block f32::NAN }; if true { + //~^ ERROR: this `if` has identical blocks Ok("foo")?; } else { - //~ ERROR same body as `if` block Ok("foo")?; } @@ -121,6 +121,7 @@ fn if_same_then_else2() -> Result<&'static str, ()> { let foo = "bar"; return Ok(&foo[0..]); } else if true { + //~^ ERROR: this `if` has identical blocks let foo = ""; return Ok(&foo[0..]); } else { diff --git a/tests/ui/if_same_then_else2.stderr b/tests/ui/if_same_then_else2.stderr index 704cfd9669ac..8a2fdcff3979 100644 --- a/tests/ui/if_same_then_else2.stderr +++ b/tests/ui/if_same_then_else2.stderr @@ -3,43 +3,47 @@ error: this `if` has identical blocks | LL | if true { | _____________^ +LL | | LL | | for _ in &[42] { LL | | let foo: &Option<_> = &Some::(42); -LL | | if foo.is_some() { ... | LL | | } LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:23:12 + --> $DIR/if_same_then_else2.rs:24:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | for _ in &[42] { LL | | let bar: &Option<_> = &Some::(42); +LL | | if bar.is_some() { ... | LL | | } LL | | } | |_____^ - = note: `-D clippy::if-same-then-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/if_same_then_else2.rs:1:9 + | +LL | #![deny(clippy::if_same_then_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has identical blocks --> $DIR/if_same_then_else2.rs:35:13 | LL | if true { | _____________^ +LL | | LL | | if let Some(a) = Some(42) {} LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:37:12 + --> $DIR/if_same_then_else2.rs:38:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | if let Some(a) = Some(42) {} LL | | } | |_____^ @@ -49,16 +53,16 @@ error: this `if` has identical blocks | LL | if true { | _____________^ +LL | | LL | | if let (1, .., 3) = (1, 2, 3) {} LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:44:12 + --> $DIR/if_same_then_else2.rs:45:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | if let (1, .., 3) = (1, 2, 3) {} LL | | } | |_____^ @@ -68,16 +72,16 @@ error: this `if` has identical blocks | LL | let _ = if true { | _____________________^ +LL | | LL | | f32::NAN LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:94:12 + --> $DIR/if_same_then_else2.rs:95:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | f32::NAN LL | | }; | |_____^ @@ -87,16 +91,16 @@ error: this `if` has identical blocks | LL | if true { | _____________^ +LL | | LL | | Ok("foo")?; LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:101:12 + --> $DIR/if_same_then_else2.rs:102:12 | LL | } else { | ____________^ -LL | | //~ ERROR same body as `if` block LL | | Ok("foo")?; LL | | } | |_____^ @@ -106,13 +110,14 @@ error: this `if` has identical blocks | LL | } else if true { | ____________________^ +LL | | LL | | let foo = ""; LL | | return Ok(&foo[0..]); LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:126:12 + --> $DIR/if_same_then_else2.rs:127:12 | LL | } else { | ____________^ diff --git a/tests/ui/if_then_some_else_none.stderr b/tests/ui/if_then_some_else_none.stderr index d728a3c31a3b..62ffb60f1ae9 100644 --- a/tests/ui/if_then_some_else_none.stderr +++ b/tests/ui/if_then_some_else_none.stderr @@ -1,4 +1,4 @@ -error: this could be simplified with `bool::then` +warning: this could be simplified with `bool::then` --> $DIR/if_then_some_else_none.rs:5:13 | LL | let _ = if foo() { @@ -11,9 +11,13 @@ LL | | }; | |_____^ | = help: consider using `bool::then` like: `foo().then(|| { /* snippet */ "foo" })` - = note: `-D clippy::if-then-some-else-none` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/if_then_some_else_none.rs:1:9 + | +LL | #![warn(clippy::if_then_some_else_none)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this could be simplified with `bool::then` +warning: this could be simplified with `bool::then` --> $DIR/if_then_some_else_none.rs:13:13 | LL | let _ = if matches!(true, true) { @@ -27,7 +31,7 @@ LL | | }; | = help: consider using `bool::then` like: `matches!(true, true).then(|| { /* snippet */ matches!(true, false) })` -error: this could be simplified with `bool::then_some` +warning: this could be simplified with `bool::then_some` --> $DIR/if_then_some_else_none.rs:22:28 | LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); @@ -35,7 +39,7 @@ LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); | = help: consider using `bool::then_some` like: `(o < 32).then_some(o)` -error: this could be simplified with `bool::then_some` +warning: this could be simplified with `bool::then_some` --> $DIR/if_then_some_else_none.rs:26:13 | LL | let _ = if !x { Some(0) } else { None }; @@ -43,7 +47,7 @@ LL | let _ = if !x { Some(0) } else { None }; | = help: consider using `bool::then_some` like: `(!x).then_some(0)` -error: this could be simplified with `bool::then` +warning: this could be simplified with `bool::then` --> $DIR/if_then_some_else_none.rs:81:13 | LL | let _ = if foo() { @@ -57,5 +61,5 @@ LL | | }; | = help: consider using `bool::then` like: `foo().then(|| { /* snippet */ 150 })` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/ifs_same_cond.rs b/tests/ui/ifs_same_cond.rs index 9850fc0919e1..236360cf5e9d 100644 --- a/tests/ui/ifs_same_cond.rs +++ b/tests/ui/ifs_same_cond.rs @@ -1,4 +1,4 @@ -#![warn(clippy::ifs_same_cond)] +#![deny(clippy::ifs_same_cond)] #![allow(clippy::if_same_then_else, clippy::comparison_chain)] // all empty blocks fn ifs_same_cond() { @@ -7,18 +7,18 @@ fn ifs_same_cond() { if b { } else if b { - //~ ERROR ifs same condition + //~^ ERROR: this `if` has the same condition as a previous `if` } if a == 1 { } else if a == 1 { - //~ ERROR ifs same condition + //~^ ERROR: this `if` has the same condition as a previous `if` } if 2 * a == 1 { } else if 2 * a == 2 { } else if 2 * a == 1 { - //~ ERROR ifs same condition + //~^ ERROR: this `if` has the same condition as a previous `if` } else if a == 1 { } diff --git a/tests/ui/ifs_same_cond.stderr b/tests/ui/ifs_same_cond.stderr index 4113087327a2..915f2d15bd69 100644 --- a/tests/ui/ifs_same_cond.stderr +++ b/tests/ui/ifs_same_cond.stderr @@ -9,7 +9,11 @@ note: same as this | LL | if b { | ^ - = note: `-D clippy::ifs-same-cond` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ifs_same_cond.rs:1:9 + | +LL | #![deny(clippy::ifs_same_cond)] + | ^^^^^^^^^^^^^^^^^^^^^ error: this `if` has the same condition as a previous `if` --> $DIR/ifs_same_cond.rs:14:15 diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index e28b1bf0cdd9..dc1e01014586 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,4 +1,4 @@ -error: multiple implementations of this structure +warning: multiple implementations of this structure --> $DIR/impl.rs:10:1 | LL | / impl MyStruct { @@ -13,9 +13,13 @@ LL | / impl MyStruct { LL | | fn first() {} LL | | } | |_^ - = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/impl.rs:2:9 + | +LL | #![warn(clippy::multiple_inherent_impl)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: multiple implementations of this structure +warning: multiple implementations of this structure --> $DIR/impl.rs:24:5 | LL | / impl super::MyStruct { @@ -31,7 +35,7 @@ LL | | fn first() {} LL | | } | |_^ -error: multiple implementations of this structure +warning: multiple implementations of this structure --> $DIR/impl.rs:44:1 | LL | / impl WithArgs { @@ -47,7 +51,7 @@ LL | | fn f2() {} LL | | } | |_^ -error: multiple implementations of this structure +warning: multiple implementations of this structure --> $DIR/impl.rs:65:1 | LL | impl OneAllowedImpl {} // Lint, only one of the three blocks is allowed. @@ -59,5 +63,5 @@ note: first implementation here LL | impl OneAllowedImpl {} | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/impl_trait_in_params.stderr b/tests/ui/impl_trait_in_params.stderr index 80383743525f..8a42ff219bd1 100644 --- a/tests/ui/impl_trait_in_params.stderr +++ b/tests/ui/impl_trait_in_params.stderr @@ -1,16 +1,20 @@ -error: '`impl Trait` used as a function parameter' +warning: '`impl Trait` used as a function parameter' --> $DIR/impl_trait_in_params.rs:8:13 | LL | pub fn a(_: impl Trait) {} | ^^^^^^^^^^ | - = note: `-D clippy::impl-trait-in-params` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/impl_trait_in_params.rs:2:9 + | +LL | #![warn(clippy::impl_trait_in_params)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a type parameter | LL | pub fn a<{ /* Generic name */ }: Trait>(_: impl Trait) {} | +++++++++++++++++++++++++++++++ -error: '`impl Trait` used as a function parameter' +warning: '`impl Trait` used as a function parameter' --> $DIR/impl_trait_in_params.rs:9:29 | LL | pub fn c(_: C, _: impl Trait) {} @@ -21,5 +25,5 @@ help: add a type parameter LL | pub fn c(_: C, _: impl Trait) {} | +++++++++++++++++++++++++++++++ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/implicit_clone.fixed b/tests/ui/implicit_clone.fixed index 8ccc3da7b47c..e62db8b40be6 100644 --- a/tests/ui/implicit_clone.fixed +++ b/tests/ui/implicit_clone.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::implicit_clone)] #![allow(clippy::clone_on_copy, clippy::redundant_clone)] use std::borrow::Borrow; diff --git a/tests/ui/implicit_clone.rs b/tests/ui/implicit_clone.rs index 593333126077..88352b06af3c 100644 --- a/tests/ui/implicit_clone.rs +++ b/tests/ui/implicit_clone.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::implicit_clone)] #![allow(clippy::clone_on_copy, clippy::redundant_clone)] use std::borrow::Borrow; diff --git a/tests/ui/implicit_clone.stderr b/tests/ui/implicit_clone.stderr index 92c1aa58affb..edc65cd9005b 100644 --- a/tests/ui/implicit_clone.stderr +++ b/tests/ui/implicit_clone.stderr @@ -1,76 +1,80 @@ -error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type --> $DIR/implicit_clone.rs:66:13 | LL | let _ = vec.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `vec.clone()` | - = note: `-D clippy::implicit-clone` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/implicit_clone.rs:2:9 + | +LL | #![warn(clippy::implicit_clone)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type +warning: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type --> $DIR/implicit_clone.rs:67:13 | LL | let _ = vec.to_vec(); | ^^^^^^^^^^^^ help: consider using: `vec.clone()` -error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type --> $DIR/implicit_clone.rs:71:13 | LL | let _ = vec_ref.to_owned(); | ^^^^^^^^^^^^^^^^^^ help: consider using: `vec_ref.clone()` -error: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type +warning: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type --> $DIR/implicit_clone.rs:72:13 | LL | let _ = vec_ref.to_vec(); | ^^^^^^^^^^^^^^^^ help: consider using: `vec_ref.clone()` -error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `String` by calling `to_owned` on its dereferenced type --> $DIR/implicit_clone.rs:84:13 | LL | let _ = str.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `str.clone()` -error: implicitly cloning a `Kitten` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `Kitten` by calling `to_owned` on its dereferenced type --> $DIR/implicit_clone.rs:88:13 | LL | let _ = kitten.to_owned(); | ^^^^^^^^^^^^^^^^^ help: consider using: `kitten.clone()` -error: implicitly cloning a `PathBuf` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `PathBuf` by calling `to_owned` on its dereferenced type --> $DIR/implicit_clone.rs:98:13 | LL | let _ = pathbuf.to_owned(); | ^^^^^^^^^^^^^^^^^^ help: consider using: `pathbuf.clone()` -error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type +warning: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type --> $DIR/implicit_clone.rs:99:13 | LL | let _ = pathbuf.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `pathbuf.clone()` -error: implicitly cloning a `OsString` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `OsString` by calling `to_owned` on its dereferenced type --> $DIR/implicit_clone.rs:102:13 | LL | let _ = os_string.to_owned(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `os_string.clone()` -error: implicitly cloning a `OsString` by calling `to_os_string` on its dereferenced type +warning: implicitly cloning a `OsString` by calling `to_os_string` on its dereferenced type --> $DIR/implicit_clone.rs:103:13 | LL | let _ = os_string.to_os_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `os_string.clone()` -error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type +warning: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type --> $DIR/implicit_clone.rs:114:13 | LL | let _ = pathbuf_ref.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(*pathbuf_ref).clone()` -error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type +warning: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type --> $DIR/implicit_clone.rs:117:13 | LL | let _ = pathbuf_ref.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(**pathbuf_ref).clone()` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/implicit_hasher.rs b/tests/ui/implicit_hasher.rs index fd96ca3f466e..72c6a5cadb0f 100644 --- a/tests/ui/implicit_hasher.rs +++ b/tests/ui/implicit_hasher.rs @@ -1,5 +1,5 @@ -// aux-build:implicit_hasher_macros.rs -#![deny(clippy::implicit_hasher)] +//@aux-build:implicit_hasher_macros.rs +#![warn(clippy::implicit_hasher)] #![allow(unused)] #[macro_use] diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index 59b0fba2a4cf..427134b1241d 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -1,4 +1,4 @@ -error: impl for `HashMap` should be generalized over different hashers +warning: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:16:35 | LL | impl Foo for HashMap { @@ -7,7 +7,7 @@ LL | impl Foo for HashMap { note: the lint level is defined here --> $DIR/implicit_hasher.rs:2:9 | -LL | #![deny(clippy::implicit_hasher)] +LL | #![warn(clippy::implicit_hasher)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | @@ -18,7 +18,7 @@ help: ...and use generic constructor LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: impl for `HashMap` should be generalized over different hashers +warning: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:25:36 | LL | impl Foo for (HashMap,) { @@ -33,7 +33,7 @@ help: ...and use generic constructor LL | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: impl for `HashMap` should be generalized over different hashers +warning: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:30:19 | LL | impl Foo for HashMap { @@ -48,7 +48,7 @@ help: ...and use generic constructor LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: impl for `HashSet` should be generalized over different hashers +warning: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:47:32 | LL | impl Foo for HashSet { @@ -63,7 +63,7 @@ help: ...and use generic constructor LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: impl for `HashSet` should be generalized over different hashers +warning: impl for `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:52:19 | LL | impl Foo for HashSet { @@ -78,7 +78,7 @@ help: ...and use generic constructor LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: parameter of type `HashMap` should be generalized over different hashers +warning: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:69:23 | LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} @@ -89,7 +89,7 @@ help: consider adding a type parameter LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~~~ -error: parameter of type `HashSet` should be generalized over different hashers +warning: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:69:53 | LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} @@ -100,7 +100,7 @@ help: consider adding a type parameter LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~ -error: impl for `HashMap` should be generalized over different hashers +warning: impl for `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:73:43 | LL | impl Foo for HashMap { @@ -109,7 +109,7 @@ LL | impl Foo for HashMap { LL | gen!(impl); | ---------- in this macro invocation | - = note: this error originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider adding a type parameter | LL | impl Foo for HashMap { @@ -119,7 +119,7 @@ help: ...and use generic constructor LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: parameter of type `HashMap` should be generalized over different hashers +warning: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:81:33 | LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} @@ -128,13 +128,13 @@ LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) LL | gen!(fn bar); | ------------ in this macro invocation | - = note: this error originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider adding a type parameter | LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~~~ -error: parameter of type `HashSet` should be generalized over different hashers +warning: parameter of type `HashSet` should be generalized over different hashers --> $DIR/implicit_hasher.rs:81:63 | LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} @@ -143,13 +143,13 @@ LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) LL | gen!(fn bar); | ------------ in this macro invocation | - = note: this error originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider adding a type parameter | LL | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~ -error: parameter of type `HashMap` should be generalized over different hashers +warning: parameter of type `HashMap` should be generalized over different hashers --> $DIR/implicit_hasher.rs:100:35 | LL | pub async fn election_vote(_data: HashMap) {} @@ -160,5 +160,5 @@ help: consider adding a type parameter LL | pub async fn election_vote(_data: HashMap) {} | +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/implicit_return.fixed b/tests/ui/implicit_return.fixed index 5e55b8b67391..64813eafda64 100644 --- a/tests/ui/implicit_return.fixed +++ b/tests/ui/implicit_return.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![warn(clippy::implicit_return)] #![allow(clippy::needless_return, clippy::needless_bool, unused, clippy::never_loop)] diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs index 76f0a9803520..39d47b110db7 100644 --- a/tests/ui/implicit_return.rs +++ b/tests/ui/implicit_return.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![warn(clippy::implicit_return)] #![allow(clippy::needless_return, clippy::needless_bool, unused, clippy::never_loop)] diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index 522bc3bf895a..39e0afd1992f 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -1,90 +1,94 @@ -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:12:5 | LL | true | ^^^^ help: add `return` as shown: `return true` | - = note: `-D clippy::implicit-return` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/implicit_return.rs:3:9 + | +LL | #![warn(clippy::implicit_return)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:16:15 | LL | if true { true } else { false } | ^^^^ help: add `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:16:29 | LL | if true { true } else { false } | ^^^^^ help: add `return` as shown: `return false` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:22:17 | LL | true => false, | ^^^^^ help: add `return` as shown: `return false` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:23:20 | LL | false => { true }, | ^^^^ help: add `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:36:9 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:43:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:51:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:69:18 | LL | let _ = || { true }; | ^^^^ help: add `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:70:16 | LL | let _ = || true; | ^^^^ help: add `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:78:5 | LL | format!("test {}", "test") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:87:5 | LL | m!(true, false) | ^^^^^^^^^^^^^^^ help: add `return` as shown: `return m!(true, false)` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:93:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:98:17 | LL | break 'outer false; | ^^^^^^^^^^^^^^^^^^ help: change `break` to `return` as shown: `return false` -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:113:5 | LL | / loop { @@ -99,11 +103,11 @@ LL + m!(true); LL + } | -error: missing `return` statement +warning: missing `return` statement --> $DIR/implicit_return.rs:127:5 | LL | true | ^^^^ help: add `return` as shown: `return true` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/implicit_saturating_add.fixed b/tests/ui/implicit_saturating_add.fixed index 7d363d59a6f0..7fc510d6b415 100644 --- a/tests/ui/implicit_saturating_add.fixed +++ b/tests/ui/implicit_saturating_add.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::implicit_saturating_add)] diff --git a/tests/ui/implicit_saturating_add.rs b/tests/ui/implicit_saturating_add.rs index 31a5916277fa..3dcd91f42fed 100644 --- a/tests/ui/implicit_saturating_add.rs +++ b/tests/ui/implicit_saturating_add.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::implicit_saturating_add)] diff --git a/tests/ui/implicit_saturating_add.stderr b/tests/ui/implicit_saturating_add.stderr index 42ae1b488853..d5a5577c0e8b 100644 --- a/tests/ui/implicit_saturating_add.stderr +++ b/tests/ui/implicit_saturating_add.stderr @@ -1,4 +1,4 @@ -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:23:5 | LL | / if u_8 != u8::MAX { @@ -6,9 +6,13 @@ LL | | u_8 += 1; LL | | } | |_____^ help: use instead: `u_8 = u_8.saturating_add(1);` | - = note: `-D clippy::implicit-saturating-add` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/implicit_saturating_add.rs:4:9 + | +LL | #![warn(clippy::implicit_saturating_add)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:27:5 | LL | / if u_8 < u8::MAX { @@ -16,7 +20,7 @@ LL | | u_8 += 1; LL | | } | |_____^ help: use instead: `u_8 = u_8.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:35:5 | LL | / if u_16 != u16::MAX { @@ -24,7 +28,7 @@ LL | | u_16 += 1; LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:39:5 | LL | / if u_16 < u16::MAX { @@ -32,7 +36,7 @@ LL | | u_16 += 1; LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:43:5 | LL | / if u16::MAX > u_16 { @@ -40,7 +44,7 @@ LL | | u_16 += 1; LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:47:5 | LL | / if u_32 != u32::MAX { @@ -48,7 +52,7 @@ LL | | u_32 += 1; LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:51:5 | LL | / if u_32 < u32::MAX { @@ -56,7 +60,7 @@ LL | | u_32 += 1; LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:55:5 | LL | / if u32::MAX > u_32 { @@ -64,7 +68,7 @@ LL | | u_32 += 1; LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:59:5 | LL | / if u_64 != u64::MAX { @@ -72,7 +76,7 @@ LL | | u_64 += 1; LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:63:5 | LL | / if u_64 < u64::MAX { @@ -80,7 +84,7 @@ LL | | u_64 += 1; LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:67:5 | LL | / if u64::MAX > u_64 { @@ -88,7 +92,7 @@ LL | | u_64 += 1; LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:71:5 | LL | / if i_8 != i8::MAX { @@ -96,7 +100,7 @@ LL | | i_8 += 1; LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:75:5 | LL | / if i_8 < i8::MAX { @@ -104,7 +108,7 @@ LL | | i_8 += 1; LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:79:5 | LL | / if i8::MAX > i_8 { @@ -112,7 +116,7 @@ LL | | i_8 += 1; LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:83:5 | LL | / if i_16 != i16::MAX { @@ -120,7 +124,7 @@ LL | | i_16 += 1; LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:87:5 | LL | / if i_16 < i16::MAX { @@ -128,7 +132,7 @@ LL | | i_16 += 1; LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:91:5 | LL | / if i16::MAX > i_16 { @@ -136,7 +140,7 @@ LL | | i_16 += 1; LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:95:5 | LL | / if i_32 != i32::MAX { @@ -144,7 +148,7 @@ LL | | i_32 += 1; LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:99:5 | LL | / if i_32 < i32::MAX { @@ -152,7 +156,7 @@ LL | | i_32 += 1; LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:103:5 | LL | / if i32::MAX > i_32 { @@ -160,7 +164,7 @@ LL | | i_32 += 1; LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:107:5 | LL | / if i_64 != i64::MAX { @@ -168,7 +172,7 @@ LL | | i_64 += 1; LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:111:5 | LL | / if i_64 < i64::MAX { @@ -176,7 +180,7 @@ LL | | i_64 += 1; LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:115:5 | LL | / if i64::MAX > i_64 { @@ -184,7 +188,7 @@ LL | | i_64 += 1; LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` -error: manual saturating add detected +warning: manual saturating add detected --> $DIR/implicit_saturating_add.rs:151:12 | LL | } else if u_32 < u32::MAX { @@ -193,5 +197,5 @@ LL | | u_32 += 1; LL | | } | |_____^ help: use instead: `{u_32 = u_32.saturating_add(1); }` -error: aborting due to 24 previous errors +warning: 24 warnings emitted diff --git a/tests/ui/implicit_saturating_sub.fixed b/tests/ui/implicit_saturating_sub.fixed index 93df81b1a7ff..1a11db0982f7 100644 --- a/tests/ui/implicit_saturating_sub.fixed +++ b/tests/ui/implicit_saturating_sub.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_assignments, unused_mut, clippy::assign_op_pattern)] #![warn(clippy::implicit_saturating_sub)] diff --git a/tests/ui/implicit_saturating_sub.rs b/tests/ui/implicit_saturating_sub.rs index 8340bc8264d5..9369df67430c 100644 --- a/tests/ui/implicit_saturating_sub.rs +++ b/tests/ui/implicit_saturating_sub.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_assignments, unused_mut, clippy::assign_op_pattern)] #![warn(clippy::implicit_saturating_sub)] diff --git a/tests/ui/implicit_saturating_sub.stderr b/tests/ui/implicit_saturating_sub.stderr index 5e589d931e43..e9e707f402da 100644 --- a/tests/ui/implicit_saturating_sub.stderr +++ b/tests/ui/implicit_saturating_sub.stderr @@ -1,4 +1,4 @@ -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:28:5 | LL | / if u_8 > 0 { @@ -6,9 +6,13 @@ LL | | u_8 = u_8 - 1; LL | | } | |_____^ help: try: `u_8 = u_8.saturating_sub(1);` | - = note: `-D clippy::implicit-saturating-sub` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/implicit_saturating_sub.rs:3:9 + | +LL | #![warn(clippy::implicit_saturating_sub)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:35:13 | LL | / if u_8 > 0 { @@ -16,7 +20,7 @@ LL | | u_8 -= 1; LL | | } | |_____________^ help: try: `u_8 = u_8.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:49:5 | LL | / if u_16 > 0 { @@ -24,7 +28,7 @@ LL | | u_16 -= 1; LL | | } | |_____^ help: try: `u_16 = u_16.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:59:5 | LL | / if u_32 != 0 { @@ -32,7 +36,7 @@ LL | | u_32 -= 1; LL | | } | |_____^ help: try: `u_32 = u_32.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:80:5 | LL | / if u_64 > 0 { @@ -40,7 +44,7 @@ LL | | u_64 -= 1; LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:85:5 | LL | / if 0 < u_64 { @@ -48,7 +52,7 @@ LL | | u_64 -= 1; LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:90:5 | LL | / if 0 != u_64 { @@ -56,7 +60,7 @@ LL | | u_64 -= 1; LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:111:5 | LL | / if u_usize > 0 { @@ -64,7 +68,7 @@ LL | | u_usize -= 1; LL | | } | |_____^ help: try: `u_usize = u_usize.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:123:5 | LL | / if i_8 > i8::MIN { @@ -72,7 +76,7 @@ LL | | i_8 -= 1; LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:128:5 | LL | / if i_8 > i8::MIN { @@ -80,7 +84,7 @@ LL | | i_8 -= 1; LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:133:5 | LL | / if i_8 != i8::MIN { @@ -88,7 +92,7 @@ LL | | i_8 -= 1; LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:138:5 | LL | / if i_8 != i8::MIN { @@ -96,7 +100,7 @@ LL | | i_8 -= 1; LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:148:5 | LL | / if i_16 > i16::MIN { @@ -104,7 +108,7 @@ LL | | i_16 -= 1; LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:153:5 | LL | / if i_16 > i16::MIN { @@ -112,7 +116,7 @@ LL | | i_16 -= 1; LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:158:5 | LL | / if i_16 != i16::MIN { @@ -120,7 +124,7 @@ LL | | i_16 -= 1; LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:163:5 | LL | / if i_16 != i16::MIN { @@ -128,7 +132,7 @@ LL | | i_16 -= 1; LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:173:5 | LL | / if i_32 > i32::MIN { @@ -136,7 +140,7 @@ LL | | i_32 -= 1; LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:178:5 | LL | / if i_32 > i32::MIN { @@ -144,7 +148,7 @@ LL | | i_32 -= 1; LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:183:5 | LL | / if i_32 != i32::MIN { @@ -152,7 +156,7 @@ LL | | i_32 -= 1; LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:188:5 | LL | / if i_32 != i32::MIN { @@ -160,7 +164,7 @@ LL | | i_32 -= 1; LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:198:5 | LL | / if i64::MIN < i_64 { @@ -168,7 +172,7 @@ LL | | i_64 -= 1; LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:203:5 | LL | / if i64::MIN != i_64 { @@ -176,7 +180,7 @@ LL | | i_64 -= 1; LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` -error: implicitly performing saturating subtraction +warning: implicitly performing saturating subtraction --> $DIR/implicit_saturating_sub.rs:208:5 | LL | / if i64::MIN < i_64 { @@ -184,5 +188,5 @@ LL | | i_64 -= 1; LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` -error: aborting due to 23 previous errors +warning: 23 warnings emitted diff --git a/tests/ui/inconsistent_digit_grouping.fixed b/tests/ui/inconsistent_digit_grouping.fixed index dd683e7f746a..073a046ccc54 100644 --- a/tests/ui/inconsistent_digit_grouping.fixed +++ b/tests/ui/inconsistent_digit_grouping.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #[warn(clippy::inconsistent_digit_grouping)] -#[deny(clippy::unreadable_literal)] +#[warn(clippy::unreadable_literal)] #[allow(unused_variables, clippy::excessive_precision)] fn main() { macro_rules! mac1 { diff --git a/tests/ui/inconsistent_digit_grouping.rs b/tests/ui/inconsistent_digit_grouping.rs index d5d27c853c28..ac644f42126a 100644 --- a/tests/ui/inconsistent_digit_grouping.rs +++ b/tests/ui/inconsistent_digit_grouping.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #[warn(clippy::inconsistent_digit_grouping)] -#[deny(clippy::unreadable_literal)] +#[warn(clippy::unreadable_literal)] #[allow(unused_variables, clippy::excessive_precision)] fn main() { macro_rules! mac1 { diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index b8ac91554620..f9084125d883 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -1,36 +1,40 @@ -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:26:16 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` | - = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/inconsistent_digit_grouping.rs:2:8 + | +LL | #[warn(clippy::inconsistent_digit_grouping)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:26:26 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^ help: consider: `12_345_678` -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:26:38 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `1_234_567` -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:26:48 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32` -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:26:64 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/inconsistent_digit_grouping.rs:29:13 | LL | let _ = 0x100000; @@ -39,32 +43,32 @@ LL | let _ = 0x100000; note: the lint level is defined here --> $DIR/inconsistent_digit_grouping.rs:3:8 | -LL | #[deny(clippy::unreadable_literal)] +LL | #[warn(clippy::unreadable_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/inconsistent_digit_grouping.rs:30:13 | LL | let _ = 0x1000000; | ^^^^^^^^^ help: consider: `0x0100_0000` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/inconsistent_digit_grouping.rs:31:13 | LL | let _ = 0x10000000; | ^^^^^^^^^^ help: consider: `0x1000_0000` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/inconsistent_digit_grouping.rs:32:13 | LL | let _ = 0x100000000_u64; | ^^^^^^^^^^^^^^^ help: consider: `0x0001_0000_0000_u64` -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/inconsistent_digit_grouping.rs:35:18 | LL | let _: f32 = 1_23_456.; | ^^^^^^^^^ help: consider: `123_456.` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/inconsistent_struct_constructor.fixed b/tests/ui/inconsistent_struct_constructor.fixed index 74ba2f1c5e70..6c89779a7d3c 100644 --- a/tests/ui/inconsistent_struct_constructor.fixed +++ b/tests/ui/inconsistent_struct_constructor.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::inconsistent_struct_constructor)] #![allow(clippy::redundant_field_names)] #![allow(clippy::unnecessary_operation)] diff --git a/tests/ui/inconsistent_struct_constructor.rs b/tests/ui/inconsistent_struct_constructor.rs index ba96e1e330f5..50c28b63fe80 100644 --- a/tests/ui/inconsistent_struct_constructor.rs +++ b/tests/ui/inconsistent_struct_constructor.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::inconsistent_struct_constructor)] #![allow(clippy::redundant_field_names)] #![allow(clippy::unnecessary_operation)] diff --git a/tests/ui/inconsistent_struct_constructor.stderr b/tests/ui/inconsistent_struct_constructor.stderr index c90189e964f0..1e69818087f1 100644 --- a/tests/ui/inconsistent_struct_constructor.stderr +++ b/tests/ui/inconsistent_struct_constructor.stderr @@ -1,12 +1,16 @@ -error: struct constructor field order is inconsistent with struct definition field order +warning: struct constructor field order is inconsistent with struct definition field order --> $DIR/inconsistent_struct_constructor.rs:33:9 | LL | Foo { y, x, z }; | ^^^^^^^^^^^^^^^ help: try: `Foo { x, y, z }` | - = note: `-D clippy::inconsistent-struct-constructor` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/inconsistent_struct_constructor.rs:2:9 + | +LL | #![warn(clippy::inconsistent_struct_constructor)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: struct constructor field order is inconsistent with struct definition field order +warning: struct constructor field order is inconsistent with struct definition field order --> $DIR/inconsistent_struct_constructor.rs:55:9 | LL | / Foo { @@ -16,5 +20,5 @@ LL | | ..Default::default() LL | | }; | |_________^ help: try: `Foo { x, z, ..Default::default() }` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.rs b/tests/ui/index_refutable_slice/if_let_slice_binding.rs index 0a3374d11b03..a894300be225 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.rs +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.rs @@ -1,4 +1,4 @@ -#![deny(clippy::index_refutable_slice)] +#![warn(clippy::index_refutable_slice)] #![allow(clippy::uninlined_format_args)] enum SomeEnum { diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr index 0a13ac1354e5..3a7bf2979377 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr @@ -1,4 +1,4 @@ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:14:17 | LL | if let Some(slice) = slice { @@ -7,7 +7,7 @@ LL | if let Some(slice) = slice { note: the lint level is defined here --> $DIR/if_let_slice_binding.rs:1:9 | -LL | #![deny(clippy::index_refutable_slice)] +LL | #![warn(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using a slice pattern here | @@ -18,7 +18,7 @@ help: and replace the index expressions here LL | println!("{}", slice_0); | ~~~~~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:20:17 | LL | if let Some(slice) = slice { @@ -33,7 +33,7 @@ help: and replace the index expressions here LL | println!("{}", slice_0); | ~~~~~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:26:17 | LL | if let Some(slice) = slice { @@ -49,7 +49,7 @@ LL ~ println!("{}", slice_2); LL ~ println!("{}", slice_0); | -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:33:26 | LL | if let SomeEnum::One(slice) | SomeEnum::Three(slice) = slice_wrapped { @@ -64,7 +64,7 @@ help: and replace the index expressions here LL | println!("{}", slice_0); | ~~~~~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:40:29 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { @@ -79,7 +79,7 @@ help: and replace the index expressions here LL | println!("{} -> {}", a_2, b[1]); | ~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:40:38 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { @@ -94,7 +94,7 @@ help: and replace the index expressions here LL | println!("{} -> {}", a[2], b_1); | ~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:47:21 | LL | if let Some(ref slice) = slice { @@ -109,7 +109,7 @@ help: and replace the index expressions here LL | println!("{:?}", slice_1); | ~~~~~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:55:17 | LL | if let Some(slice) = &slice { @@ -124,7 +124,7 @@ help: and replace the index expressions here LL | println!("{:?}", slice_0); | ~~~~~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:124:17 | LL | if let Some(slice) = wrap.inner { @@ -139,7 +139,7 @@ help: and replace the index expressions here LL | println!("This is awesome! {}", slice_0); | ~~~~~~~ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/if_let_slice_binding.rs:131:17 | LL | if let Some(slice) = wrap.inner { @@ -154,5 +154,5 @@ help: and replace the index expressions here LL | println!("This is super awesome! {}", slice_0); | ~~~~~~~ -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/index_refutable_slice/slice_indexing_in_macro.rs b/tests/ui/index_refutable_slice/slice_indexing_in_macro.rs index 406e82083f88..0df1f281bd87 100644 --- a/tests/ui/index_refutable_slice/slice_indexing_in_macro.rs +++ b/tests/ui/index_refutable_slice/slice_indexing_in_macro.rs @@ -1,4 +1,4 @@ -#![deny(clippy::index_refutable_slice)] +#![warn(clippy::index_refutable_slice)] extern crate if_chain; use if_chain::if_chain; diff --git a/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr b/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr index 11b19428b4fd..d0b46fbcb820 100644 --- a/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr +++ b/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr @@ -1,4 +1,4 @@ -error: this binding can be a slice pattern to avoid indexing +warning: this binding can be a slice pattern to avoid indexing --> $DIR/slice_indexing_in_macro.rs:23:21 | LL | if let Some(slice) = slice; @@ -7,7 +7,7 @@ LL | if let Some(slice) = slice; note: the lint level is defined here --> $DIR/slice_indexing_in_macro.rs:1:9 | -LL | #![deny(clippy::index_refutable_slice)] +LL | #![warn(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using a slice pattern here | @@ -18,5 +18,5 @@ help: and replace the index expressions here LL | println!("{}", slice_0); | ~~~~~~~ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/indexing_slicing_index.rs b/tests/ui/indexing_slicing_index.rs index 26abc9edb5e4..2e798306c6c3 100644 --- a/tests/ui/indexing_slicing_index.rs +++ b/tests/ui/indexing_slicing_index.rs @@ -8,6 +8,7 @@ const ARR: [i32; 2] = [1, 2]; const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false. const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. +//~^ ERROR: evaluation of constant value failed const fn idx() -> usize { 1 @@ -29,6 +30,8 @@ fn main() { x[const { idx4() }]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays. const { &ARR[idx()] }; // This should be linted, since `suppress-restriction-lint-in-const` default is false. const { &ARR[idx4()] }; // This should be linted, since `suppress-restriction-lint-in-const` default is false. + // + //~^^ ERROR: failed let y = &x; y[0]; // Ok, referencing shouldn't affect this lint. See the issue 6021 diff --git a/tests/ui/indexing_slicing_index.stderr b/tests/ui/indexing_slicing_index.stderr index 8fd77913a3fd..a44d058ea8ee 100644 --- a/tests/ui/indexing_slicing_index.stderr +++ b/tests/ui/indexing_slicing_index.stderr @@ -1,4 +1,4 @@ -error: indexing may panic +warning: indexing may panic --> $DIR/indexing_slicing_index.rs:9:20 | LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false. @@ -6,9 +6,13 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re | = help: consider using `.get(n)` or `.get_mut(n)` instead = note: the suggestion might not be applicable in constant blocks - = note: `-D clippy::indexing-slicing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/indexing_slicing_index.rs:2:9 + | +LL | #![warn(clippy::indexing_slicing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: indexing may panic +warning: indexing may panic --> $DIR/indexing_slicing_index.rs:10:24 | LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. @@ -18,27 +22,27 @@ LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. = note: the suggestion might not be applicable in constant blocks error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/indexing_slicing_index.rs:31:14 + --> $DIR/indexing_slicing_index.rs:32:14 | LL | const { &ARR[idx4()] }; // This should be linted, since `suppress-restriction-lint-in-const` default is false. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant used - --> $DIR/indexing_slicing_index.rs:31:5 + --> $DIR/indexing_slicing_index.rs:32:5 | LL | const { &ARR[idx4()] }; // This should be linted, since `suppress-restriction-lint-in-const` default is false. | ^^^^^^^^^^^^^^^^^^^^^^ -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:22:5 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:23:5 | LL | x[index]; | ^^^^^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:30:14 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:31:14 | LL | const { &ARR[idx()] }; // This should be linted, since `suppress-restriction-lint-in-const` default is false. | ^^^^^^^^^^ @@ -46,8 +50,8 @@ LL | const { &ARR[idx()] }; // This should be linted, since `suppress-restri = help: consider using `.get(n)` or `.get_mut(n)` instead = note: the suggestion might not be applicable in constant blocks -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:31:14 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:32:14 | LL | const { &ARR[idx4()] }; // This should be linted, since `suppress-restriction-lint-in-const` default is false. | ^^^^^^^^^^^ @@ -55,40 +59,40 @@ LL | const { &ARR[idx4()] }; // This should be linted, since `suppress-restr = help: consider using `.get(n)` or `.get_mut(n)` instead = note: the suggestion might not be applicable in constant blocks -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:38:5 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:41:5 | LL | v[0]; | ^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:39:5 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:42:5 | LL | v[10]; | ^^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:40:5 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:43:5 | LL | v[1 << 3]; | ^^^^^^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:46:5 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:49:5 | LL | v[N]; | ^^^^ | = help: consider using `.get(n)` or `.get_mut(n)` instead -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:47:5 +warning: indexing may panic + --> $DIR/indexing_slicing_index.rs:50:5 | LL | v[M]; | ^^^^ @@ -101,6 +105,6 @@ error[E0080]: evaluation of constant value failed LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 -error: aborting due to 12 previous errors +error: aborting due to 2 previous errors; 10 warnings emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/indexing_slicing_slice.stderr b/tests/ui/indexing_slicing_slice.stderr index dc54bd41365d..e3cb7e028630 100644 --- a/tests/ui/indexing_slicing_slice.stderr +++ b/tests/ui/indexing_slicing_slice.stderr @@ -1,13 +1,17 @@ -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:12:6 | LL | &x[index..]; | ^^^^^^^^^^ | = help: consider using `.get(n..)` or .get_mut(n..)` instead - = note: `-D clippy::indexing-slicing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/indexing_slicing_slice.rs:1:9 + | +LL | #![warn(clippy::indexing_slicing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:13:6 | LL | &x[..index]; @@ -15,7 +19,7 @@ LL | &x[..index]; | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:14:6 | LL | &x[index_from..index_to]; @@ -23,7 +27,7 @@ LL | &x[index_from..index_to]; | = help: consider using `.get(n..m)` or `.get_mut(n..m)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:15:6 | LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. @@ -31,7 +35,7 @@ LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from. | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:15:6 | LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. @@ -39,7 +43,7 @@ LL | &x[index_from..][..index_to]; // Two lint reports, one for [index_from. | = help: consider using `.get(n..)` or .get_mut(n..)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:16:6 | LL | &x[5..][..10]; // Two lint reports, one for out of bounds [5..] and another for slicing [..10]. @@ -47,15 +51,19 @@ LL | &x[5..][..10]; // Two lint reports, one for out of bounds [5..] and ano | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: range is out of bounds +warning: range is out of bounds --> $DIR/indexing_slicing_slice.rs:16:8 | LL | &x[5..][..10]; // Two lint reports, one for out of bounds [5..] and another for slicing [..10]. | ^ | - = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/indexing_slicing_slice.rs:4:9 + | +LL | #![warn(clippy::out_of_bounds_indexing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:17:6 | LL | &x[0..][..3]; @@ -63,7 +71,7 @@ LL | &x[0..][..3]; | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:18:6 | LL | &x[1..][..5]; @@ -71,19 +79,19 @@ LL | &x[1..][..5]; | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: range is out of bounds +warning: range is out of bounds --> $DIR/indexing_slicing_slice.rs:25:12 | LL | &y[0..=4]; | ^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/indexing_slicing_slice.rs:26:11 | LL | &y[..=4]; | ^ -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:31:6 | LL | &v[10..100]; @@ -91,7 +99,7 @@ LL | &v[10..100]; | = help: consider using `.get(n..m)` or `.get_mut(n..m)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:32:6 | LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. @@ -99,13 +107,13 @@ LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [. | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: range is out of bounds +warning: range is out of bounds --> $DIR/indexing_slicing_slice.rs:32:8 | LL | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^ -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:33:6 | LL | &v[10..]; @@ -113,7 +121,7 @@ LL | &v[10..]; | = help: consider using `.get(n..)` or .get_mut(n..)` instead -error: slicing may panic +warning: slicing may panic --> $DIR/indexing_slicing_slice.rs:34:6 | LL | &v[..100]; @@ -121,5 +129,5 @@ LL | &v[..100]; | = help: consider using `.get(..n)`or `.get_mut(..n)` instead -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/inefficient_to_string.fixed b/tests/ui/inefficient_to_string.fixed index c972b9419ef7..18acc4191fd8 100644 --- a/tests/ui/inefficient_to_string.fixed +++ b/tests/ui/inefficient_to_string.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::inefficient_to_string)] +//@run-rustfix +#![warn(clippy::inefficient_to_string)] use std::borrow::Cow; diff --git a/tests/ui/inefficient_to_string.rs b/tests/ui/inefficient_to_string.rs index acdc55aa0d69..28df3f113ba1 100644 --- a/tests/ui/inefficient_to_string.rs +++ b/tests/ui/inefficient_to_string.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::inefficient_to_string)] +//@run-rustfix +#![warn(clippy::inefficient_to_string)] use std::borrow::Cow; diff --git a/tests/ui/inefficient_to_string.stderr b/tests/ui/inefficient_to_string.stderr index 914dc92bfb65..41103d713fe3 100644 --- a/tests/ui/inefficient_to_string.stderr +++ b/tests/ui/inefficient_to_string.stderr @@ -1,4 +1,4 @@ -error: calling `to_string` on `&&str` +warning: calling `to_string` on `&&str` --> $DIR/inefficient_to_string.rs:11:21 | LL | let _: String = rrstr.to_string(); @@ -8,10 +8,10 @@ LL | let _: String = rrstr.to_string(); note: the lint level is defined here --> $DIR/inefficient_to_string.rs:2:9 | -LL | #![deny(clippy::inefficient_to_string)] +LL | #![warn(clippy::inefficient_to_string)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `to_string` on `&&&str` +warning: calling `to_string` on `&&&str` --> $DIR/inefficient_to_string.rs:12:21 | LL | let _: String = rrrstr.to_string(); @@ -19,7 +19,7 @@ LL | let _: String = rrrstr.to_string(); | = help: `&&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString` -error: calling `to_string` on `&&std::string::String` +warning: calling `to_string` on `&&std::string::String` --> $DIR/inefficient_to_string.rs:20:21 | LL | let _: String = rrstring.to_string(); @@ -27,7 +27,7 @@ LL | let _: String = rrstring.to_string(); | = help: `&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` -error: calling `to_string` on `&&&std::string::String` +warning: calling `to_string` on `&&&std::string::String` --> $DIR/inefficient_to_string.rs:21:21 | LL | let _: String = rrrstring.to_string(); @@ -35,7 +35,7 @@ LL | let _: String = rrrstring.to_string(); | = help: `&&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` -error: calling `to_string` on `&&std::borrow::Cow<'_, str>` +warning: calling `to_string` on `&&std::borrow::Cow<'_, str>` --> $DIR/inefficient_to_string.rs:29:21 | LL | let _: String = rrcow.to_string(); @@ -43,7 +43,7 @@ LL | let _: String = rrcow.to_string(); | = help: `&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString` -error: calling `to_string` on `&&&std::borrow::Cow<'_, str>` +warning: calling `to_string` on `&&&std::borrow::Cow<'_, str>` --> $DIR/inefficient_to_string.rs:30:21 | LL | let _: String = rrrcow.to_string(); @@ -51,5 +51,5 @@ LL | let _: String = rrrcow.to_string(); | = help: `&&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/infallible_destructuring_match.fixed b/tests/ui/infallible_destructuring_match.fixed index 61985e56b769..e396ae94aaab 100644 --- a/tests/ui/infallible_destructuring_match.fixed +++ b/tests/ui/infallible_destructuring_match.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(exhaustive_patterns, never_type)] #![allow(dead_code, unreachable_code, unused_variables)] #![allow(clippy::let_and_return)] diff --git a/tests/ui/infallible_destructuring_match.rs b/tests/ui/infallible_destructuring_match.rs index f2768245bbc4..3fce7bbb6c71 100644 --- a/tests/ui/infallible_destructuring_match.rs +++ b/tests/ui/infallible_destructuring_match.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(exhaustive_patterns, never_type)] #![allow(dead_code, unreachable_code, unused_variables)] #![allow(clippy::let_and_return)] diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index f8a50f0223d6..95504fc9e296 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,4 +1,4 @@ -error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` +warning: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` --> $DIR/infallible_destructuring_match.rs:29:5 | LL | / let data = match wrapper { @@ -6,9 +6,9 @@ LL | | SingleVariantEnum::Variant(i) => i, LL | | }; | |______^ help: try this: `let SingleVariantEnum::Variant(data) = wrapper;` | - = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` + = note: `#[warn(clippy::infallible_destructuring_match)]` on by default -error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` +warning: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` --> $DIR/infallible_destructuring_match.rs:61:5 | LL | / let data = match wrapper { @@ -16,7 +16,7 @@ LL | | TupleStruct(i) => i, LL | | }; | |______^ help: try this: `let TupleStruct(data) = wrapper;` -error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` +warning: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` --> $DIR/infallible_destructuring_match.rs:85:5 | LL | / let data = match wrapper { @@ -24,7 +24,7 @@ LL | | TupleStructWithNonCopy(ref n) => n, LL | | }; | |______^ help: try this: `let TupleStructWithNonCopy(ref data) = wrapper;` -error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` +warning: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` --> $DIR/infallible_destructuring_match.rs:104:5 | LL | / let data = match wrapper { @@ -32,5 +32,5 @@ LL | | Ok(i) => i, LL | | }; | |______^ help: try this: `let Ok(data) = wrapper;` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/infinite_iter.rs b/tests/ui/infinite_iter.rs index 622644f675d3..25afbe25e5ca 100644 --- a/tests/ui/infinite_iter.rs +++ b/tests/ui/infinite_iter.rs @@ -1,4 +1,5 @@ #![allow(clippy::uninlined_format_args)] +#![warn(clippy::infinite_iter)] use std::iter::repeat; fn square_is_lower_64(x: &u32) -> bool { @@ -6,7 +7,7 @@ fn square_is_lower_64(x: &u32) -> bool { } #[allow(clippy::maybe_infinite_iter)] -#[deny(clippy::infinite_iter)] +#[warn(clippy::infinite_iter)] fn infinite_iters() { repeat(0_u8).collect::>(); // infinite iter (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter @@ -27,7 +28,7 @@ fn infinite_iters() { (0..).next(); // iterator is not exhausted } -#[deny(clippy::maybe_infinite_iter)] +#[warn(clippy::maybe_infinite_iter)] fn potential_infinite_iters() { (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index b911163f715e..98ecd2dcc9d0 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -1,29 +1,29 @@ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:11:5 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:12:5 | LL | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/infinite_iter.rs:9:8 + --> $DIR/infinite_iter.rs:10:8 | -LL | #[deny(clippy::infinite_iter)] +LL | #[warn(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:12:5 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:13:5 | LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:13:5 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:14:5 | LL | (0..8_u64).chain(0..).max(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:18:5 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:19:5 | LL | / (0..8_u32) LL | | .rev() @@ -32,38 +32,38 @@ LL | | .map(|x| x + 1_u32) LL | | .for_each(|x| println!("{}", x)); // infinite iter | |________________________________________^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:24:5 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:25:5 | LL | (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:25:5 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:26:5 | LL | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:32:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:33:5 | LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/infinite_iter.rs:30:8 + --> $DIR/infinite_iter.rs:31:8 | -LL | #[deny(clippy::maybe_infinite_iter)] +LL | #[warn(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:33:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:34:5 | LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:34:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:35:5 | LL | / (1..) LL | | .scan(0, |state, x| { @@ -73,37 +73,41 @@ LL | | }) LL | | .min(); // maybe infinite iter | |______________^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:40:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:41:5 | LL | (0..).find(|x| *x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:41:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:42:5 | LL | (0..).position(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:42:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:43:5 | LL | (0..).any(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ -error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:43:5 +warning: possible infinite iteration detected + --> $DIR/infinite_iter.rs:44:5 | LL | (0..).all(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ -error: infinite iteration detected - --> $DIR/infinite_iter.rs:65:31 +warning: infinite iteration detected + --> $DIR/infinite_iter.rs:66:31 | LL | let _: HashSet = (0..).collect(); // Infinite iter | ^^^^^^^^^^^^^^^ | - = note: `#[deny(clippy::infinite_iter)]` on by default +note: the lint level is defined here + --> $DIR/infinite_iter.rs:2:9 + | +LL | #![warn(clippy::infinite_iter)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs index 38e64b9ac0ad..0765889d41a1 100644 --- a/tests/ui/infinite_loop.rs +++ b/tests/ui/infinite_loop.rs @@ -1,3 +1,5 @@ +#![warn(clippy::while_immutable_condition)] + fn fn_val(i: i32) -> i32 { unimplemented!() } diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index 85258b9d64f9..d220be1fe98e 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,78 +1,82 @@ -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:20:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:22:11 | LL | while y < 10 { | ^^^^^^ | = note: this may lead to an infinite or to a never running loop - = note: `#[deny(clippy::while_immutable_condition)]` on by default +note: the lint level is defined here + --> $DIR/infinite_loop.rs:1:9 + | +LL | #![warn(clippy::while_immutable_condition)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:25:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:27:11 | LL | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:32:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:34:11 | LL | while !cond { | ^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:76:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:78:11 | LL | while i < 3 { | ^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:81:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:83:11 | LL | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:85:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:87:11 | LL | while i < 3 { | ^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:100:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:102:11 | LL | while i < 3 { | ^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:105:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:107:11 | LL | while i < 3 { | ^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:171:15 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:173:15 | LL | while self.count < n { | ^^^^^^^^^^^^^^ | = note: this may lead to an infinite or to a never running loop -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:179:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:181:11 | LL | while y < 10 { | ^^^^^^ @@ -81,8 +85,8 @@ LL | while y < 10 { = note: this loop contains `return`s or `break`s = help: rewrite it as `if cond { loop { } }` -error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:186:11 +warning: variables in the condition are not mutated in the loop body + --> $DIR/infinite_loop.rs:188:11 | LL | while y < 10 { | ^^^^^^ @@ -91,5 +95,5 @@ LL | while y < 10 { = note: this loop contains `return`s or `break`s = help: rewrite it as `if cond { loop { } }` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/inherent_to_string.rs b/tests/ui/inherent_to_string.rs index aeb0a0c1e2e8..c056396cded4 100644 --- a/tests/ui/inherent_to_string.rs +++ b/tests/ui/inherent_to_string.rs @@ -42,6 +42,7 @@ impl B { impl C { // Should be detected and emit error as C also implements Display fn to_string(&self) -> String { + //~^ ERROR: which shadows the implementation of `Display` "C.to_string()".to_string() } } diff --git a/tests/ui/inherent_to_string.stderr b/tests/ui/inherent_to_string.stderr index 443fecae1aad..37e5ccfbfd82 100644 --- a/tests/ui/inherent_to_string.stderr +++ b/tests/ui/inherent_to_string.stderr @@ -1,4 +1,4 @@ -error: implementation of inherent method `to_string(&self) -> String` for type `A` +warning: implementation of inherent method `to_string(&self) -> String` for type `A` --> $DIR/inherent_to_string.rs:20:5 | LL | / fn to_string(&self) -> String { @@ -7,12 +7,17 @@ LL | | } | |_____^ | = help: implement trait `Display` for type `A` instead - = note: `-D clippy::inherent-to-string` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/inherent_to_string.rs:1:9 + | +LL | #![warn(clippy::inherent_to_string)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `C` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display` --> $DIR/inherent_to_string.rs:44:5 | LL | / fn to_string(&self) -> String { +LL | | LL | | "C.to_string()".to_string() LL | | } | |_____^ @@ -24,5 +29,5 @@ note: the lint level is defined here LL | #![deny(clippy::inherent_to_string_shadow_display)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/inline_fn_without_body.fixed b/tests/ui/inline_fn_without_body.fixed index fe21a71a42c2..9c5819558fea 100644 --- a/tests/ui/inline_fn_without_body.fixed +++ b/tests/ui/inline_fn_without_body.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::inline_fn_without_body)] #![allow(clippy::inline_always)] diff --git a/tests/ui/inline_fn_without_body.rs b/tests/ui/inline_fn_without_body.rs index 507469894665..43ffaf8122b6 100644 --- a/tests/ui/inline_fn_without_body.rs +++ b/tests/ui/inline_fn_without_body.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::inline_fn_without_body)] #![allow(clippy::inline_always)] diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 32d35e209b01..00edf92d2b31 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -1,4 +1,4 @@ -error: use of `#[inline]` on trait method `default_inline` which has no body +warning: use of `#[inline]` on trait method `default_inline` which has no body --> $DIR/inline_fn_without_body.rs:7:5 | LL | #[inline] @@ -6,9 +6,13 @@ LL | #[inline] LL | | fn default_inline(); | |____- help: remove | - = note: `-D clippy::inline-fn-without-body` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/inline_fn_without_body.rs:3:9 + | +LL | #![warn(clippy::inline_fn_without_body)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `#[inline]` on trait method `always_inline` which has no body +warning: use of `#[inline]` on trait method `always_inline` which has no body --> $DIR/inline_fn_without_body.rs:10:5 | LL | #[inline(always)] @@ -16,7 +20,7 @@ LL | #[inline(always)] LL | | fn always_inline(); | |____- help: remove -error: use of `#[inline]` on trait method `never_inline` which has no body +warning: use of `#[inline]` on trait method `never_inline` which has no body --> $DIR/inline_fn_without_body.rs:13:5 | LL | #[inline(never)] @@ -24,5 +28,5 @@ LL | #[inline(never)] LL | | fn never_inline(); | |____- help: remove -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/inspect_for_each.stderr b/tests/ui/inspect_for_each.stderr index 67c2d5e53c78..fcbb4e53fdf4 100644 --- a/tests/ui/inspect_for_each.stderr +++ b/tests/ui/inspect_for_each.stderr @@ -1,4 +1,4 @@ -error: called `inspect(..).for_each(..)` on an `Iterator` +warning: called `inspect(..).for_each(..)` on an `Iterator` --> $DIR/inspect_for_each.rs:7:19 | LL | a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| { @@ -10,7 +10,11 @@ LL | | }); | |______^ | = help: move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)` - = note: `-D clippy::inspect-for-each` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/inspect_for_each.rs:1:9 + | +LL | #![warn(clippy::inspect_for_each)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/int_plus_one.fixed b/tests/ui/int_plus_one.fixed index 642830f24f58..5a36ec462d4c 100644 --- a/tests/ui/int_plus_one.fixed +++ b/tests/ui/int_plus_one.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[allow(clippy::no_effect, clippy::unnecessary_operation)] #[warn(clippy::int_plus_one)] diff --git a/tests/ui/int_plus_one.rs b/tests/ui/int_plus_one.rs index 0755a0c79d28..bffa4afd6b08 100644 --- a/tests/ui/int_plus_one.rs +++ b/tests/ui/int_plus_one.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[allow(clippy::no_effect, clippy::unnecessary_operation)] #[warn(clippy::int_plus_one)] diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index c5b020ba8ced..46f5cd63dfa5 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,28 +1,32 @@ -error: unnecessary `>= y + 1` or `x - 1 >=` +warning: unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:9:13 | LL | let _ = x >= y + 1; | ^^^^^^^^^^ help: change it to: `x > y` | - = note: `-D clippy::int-plus-one` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/int_plus_one.rs:4:8 + | +LL | #[warn(clippy::int_plus_one)] + | ^^^^^^^^^^^^^^^^^^^^ -error: unnecessary `>= y + 1` or `x - 1 >=` +warning: unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:10:13 | LL | let _ = y + 1 <= x; | ^^^^^^^^^^ help: change it to: `y < x` -error: unnecessary `>= y + 1` or `x - 1 >=` +warning: unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:12:13 | LL | let _ = x - 1 >= y; | ^^^^^^^^^^ help: change it to: `x > y` -error: unnecessary `>= y + 1` or `x - 1 >=` +warning: unnecessary `>= y + 1` or `x - 1 >=` --> $DIR/int_plus_one.rs:13:13 | LL | let _ = y <= x - 1; | ^^^^^^^^^^ help: change it to: `y < x` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/integer_arithmetic.rs b/tests/ui/integer_arithmetic.rs index 67f24b4548aa..023c581cd5ac 100644 --- a/tests/ui/integer_arithmetic.rs +++ b/tests/ui/integer_arithmetic.rs @@ -1,4 +1,4 @@ -#![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] +#![warn(clippy::integer_arithmetic, clippy::float_arithmetic, unconditional_panic)] #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::op_ref)] #[rustfmt::skip] diff --git a/tests/ui/integer_arithmetic.stderr b/tests/ui/integer_arithmetic.stderr index 9a795b1f2915..de6a15f7c4bc 100644 --- a/tests/ui/integer_arithmetic.stderr +++ b/tests/ui/integer_arithmetic.stderr @@ -1,169 +1,177 @@ -error: this operation will panic at runtime +warning: this operation will panic at runtime --> $DIR/integer_arithmetic.rs:30:5 | LL | i /= 0; | ^^^^^^ attempt to divide `_` by zero | - = note: `#[deny(unconditional_panic)]` on by default +note: the lint level is defined here + --> $DIR/integer_arithmetic.rs:1:63 + | +LL | #![warn(clippy::integer_arithmetic, clippy::float_arithmetic, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime +warning: this operation will panic at runtime --> $DIR/integer_arithmetic.rs:35:5 | LL | i %= 0; | ^^^^^^ attempt to calculate the remainder of `_` with a divisor of zero -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:9:5 | LL | 1 + i; | ^^^^^ | - = note: `-D clippy::integer-arithmetic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/integer_arithmetic.rs:1:9 + | +LL | #![warn(clippy::integer_arithmetic, clippy::float_arithmetic, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:10:5 | LL | i * 2; | ^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:11:5 | LL | / 1 % LL | | i / 2; // no error, this is part of the expression in the preceding line | |_____^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:13:5 | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:14:5 | LL | -i; | ^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:15:5 | LL | i >> 1; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:16:5 | LL | i << 1; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:26:5 | LL | i += 1; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:27:5 | LL | i -= 1; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:28:5 | LL | i *= 2; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:31:11 | LL | i /= -1; | ^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:32:5 | LL | i /= var1; | ^^^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:33:5 | LL | i /= var2; | ^^^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:36:11 | LL | i %= -1; | ^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:37:5 | LL | i %= var1; | ^^^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:38:5 | LL | i %= var2; | ^^^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:39:5 | LL | i <<= 3; | ^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:40:5 | LL | i >>= 2; | ^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:82:5 | LL | 3 + &1; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:83:5 | LL | &3 + 1; | ^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:84:5 | LL | &3 + &1; | ^^^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:89:5 | LL | a + x | ^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:93:5 | LL | x + y | ^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:97:5 | LL | x + y | ^^^^^ -error: integer arithmetic detected +warning: integer arithmetic detected --> $DIR/integer_arithmetic.rs:101:5 | LL | (&x + &y) | ^^^^^^^^^ -error: aborting due to 27 previous errors +warning: 27 warnings emitted diff --git a/tests/ui/integer_division.stderr b/tests/ui/integer_division.stderr index ca8001279207..6c5e51ff006e 100644 --- a/tests/ui/integer_division.stderr +++ b/tests/ui/integer_division.stderr @@ -1,13 +1,17 @@ -error: integer division +warning: integer division --> $DIR/integer_division.rs:5:13 | LL | let n = 1 / 2; | ^^^^^ | = help: division of integers may cause loss of precision. consider using floats - = note: `-D clippy::integer-division` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/integer_division.rs:1:9 + | +LL | #![warn(clippy::integer_division)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: integer division +warning: integer division --> $DIR/integer_division.rs:6:13 | LL | let o = 1 / two; @@ -15,7 +19,7 @@ LL | let o = 1 / two; | = help: division of integers may cause loss of precision. consider using floats -error: integer division +warning: integer division --> $DIR/integer_division.rs:7:13 | LL | let p = two / 4; @@ -23,5 +27,5 @@ LL | let p = two / 4; | = help: division of integers may cause loss of precision. consider using floats -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/into_iter_on_ref.fixed b/tests/ui/into_iter_on_ref.fixed index b77f17944d89..0f3273517f9a 100644 --- a/tests/ui/into_iter_on_ref.fixed +++ b/tests/ui/into_iter_on_ref.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::useless_vec, clippy::needless_borrow)] -#![warn(clippy::into_iter_on_ref)] +#![deny(clippy::into_iter_on_ref)] struct X; use std::collections::*; @@ -11,35 +11,35 @@ fn main() { for _ in &vec![X, X] {} let _ = vec![1, 2, 3].into_iter(); - let _ = (&vec![1, 2, 3]).iter(); //~ WARN equivalent to .iter() - let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ WARN equivalent to .iter() - let _ = std::rc::Rc::from(&[X][..]).iter(); //~ WARN equivalent to .iter() - let _ = std::sync::Arc::from(&[X][..]).iter(); //~ WARN equivalent to .iter() + let _ = (&vec![1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter() + let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ ERROR: equivalent to `.iter() + let _ = std::rc::Rc::from(&[X][..]).iter(); //~ ERROR: equivalent to `.iter() + let _ = std::sync::Arc::from(&[X][..]).iter(); //~ ERROR: equivalent to `.iter() - let _ = (&&&&&&&[1, 2, 3]).iter(); //~ ERROR equivalent to .iter() - let _ = (&&&&mut &&&[1, 2, 3]).iter(); //~ ERROR equivalent to .iter() - let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); //~ ERROR equivalent to .iter_mut() + let _ = (&&&&&&&[1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&&&&mut &&&[1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); //~ ERROR: equivalent to `.iter_mut() - let _ = (&Some(4)).iter(); //~ WARN equivalent to .iter() - let _ = (&mut Some(5)).iter_mut(); //~ WARN equivalent to .iter_mut() - let _ = (&Ok::<_, i32>(6)).iter(); //~ WARN equivalent to .iter() - let _ = (&mut Err::(7)).iter_mut(); //~ WARN equivalent to .iter_mut() - let _ = (&Vec::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&mut Vec::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() - let _ = (&BTreeMap::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&mut BTreeMap::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() - let _ = (&VecDeque::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&mut VecDeque::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() - let _ = (&LinkedList::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&mut LinkedList::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() - let _ = (&HashMap::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&mut HashMap::::new()).iter_mut(); //~ WARN equivalent to .iter_mut() + let _ = (&Some(4)).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut Some(5)).iter_mut(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&Ok::<_, i32>(6)).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut Err::(7)).iter_mut(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&Vec::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut Vec::::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&BTreeMap::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut BTreeMap::::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&VecDeque::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut VecDeque::::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&LinkedList::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut LinkedList::::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&HashMap::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut HashMap::::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut() - let _ = (&BTreeSet::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&BinaryHeap::::new()).iter(); //~ WARN equivalent to .iter() - let _ = (&HashSet::::new()).iter(); //~ WARN equivalent to .iter() - let _ = std::path::Path::new("12/34").iter(); //~ WARN equivalent to .iter() - let _ = std::path::PathBuf::from("12/34").iter(); //~ ERROR equivalent to .iter() + let _ = (&BTreeSet::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&BinaryHeap::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = (&HashSet::::new()).iter(); //~ ERROR: equivalent to `.iter() + let _ = std::path::Path::new("12/34").iter(); //~ ERROR: equivalent to `.iter() + let _ = std::path::PathBuf::from("12/34").iter(); //~ ERROR: equivalent to `.iter() - let _ = (&[1, 2, 3]).iter().next(); //~ WARN equivalent to .iter() + let _ = (&[1, 2, 3]).iter().next(); //~ ERROR: equivalent to `.iter() } diff --git a/tests/ui/into_iter_on_ref.rs b/tests/ui/into_iter_on_ref.rs index 3854bb05af8f..7978ffba7c50 100644 --- a/tests/ui/into_iter_on_ref.rs +++ b/tests/ui/into_iter_on_ref.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::useless_vec, clippy::needless_borrow)] -#![warn(clippy::into_iter_on_ref)] +#![deny(clippy::into_iter_on_ref)] struct X; use std::collections::*; @@ -11,35 +11,35 @@ fn main() { for _ in &vec![X, X] {} let _ = vec![1, 2, 3].into_iter(); - let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() - let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() - let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() - let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() + let _ = (&vec![1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ ERROR: equivalent to `.iter() + let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ ERROR: equivalent to `.iter() - let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() - let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() - let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() + let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter_mut() - let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut() - let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut Err::(7)).into_iter(); //~ WARN equivalent to .iter_mut() - let _ = (&Vec::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut Vec::::new()).into_iter(); //~ WARN equivalent to .iter_mut() - let _ = (&BTreeMap::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut BTreeMap::::new()).into_iter(); //~ WARN equivalent to .iter_mut() - let _ = (&VecDeque::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut VecDeque::::new()).into_iter(); //~ WARN equivalent to .iter_mut() - let _ = (&LinkedList::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut LinkedList::::new()).into_iter(); //~ WARN equivalent to .iter_mut() - let _ = (&HashMap::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&mut HashMap::::new()).into_iter(); //~ WARN equivalent to .iter_mut() + let _ = (&Some(4)).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut Some(5)).into_iter(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&Ok::<_, i32>(6)).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut Err::(7)).into_iter(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&Vec::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut Vec::::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&BTreeMap::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut BTreeMap::::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&VecDeque::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut VecDeque::::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&LinkedList::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut LinkedList::::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut() + let _ = (&HashMap::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&mut HashMap::::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut() - let _ = (&BTreeSet::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&BinaryHeap::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = (&HashSet::::new()).into_iter(); //~ WARN equivalent to .iter() - let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter() - let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter() + let _ = (&BTreeSet::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&BinaryHeap::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = (&HashSet::::new()).into_iter(); //~ ERROR: equivalent to `.iter() + let _ = std::path::Path::new("12/34").into_iter(); //~ ERROR: equivalent to `.iter() + let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR: equivalent to `.iter() - let _ = (&[1, 2, 3]).into_iter().next(); //~ WARN equivalent to .iter() + let _ = (&[1, 2, 3]).into_iter().next(); //~ ERROR: equivalent to `.iter() } diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index 28003b365bbd..3d3f1ba95e40 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,165 +1,169 @@ error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` --> $DIR/into_iter_on_ref.rs:14:30 | -LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&vec![1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` | - = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/into_iter_on_ref.rs:3:9 + | +LL | #![deny(clippy::into_iter_on_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` --> $DIR/into_iter_on_ref.rs:15:46 | -LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() +LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` --> $DIR/into_iter_on_ref.rs:16:41 | -LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` --> $DIR/into_iter_on_ref.rs:17:44 | -LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` --> $DIR/into_iter_on_ref.rs:19:32 | -LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` --> $DIR/into_iter_on_ref.rs:20:36 | -LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `array` --> $DIR/into_iter_on_ref.rs:21:40 | -LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() +LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Option` --> $DIR/into_iter_on_ref.rs:23:24 | -LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&Some(4)).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Option` --> $DIR/into_iter_on_ref.rs:24:28 | -LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut Some(5)).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Result` --> $DIR/into_iter_on_ref.rs:25:32 | -LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&Ok::<_, i32>(6)).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Result` --> $DIR/into_iter_on_ref.rs:26:37 | -LL | let _ = (&mut Err::(7)).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut Err::(7)).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` --> $DIR/into_iter_on_ref.rs:27:34 | -LL | let _ = (&Vec::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&Vec::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Vec` --> $DIR/into_iter_on_ref.rs:28:38 | -LL | let _ = (&mut Vec::::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut Vec::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeMap` --> $DIR/into_iter_on_ref.rs:29:44 | -LL | let _ = (&BTreeMap::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&BTreeMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `BTreeMap` --> $DIR/into_iter_on_ref.rs:30:48 | -LL | let _ = (&mut BTreeMap::::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut BTreeMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `VecDeque` --> $DIR/into_iter_on_ref.rs:31:39 | -LL | let _ = (&VecDeque::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&VecDeque::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `VecDeque` --> $DIR/into_iter_on_ref.rs:32:43 | -LL | let _ = (&mut VecDeque::::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut VecDeque::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `LinkedList` --> $DIR/into_iter_on_ref.rs:33:41 | -LL | let _ = (&LinkedList::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&LinkedList::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `LinkedList` --> $DIR/into_iter_on_ref.rs:34:45 | -LL | let _ = (&mut LinkedList::::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut LinkedList::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashMap` --> $DIR/into_iter_on_ref.rs:35:43 | -LL | let _ = (&HashMap::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&HashMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `HashMap` --> $DIR/into_iter_on_ref.rs:36:47 | -LL | let _ = (&mut HashMap::::new()).into_iter(); //~ WARN equivalent to .iter_mut() +LL | let _ = (&mut HashMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeSet` --> $DIR/into_iter_on_ref.rs:38:39 | -LL | let _ = (&BTreeSet::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&BTreeSet::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BinaryHeap` --> $DIR/into_iter_on_ref.rs:39:41 | -LL | let _ = (&BinaryHeap::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&BinaryHeap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashSet` --> $DIR/into_iter_on_ref.rs:40:38 | -LL | let _ = (&HashSet::::new()).into_iter(); //~ WARN equivalent to .iter() +LL | let _ = (&HashSet::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Path` --> $DIR/into_iter_on_ref.rs:41:43 | -LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter() +LL | let _ = std::path::Path::new("12/34").into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `PathBuf` --> $DIR/into_iter_on_ref.rs:42:47 | -LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter() +LL | let _ = std::path::PathBuf::from("12/34").into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` --> $DIR/into_iter_on_ref.rs:44:26 | -LL | let _ = (&[1, 2, 3]).into_iter().next(); //~ WARN equivalent to .iter() +LL | let _ = (&[1, 2, 3]).into_iter().next(); | ^^^^^^^^^ help: call directly: `iter` error: aborting due to 27 previous errors diff --git a/tests/ui/invalid_null_ptr_usage.fixed b/tests/ui/invalid_null_ptr_usage.fixed index 4f5322ebf202..a9f087d47581 100644 --- a/tests/ui/invalid_null_ptr_usage.fixed +++ b/tests/ui/invalid_null_ptr_usage.fixed @@ -1,4 +1,5 @@ -// run-rustfix +//@run-rustfix +#![warn(clippy::invalid_null_ptr_usage)] fn main() { unsafe { diff --git a/tests/ui/invalid_null_ptr_usage.rs b/tests/ui/invalid_null_ptr_usage.rs index ae51c52d8af0..50b13a591c24 100644 --- a/tests/ui/invalid_null_ptr_usage.rs +++ b/tests/ui/invalid_null_ptr_usage.rs @@ -1,4 +1,5 @@ -// run-rustfix +//@run-rustfix +#![warn(clippy::invalid_null_ptr_usage)] fn main() { unsafe { diff --git a/tests/ui/invalid_null_ptr_usage.stderr b/tests/ui/invalid_null_ptr_usage.stderr index 532c36abe519..bffebfb625ba 100644 --- a/tests/ui/invalid_null_ptr_usage.stderr +++ b/tests/ui/invalid_null_ptr_usage.stderr @@ -1,154 +1,158 @@ -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:5:59 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:6:59 | LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` | - = note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default +note: the lint level is defined here + --> $DIR/invalid_null_ptr_usage.rs:2:9 + | +LL | #![warn(clippy::invalid_null_ptr_usage)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:6:59 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:7:59 | LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:8:63 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:9:63 | LL | let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:10:33 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:11:33 | LL | std::ptr::copy::(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:11:73 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:12:73 | LL | std::ptr::copy::(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:13:48 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:14:48 | LL | std::ptr::copy_nonoverlapping::(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:14:88 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:15:88 | LL | std::ptr::copy_nonoverlapping::(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:19:36 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:20:36 | LL | let _a: A = std::ptr::read(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:20:36 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:21:36 | LL | let _a: A = std::ptr::read(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:22:46 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:23:46 | LL | let _a: A = std::ptr::read_unaligned(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:23:46 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:24:46 | LL | let _a: A = std::ptr::read_unaligned(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:25:45 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:26:45 | LL | let _a: A = std::ptr::read_volatile(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:26:45 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:27:45 | LL | let _a: A = std::ptr::read_volatile(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:28:39 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:29:39 | LL | let _a: A = std::ptr::replace(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:30:69 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:31:69 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:31:69 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:32:69 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:33:73 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:34:73 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:35:29 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:36:29 | LL | std::ptr::swap::(std::ptr::null_mut(), &mut A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:36:37 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:37:37 | LL | std::ptr::swap::(&mut A, std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:38:44 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:39:44 | LL | std::ptr::swap_nonoverlapping::(std::ptr::null_mut(), &mut A, 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:39:52 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:40:52 | LL | std::ptr::swap_nonoverlapping::(&mut A, std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:41:25 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:42:25 | LL | std::ptr::write(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:43:35 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:44:35 | LL | std::ptr::write_unaligned(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:45:34 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:46:34 | LL | std::ptr::write_volatile(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:47:40 +warning: pointer must be non-null + --> $DIR/invalid_null_ptr_usage.rs:48:40 | LL | std::ptr::write_bytes::(std::ptr::null_mut(), 42, 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` -error: aborting due to 25 previous errors +warning: 25 warnings emitted diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index 03c3fb80aaab..f7cc60a7db79 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,166 +1,170 @@ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:21:5 | LL | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/invalid_upcast_comparisons.rs:1:9 + | +LL | #![warn(clippy::invalid_upcast_comparisons)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:22:5 | LL | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:23:5 | LL | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:24:5 | LL | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:25:5 | LL | 300 < (u8 as u32); | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:26:5 | LL | 300 < (u8 as i32); | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:27:5 | LL | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:28:5 | LL | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:30:5 | LL | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:31:5 | LL | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:32:5 | LL | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:33:5 | LL | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:34:5 | LL | 300 >= (u8 as u32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:35:5 | LL | 300 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:36:5 | LL | 300 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:37:5 | LL | 300 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:40:5 | LL | (u8 as i32) < 0; | ^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:41:5 | LL | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:43:5 | LL | (u8 as i32) >= 0; | ^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:44:5 | LL | -5 == (u8 as i32); | ^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:47:5 | LL | 1337 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:48:5 | LL | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:50:5 | LL | 1337 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:51:5 | LL | 1337 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always true +warning: because of the numeric bounds on `u8` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:65:5 | LL | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:66:5 | LL | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ -error: because of the numeric bounds on `u8` prior to casting, this expression is always false +warning: because of the numeric bounds on `u8` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:82:5 | LL | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ -error: aborting due to 27 previous errors +warning: 27 warnings emitted diff --git a/tests/ui/invalid_utf8_in_unchecked.stderr b/tests/ui/invalid_utf8_in_unchecked.stderr index c89cd2758ee9..59af0f9ca1d1 100644 --- a/tests/ui/invalid_utf8_in_unchecked.stderr +++ b/tests/ui/invalid_utf8_in_unchecked.stderr @@ -1,22 +1,26 @@ -error: non UTF-8 literal in `std::str::from_utf8_unchecked` +warning: non UTF-8 literal in `std::str::from_utf8_unchecked` --> $DIR/invalid_utf8_in_unchecked.rs:16:9 | LL | std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::invalid-utf8-in-unchecked` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/invalid_utf8_in_unchecked.rs:1:9 + | +LL | #![warn(clippy::invalid_utf8_in_unchecked)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: non UTF-8 literal in `std::str::from_utf8_unchecked` +warning: non UTF-8 literal in `std::str::from_utf8_unchecked` --> $DIR/invalid_utf8_in_unchecked.rs:17:9 | -LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'/x82', b'i', b'p', b'p', b'y']); +LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: non UTF-8 literal in `std::str::from_utf8_unchecked` +warning: non UTF-8 literal in `std::str::from_utf8_unchecked` --> $DIR/invalid_utf8_in_unchecked.rs:18:9 | -LL | std::str::from_utf8_unchecked(b"cl/x82ippy"); +LL | std::str::from_utf8_unchecked(b"cl\x82ippy"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/is_digit_ascii_radix.fixed b/tests/ui/is_digit_ascii_radix.fixed index c0ba647d7079..bc43303a680d 100644 --- a/tests/ui/is_digit_ascii_radix.fixed +++ b/tests/ui/is_digit_ascii_radix.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::is_digit_ascii_radix)] diff --git a/tests/ui/is_digit_ascii_radix.rs b/tests/ui/is_digit_ascii_radix.rs index 68e3f3243d96..93cba5c8e4e5 100644 --- a/tests/ui/is_digit_ascii_radix.rs +++ b/tests/ui/is_digit_ascii_radix.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::is_digit_ascii_radix)] diff --git a/tests/ui/is_digit_ascii_radix.stderr b/tests/ui/is_digit_ascii_radix.stderr index dc5cb2913ae1..d8a7ddc784f1 100644 --- a/tests/ui/is_digit_ascii_radix.stderr +++ b/tests/ui/is_digit_ascii_radix.stderr @@ -1,22 +1,26 @@ -error: use of `char::is_digit` with literal radix of 10 +warning: use of `char::is_digit` with literal radix of 10 --> $DIR/is_digit_ascii_radix.rs:11:13 | LL | let _ = c.is_digit(10); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_digit()` | - = note: `-D clippy::is-digit-ascii-radix` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/is_digit_ascii_radix.rs:3:9 + | +LL | #![warn(clippy::is_digit_ascii_radix)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `char::is_digit` with literal radix of 16 +warning: use of `char::is_digit` with literal radix of 16 --> $DIR/is_digit_ascii_radix.rs:12:13 | LL | let _ = c.is_digit(16); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_hexdigit()` -error: use of `char::is_digit` with literal radix of 16 +warning: use of `char::is_digit` with literal radix of 16 --> $DIR/is_digit_ascii_radix.rs:13:13 | LL | let _ = c.is_digit(0x10); | ^^^^^^^^^^^^^^^^ help: try: `c.is_ascii_hexdigit()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/issue-3145.rs b/tests/ui/issue-3145.rs index 586d13647d15..0b07de1144ce 100644 --- a/tests/ui/issue-3145.rs +++ b/tests/ui/issue-3145.rs @@ -1,3 +1,3 @@ fn main() { - println!("{}" a); //~ERROR expected `,`, found `a` + println!("{}" a); //~ERROR: expected `,`, found `a` } diff --git a/tests/ui/issue-3145.stderr b/tests/ui/issue-3145.stderr index a35032aa150d..d7c2c88a2047 100644 --- a/tests/ui/issue-3145.stderr +++ b/tests/ui/issue-3145.stderr @@ -1,7 +1,7 @@ error: expected `,`, found `a` --> $DIR/issue-3145.rs:2:19 | -LL | println!("{}" a); //~ERROR expected `,`, found `a` +LL | println!("{}" a); | ^ expected `,` error: aborting due to previous error diff --git a/tests/ui/issue-7447.stderr b/tests/ui/issue-7447.stderr index 8d8c29f13858..d0e78f6046f0 100644 --- a/tests/ui/issue-7447.stderr +++ b/tests/ui/issue-7447.stderr @@ -1,19 +1,19 @@ -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/issue-7447.rs:23:15 | LL | byte_view(panic!()); | ^^^^^^^^ | - = note: `-D clippy::diverging-sub-expression` implied by `-D warnings` - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: `#[warn(clippy::diverging_sub_expression)]` on by default + = note: this warning originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: sub-expression diverges +warning: sub-expression diverges --> $DIR/issue-7447.rs:24:19 | LL | group_entries(panic!()); | ^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/issue_2356.fixed b/tests/ui/issue_2356.fixed index a73ee0fb2e59..30b4054986de 100644 --- a/tests/ui/issue_2356.fixed +++ b/tests/ui/issue_2356.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![deny(clippy::while_let_on_iterator)] #![allow(unused_mut)] #![allow(clippy::uninlined_format_args)] @@ -16,6 +16,7 @@ impl Foo { fn foo2>(mut it: I) { for e in it { + //~^ ERROR: could be written as a `for` loop println!("{:?}", e); } } diff --git a/tests/ui/issue_2356.rs b/tests/ui/issue_2356.rs index 9dd9069609b1..b0e73c34ac32 100644 --- a/tests/ui/issue_2356.rs +++ b/tests/ui/issue_2356.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![deny(clippy::while_let_on_iterator)] #![allow(unused_mut)] #![allow(clippy::uninlined_format_args)] @@ -16,6 +16,7 @@ impl Foo { fn foo2>(mut it: I) { while let Some(e) = it.next() { + //~^ ERROR: could be written as a `for` loop println!("{:?}", e); } } diff --git a/tests/ui/issue_4266.stderr b/tests/ui/issue_4266.stderr index fd553aa4538a..77194534cb78 100644 --- a/tests/ui/issue_4266.stderr +++ b/tests/ui/issue_4266.stderr @@ -1,25 +1,25 @@ -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/issue_4266.rs:4:1 | LL | async fn sink1<'a>(_: &'a str) {} // lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::needless-lifetimes` implied by `-D warnings` + = note: `#[warn(clippy::needless_lifetimes)]` on by default -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/issue_4266.rs:8:1 | LL | async fn one_to_one<'a>(s: &'a str) -> &'a str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: methods called `new` usually take no `self` +warning: methods called `new` usually take no `self` --> $DIR/issue_4266.rs:28:22 | LL | pub async fn new(&mut self) -> Self { | ^^^^^^^^^ | = help: consider choosing a less ambiguous name - = note: `-D clippy::wrong-self-convention` implied by `-D warnings` + = note: `#[warn(clippy::wrong_self_convention)]` on by default -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index 2523c53ac53a..b6ad4ba81809 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -1,4 +1,4 @@ -error: adding items after statements is confusing, since items exist from the start of the scope +warning: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:13:5 | LL | / fn foo() { @@ -6,9 +6,13 @@ LL | | println!("foo"); LL | | } | |_____^ | - = note: `-D clippy::items-after-statements` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/item_after_statement.rs:1:9 + | +LL | #![warn(clippy::items_after_statements)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: adding items after statements is confusing, since items exist from the start of the scope +warning: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:20:5 | LL | / fn foo() { @@ -16,7 +20,7 @@ LL | | println!("foo"); LL | | } | |_____^ -error: adding items after statements is confusing, since items exist from the start of the scope +warning: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:33:13 | LL | / fn say_something() { @@ -27,7 +31,7 @@ LL | | } LL | b!(); | ---- in this macro invocation | - = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/iter_cloned_collect.fixed b/tests/ui/iter_cloned_collect.fixed index 9b8621335804..88f08bb991b8 100644 --- a/tests/ui/iter_cloned_collect.fixed +++ b/tests/ui/iter_cloned_collect.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] diff --git a/tests/ui/iter_cloned_collect.rs b/tests/ui/iter_cloned_collect.rs index 639f50665f2a..d3438b7f51a2 100644 --- a/tests/ui/iter_cloned_collect.rs +++ b/tests/ui/iter_cloned_collect.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] diff --git a/tests/ui/iter_cloned_collect.stderr b/tests/ui/iter_cloned_collect.stderr index b2cc497bf433..4d08af5a0ca8 100644 --- a/tests/ui/iter_cloned_collect.stderr +++ b/tests/ui/iter_cloned_collect.stderr @@ -1,18 +1,18 @@ -error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable +warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable --> $DIR/iter_cloned_collect.rs:10:27 | LL | let v2: Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` | - = note: `-D clippy::iter-cloned-collect` implied by `-D warnings` + = note: `#[warn(clippy::iter_cloned_collect)]` on by default -error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable +warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable --> $DIR/iter_cloned_collect.rs:15:38 | LL | let _: Vec = vec![1, 2, 3].iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` -error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable +warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable --> $DIR/iter_cloned_collect.rs:20:24 | LL | .to_bytes() @@ -22,17 +22,17 @@ LL | | .cloned() LL | | .collect(); | |______________________^ help: try: `.to_vec()` -error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable +warning: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable --> $DIR/iter_cloned_collect.rs:28:24 | LL | let _: Vec<_> = arr.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` -error: called `iter().copied().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable +warning: called `iter().copied().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable --> $DIR/iter_cloned_collect.rs:31:26 | LL | let _: Vec = v.iter().copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/iter_count.fixed b/tests/ui/iter_count.fixed index 90a6eef75261..4367a12f820d 100644 --- a/tests/ui/iter_count.fixed +++ b/tests/ui/iter_count.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:option_helpers.rs +//@run-rustfix +//@aux-build:option_helpers.rs #![warn(clippy::iter_count)] #![allow( diff --git a/tests/ui/iter_count.rs b/tests/ui/iter_count.rs index 6681a480a28c..8c7543cf03b3 100644 --- a/tests/ui/iter_count.rs +++ b/tests/ui/iter_count.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:option_helpers.rs +//@run-rustfix +//@aux-build:option_helpers.rs #![warn(clippy::iter_count)] #![allow( diff --git a/tests/ui/iter_count.stderr b/tests/ui/iter_count.stderr index 2e3d7fc35de9..977055cd4d32 100644 --- a/tests/ui/iter_count.stderr +++ b/tests/ui/iter_count.stderr @@ -1,154 +1,158 @@ -error: called `.iter().count()` on a `slice` +warning: called `.iter().count()` on a `slice` --> $DIR/iter_count.rs:54:6 | LL | &vec[..].iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` | - = note: `-D clippy::iter-count` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_count.rs:4:9 + | +LL | #![warn(clippy::iter_count)] + | ^^^^^^^^^^^^^^^^^^ -error: called `.iter().count()` on a `Vec` +warning: called `.iter().count()` on a `Vec` --> $DIR/iter_count.rs:55:5 | LL | vec.iter().count(); | ^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` -error: called `.iter().count()` on a `slice` +warning: called `.iter().count()` on a `slice` --> $DIR/iter_count.rs:56:5 | LL | boxed_slice.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice.len()` -error: called `.iter().count()` on a `VecDeque` +warning: called `.iter().count()` on a `VecDeque` --> $DIR/iter_count.rs:57:5 | LL | vec_deque.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` -error: called `.iter().count()` on a `HashSet` +warning: called `.iter().count()` on a `HashSet` --> $DIR/iter_count.rs:58:5 | LL | hash_set.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_set.len()` -error: called `.iter().count()` on a `HashMap` +warning: called `.iter().count()` on a `HashMap` --> $DIR/iter_count.rs:59:5 | LL | hash_map.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` -error: called `.iter().count()` on a `BTreeMap` +warning: called `.iter().count()` on a `BTreeMap` --> $DIR/iter_count.rs:60:5 | LL | b_tree_map.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` -error: called `.iter().count()` on a `BTreeSet` +warning: called `.iter().count()` on a `BTreeSet` --> $DIR/iter_count.rs:61:5 | LL | b_tree_set.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_set.len()` -error: called `.iter().count()` on a `LinkedList` +warning: called `.iter().count()` on a `LinkedList` --> $DIR/iter_count.rs:62:5 | LL | linked_list.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` -error: called `.iter().count()` on a `BinaryHeap` +warning: called `.iter().count()` on a `BinaryHeap` --> $DIR/iter_count.rs:63:5 | LL | binary_heap.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `binary_heap.len()` -error: called `.iter_mut().count()` on a `Vec` +warning: called `.iter_mut().count()` on a `Vec` --> $DIR/iter_count.rs:65:5 | LL | vec.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` -error: called `.iter_mut().count()` on a `slice` +warning: called `.iter_mut().count()` on a `slice` --> $DIR/iter_count.rs:66:6 | LL | &vec[..].iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` -error: called `.iter_mut().count()` on a `VecDeque` +warning: called `.iter_mut().count()` on a `VecDeque` --> $DIR/iter_count.rs:67:5 | LL | vec_deque.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` -error: called `.iter_mut().count()` on a `HashMap` +warning: called `.iter_mut().count()` on a `HashMap` --> $DIR/iter_count.rs:68:5 | LL | hash_map.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` -error: called `.iter_mut().count()` on a `BTreeMap` +warning: called `.iter_mut().count()` on a `BTreeMap` --> $DIR/iter_count.rs:69:5 | LL | b_tree_map.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` -error: called `.iter_mut().count()` on a `LinkedList` +warning: called `.iter_mut().count()` on a `LinkedList` --> $DIR/iter_count.rs:70:5 | LL | linked_list.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` -error: called `.into_iter().count()` on a `slice` +warning: called `.into_iter().count()` on a `slice` --> $DIR/iter_count.rs:72:6 | LL | &vec[..].into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` -error: called `.into_iter().count()` on a `Vec` +warning: called `.into_iter().count()` on a `Vec` --> $DIR/iter_count.rs:73:5 | LL | vec.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` -error: called `.into_iter().count()` on a `VecDeque` +warning: called `.into_iter().count()` on a `VecDeque` --> $DIR/iter_count.rs:74:5 | LL | vec_deque.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` -error: called `.into_iter().count()` on a `HashSet` +warning: called `.into_iter().count()` on a `HashSet` --> $DIR/iter_count.rs:75:5 | LL | hash_set.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_set.len()` -error: called `.into_iter().count()` on a `HashMap` +warning: called `.into_iter().count()` on a `HashMap` --> $DIR/iter_count.rs:76:5 | LL | hash_map.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` -error: called `.into_iter().count()` on a `BTreeMap` +warning: called `.into_iter().count()` on a `BTreeMap` --> $DIR/iter_count.rs:77:5 | LL | b_tree_map.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` -error: called `.into_iter().count()` on a `BTreeSet` +warning: called `.into_iter().count()` on a `BTreeSet` --> $DIR/iter_count.rs:78:5 | LL | b_tree_set.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_set.len()` -error: called `.into_iter().count()` on a `LinkedList` +warning: called `.into_iter().count()` on a `LinkedList` --> $DIR/iter_count.rs:79:5 | LL | linked_list.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` -error: called `.into_iter().count()` on a `BinaryHeap` +warning: called `.into_iter().count()` on a `BinaryHeap` --> $DIR/iter_count.rs:80:5 | LL | binary_heap.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `binary_heap.len()` -error: aborting due to 25 previous errors +warning: 25 warnings emitted diff --git a/tests/ui/iter_kv_map.fixed b/tests/ui/iter_kv_map.fixed index f2a4c284cb16..64201b553fdd 100644 --- a/tests/ui/iter_kv_map.fixed +++ b/tests/ui/iter_kv_map.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_kv_map)] #![allow(unused_mut, clippy::redundant_clone, clippy::suspicious_map, clippy::map_identity)] diff --git a/tests/ui/iter_kv_map.rs b/tests/ui/iter_kv_map.rs index ad6564df4084..ec0231ba5727 100644 --- a/tests/ui/iter_kv_map.rs +++ b/tests/ui/iter_kv_map.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_kv_map)] #![allow(unused_mut, clippy::redundant_clone, clippy::suspicious_map, clippy::map_identity)] diff --git a/tests/ui/iter_kv_map.stderr b/tests/ui/iter_kv_map.stderr index e00da223b4dd..0d2a4233c145 100644 --- a/tests/ui/iter_kv_map.stderr +++ b/tests/ui/iter_kv_map.stderr @@ -1,78 +1,82 @@ -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:16:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` | - = note: `-D clippy::iter-kv-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_kv_map.rs:3:9 + | +LL | #![warn(clippy::iter_kv_map)] + | ^^^^^^^^^^^^^^^^^^^ -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:17:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:18:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:20:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:21:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:23:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:24:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:26:13 | LL | let _ = map.clone().iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().values()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:27:13 | LL | let _ = map.iter().map(|(key, _)| key).filter(|x| *x % 2 == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:37:13 | LL | let _ = map.iter().map(|(key, _value)| key * 9).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys().map(|key| key * 9)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:38:13 | LL | let _ = map.iter().map(|(_key, value)| value * 17).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|value| value * 17)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:41:13 | LL | let _ = map.clone().into_iter().map(|(_, ref val)| ref_acceptor(val)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|ref val| ref_acceptor(val))` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:44:13 | LL | let _ = map @@ -94,85 +98,85 @@ LL + val LL + }) | -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:54:13 | LL | let _ = map.clone().into_iter().map(|(_, mut val)| val).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:58:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:59:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:60:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:62:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:63:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:65:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:66:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:68:13 | LL | let _ = map.clone().iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().values()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:69:13 | LL | let _ = map.iter().map(|(key, _)| key).filter(|x| *x % 2 == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` -error: iterating on a map's keys +warning: iterating on a map's keys --> $DIR/iter_kv_map.rs:79:13 | LL | let _ = map.iter().map(|(key, _value)| key * 9).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys().map(|key| key * 9)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:80:13 | LL | let _ = map.iter().map(|(_key, value)| value * 17).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|value| value * 17)` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:83:13 | LL | let _ = map.clone().into_iter().map(|(_, ref val)| ref_acceptor(val)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|ref val| ref_acceptor(val))` -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:86:13 | LL | let _ = map @@ -194,11 +198,11 @@ LL + val LL + }) | -error: iterating on a map's values +warning: iterating on a map's values --> $DIR/iter_kv_map.rs:96:13 | LL | let _ = map.clone().into_iter().map(|(_, mut val)| val).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` -error: aborting due to 28 previous errors +warning: 28 warnings emitted diff --git a/tests/ui/iter_next_slice.fixed b/tests/ui/iter_next_slice.fixed index f612d26aaabc..d862abc34e0b 100644 --- a/tests/ui/iter_next_slice.fixed +++ b/tests/ui/iter_next_slice.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_next_slice)] fn main() { diff --git a/tests/ui/iter_next_slice.rs b/tests/ui/iter_next_slice.rs index 5195f1c86675..da6fc46e4287 100644 --- a/tests/ui/iter_next_slice.rs +++ b/tests/ui/iter_next_slice.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_next_slice)] fn main() { diff --git a/tests/ui/iter_next_slice.stderr b/tests/ui/iter_next_slice.stderr index d8b89061ff89..8352ef4924d1 100644 --- a/tests/ui/iter_next_slice.stderr +++ b/tests/ui/iter_next_slice.stderr @@ -1,28 +1,32 @@ -error: using `.iter().next()` on an array +warning: using `.iter().next()` on an array --> $DIR/iter_next_slice.rs:9:13 | LL | let _ = s.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `s.first()` | - = note: `-D clippy::iter-next-slice` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_next_slice.rs:2:9 + | +LL | #![warn(clippy::iter_next_slice)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: using `.iter().next()` on a Slice without end index +warning: using `.iter().next()` on a Slice without end index --> $DIR/iter_next_slice.rs:12:13 | LL | let _ = s[2..].iter().next(); | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)` -error: using `.iter().next()` on a Slice without end index +warning: using `.iter().next()` on a Slice without end index --> $DIR/iter_next_slice.rs:15:13 | LL | let _ = v[5..].iter().next(); | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)` -error: using `.iter().next()` on an array +warning: using `.iter().next()` on an array --> $DIR/iter_next_slice.rs:18:13 | LL | let _ = v.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `v.first()` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/iter_not_returning_iterator.stderr b/tests/ui/iter_not_returning_iterator.stderr index 44f029558369..77b0234d47bb 100644 --- a/tests/ui/iter_not_returning_iterator.stderr +++ b/tests/ui/iter_not_returning_iterator.stderr @@ -1,22 +1,26 @@ -error: this method is named `iter` but its return type does not implement `Iterator` +warning: this method is named `iter` but its return type does not implement `Iterator` --> $DIR/iter_not_returning_iterator.rs:30:5 | LL | fn iter(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::iter-not-returning-iterator` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_not_returning_iterator.rs:1:9 + | +LL | #![warn(clippy::iter_not_returning_iterator)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this method is named `iter_mut` but its return type does not implement `Iterator` +warning: this method is named `iter_mut` but its return type does not implement `Iterator` --> $DIR/iter_not_returning_iterator.rs:34:5 | LL | fn iter_mut(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this method is named `iter` but its return type does not implement `Iterator` +warning: this method is named `iter` but its return type does not implement `Iterator` --> $DIR/iter_not_returning_iterator.rs:50:5 | LL | fn iter(&self) -> Self::I; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/iter_nth.rs b/tests/ui/iter_nth.rs index 9c21dd82ee45..e7fb97d4fbc8 100644 --- a/tests/ui/iter_nth.rs +++ b/tests/ui/iter_nth.rs @@ -1,4 +1,4 @@ -// aux-build:option_helpers.rs +//@aux-build:option_helpers.rs #![warn(clippy::iter_nth)] diff --git a/tests/ui/iter_nth.stderr b/tests/ui/iter_nth.stderr index a0fe353bcf75..40d381f2c97e 100644 --- a/tests/ui/iter_nth.stderr +++ b/tests/ui/iter_nth.stderr @@ -1,13 +1,17 @@ -error: called `.iter().nth()` on a Vec +warning: called `.iter().nth()` on a Vec --> $DIR/iter_nth.rs:33:23 | LL | let bad_vec = some_vec.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: calling `.get()` is both faster and more readable - = note: `-D clippy::iter-nth` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_nth.rs:3:9 + | +LL | #![warn(clippy::iter_nth)] + | ^^^^^^^^^^^^^^^^ -error: called `.iter().nth()` on a slice +warning: called `.iter().nth()` on a slice --> $DIR/iter_nth.rs:34:26 | LL | let bad_slice = &some_vec[..].iter().nth(3); @@ -15,7 +19,7 @@ LL | let bad_slice = &some_vec[..].iter().nth(3); | = help: calling `.get()` is both faster and more readable -error: called `.iter().nth()` on a slice +warning: called `.iter().nth()` on a slice --> $DIR/iter_nth.rs:35:31 | LL | let bad_boxed_slice = boxed_slice.iter().nth(3); @@ -23,7 +27,7 @@ LL | let bad_boxed_slice = boxed_slice.iter().nth(3); | = help: calling `.get()` is both faster and more readable -error: called `.iter().nth()` on a VecDeque +warning: called `.iter().nth()` on a VecDeque --> $DIR/iter_nth.rs:36:29 | LL | let bad_vec_deque = some_vec_deque.iter().nth(3); @@ -31,7 +35,7 @@ LL | let bad_vec_deque = some_vec_deque.iter().nth(3); | = help: calling `.get()` is both faster and more readable -error: called `.iter_mut().nth()` on a Vec +warning: called `.iter_mut().nth()` on a Vec --> $DIR/iter_nth.rs:41:23 | LL | let bad_vec = some_vec.iter_mut().nth(3); @@ -39,7 +43,7 @@ LL | let bad_vec = some_vec.iter_mut().nth(3); | = help: calling `.get_mut()` is both faster and more readable -error: called `.iter_mut().nth()` on a slice +warning: called `.iter_mut().nth()` on a slice --> $DIR/iter_nth.rs:44:26 | LL | let bad_slice = &some_vec[..].iter_mut().nth(3); @@ -47,7 +51,7 @@ LL | let bad_slice = &some_vec[..].iter_mut().nth(3); | = help: calling `.get_mut()` is both faster and more readable -error: called `.iter_mut().nth()` on a VecDeque +warning: called `.iter_mut().nth()` on a VecDeque --> $DIR/iter_nth.rs:47:29 | LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); @@ -55,5 +59,5 @@ LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); | = help: calling `.get_mut()` is both faster and more readable -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/iter_nth_zero.fixed b/tests/ui/iter_nth_zero.fixed index f23671c26e4c..587b0d1d366a 100644 --- a/tests/ui/iter_nth_zero.fixed +++ b/tests/ui/iter_nth_zero.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_nth_zero)] use std::collections::HashSet; diff --git a/tests/ui/iter_nth_zero.rs b/tests/ui/iter_nth_zero.rs index 7c968d498457..93b576ec56fe 100644 --- a/tests/ui/iter_nth_zero.rs +++ b/tests/ui/iter_nth_zero.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_nth_zero)] use std::collections::HashSet; diff --git a/tests/ui/iter_nth_zero.stderr b/tests/ui/iter_nth_zero.stderr index 29c56f3a94f5..d9dc4f094352 100644 --- a/tests/ui/iter_nth_zero.stderr +++ b/tests/ui/iter_nth_zero.stderr @@ -1,22 +1,26 @@ -error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent +warning: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent --> $DIR/iter_nth_zero.rs:20:14 | LL | let _x = s.iter().nth(0); | ^^^^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `s.iter().next()` | - = note: `-D clippy::iter-nth-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_nth_zero.rs:3:9 + | +LL | #![warn(clippy::iter_nth_zero)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent +warning: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent --> $DIR/iter_nth_zero.rs:25:14 | LL | let _y = iter.nth(0); | ^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter.next()` -error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent +warning: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent --> $DIR/iter_nth_zero.rs:30:22 | LL | let _unwrapped = iter2.nth(0).unwrap(); | ^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter2.next()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/iter_on_empty_collections.fixed b/tests/ui/iter_on_empty_collections.fixed index bd9b07aefbfb..81cc7265e11e 100644 --- a/tests/ui/iter_on_empty_collections.fixed +++ b/tests/ui/iter_on_empty_collections.fixed @@ -1,14 +1,14 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_on_empty_collections)] #![allow(clippy::iter_next_slice, clippy::redundant_clone)] fn array() { - assert_eq!(std::iter::empty().next(), Option::::None); - assert_eq!(std::iter::empty().next(), Option::<&mut i32>::None); - assert_eq!(std::iter::empty().next(), Option::<&i32>::None); - assert_eq!(std::iter::empty().next(), Option::::None); - assert_eq!(std::iter::empty().next(), Option::<&mut i32>::None); - assert_eq!(std::iter::empty().next(), Option::<&i32>::None); + assert_eq!([].into_iter().next(), Option::::None); + assert_eq!([].iter_mut().next(), Option::<&mut i32>::None); + assert_eq!([].iter().next(), Option::<&i32>::None); + assert_eq!(None.into_iter().next(), Option::::None); + assert_eq!(None.iter_mut().next(), Option::<&mut i32>::None); + assert_eq!(None.iter().next(), Option::<&i32>::None); // Don't trigger on non-iter methods let _: Option = None.clone(); diff --git a/tests/ui/iter_on_empty_collections.rs b/tests/ui/iter_on_empty_collections.rs index e15ba94bd465..81cc7265e11e 100644 --- a/tests/ui/iter_on_empty_collections.rs +++ b/tests/ui/iter_on_empty_collections.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_on_empty_collections)] #![allow(clippy::iter_next_slice, clippy::redundant_clone)] diff --git a/tests/ui/iter_on_empty_collections.stderr b/tests/ui/iter_on_empty_collections.stderr index cbd611769569..b0622853a6be 100644 --- a/tests/ui/iter_on_empty_collections.stderr +++ b/tests/ui/iter_on_empty_collections.stderr @@ -1,40 +1,44 @@ -error: `into_iter` call on an empty collection +warning: `into_iter` call on an empty collection --> $DIR/iter_on_empty_collections.rs:6:16 | LL | assert_eq!([].into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^ help: try: `std::iter::empty()` | - = note: `-D clippy::iter-on-empty-collections` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_on_empty_collections.rs:2:9 + | +LL | #![warn(clippy::iter_on_empty_collections)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `iter_mut` call on an empty collection +warning: `iter_mut` call on an empty collection --> $DIR/iter_on_empty_collections.rs:7:16 | LL | assert_eq!([].iter_mut().next(), Option::<&mut i32>::None); | ^^^^^^^^^^^^^ help: try: `std::iter::empty()` -error: `iter` call on an empty collection +warning: `iter` call on an empty collection --> $DIR/iter_on_empty_collections.rs:8:16 | LL | assert_eq!([].iter().next(), Option::<&i32>::None); | ^^^^^^^^^ help: try: `std::iter::empty()` -error: `into_iter` call on an empty collection +warning: `into_iter` call on an empty collection --> $DIR/iter_on_empty_collections.rs:9:16 | LL | assert_eq!(None.into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` -error: `iter_mut` call on an empty collection +warning: `iter_mut` call on an empty collection --> $DIR/iter_on_empty_collections.rs:10:16 | LL | assert_eq!(None.iter_mut().next(), Option::<&mut i32>::None); | ^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` -error: `iter` call on an empty collection +warning: `iter` call on an empty collection --> $DIR/iter_on_empty_collections.rs:11:16 | LL | assert_eq!(None.iter().next(), Option::<&i32>::None); | ^^^^^^^^^^^ help: try: `std::iter::empty()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/iter_on_single_items.fixed b/tests/ui/iter_on_single_items.fixed index 1fa4b03641bc..71c8c7a3f94c 100644 --- a/tests/ui/iter_on_single_items.fixed +++ b/tests/ui/iter_on_single_items.fixed @@ -1,14 +1,14 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_on_single_items)] #![allow(clippy::iter_next_slice, clippy::redundant_clone)] fn array() { - assert_eq!(std::iter::once(123).next(), Some(123)); - assert_eq!(std::iter::once(&mut 123).next(), Some(&mut 123)); - assert_eq!(std::iter::once(&123).next(), Some(&123)); - assert_eq!(std::iter::once(123).next(), Some(123)); - assert_eq!(std::iter::once(&mut 123).next(), Some(&mut 123)); - assert_eq!(std::iter::once(&123).next(), Some(&123)); + assert_eq!([123].into_iter().next(), Some(123)); + assert_eq!([123].iter_mut().next(), Some(&mut 123)); + assert_eq!([123].iter().next(), Some(&123)); + assert_eq!(Some(123).into_iter().next(), Some(123)); + assert_eq!(Some(123).iter_mut().next(), Some(&mut 123)); + assert_eq!(Some(123).iter().next(), Some(&123)); // Don't trigger on non-iter methods let _: Option = Some("test".to_string()).clone(); diff --git a/tests/ui/iter_on_single_items.rs b/tests/ui/iter_on_single_items.rs index ea96d8066c56..71c8c7a3f94c 100644 --- a/tests/ui/iter_on_single_items.rs +++ b/tests/ui/iter_on_single_items.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_on_single_items)] #![allow(clippy::iter_next_slice, clippy::redundant_clone)] diff --git a/tests/ui/iter_on_single_items.stderr b/tests/ui/iter_on_single_items.stderr index d6c547116363..9d50f0746072 100644 --- a/tests/ui/iter_on_single_items.stderr +++ b/tests/ui/iter_on_single_items.stderr @@ -1,40 +1,44 @@ -error: `into_iter` call on a collection with only one item +warning: `into_iter` call on a collection with only one item --> $DIR/iter_on_single_items.rs:6:16 | LL | assert_eq!([123].into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` | - = note: `-D clippy::iter-on-single-items` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_on_single_items.rs:2:9 + | +LL | #![warn(clippy::iter_on_single_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `iter_mut` call on a collection with only one item +warning: `iter_mut` call on a collection with only one item --> $DIR/iter_on_single_items.rs:7:16 | LL | assert_eq!([123].iter_mut().next(), Some(&mut 123)); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&mut 123)` -error: `iter` call on a collection with only one item +warning: `iter` call on a collection with only one item --> $DIR/iter_on_single_items.rs:8:16 | LL | assert_eq!([123].iter().next(), Some(&123)); | ^^^^^^^^^^^^ help: try: `std::iter::once(&123)` -error: `into_iter` call on a collection with only one item +warning: `into_iter` call on a collection with only one item --> $DIR/iter_on_single_items.rs:9:16 | LL | assert_eq!(Some(123).into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` -error: `iter_mut` call on a collection with only one item +warning: `iter_mut` call on a collection with only one item --> $DIR/iter_on_single_items.rs:10:16 | LL | assert_eq!(Some(123).iter_mut().next(), Some(&mut 123)); | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&mut 123)` -error: `iter` call on a collection with only one item +warning: `iter` call on a collection with only one item --> $DIR/iter_on_single_items.rs:11:16 | LL | assert_eq!(Some(123).iter().next(), Some(&123)); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&123)` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/iter_overeager_cloned.fixed b/tests/ui/iter_overeager_cloned.fixed index c100705d0178..bf576e9cbfb3 100644 --- a/tests/ui/iter_overeager_cloned.fixed +++ b/tests/ui/iter_overeager_cloned.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_overeager_cloned, clippy::redundant_clone, clippy::filter_next)] #![allow(dead_code, clippy::let_unit_value)] diff --git a/tests/ui/iter_overeager_cloned.rs b/tests/ui/iter_overeager_cloned.rs index 2caa88020662..df42d88eff00 100644 --- a/tests/ui/iter_overeager_cloned.rs +++ b/tests/ui/iter_overeager_cloned.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::iter_overeager_cloned, clippy::redundant_clone, clippy::filter_next)] #![allow(dead_code, clippy::let_unit_value)] diff --git a/tests/ui/iter_overeager_cloned.stderr b/tests/ui/iter_overeager_cloned.stderr index dcae7cecd33e..1548c42a5264 100644 --- a/tests/ui/iter_overeager_cloned.stderr +++ b/tests/ui/iter_overeager_cloned.stderr @@ -1,4 +1,4 @@ -error: unnecessarily eager cloning of iterator items +warning: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:8:29 | LL | let _: Option = vec.iter().cloned().last(); @@ -6,9 +6,13 @@ LL | let _: Option = vec.iter().cloned().last(); | | | help: try this: `.last().cloned()` | - = note: `-D clippy::iter-overeager-cloned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_overeager_cloned.rs:2:9 + | +LL | #![warn(clippy::iter_overeager_cloned, clippy::redundant_clone, clippy::filter_next)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessarily eager cloning of iterator items +warning: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:10:29 | LL | let _: Option = vec.iter().chain(vec.iter()).cloned().next(); @@ -16,7 +20,7 @@ LL | let _: Option = vec.iter().chain(vec.iter()).cloned().next(); | | | help: try this: `.next().cloned()` -error: unneeded cloning of iterator items +warning: unneeded cloning of iterator items --> $DIR/iter_overeager_cloned.rs:12:20 | LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); @@ -24,9 +28,13 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); | | | help: try this: `.count()` | - = note: `-D clippy::redundant-clone` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_overeager_cloned.rs:2:40 + | +LL | #![warn(clippy::iter_overeager_cloned, clippy::redundant_clone, clippy::filter_next)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessarily eager cloning of iterator items +warning: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:14:21 | LL | let _: Vec<_> = vec.iter().cloned().take(2).collect(); @@ -34,7 +42,7 @@ LL | let _: Vec<_> = vec.iter().cloned().take(2).collect(); | | | help: try this: `.take(2).cloned()` -error: unnecessarily eager cloning of iterator items +warning: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:16:21 | LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect(); @@ -42,7 +50,7 @@ LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect(); | | | help: try this: `.skip(2).cloned()` -error: unnecessarily eager cloning of iterator items +warning: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:18:13 | LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); @@ -50,7 +58,7 @@ LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | | | help: try this: `.nth(2).cloned()` -error: unnecessarily eager cloning of iterator items +warning: unnecessarily eager cloning of iterator items --> $DIR/iter_overeager_cloned.rs:20:13 | LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))] @@ -66,5 +74,5 @@ LL ~ .iter() LL ~ .flatten().cloned(); | -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/iter_skip_next.fixed b/tests/ui/iter_skip_next.fixed index d56d623b5268..8f2cefc43043 100644 --- a/tests/ui/iter_skip_next.fixed +++ b/tests/ui/iter_skip_next.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:option_helpers.rs +//@run-rustfix +//@aux-build:option_helpers.rs #![warn(clippy::iter_skip_next)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/iter_skip_next.rs b/tests/ui/iter_skip_next.rs index 3ec5d1b82142..71d83384f3a0 100644 --- a/tests/ui/iter_skip_next.rs +++ b/tests/ui/iter_skip_next.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:option_helpers.rs +//@run-rustfix +//@aux-build:option_helpers.rs #![warn(clippy::iter_skip_next)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/iter_skip_next.stderr b/tests/ui/iter_skip_next.stderr index ca6970b27f16..e2043478bb22 100644 --- a/tests/ui/iter_skip_next.stderr +++ b/tests/ui/iter_skip_next.stderr @@ -1,46 +1,50 @@ -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:16:28 | LL | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` | - = note: `-D clippy::iter-skip-next` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_skip_next.rs:4:9 + | +LL | #![warn(clippy::iter_skip_next)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:17:36 | LL | let _ = some_vec.iter().cycle().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:18:20 | LL | let _ = (1..10).skip(10).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(10)` -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:19:33 | LL | let _ = &some_vec[..].iter().skip(3).next(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(3)` -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:27:26 | LL | let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:29:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next.rs:35:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/iter_skip_next_unfixable.stderr b/tests/ui/iter_skip_next_unfixable.stderr index 4062706f9420..34b791b61564 100644 --- a/tests/ui/iter_skip_next_unfixable.stderr +++ b/tests/ui/iter_skip_next_unfixable.stderr @@ -1,4 +1,4 @@ -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next_unfixable.rs:9:26 | LL | let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect(); @@ -9,9 +9,13 @@ help: for this change `sp` has to be mutable | LL | let sp = test_string.split('|').map(|s| s.trim()); | ^^ - = note: `-D clippy::iter-skip-next` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_skip_next_unfixable.rs:1:9 + | +LL | #![warn(clippy::iter_skip_next)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next_unfixable.rs:11:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); @@ -23,7 +27,7 @@ help: for this change `s` has to be mutable LL | if let Some(s) = Some(test_string.split('|').map(|s| s.trim())) { | ^ -error: called `skip(..).next()` on an iterator +warning: called `skip(..).next()` on an iterator --> $DIR/iter_skip_next_unfixable.rs:17:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); @@ -35,5 +39,5 @@ help: for this change `s` has to be mutable LL | fn check(s: T) | ^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/iter_with_drain.fixed b/tests/ui/iter_with_drain.fixed index 0330d5549264..a118c981ee3f 100644 --- a/tests/ui/iter_with_drain.fixed +++ b/tests/ui/iter_with_drain.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // will emits unused mut warnings after fixing #![allow(unused_mut)] // will emits needless collect warnings after fixing @@ -8,21 +8,21 @@ use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque}; fn full() { let mut a = vec!["aaa".to_string(), "bbb".to_string()]; - let mut a: BinaryHeap<_> = a.into_iter().collect(); + let mut a: BinaryHeap<_> = a.drain(..).collect(); let mut a: HashSet<_> = a.drain().collect(); let mut a: VecDeque<_> = a.drain().collect(); - let mut a: Vec<_> = a.into_iter().collect(); - let mut a: HashMap<_, _> = a.into_iter().map(|x| (x.clone(), x)).collect(); + let mut a: Vec<_> = a.drain(..).collect(); + let mut a: HashMap<_, _> = a.drain(..).map(|x| (x.clone(), x)).collect(); let _: Vec<(String, String)> = a.drain().collect(); } fn closed() { let mut a = vec!["aaa".to_string(), "bbb".to_string()]; - let mut a: BinaryHeap<_> = a.into_iter().collect(); + let mut a: BinaryHeap<_> = a.drain(0..).collect(); let mut a: HashSet<_> = a.drain().collect(); let mut a: VecDeque<_> = a.drain().collect(); - let mut a: Vec<_> = a.into_iter().collect(); - let mut a: HashMap<_, _> = a.into_iter().map(|x| (x.clone(), x)).collect(); + let mut a: Vec<_> = a.drain(..a.len()).collect(); + let mut a: HashMap<_, _> = a.drain(0..a.len()).map(|x| (x.clone(), x)).collect(); let _: Vec<(String, String)> = a.drain().collect(); } diff --git a/tests/ui/iter_with_drain.rs b/tests/ui/iter_with_drain.rs index 993936fb8de3..a118c981ee3f 100644 --- a/tests/ui/iter_with_drain.rs +++ b/tests/ui/iter_with_drain.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // will emits unused mut warnings after fixing #![allow(unused_mut)] // will emits needless collect warnings after fixing diff --git a/tests/ui/iter_with_drain.stderr b/tests/ui/iter_with_drain.stderr index aa394439fa62..684754e4ade2 100644 --- a/tests/ui/iter_with_drain.stderr +++ b/tests/ui/iter_with_drain.stderr @@ -1,40 +1,44 @@ -error: `drain(..)` used on a `Vec` +warning: `drain(..)` used on a `Vec` --> $DIR/iter_with_drain.rs:11:34 | LL | let mut a: BinaryHeap<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try this: `into_iter()` | - = note: `-D clippy::iter-with-drain` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iter_with_drain.rs:6:9 + | +LL | #![warn(clippy::iter_with_drain)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: `drain(..)` used on a `VecDeque` +warning: `drain(..)` used on a `VecDeque` --> $DIR/iter_with_drain.rs:14:27 | LL | let mut a: Vec<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try this: `into_iter()` -error: `drain(..)` used on a `Vec` +warning: `drain(..)` used on a `Vec` --> $DIR/iter_with_drain.rs:15:34 | LL | let mut a: HashMap<_, _> = a.drain(..).map(|x| (x.clone(), x)).collect(); | ^^^^^^^^^ help: try this: `into_iter()` -error: `drain(..)` used on a `Vec` +warning: `drain(..)` used on a `Vec` --> $DIR/iter_with_drain.rs:21:34 | LL | let mut a: BinaryHeap<_> = a.drain(0..).collect(); | ^^^^^^^^^^ help: try this: `into_iter()` -error: `drain(..)` used on a `VecDeque` +warning: `drain(..)` used on a `VecDeque` --> $DIR/iter_with_drain.rs:24:27 | LL | let mut a: Vec<_> = a.drain(..a.len()).collect(); | ^^^^^^^^^^^^^^^^ help: try this: `into_iter()` -error: `drain(..)` used on a `Vec` +warning: `drain(..)` used on a `Vec` --> $DIR/iter_with_drain.rs:25:34 | LL | let mut a: HashMap<_, _> = a.drain(0..a.len()).map(|x| (x.clone(), x)).collect(); | ^^^^^^^^^^^^^^^^^ help: try this: `into_iter()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/iterator_step_by_zero.stderr b/tests/ui/iterator_step_by_zero.stderr index d792aea11dfa..a186e7b50d1f 100644 --- a/tests/ui/iterator_step_by_zero.stderr +++ b/tests/ui/iterator_step_by_zero.stderr @@ -1,46 +1,50 @@ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:3:13 | LL | let _ = vec!["A", "B", "B"].iter().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/iterator_step_by_zero.rs:1:8 + | +LL | #[warn(clippy::iterator_step_by_zero)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:4:13 | LL | let _ = "XXX".chars().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:5:13 | LL | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:14:13 | LL | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:15:13 | LL | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:18:13 | LL | let _ = x.step_by(0); | ^^^^^^^^^^^^ -error: `Iterator::step_by(0)` will panic at runtime +warning: `Iterator::step_by(0)` will panic at runtime --> $DIR/iterator_step_by_zero.rs:22:13 | LL | let _ = v1.iter().step_by(2 / 3); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/large_const_arrays.fixed b/tests/ui/large_const_arrays.fixed index c5af07c8a172..f7ce6fbe6bb4 100644 --- a/tests/ui/large_const_arrays.fixed +++ b/tests/ui/large_const_arrays.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::large_const_arrays)] #![allow(dead_code)] diff --git a/tests/ui/large_const_arrays.rs b/tests/ui/large_const_arrays.rs index a160b9f8ad5b..002ac77ddda9 100644 --- a/tests/ui/large_const_arrays.rs +++ b/tests/ui/large_const_arrays.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::large_const_arrays)] #![allow(dead_code)] diff --git a/tests/ui/large_const_arrays.stderr b/tests/ui/large_const_arrays.stderr index 3fb0acbca67d..98d4af6d199e 100644 --- a/tests/ui/large_const_arrays.stderr +++ b/tests/ui/large_const_arrays.stderr @@ -1,4 +1,4 @@ -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:12:1 | LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; @@ -6,9 +6,13 @@ LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; | | | help: make this a static item: `static` | - = note: `-D clippy::large-const-arrays` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/large_const_arrays.rs:3:9 + | +LL | #![warn(clippy::large_const_arrays)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:13:1 | LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; @@ -16,7 +20,7 @@ LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:14:1 | LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000]; @@ -24,7 +28,7 @@ LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:23:5 | LL | pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; @@ -32,7 +36,7 @@ LL | pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:24:5 | LL | const BAR: [u32; 1_000_000] = [0u32; 1_000_000]; @@ -40,7 +44,7 @@ LL | const BAR: [u32; 1_000_000] = [0u32; 1_000_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:25:5 | LL | pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000]; @@ -48,7 +52,7 @@ LL | pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:26:5 | LL | const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000]; @@ -56,7 +60,7 @@ LL | const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:27:5 | LL | pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000]; @@ -64,7 +68,7 @@ LL | pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000]; | | | help: make this a static item: `static` -error: large array defined as const +warning: large array defined as const --> $DIR/large_const_arrays.rs:28:5 | LL | const BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000]; @@ -72,5 +76,5 @@ LL | const BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000]; | | | help: make this a static item: `static` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/large_digit_groups.fixed b/tests/ui/large_digit_groups.fixed index ea18dac06833..f42fcd96d795 100644 --- a/tests/ui/large_digit_groups.fixed +++ b/tests/ui/large_digit_groups.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::large_digit_groups)] fn main() { diff --git a/tests/ui/large_digit_groups.rs b/tests/ui/large_digit_groups.rs index ac116d5dbda1..3db9da6a3a58 100644 --- a/tests/ui/large_digit_groups.rs +++ b/tests/ui/large_digit_groups.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::large_digit_groups)] fn main() { diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index 19c0fae98a64..032a161b486f 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -1,36 +1,40 @@ -error: digits of hex, binary or octal literal not in groups of equal size +warning: digits of hex, binary or octal literal not in groups of equal size --> $DIR/large_digit_groups.rs:23:9 | LL | 0xd_e_adbee_f_usize, | ^^^^^^^^^^^^^^^^^^^ help: consider: `0xdead_beef_usize` | - = note: `-D clippy::unusual-byte-groupings` implied by `-D warnings` + = note: `#[warn(clippy::unusual_byte_groupings)]` on by default -error: digit groups should be smaller +warning: digit groups should be smaller --> $DIR/large_digit_groups.rs:24:9 | LL | 1_23456_f32, | ^^^^^^^^^^^ help: consider: `123_456_f32` | - = note: `-D clippy::large-digit-groups` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/large_digit_groups.rs:2:9 + | +LL | #![warn(clippy::large_digit_groups)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: digit groups should be smaller +warning: digit groups should be smaller --> $DIR/large_digit_groups.rs:25:9 | LL | 1_23456.12_f32, | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` -error: digit groups should be smaller +warning: digit groups should be smaller --> $DIR/large_digit_groups.rs:26:9 | LL | 1_23456.12345_f64, | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f64` -error: digit groups should be smaller +warning: digit groups should be smaller --> $DIR/large_digit_groups.rs:27:9 | LL | 1_23456.12345_6_f64, | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f64` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/large_enum_variant.rs b/tests/ui/large_enum_variant.rs index 3b96f09d7b1d..68422ea155aa 100644 --- a/tests/ui/large_enum_variant.rs +++ b/tests/ui/large_enum_variant.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 709972b4a6e4..ef36cc20b135 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -1,4 +1,4 @@ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:10:1 | LL | / enum LargeEnum { @@ -9,13 +9,17 @@ LL | | B([i32; 8000]), LL | | } | |_^ the entire enum is at least 32004 bytes | - = note: `-D clippy::large-enum-variant` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/large_enum_variant.rs:5:9 + | +LL | #![warn(clippy::large_enum_variant)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | LL | B(Box<[i32; 8000]>), | ~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:34:1 | LL | / enum LargeEnum2 { @@ -31,7 +35,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | ContainingLargeEnum(Box), | ~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:39:1 | LL | / enum LargeEnum3 { @@ -48,7 +52,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>), | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:45:1 | LL | / enum LargeEnum4 { @@ -64,7 +68,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | StructLikeLarge { x: Box<[i32; 8000]>, y: i32 }, | ~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:50:1 | LL | / enum LargeEnum5 { @@ -80,7 +84,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:66:1 | LL | / enum LargeEnum7 { @@ -97,7 +101,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B(Box<[u8; 1255]>), | ~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:72:1 | LL | / enum LargeEnum8 { @@ -113,7 +117,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]>, [i32; 30]), | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:77:1 | LL | / enum LargeEnum9 { @@ -129,7 +133,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B(Box), | ~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:82:1 | LL | / enum LargeEnumOk2 { @@ -145,7 +149,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B(Box), | ~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:87:1 | LL | / enum LargeEnumOk3 { @@ -161,7 +165,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B(Box), | ~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:102:1 | LL | / enum CopyableLargeEnum { @@ -183,7 +187,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:107:1 | LL | / enum ManuallyCopyLargeEnum { @@ -205,7 +209,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:120:1 | LL | / enum SomeGenericPossiblyCopyEnum { @@ -227,7 +231,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | B([u64; 4000]), | ^^^^^^^^^^^^^^ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:133:1 | LL | / enum LargeEnumWithGenerics { @@ -243,7 +247,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | Large(Box<(T, [u8; 512])>), | ~~~~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:142:1 | LL | / enum WithGenerics { @@ -259,7 +263,7 @@ help: consider boxing the large fields to reduce the total size of the enum LL | Large(Box<[Foo; 64]>), | ~~~~~~~~~~~~~~~~~~~ -error: large size difference between variants +warning: large size difference between variants --> $DIR/large_enum_variant.rs:152:1 | LL | / enum LargeEnumOfConst { @@ -275,5 +279,5 @@ help: consider boxing the large fields to reduce the total size of the enum LL | Error(Box>), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/large_stack_arrays.stderr b/tests/ui/large_stack_arrays.stderr index 24e90094982a..c09a5e20966b 100644 --- a/tests/ui/large_stack_arrays.stderr +++ b/tests/ui/large_stack_arrays.stderr @@ -1,13 +1,17 @@ -error: allocating a local array larger than 512000 bytes +warning: allocating a local array larger than 512000 bytes --> $DIR/large_stack_arrays.rs:23:9 | LL | [0u32; 20_000_000], | ^^^^^^^^^^^^^^^^^^ | = help: consider allocating on the heap with `vec![0u32; 20_000_000].into_boxed_slice()` - = note: `-D clippy::large-stack-arrays` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/large_stack_arrays.rs:1:9 + | +LL | #![warn(clippy::large_stack_arrays)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: allocating a local array larger than 512000 bytes +warning: allocating a local array larger than 512000 bytes --> $DIR/large_stack_arrays.rs:24:9 | LL | [S { data: [0; 32] }; 5000], @@ -15,7 +19,7 @@ LL | [S { data: [0; 32] }; 5000], | = help: consider allocating on the heap with `vec![S { data: [0; 32] }; 5000].into_boxed_slice()` -error: allocating a local array larger than 512000 bytes +warning: allocating a local array larger than 512000 bytes --> $DIR/large_stack_arrays.rs:25:9 | LL | [Some(""); 20_000_000], @@ -23,7 +27,7 @@ LL | [Some(""); 20_000_000], | = help: consider allocating on the heap with `vec![Some(""); 20_000_000].into_boxed_slice()` -error: allocating a local array larger than 512000 bytes +warning: allocating a local array larger than 512000 bytes --> $DIR/large_stack_arrays.rs:26:9 | LL | [E::T(0); 5000], @@ -31,7 +35,7 @@ LL | [E::T(0); 5000], | = help: consider allocating on the heap with `vec![E::T(0); 5000].into_boxed_slice()` -error: allocating a local array larger than 512000 bytes +warning: allocating a local array larger than 512000 bytes --> $DIR/large_stack_arrays.rs:27:9 | LL | [0u8; usize::MAX], @@ -39,5 +43,5 @@ LL | [0u8; usize::MAX], | = help: consider allocating on the heap with `vec![0u8; usize::MAX].into_boxed_slice()` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/large_types_passed_by_value.rs b/tests/ui/large_types_passed_by_value.rs index 7601b5c66fa3..f9e3c7192ad5 100644 --- a/tests/ui/large_types_passed_by_value.rs +++ b/tests/ui/large_types_passed_by_value.rs @@ -1,5 +1,5 @@ -// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)" -// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)" +//@normalize-stderr-test: "\(\d+ byte\)" -> "(N byte)" +//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)" #![warn(clippy::large_types_passed_by_value)] diff --git a/tests/ui/large_types_passed_by_value.stderr b/tests/ui/large_types_passed_by_value.stderr index 5f42dcfb9b52..fb796e290ccb 100644 --- a/tests/ui/large_types_passed_by_value.stderr +++ b/tests/ui/large_types_passed_by_value.stderr @@ -1,52 +1,56 @@ -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:20:11 | LL | fn bad(a: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` | - = note: `-D clippy::large-types-passed-by-value` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/large_types_passed_by_value.rs:4:9 + | +LL | #![warn(clippy::large_types_passed_by_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:25:37 | LL | fn other_is_not_ok(self, other: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:31:36 | LL | fn devoure_array(&self, array: [u8; 6666]); | ^^^^^^^^^^ help: consider passing by reference instead: `&[u8; 6666]` -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:32:34 | LL | fn devoure_tuple(&self, tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider passing by reference instead: `&(LargeAndCopy, LargeAndCopy)` -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:33:50 | LL | fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^ help: consider passing by reference instead: `&[u8; 6666]` -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:33:67 | LL | fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider passing by reference instead: `&(LargeAndCopy, LargeAndCopy)` -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:58:17 | LL | fn foo_never(x: LargeAndCopy) { | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` -error: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) +warning: this argument (N byte) is passed by value, but might be more efficient if passed by reference (limit: N byte) --> $DIR/large_types_passed_by_value.rs:62:11 | LL | fn foo(x: LargeAndCopy) { | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/len_without_is_empty.stderr b/tests/ui/len_without_is_empty.stderr index 8e890e2e2590..1baf8893b9cb 100644 --- a/tests/ui/len_without_is_empty.stderr +++ b/tests/ui/len_without_is_empty.stderr @@ -1,12 +1,16 @@ -error: struct `PubOne` has a public `len` method, but no `is_empty` method +warning: struct `PubOne` has a public `len` method, but no `is_empty` method --> $DIR/len_without_is_empty.rs:7:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::len-without-is-empty` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/len_without_is_empty.rs:1:9 + | +LL | #![warn(clippy::len_without_is_empty)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method +warning: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method --> $DIR/len_without_is_empty.rs:55:1 | LL | / pub trait PubTraitsToo { @@ -14,7 +18,7 @@ LL | | fn len(&self) -> isize; LL | | } | |_^ -error: struct `HasIsEmpty` has a public `len` method, but a private `is_empty` method +warning: struct `HasIsEmpty` has a public `len` method, but a private `is_empty` method --> $DIR/len_without_is_empty.rs:68:5 | LL | pub fn len(&self) -> isize { @@ -26,7 +30,7 @@ note: `is_empty` defined here LL | fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: struct `HasWrongIsEmpty` has a public `len` method, but the `is_empty` method has an unexpected signature +warning: struct `HasWrongIsEmpty` has a public `len` method, but the `is_empty` method has an unexpected signature --> $DIR/len_without_is_empty.rs:80:5 | LL | pub fn len(&self) -> isize { @@ -39,7 +43,7 @@ LL | pub fn is_empty(&self, x: u32) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` -error: struct `MismatchedSelf` has a public `len` method, but the `is_empty` method has an unexpected signature +warning: struct `MismatchedSelf` has a public `len` method, but the `is_empty` method has an unexpected signature --> $DIR/len_without_is_empty.rs:92:5 | LL | pub fn len(self) -> isize { @@ -52,7 +56,7 @@ LL | pub fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(self) -> bool` -error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method +warning: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method --> $DIR/len_without_is_empty.rs:171:1 | LL | / pub trait DependsOnFoo: Foo { @@ -60,7 +64,7 @@ LL | | fn len(&mut self) -> usize; LL | | } | |_^ -error: struct `OptionalLen3` has a public `len` method, but the `is_empty` method has an unexpected signature +warning: struct `OptionalLen3` has a public `len` method, but the `is_empty` method has an unexpected signature --> $DIR/len_without_is_empty.rs:216:5 | LL | pub fn len(&self) -> usize { @@ -73,7 +77,7 @@ LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` -error: struct `ResultLen` has a public `len` method, but the `is_empty` method has an unexpected signature +warning: struct `ResultLen` has a public `len` method, but the `is_empty` method has an unexpected signature --> $DIR/len_without_is_empty.rs:228:5 | LL | pub fn len(&self) -> Result { @@ -86,16 +90,16 @@ LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` or `(&self) -> Result -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/len_without_is_empty.rs:228:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use a custom `Error` type instead - = note: `-D clippy::result-unit-err` implied by `-D warnings` + = note: `#[warn(clippy::result_unit_err)]` on by default -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/len_without_is_empty.rs:240:5 | LL | pub fn len(&self) -> Result { @@ -103,7 +107,7 @@ LL | pub fn len(&self) -> Result { | = help: use a custom `Error` type instead -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/len_without_is_empty.rs:244:5 | LL | pub fn is_empty(&self) -> Result { @@ -111,7 +115,7 @@ LL | pub fn is_empty(&self) -> Result { | = help: use a custom `Error` type instead -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/len_without_is_empty.rs:251:5 | LL | pub fn len(&self) -> Result { @@ -119,5 +123,5 @@ LL | pub fn len(&self) -> Result { | = help: use a custom `Error` type instead -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/len_zero.fixed b/tests/ui/len_zero.fixed index c1c0b5ae40f6..34b2021df45f 100644 --- a/tests/ui/len_zero.fixed +++ b/tests/ui/len_zero.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::len_zero)] #![allow(dead_code, unused, clippy::len_without_is_empty)] diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index cc2eb05b6bfd..c83ae2ac5538 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::len_zero)] #![allow(dead_code, unused, clippy::len_without_is_empty)] diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index b6f13780253c..96cc2529e8aa 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,132 +1,136 @@ -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:84:8 | LL | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` | - = note: `-D clippy::len-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/len_zero.rs:3:9 + | +LL | #![warn(clippy::len_zero)] + | ^^^^^^^^^^^^^^^^ -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:88:8 | LL | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:97:20 | LL | println!("{}", *s1 == ""); | ^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s1.is_empty()` | - = note: `-D clippy::comparison-to-empty` implied by `-D warnings` + = note: `#[warn(clippy::comparison_to_empty)]` on by default -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:98:20 | LL | println!("{}", **s2 == ""); | ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s2.is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:99:20 | LL | println!("{}", ***s3 == ""); | ^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s3.is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:100:20 | LL | println!("{}", ****s4 == ""); | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s4.is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:101:20 | LL | println!("{}", *****s5 == ""); | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s5.is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:102:20 | LL | println!("{}", ******(s6) == ""); | ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(s6).is_empty()` -error: comparison to empty slice +warning: comparison to empty slice --> $DIR/len_zero.rs:105:20 | LL | println!("{}", &**d2s == ""); | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(**d2s).is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:120:8 | LL | if has_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:123:8 | LL | if has_is_empty.len() != 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:126:8 | LL | if has_is_empty.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to one +warning: length comparison to one --> $DIR/len_zero.rs:129:8 | LL | if has_is_empty.len() < 1 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` -error: length comparison to one +warning: length comparison to one --> $DIR/len_zero.rs:132:8 | LL | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:143:8 | LL | if 0 == has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:146:8 | LL | if 0 != has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:149:8 | LL | if 0 < has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to one +warning: length comparison to one --> $DIR/len_zero.rs:152:8 | LL | if 1 <= has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` -error: length comparison to one +warning: length comparison to one --> $DIR/len_zero.rs:155:8 | LL | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:169:8 | LL | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero.rs:182:8 | LL | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!b.is_empty()` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/len_zero_ranges.fixed b/tests/ui/len_zero_ranges.fixed index 797817662427..4b1241ec86b4 100644 --- a/tests/ui/len_zero_ranges.fixed +++ b/tests/ui/len_zero_ranges.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::len_zero)] #![allow(unused)] diff --git a/tests/ui/len_zero_ranges.rs b/tests/ui/len_zero_ranges.rs index a0eb51cc9760..4b47132c7661 100644 --- a/tests/ui/len_zero_ranges.rs +++ b/tests/ui/len_zero_ranges.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::len_zero)] #![allow(unused)] diff --git a/tests/ui/len_zero_ranges.stderr b/tests/ui/len_zero_ranges.stderr index d0defb5a79ed..0d8aedfff181 100644 --- a/tests/ui/len_zero_ranges.stderr +++ b/tests/ui/len_zero_ranges.stderr @@ -1,16 +1,20 @@ -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero_ranges.rs:9:17 | LL | let _ = (0..42).len() == 0; | ^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0..42).is_empty()` | - = note: `-D clippy::len-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/len_zero_ranges.rs:3:9 + | +LL | #![warn(clippy::len_zero)] + | ^^^^^^^^^^^^^^^^ -error: length comparison to zero +warning: length comparison to zero --> $DIR/len_zero_ranges.rs:13:17 | LL | let _ = (0_u8..=42).len() == 0; | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0_u8..=42).is_empty()` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/let_and_return.stderr b/tests/ui/let_and_return.stderr index 17fd694bf7ac..c1c312b54548 100644 --- a/tests/ui/let_and_return.stderr +++ b/tests/ui/let_and_return.stderr @@ -1,4 +1,4 @@ -error: returning the result of a `let` binding from a block +warning: returning the result of a `let` binding from a block --> $DIR/let_and_return.rs:7:5 | LL | let x = 5; @@ -6,14 +6,18 @@ LL | let x = 5; LL | x | ^ | - = note: `-D clippy::let-and-return` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/let_and_return.rs:2:9 + | +LL | #![warn(clippy::let_and_return)] + | ^^^^^^^^^^^^^^^^^^^^^^ help: return the expression directly | LL ~ LL ~ 5 | -error: returning the result of a `let` binding from a block +warning: returning the result of a `let` binding from a block --> $DIR/let_and_return.rs:13:9 | LL | let x = 5; @@ -27,7 +31,7 @@ LL ~ LL ~ 5 | -error: returning the result of a `let` binding from a block +warning: returning the result of a `let` binding from a block --> $DIR/let_and_return.rs:164:13 | LL | let clone = Arc::clone(&self.foo); @@ -41,5 +45,5 @@ LL ~ LL ~ Arc::clone(&self.foo) as _ | -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index f2e0edb6fbc3..0e95f0509400 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,4 +1,4 @@ -error: `if _ { .. } else { .. }` is an expression +warning: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:66:5 | LL | / let mut foo = 0; @@ -8,9 +8,13 @@ LL | | } | |_____^ help: it is more idiomatic to write: `let foo = if f() { 42 } else { 0 };` | = note: you might not need `mut` at all - = note: `-D clippy::useless-let-if-seq` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/let_if_seq.rs:9:9 + | +LL | #![warn(clippy::useless_let_if_seq)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `if _ { .. } else { .. }` is an expression +warning: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:71:5 | LL | / let mut bar = 0; @@ -24,7 +28,7 @@ LL | | } | = note: you might not need `mut` at all -error: `if _ { .. } else { .. }` is an expression +warning: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:79:5 | LL | / let quz; @@ -35,7 +39,7 @@ LL | | quz = 0; LL | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` -error: `if _ { .. } else { .. }` is an expression +warning: `if _ { .. } else { .. }` is an expression --> $DIR/let_if_seq.rs:108:5 | LL | / let mut baz = 0; @@ -46,5 +50,5 @@ LL | | } | = note: you might not need `mut` at all -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/let_underscore_future.stderr b/tests/ui/let_underscore_future.stderr index 33a748736a88..0291cc08e446 100644 --- a/tests/ui/let_underscore_future.stderr +++ b/tests/ui/let_underscore_future.stderr @@ -1,13 +1,13 @@ -error: non-binding `let` on a future +warning: non-binding `let` on a future --> $DIR/let_underscore_future.rs:14:5 | LL | let _ = some_async_fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider awaiting the future or dropping explicitly with `std::mem::drop` - = note: `-D clippy::let-underscore-future` implied by `-D warnings` + = note: `#[warn(clippy::let_underscore_future)]` on by default -error: non-binding `let` on a future +warning: non-binding `let` on a future --> $DIR/let_underscore_future.rs:15:5 | LL | let _ = custom(); @@ -15,7 +15,7 @@ LL | let _ = custom(); | = help: consider awaiting the future or dropping explicitly with `std::mem::drop` -error: non-binding `let` on a future +warning: non-binding `let` on a future --> $DIR/let_underscore_future.rs:19:5 | LL | let _ = future; @@ -23,5 +23,5 @@ LL | let _ = future; | = help: consider awaiting the future or dropping explicitly with `std::mem::drop` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/let_underscore_lock.stderr b/tests/ui/let_underscore_lock.stderr index f137d4112092..3909a9e606c6 100644 --- a/tests/ui/let_underscore_lock.stderr +++ b/tests/ui/let_underscore_lock.stderr @@ -1,13 +1,17 @@ -error: non-binding `let` on a synchronization lock +warning: non-binding `let` on a synchronization lock --> $DIR/let_underscore_lock.rs:9:5 | LL | let _ = p_m.lock(); | ^^^^^^^^^^^^^^^^^^^ | = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` - = note: `-D clippy::let-underscore-lock` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/let_underscore_lock.rs:1:9 + | +LL | #![warn(clippy::let_underscore_lock)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: non-binding `let` on a synchronization lock +warning: non-binding `let` on a synchronization lock --> $DIR/let_underscore_lock.rs:12:5 | LL | let _ = p_m1.lock(); @@ -15,7 +19,7 @@ LL | let _ = p_m1.lock(); | = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` -error: non-binding `let` on a synchronization lock +warning: non-binding `let` on a synchronization lock --> $DIR/let_underscore_lock.rs:15:5 | LL | let _ = p_rw.read(); @@ -23,7 +27,7 @@ LL | let _ = p_rw.read(); | = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` -error: non-binding `let` on a synchronization lock +warning: non-binding `let` on a synchronization lock --> $DIR/let_underscore_lock.rs:16:5 | LL | let _ = p_rw.write(); @@ -31,5 +35,5 @@ LL | let _ = p_rw.write(); | = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/let_underscore_must_use.stderr b/tests/ui/let_underscore_must_use.stderr index 28d760eb46ec..2a73b2761c3e 100644 --- a/tests/ui/let_underscore_must_use.stderr +++ b/tests/ui/let_underscore_must_use.stderr @@ -1,13 +1,17 @@ -error: non-binding `let` on a result of a `#[must_use]` function +warning: non-binding `let` on a result of a `#[must_use]` function --> $DIR/let_underscore_must_use.rs:67:5 | LL | let _ = f(); | ^^^^^^^^^^^^ | = help: consider explicitly using function result - = note: `-D clippy::let-underscore-must-use` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/let_underscore_must_use.rs:1:9 + | +LL | #![warn(clippy::let_underscore_must_use)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: non-binding `let` on an expression with `#[must_use]` type +warning: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:68:5 | LL | let _ = g(); @@ -15,7 +19,7 @@ LL | let _ = g(); | = help: consider explicitly using expression value -error: non-binding `let` on a result of a `#[must_use]` function +warning: non-binding `let` on a result of a `#[must_use]` function --> $DIR/let_underscore_must_use.rs:70:5 | LL | let _ = l(0_u32); @@ -23,7 +27,7 @@ LL | let _ = l(0_u32); | = help: consider explicitly using function result -error: non-binding `let` on a result of a `#[must_use]` function +warning: non-binding `let` on a result of a `#[must_use]` function --> $DIR/let_underscore_must_use.rs:74:5 | LL | let _ = s.f(); @@ -31,7 +35,7 @@ LL | let _ = s.f(); | = help: consider explicitly using function result -error: non-binding `let` on an expression with `#[must_use]` type +warning: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:75:5 | LL | let _ = s.g(); @@ -39,7 +43,7 @@ LL | let _ = s.g(); | = help: consider explicitly using expression value -error: non-binding `let` on a result of a `#[must_use]` function +warning: non-binding `let` on a result of a `#[must_use]` function --> $DIR/let_underscore_must_use.rs:78:5 | LL | let _ = S::h(); @@ -47,7 +51,7 @@ LL | let _ = S::h(); | = help: consider explicitly using function result -error: non-binding `let` on an expression with `#[must_use]` type +warning: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:79:5 | LL | let _ = S::p(); @@ -55,7 +59,7 @@ LL | let _ = S::p(); | = help: consider explicitly using expression value -error: non-binding `let` on a result of a `#[must_use]` function +warning: non-binding `let` on a result of a `#[must_use]` function --> $DIR/let_underscore_must_use.rs:81:5 | LL | let _ = S::a(); @@ -63,7 +67,7 @@ LL | let _ = S::a(); | = help: consider explicitly using function result -error: non-binding `let` on an expression with `#[must_use]` type +warning: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:83:5 | LL | let _ = if true { Ok(()) } else { Err(()) }; @@ -71,7 +75,7 @@ LL | let _ = if true { Ok(()) } else { Err(()) }; | = help: consider explicitly using expression value -error: non-binding `let` on a result of a `#[must_use]` function +warning: non-binding `let` on a result of a `#[must_use]` function --> $DIR/let_underscore_must_use.rs:87:5 | LL | let _ = a.is_ok(); @@ -79,7 +83,7 @@ LL | let _ = a.is_ok(); | = help: consider explicitly using function result -error: non-binding `let` on an expression with `#[must_use]` type +warning: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:89:5 | LL | let _ = a.map(|_| ()); @@ -87,7 +91,7 @@ LL | let _ = a.map(|_| ()); | = help: consider explicitly using expression value -error: non-binding `let` on an expression with `#[must_use]` type +warning: non-binding `let` on an expression with `#[must_use]` type --> $DIR/let_underscore_must_use.rs:91:5 | LL | let _ = a; @@ -95,5 +99,5 @@ LL | let _ = a; | = help: consider explicitly using expression value -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/let_underscore_untyped.stderr b/tests/ui/let_underscore_untyped.stderr index 36c3d1214d6b..90c41bcbc7ca 100644 --- a/tests/ui/let_underscore_untyped.stderr +++ b/tests/ui/let_underscore_untyped.stderr @@ -1,13 +1,17 @@ -error: non-binding `let` without a type annotation +warning: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:32:5 | LL | let _ = a(); | ^^^^^^^^^^^^ | = help: consider adding a type annotation or removing the `let` keyword - = note: `-D clippy::let-underscore-untyped` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/let_underscore_untyped.rs:2:9 + | +LL | #![warn(clippy::let_underscore_untyped)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: non-binding `let` without a type annotation +warning: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:33:5 | LL | let _ = b(1); @@ -15,7 +19,7 @@ LL | let _ = b(1); | = help: consider adding a type annotation or removing the `let` keyword -error: non-binding `let` without a type annotation +warning: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:34:5 | LL | let _ = c(); @@ -23,7 +27,7 @@ LL | let _ = c(); | = help: consider adding a type annotation or removing the `let` keyword -error: non-binding `let` without a type annotation +warning: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:35:5 | LL | let _ = d(&1); @@ -31,7 +35,7 @@ LL | let _ = d(&1); | = help: consider adding a type annotation or removing the `let` keyword -error: non-binding `let` without a type annotation +warning: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:36:5 | LL | let _ = e(); @@ -39,7 +43,7 @@ LL | let _ = e(); | = help: consider adding a type annotation or removing the `let` keyword -error: non-binding `let` without a type annotation +warning: non-binding `let` without a type annotation --> $DIR/let_underscore_untyped.rs:37:5 | LL | let _ = f(); @@ -47,5 +51,5 @@ LL | let _ = f(); | = help: consider adding a type annotation or removing the `let` keyword -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/let_unit.fixed b/tests/ui/let_unit.fixed index 6343cff0f7ff..5b2f6abac292 100644 --- a/tests/ui/let_unit.fixed +++ b/tests/ui/let_unit.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![warn(clippy::let_unit_value)] @@ -77,10 +77,10 @@ fn _returns_generic() { } let _: () = f(); // Ok - let _: () = f(); // Lint. + let x: () = f(); // Lint. let _: () = f2(0i32); // Ok - let _: () = f2(0i32); // Lint. + let x: () = f2(0i32); // Lint. f3(()); // Lint f3(()); // Lint @@ -99,7 +99,7 @@ fn _returns_generic() { }; let _: () = if true { f() } else { f2(0) }; // Ok - let _: () = if true { f() } else { f2(0) }; // Lint + let x: () = if true { f() } else { f2(0) }; // Lint // Ok let _: () = match Some(0) { diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index c9bb2849f5cf..b0a2bbbe3bf2 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![warn(clippy::let_unit_value)] diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index 49da74ca7e1c..3664b6126cf7 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,18 +1,22 @@ -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:14:5 | LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `println!("x");` | - = note: `-D clippy::let-unit-value` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/let_unit.rs:4:9 + | +LL | #![warn(clippy::let_unit_value)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:18:9 | LL | let _a = (); | ^^^^^^^^^^^^ help: omit the `let` binding: `();` -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:53:5 | LL | / let _ = v @@ -35,7 +39,7 @@ LL + .next() LL + .unwrap(); | -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:80:5 | LL | let x: () = f(); // Lint. @@ -43,7 +47,7 @@ LL | let x: () = f(); // Lint. | | | help: use a wild (`_`) binding: `_` -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:83:5 | LL | let x: () = f2(0i32); // Lint. @@ -51,19 +55,19 @@ LL | let x: () = f2(0i32); // Lint. | | | help: use a wild (`_`) binding: `_` -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:85:5 | LL | let _: () = f3(()); // Lint | ^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `f3(());` -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:86:5 | LL | let x: () = f3(()); // Lint | ^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `f3(());` -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:102:5 | LL | let x: () = if true { f() } else { f2(0) }; // Lint @@ -71,7 +75,7 @@ LL | let x: () = if true { f() } else { f2(0) }; // Lint | | | help: use a wild (`_`) binding: `_` -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:113:5 | LL | / let _: () = match Some(0) { @@ -92,11 +96,17 @@ LL + Some(_) => (), LL + }; | -error: this let-binding has unit value +warning: this let-binding has unit value --> $DIR/let_unit.rs:160:13 | LL | let _: () = z; | ^^^^^^^^^^^^^^ help: omit the `let` binding: `z;` + | +note: the lint level is defined here + --> $DIR/let_unit.rs:156:16 + | +LL | #[warn(clippy::let_unit_value)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/linkedlist.stderr b/tests/ui/linkedlist.stderr index c76c94961312..2aad594a610d 100644 --- a/tests/ui/linkedlist.stderr +++ b/tests/ui/linkedlist.stderr @@ -1,13 +1,17 @@ -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:8:10 | LL | const C: LinkedList = LinkedList::new(); | ^^^^^^^^^^^^^^^ | = help: a `VecDeque` might work - = note: `-D clippy::linkedlist` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/linkedlist.rs:2:9 + | +LL | #![warn(clippy::linkedlist)] + | ^^^^^^^^^^^^^^^^^^ -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:9:11 | LL | static S: LinkedList = LinkedList::new(); @@ -15,7 +19,7 @@ LL | static S: LinkedList = LinkedList::new(); | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:12:16 | LL | type Baz = LinkedList; @@ -23,7 +27,7 @@ LL | type Baz = LinkedList; | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:13:15 | LL | fn foo(_: LinkedList); @@ -31,7 +35,7 @@ LL | fn foo(_: LinkedList); | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:14:23 | LL | const BAR: Option>; @@ -39,7 +43,7 @@ LL | const BAR: Option>; | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:24:29 | LL | priv_linked_list_field: LinkedList, @@ -47,7 +51,7 @@ LL | priv_linked_list_field: LinkedList, | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:28:15 | LL | fn foo(_: LinkedList) {} @@ -55,7 +59,7 @@ LL | fn foo(_: LinkedList) {} | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:33:34 | LL | fn test(my_favorite_linked_list: LinkedList) {} @@ -63,7 +67,7 @@ LL | fn test(my_favorite_linked_list: LinkedList) {} | = help: a `VecDeque` might work -error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? +warning: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? --> $DIR/linkedlist.rs:34:25 | LL | fn test_ret() -> Option> { @@ -71,5 +75,5 @@ LL | fn test_ret() -> Option> { | = help: a `VecDeque` might work -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index 9bc7948c7cc1..15441ed62311 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -1,70 +1,86 @@ -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:12:15 | LL | let ok4 = 0xab_cd_i32; | ^^^^^^^^^^^ help: remove the underscore: `0xab_cdi32` | - = note: `-D clippy::separated-literal-suffix` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/literals.rs:6:9 + | +LL | #![warn(clippy::separated_literal_suffix)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:13:15 | LL | let ok5 = 0xAB_CD_u32; | ^^^^^^^^^^^ help: remove the underscore: `0xAB_CDu32` -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:14:15 | LL | let ok5 = 0xAB_CD_isize; | ^^^^^^^^^^^^^ help: remove the underscore: `0xAB_CDisize` -error: inconsistent casing in hexadecimal literal +warning: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:15:17 | LL | let fail1 = 0xabCD; | ^^^^^^ | - = note: `-D clippy::mixed-case-hex-literals` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/literals.rs:3:9 + | +LL | #![warn(clippy::mixed_case_hex_literals)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:16:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ help: remove the underscore: `0xabCDu32` -error: inconsistent casing in hexadecimal literal +warning: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:16:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:17:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ help: remove the underscore: `0xabCDisize` -error: inconsistent casing in hexadecimal literal +warning: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:17:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/literals.rs:18:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ help: add an underscore: `000_123_usize` | - = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/literals.rs:5:9 + | +LL | #![warn(clippy::unseparated_literal_suffix)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this is a decimal constant +warning: this is a decimal constant --> $DIR/literals.rs:18:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ | - = note: `-D clippy::zero-prefixed-literal` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/literals.rs:4:9 + | +LL | #![warn(clippy::zero_prefixed_literal)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you mean to use a decimal constant, remove the `0` to avoid confusion | LL | let fail_multi_zero = 123usize; @@ -74,13 +90,13 @@ help: if you mean to use an octal constant, use `0o` LL | let fail_multi_zero = 0o123usize; | ~~~~~~~~~~ -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:21:16 | LL | let ok10 = 0_i64; | ^^^^^ help: remove the underscore: `0i64` -error: this is a decimal constant +warning: this is a decimal constant --> $DIR/literals.rs:22:17 | LL | let fail8 = 0123; @@ -95,41 +111,41 @@ help: if you mean to use an octal constant, use `0o` LL | let fail8 = 0o123; | ~~~~~ -error: integer type suffix should not be separated by an underscore +warning: integer type suffix should not be separated by an underscore --> $DIR/literals.rs:31:16 | LL | let ok17 = 0x123_4567_8901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: remove the underscore: `0x123_4567_8901usize` -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/literals.rs:34:18 | LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` | - = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` + = note: `#[warn(clippy::inconsistent_digit_grouping)]` on by default -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/literals.rs:35:18 | LL | let fail22 = 3__4___23; | ^^^^^^^^^ help: consider: `3_423` -error: digits grouped inconsistently by underscores +warning: digits grouped inconsistently by underscores --> $DIR/literals.rs:36:18 | LL | let fail23 = 3__16___23; | ^^^^^^^^^^ help: consider: `31_623` -error: digits of hex, binary or octal literal not in groups of equal size +warning: digits of hex, binary or octal literal not in groups of equal size --> $DIR/literals.rs:38:18 | LL | let fail24 = 0xAB_ABC_AB; | ^^^^^^^^^^^ help: consider: `0x0ABA_BCAB` | - = note: `-D clippy::unusual-byte-groupings` implied by `-D warnings` + = note: `#[warn(clippy::unusual_byte_groupings)]` on by default -error: this is a decimal constant +warning: this is a decimal constant --> $DIR/literals.rs:46:13 | LL | let _ = 08; @@ -140,7 +156,7 @@ help: if you mean to use a decimal constant, remove the `0` to avoid confusion LL | let _ = 8; | ~ -error: this is a decimal constant +warning: this is a decimal constant --> $DIR/literals.rs:47:13 | LL | let _ = 09; @@ -151,7 +167,7 @@ help: if you mean to use a decimal constant, remove the `0` to avoid confusion LL | let _ = 9; | ~ -error: this is a decimal constant +warning: this is a decimal constant --> $DIR/literals.rs:48:13 | LL | let _ = 089; @@ -162,5 +178,5 @@ help: if you mean to use a decimal constant, remove the `0` to avoid confusion LL | let _ = 89; | ~~ -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/lossy_float_literal.fixed b/tests/ui/lossy_float_literal.fixed index 24e372354fc0..a20885756103 100644 --- a/tests/ui/lossy_float_literal.fixed +++ b/tests/ui/lossy_float_literal.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::lossy_float_literal)] fn main() { diff --git a/tests/ui/lossy_float_literal.rs b/tests/ui/lossy_float_literal.rs index 3dcf98fa0bdd..1a75f214c856 100644 --- a/tests/ui/lossy_float_literal.rs +++ b/tests/ui/lossy_float_literal.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::lossy_float_literal)] fn main() { diff --git a/tests/ui/lossy_float_literal.stderr b/tests/ui/lossy_float_literal.stderr index d2193c0c8195..e6b49abfd8c8 100644 --- a/tests/ui/lossy_float_literal.stderr +++ b/tests/ui/lossy_float_literal.stderr @@ -1,70 +1,74 @@ -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:6:18 | LL | let _: f32 = 16_777_217.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_216.0` | - = note: `-D clippy::lossy-float-literal` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/lossy_float_literal.rs:2:9 + | +LL | #![warn(clippy::lossy_float_literal)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:7:18 | LL | let _: f32 = 16_777_219.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:8:18 | LL | let _: f32 = 16_777_219.; | ^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:9:18 | LL | let _: f32 = 16_777_219.000; | ^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:10:13 | LL | let _ = 16_777_219f32; | ^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220_f32` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:11:19 | LL | let _: f32 = -16_777_219.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:12:18 | LL | let _: f64 = 9_007_199_254_740_993.0; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:13:18 | LL | let _: f64 = 9_007_199_254_740_993.; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:14:18 | LL | let _: f64 = 9_007_199_254_740_993.00; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:15:13 | LL | let _ = 9_007_199_254_740_993f64; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992_f64` -error: literal cannot be represented as the underlying type without loss of precision +warning: literal cannot be represented as the underlying type without loss of precision --> $DIR/lossy_float_literal.rs:16:19 | LL | let _: f64 = -9_007_199_254_740_993.0; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/macro_use_imports.fixed b/tests/ui/macro_use_imports.fixed index e612480d264b..77a94efa771d 100644 --- a/tests/ui/macro_use_imports.fixed +++ b/tests/ui/macro_use_imports.fixed @@ -1,8 +1,8 @@ -// aux-build:macro_rules.rs -// aux-build:macro_use_helper.rs -// aux-build:proc_macro_derive.rs -// run-rustfix -// ignore-32bit +//@aux-build:macro_rules.rs +//@aux-build:macro_use_helper.rs +//@aux-build:proc_macro_derive.rs:proc-macro +//@run-rustfix +//@ignore-32bit #![feature(lint_reasons)] #![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)] @@ -16,13 +16,13 @@ extern crate macro_use_helper as mac; extern crate proc_macro_derive as mini_mac; mod a { - use mac::{pub_macro, function_macro, ty_macro, inner_mod_macro, pub_in_private_macro}; + #[macro_use] use mac; - use mini_mac::ClippyMiniMacroTest; + #[macro_use] use mini_mac; - use mac::{inner::foofoo, inner::try_err}; + #[macro_use] use mac::inner; - use mac::inner::nested::string_add; + #[macro_use] use mac::inner::nested; #[derive(ClippyMiniMacroTest)] diff --git a/tests/ui/macro_use_imports.rs b/tests/ui/macro_use_imports.rs index b34817cc3b26..77a94efa771d 100644 --- a/tests/ui/macro_use_imports.rs +++ b/tests/ui/macro_use_imports.rs @@ -1,8 +1,8 @@ -// aux-build:macro_rules.rs -// aux-build:macro_use_helper.rs -// aux-build:proc_macro_derive.rs -// run-rustfix -// ignore-32bit +//@aux-build:macro_rules.rs +//@aux-build:macro_use_helper.rs +//@aux-build:proc_macro_derive.rs:proc-macro +//@run-rustfix +//@ignore-32bit #![feature(lint_reasons)] #![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)] diff --git a/tests/ui/macro_use_imports.stderr b/tests/ui/macro_use_imports.stderr index 61843124ccd9..ca35fbeb3e31 100644 --- a/tests/ui/macro_use_imports.stderr +++ b/tests/ui/macro_use_imports.stderr @@ -1,28 +1,20 @@ -error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:25:5 - | -LL | #[macro_use] - | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` - | - = note: `-D clippy::macro-use-imports` implied by `-D warnings` - -error: `macro_use` attributes are no longer needed in the Rust 2018 edition +warning: `macro_use` attributes are no longer needed in the Rust 2018 edition --> $DIR/macro_use_imports.rs:21:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;` - -error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:23:5 | -LL | #[macro_use] - | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};` +note: the lint level is defined here + --> $DIR/macro_use_imports.rs:10:9 + | +LL | #![warn(clippy::macro_use_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `macro_use` attributes are no longer needed in the Rust 2018 edition +warning: `macro_use` attributes are no longer needed in the Rust 2018 edition --> $DIR/macro_use_imports.rs:19:5 | LL | #[macro_use] - | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, function_macro, ty_macro, inner_mod_macro, pub_in_private_macro};` + | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, function_macro, ty_macro, foofoo, try_err, string_add, inner_mod_macro, pub_in_private_macro};` -error: aborting due to 4 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/macro_use_imports_expect.rs b/tests/ui/macro_use_imports_expect.rs index 8a1b05da9efc..92dc575dd195 100644 --- a/tests/ui/macro_use_imports_expect.rs +++ b/tests/ui/macro_use_imports_expect.rs @@ -1,7 +1,7 @@ -// aux-build:macro_rules.rs -// aux-build:macro_use_helper.rs -// aux-build:proc_macro_derive.rs -// ignore-32bit +//@aux-build:macro_rules.rs +//@aux-build:macro_use_helper.rs +//@aux-build:proc_macro_derive.rs:proc-macro +//@ignore-32bit #![feature(lint_reasons)] #![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)] diff --git a/tests/ui/macro_use_imports_expect.stderr b/tests/ui/macro_use_imports_expect.stderr new file mode 100644 index 000000000000..21e50e7fbfdb --- /dev/null +++ b/tests/ui/macro_use_imports_expect.stderr @@ -0,0 +1,16 @@ +warning: this lint expectation is unfulfilled + --> $DIR/macro_use_imports_expect.rs:24:14 + | +LL | #[expect(clippy::macro_use_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unfulfilled_lint_expectations)]` on by default + +warning: this lint expectation is unfulfilled + --> $DIR/macro_use_imports_expect.rs:27:14 + | +LL | #[expect(clippy::macro_use_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 2 warnings emitted + diff --git a/tests/ui/manual_assert.edition2018.fixed b/tests/ui/manual_assert.edition2018.fixed index 8c7e919bf62a..ab9b375dc03d 100644 --- a/tests/ui/manual_assert.edition2018.fixed +++ b/tests/ui/manual_assert.edition2018.fixed @@ -1,7 +1,7 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix #![warn(clippy::manual_assert)] #![allow(dead_code, unused_doc_comments)] diff --git a/tests/ui/manual_assert.edition2018.stderr b/tests/ui/manual_assert.edition2018.stderr index 3555ac29243a..76e707070105 100644 --- a/tests/ui/manual_assert.edition2018.stderr +++ b/tests/ui/manual_assert.edition2018.stderr @@ -1,4 +1,4 @@ -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:31:5 | LL | / if !a.is_empty() { @@ -6,9 +6,13 @@ LL | | panic!("qaqaq{:?}", a); LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qaqaq{:?}", a);` | - = note: `-D clippy::manual-assert` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_assert.rs:6:9 + | +LL | #![warn(clippy::manual_assert)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:34:5 | LL | / if !a.is_empty() { @@ -16,7 +20,7 @@ LL | | panic!("qwqwq"); LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:51:5 | LL | / if b.is_empty() { @@ -24,7 +28,7 @@ LL | | panic!("panic1"); LL | | } | |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:54:5 | LL | / if b.is_empty() && a.is_empty() { @@ -32,7 +36,7 @@ LL | | panic!("panic2"); LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:57:5 | LL | / if a.is_empty() && !b.is_empty() { @@ -40,7 +44,7 @@ LL | | panic!("panic3"); LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:60:5 | LL | / if b.is_empty() || a.is_empty() { @@ -48,7 +52,7 @@ LL | | panic!("panic4"); LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:63:5 | LL | / if a.is_empty() || !b.is_empty() { @@ -56,7 +60,7 @@ LL | | panic!("panic5"); LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:66:5 | LL | / if a.is_empty() { @@ -64,7 +68,7 @@ LL | | panic!("with expansion {}", one!()) LL | | } | |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:78:5 | LL | / if a > 2 { @@ -81,5 +85,5 @@ help: try instead LL | assert!(!(a > 2), "panic with comment"); | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/manual_assert.edition2021.fixed b/tests/ui/manual_assert.edition2021.fixed index 8c7e919bf62a..ab9b375dc03d 100644 --- a/tests/ui/manual_assert.edition2021.fixed +++ b/tests/ui/manual_assert.edition2021.fixed @@ -1,7 +1,7 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix #![warn(clippy::manual_assert)] #![allow(dead_code, unused_doc_comments)] diff --git a/tests/ui/manual_assert.edition2021.stderr b/tests/ui/manual_assert.edition2021.stderr index 3555ac29243a..76e707070105 100644 --- a/tests/ui/manual_assert.edition2021.stderr +++ b/tests/ui/manual_assert.edition2021.stderr @@ -1,4 +1,4 @@ -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:31:5 | LL | / if !a.is_empty() { @@ -6,9 +6,13 @@ LL | | panic!("qaqaq{:?}", a); LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qaqaq{:?}", a);` | - = note: `-D clippy::manual-assert` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_assert.rs:6:9 + | +LL | #![warn(clippy::manual_assert)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:34:5 | LL | / if !a.is_empty() { @@ -16,7 +20,7 @@ LL | | panic!("qwqwq"); LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:51:5 | LL | / if b.is_empty() { @@ -24,7 +28,7 @@ LL | | panic!("panic1"); LL | | } | |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:54:5 | LL | / if b.is_empty() && a.is_empty() { @@ -32,7 +36,7 @@ LL | | panic!("panic2"); LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:57:5 | LL | / if a.is_empty() && !b.is_empty() { @@ -40,7 +44,7 @@ LL | | panic!("panic3"); LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:60:5 | LL | / if b.is_empty() || a.is_empty() { @@ -48,7 +52,7 @@ LL | | panic!("panic4"); LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:63:5 | LL | / if a.is_empty() || !b.is_empty() { @@ -56,7 +60,7 @@ LL | | panic!("panic5"); LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:66:5 | LL | / if a.is_empty() { @@ -64,7 +68,7 @@ LL | | panic!("with expansion {}", one!()) LL | | } | |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());` -error: only a `panic!` in `if`-then statement +warning: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:78:5 | LL | / if a > 2 { @@ -81,5 +85,5 @@ help: try instead LL | assert!(!(a > 2), "panic with comment"); | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/manual_assert.rs b/tests/ui/manual_assert.rs index f037c5b8405c..eac52d1b5de5 100644 --- a/tests/ui/manual_assert.rs +++ b/tests/ui/manual_assert.rs @@ -1,7 +1,7 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix #![warn(clippy::manual_assert)] #![allow(dead_code, unused_doc_comments)] diff --git a/tests/ui/manual_async_fn.fixed b/tests/ui/manual_async_fn.fixed index b7e46a4a8ccc..a92d89bf7cae 100644 --- a/tests/ui/manual_async_fn.fixed +++ b/tests/ui/manual_async_fn.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_async_fn)] #![allow(unused)] diff --git a/tests/ui/manual_async_fn.rs b/tests/ui/manual_async_fn.rs index b05429da6622..dae7201dcaa8 100644 --- a/tests/ui/manual_async_fn.rs +++ b/tests/ui/manual_async_fn.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_async_fn)] #![allow(unused)] diff --git a/tests/ui/manual_async_fn.stderr b/tests/ui/manual_async_fn.stderr index 0a903ed6fd43..ebad45a23cc3 100644 --- a/tests/ui/manual_async_fn.stderr +++ b/tests/ui/manual_async_fn.stderr @@ -1,10 +1,14 @@ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:7:1 | LL | fn fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::manual-async-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_async_fn.rs:2:9 + | +LL | #![warn(clippy::manual_async_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: make the function `async` and return the output of the future directly | LL | async fn fut() -> i32 { @@ -14,7 +18,7 @@ help: move the body of the async block to the enclosing function LL | fn fut() -> impl Future { 42 } | ~~~~~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:12:1 | LL | fn fut2() ->impl Future { @@ -29,7 +33,7 @@ help: move the body of the async block to the enclosing function LL | fn fut2() ->impl Future { 42 } | ~~~~~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:17:1 | LL | fn fut3()-> impl Future { @@ -44,7 +48,7 @@ help: move the body of the async block to the enclosing function LL | fn fut3()-> impl Future { 42 } | ~~~~~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:21:1 | LL | fn empty_fut() -> impl Future { @@ -59,7 +63,7 @@ help: move the body of the async block to the enclosing function LL | fn empty_fut() -> impl Future {} | ~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:26:1 | LL | fn empty_fut2() ->impl Future { @@ -74,7 +78,7 @@ help: move the body of the async block to the enclosing function LL | fn empty_fut2() ->impl Future {} | ~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:31:1 | LL | fn empty_fut3()-> impl Future { @@ -89,7 +93,7 @@ help: move the body of the async block to the enclosing function LL | fn empty_fut3()-> impl Future {} | ~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:35:1 | LL | fn core_fut() -> impl core::future::Future { @@ -104,7 +108,7 @@ help: move the body of the async block to the enclosing function LL | fn core_fut() -> impl core::future::Future { 42 } | ~~~~~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:57:5 | LL | fn inh_fut() -> impl Future { @@ -131,7 +135,7 @@ LL + 42 LL + } | -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:92:1 | LL | fn elided(_: &i32) -> impl Future + '_ { @@ -146,7 +150,7 @@ help: move the body of the async block to the enclosing function LL | fn elided(_: &i32) -> impl Future + '_ { 42 } | ~~~~~~ -error: this function can be simplified using the `async fn` syntax +warning: this function can be simplified using the `async fn` syntax --> $DIR/manual_async_fn.rs:101:1 | LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + 'a + 'b { @@ -161,5 +165,5 @@ help: move the body of the async block to the enclosing function LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + 'a + 'b { 42 } | ~~~~~~ -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/manual_bits.fixed b/tests/ui/manual_bits.fixed index e7f8cd878ca7..037de0262e2f 100644 --- a/tests/ui/manual_bits.fixed +++ b/tests/ui/manual_bits.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_bits)] #![allow( diff --git a/tests/ui/manual_bits.rs b/tests/ui/manual_bits.rs index 7b1d15495287..b15a531ec175 100644 --- a/tests/ui/manual_bits.rs +++ b/tests/ui/manual_bits.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_bits)] #![allow( diff --git a/tests/ui/manual_bits.stderr b/tests/ui/manual_bits.stderr index 652fafbc41d8..e181b855e6c2 100644 --- a/tests/ui/manual_bits.stderr +++ b/tests/ui/manual_bits.stderr @@ -1,178 +1,182 @@ -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:16:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` | - = note: `-D clippy::manual-bits` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_bits.rs:3:9 + | +LL | #![warn(clippy::manual_bits)] + | ^^^^^^^^^^^^^^^^^^^ -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:17:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i16::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:18:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i32::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:19:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i64::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:20:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `i128::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:21:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `isize::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:23:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `u8::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:24:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u16::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:25:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u32::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:26:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u64::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:27:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:28:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `usize::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:30:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:31:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i16::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:32:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i32::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:33:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i64::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:34:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `i128::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:35:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `isize::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:37:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `u8::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:38:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u16::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:39:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u32::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:40:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u64::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:41:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:42:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `usize::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:52:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `Word::BITS as usize` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:56:18 | LL | let _: u32 = (size_of::() * 8) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:57:18 | LL | let _: u32 = (size_of::() * 8).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:58:13 | LL | let _ = (size_of::() * 8).pow(5); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(u128::BITS as usize)` -error: usage of `mem::size_of::()` to obtain the size of `T` in bits +warning: usage of `mem::size_of::()` to obtain the size of `T` in bits --> $DIR/manual_bits.rs:59:14 | LL | let _ = &(size_of::() * 8); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(u128::BITS as usize)` -error: aborting due to 29 previous errors +warning: 29 warnings emitted diff --git a/tests/ui/manual_clamp.stderr b/tests/ui/manual_clamp.stderr index 988ad1527e83..0ff0094200db 100644 --- a/tests/ui/manual_clamp.stderr +++ b/tests/ui/manual_clamp.stderr @@ -1,4 +1,4 @@ -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:76:5 | LL | / if x9 < min { @@ -10,9 +10,13 @@ LL | | } | |_____^ help: replace with clamp: `x9 = x9.clamp(min, max);` | = note: clamp will panic if max < min - = note: `-D clippy::manual-clamp` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_clamp.rs:1:9 + | +LL | #![warn(clippy::manual_clamp)] + | ^^^^^^^^^^^^^^^^^^^^ -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:91:5 | LL | / if x11 > max { @@ -25,7 +29,7 @@ LL | | } | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:99:5 | LL | / if min > x12 { @@ -38,7 +42,7 @@ LL | | } | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:107:5 | LL | / if max < x13 { @@ -51,7 +55,7 @@ LL | | } | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:161:5 | LL | / if max < x33 { @@ -64,7 +68,7 @@ LL | | } | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:21:14 | LL | let x0 = if max < input { @@ -79,7 +83,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:29:14 | LL | let x1 = if input > max { @@ -94,7 +98,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:37:14 | LL | let x2 = if input < min { @@ -109,7 +113,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:45:14 | LL | let x3 = if min > input { @@ -124,7 +128,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:53:14 | LL | let x4 = input.max(min).min(max); @@ -132,7 +136,7 @@ LL | let x4 = input.max(min).min(max); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:55:14 | LL | let x5 = input.min(max).max(min); @@ -140,7 +144,7 @@ LL | let x5 = input.min(max).max(min); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:57:14 | LL | let x6 = match input { @@ -153,7 +157,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:63:14 | LL | let x7 = match input { @@ -166,7 +170,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:69:14 | LL | let x8 = match input { @@ -179,7 +183,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:83:15 | LL | let x10 = match input { @@ -192,7 +196,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:114:15 | LL | let x14 = if input > CONST_MAX { @@ -207,7 +211,7 @@ LL | | }; | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:123:19 | LL | let x15 = if input > max { @@ -223,7 +227,7 @@ LL | | }; = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:134:19 | LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); @@ -231,7 +235,7 @@ LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:135:19 | LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); @@ -239,7 +243,7 @@ LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:136:19 | LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); @@ -247,7 +251,7 @@ LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:137:19 | LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); @@ -255,7 +259,7 @@ LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:138:19 | LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); @@ -263,7 +267,7 @@ LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:139:19 | LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); @@ -271,7 +275,7 @@ LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:140:19 | LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); @@ -279,7 +283,7 @@ LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:141:19 | LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); @@ -287,7 +291,7 @@ LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:143:19 | LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); @@ -296,7 +300,7 @@ LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:144:19 | LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); @@ -305,7 +309,7 @@ LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:145:19 | LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); @@ -314,7 +318,7 @@ LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:146:19 | LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); @@ -323,7 +327,7 @@ LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:147:19 | LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); @@ -332,7 +336,7 @@ LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:148:19 | LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); @@ -341,7 +345,7 @@ LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:149:19 | LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); @@ -350,7 +354,7 @@ LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:150:19 | LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); @@ -359,7 +363,7 @@ LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); = note: clamp will panic if max < min, min.is_nan(), or max.is_nan() = note: clamp returns NaN if the input is NaN -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:153:5 | LL | / if x32 < min { @@ -371,7 +375,7 @@ LL | | } | = note: clamp will panic if max < min -error: clamp-like pattern without using clamp function +warning: clamp-like pattern without using clamp function --> $DIR/manual_clamp.rs:321:13 | LL | let _ = if input < min { @@ -386,5 +390,5 @@ LL | | }; | = note: clamp will panic if max < min -error: aborting due to 35 previous errors +warning: 35 warnings emitted diff --git a/tests/ui/manual_filter.fixed b/tests/ui/manual_filter.fixed index ef6780dc96d9..755caa664d59 100644 --- a/tests/ui/manual_filter.fixed +++ b/tests/ui/manual_filter.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_filter)] #![allow(unused_variables, dead_code)] diff --git a/tests/ui/manual_filter.rs b/tests/ui/manual_filter.rs index ea0ce83172b7..faccfe9db12a 100644 --- a/tests/ui/manual_filter.rs +++ b/tests/ui/manual_filter.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_filter)] #![allow(unused_variables, dead_code)] diff --git a/tests/ui/manual_filter.stderr b/tests/ui/manual_filter.stderr index 53dea9229306..6ac619437a7a 100644 --- a/tests/ui/manual_filter.stderr +++ b/tests/ui/manual_filter.stderr @@ -1,4 +1,4 @@ -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:7:5 | LL | / match Some(0) { @@ -10,9 +10,13 @@ LL | | }, LL | | }; | |_____^ help: try this: `Some(0).filter(|&x| x <= 0)` | - = note: `-D clippy::manual-filter` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_filter.rs:3:9 + | +LL | #![warn(clippy::manual_filter)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:18:5 | LL | / match Some(1) { @@ -24,7 +28,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(1).filter(|&x| x <= 0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:29:5 | LL | / match Some(2) { @@ -36,7 +40,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(2).filter(|&x| x <= 0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:40:5 | LL | / match Some(3) { @@ -48,7 +52,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(3).filter(|&x| x > 0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:52:5 | LL | / match y { @@ -60,7 +64,7 @@ LL | | }, LL | | }; | |_____^ help: try this: `y.filter(|&x| x <= 0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:64:5 | LL | / match Some(5) { @@ -72,7 +76,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(5).filter(|&x| x > 0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:75:5 | LL | / match Some(6) { @@ -84,7 +88,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(6).as_ref().filter(|&x| x > &0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:87:5 | LL | / match Some(String::new()) { @@ -96,7 +100,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(String::new()).filter(|x| external_cond)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:98:5 | LL | / if let Some(x) = Some(7) { @@ -106,7 +110,7 @@ LL | | None LL | | }; | |_____^ help: try this: `Some(7).filter(|&x| external_cond)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:104:5 | LL | / match &Some(8) { @@ -118,7 +122,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(8).filter(|&x| x != 0)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:115:5 | LL | / match Some(9) { @@ -130,7 +134,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(9).filter(|&x| x > 10 && x < 100)` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:141:5 | LL | / match Some(11) { @@ -150,7 +154,7 @@ LL + x > 10 && x < 100 LL ~ }); | -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:185:13 | LL | let _ = match Some(14) { @@ -163,7 +167,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(14).filter(|&x| unsafe { f(x) })` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:195:13 | LL | let _ = match Some(15) { @@ -175,7 +179,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(15).filter(|&x| unsafe { f(x) })` -error: manual implementation of `Option::filter` +warning: manual implementation of `Option::filter` --> $DIR/manual_filter.rs:205:12 | LL | } else if let Some(x) = Some(16) { @@ -187,5 +191,5 @@ LL | | None LL | | }; | |_____^ help: try this: `{ Some(16).filter(|&x| x % 2 == 0) }` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/manual_filter_map.fixed b/tests/ui/manual_filter_map.fixed index 4936dc9b2e01..831323089e7f 100644 --- a/tests/ui/manual_filter_map.fixed +++ b/tests/ui/manual_filter_map.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::manual_filter_map)] #![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure diff --git a/tests/ui/manual_filter_map.rs b/tests/ui/manual_filter_map.rs index 8c67e827b4c3..2692303d3138 100644 --- a/tests/ui/manual_filter_map.rs +++ b/tests/ui/manual_filter_map.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::manual_filter_map)] #![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure diff --git a/tests/ui/manual_filter_map.stderr b/tests/ui/manual_filter_map.stderr index 6e5bbe8f2aaf..afb0975d9ec2 100644 --- a/tests/ui/manual_filter_map.stderr +++ b/tests/ui/manual_filter_map.stderr @@ -1,24 +1,28 @@ -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:8:19 | LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))` | - = note: `-D clippy::manual-filter-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_filter_map.rs:3:9 + | +LL | #![warn(clippy::manual_filter_map)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:11:19 | LL | let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:14:19 | LL | let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_res(a).ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:17:10 | LL | .filter(|&x| to_ref(to_opt(x)).is_some()) @@ -26,7 +30,7 @@ LL | .filter(|&x| to_ref(to_opt(x)).is_some()) LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| *to_ref(to_opt(y)))` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:20:10 | LL | .filter(|x| to_ref(to_opt(*x)).is_some()) @@ -34,7 +38,7 @@ LL | .filter(|x| to_ref(to_opt(*x)).is_some()) LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| *to_ref(to_opt(y)))` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:24:10 | LL | .filter(|&x| to_ref(to_res(x)).is_ok()) @@ -42,7 +46,7 @@ LL | .filter(|&x| to_ref(to_res(x)).is_ok()) LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| to_ref(to_res(y)).ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:27:10 | LL | .filter(|x| to_ref(to_res(*x)).is_ok()) @@ -50,75 +54,75 @@ LL | .filter(|x| to_ref(to_res(*x)).is_ok()) LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| to_ref(to_res(y)).ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:33:27 | LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` | - = note: `-D clippy::manual-find-map` implied by `-D warnings` + = note: `#[warn(clippy::manual_find_map)]` on by default -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:34:28 | LL | iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:35:31 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:36:31 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:38:30 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:39:31 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:40:32 | LL | iter::<&&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:41:31 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:42:32 | LL | iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:43:35 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_filter_map.rs:44:35 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:92:10 | LL | .filter(|f| f.option_field.is_some()) @@ -126,7 +130,7 @@ LL | .filter(|f| f.option_field.is_some()) LL | | .map(|f| f.option_field.clone().unwrap()); | |_________________________________________________^ help: try: `filter_map(|f| f.option_field.clone())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:97:10 | LL | .filter(|f| f.ref_field.is_some()) @@ -134,7 +138,7 @@ LL | .filter(|f| f.ref_field.is_some()) LL | | .map(|f| f.ref_field.cloned().unwrap()); | |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.cloned())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:102:10 | LL | .filter(|f| f.ref_field.is_some()) @@ -142,7 +146,7 @@ LL | .filter(|f| f.ref_field.is_some()) LL | | .map(|f| f.ref_field.copied().unwrap()); | |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.copied())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:107:10 | LL | .filter(|f| f.result_field.is_ok()) @@ -150,7 +154,7 @@ LL | .filter(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.clone().unwrap()); | |_________________________________________________^ help: try: `filter_map(|f| f.result_field.clone().ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:112:10 | LL | .filter(|f| f.result_field.is_ok()) @@ -158,7 +162,7 @@ LL | .filter(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_ref().unwrap()); | |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_ref().ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:117:10 | LL | .filter(|f| f.result_field.is_ok()) @@ -166,7 +170,7 @@ LL | .filter(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_deref().unwrap()); | |____________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref().ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:122:10 | LL | .filter(|f| f.result_field.is_ok()) @@ -174,7 +178,7 @@ LL | .filter(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_mut().unwrap()); | |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_mut().ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:127:10 | LL | .filter(|f| f.result_field.is_ok()) @@ -182,7 +186,7 @@ LL | .filter(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_deref_mut().unwrap()); | |________________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref_mut().ok())` -error: `filter(..).map(..)` can be simplified as `filter_map(..)` +warning: `filter(..).map(..)` can be simplified as `filter_map(..)` --> $DIR/manual_filter_map.rs:132:10 | LL | .filter(|f| f.result_field.is_ok()) @@ -190,5 +194,5 @@ LL | .filter(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.to_owned().unwrap()); | |____________________________________________________^ help: try: `filter_map(|f| f.result_field.to_owned().ok())` -error: aborting due to 27 previous errors +warning: 27 warnings emitted diff --git a/tests/ui/manual_find.stderr b/tests/ui/manual_find.stderr index ea04bb066e61..01695846375d 100644 --- a/tests/ui/manual_find.stderr +++ b/tests/ui/manual_find.stderr @@ -1,4 +1,4 @@ -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find.rs:5:5 | LL | / for s in strings { @@ -10,9 +10,13 @@ LL | | None | |________^ help: replace with an iterator: `strings.into_iter().find(|s| s == String::new())` | = note: you may need to dereference some variables - = note: `-D clippy::manual-find` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_find.rs:2:9 + | +LL | #![warn(clippy::manual_find)] + | ^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find.rs:14:5 | LL | / for (s, _) in arr { @@ -25,5 +29,5 @@ LL | | None | = note: you may need to dereference some variables -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/manual_find_fixable.fixed b/tests/ui/manual_find_fixable.fixed index 2bce6e624c90..19bc23b1f784 100644 --- a/tests/ui/manual_find_fixable.fixed +++ b/tests/ui/manual_find_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_find)] #![allow(unused)] #![allow(clippy::needless_return, clippy::uninlined_format_args)] @@ -20,7 +20,12 @@ struct Data { is_true: bool, } fn with_struct(arr: Vec) -> Option { - arr.into_iter().find(|el| el.name.len() == 10) + for el in arr { + if el.name.len() == 10 { + return Some(el); + } + } + None } struct Tuple(usize, usize); @@ -35,7 +40,12 @@ impl A { } } fn with_method_call(arr: Vec) -> Option { - arr.into_iter().find(|el| el.should_keep()) + for el in arr { + if el.should_keep() { + return Some(el); + } + } + None } fn with_closure(arr: Vec) -> Option { @@ -49,7 +59,12 @@ fn with_closure2(arr: HashMap) -> Option { } fn with_bool(arr: Vec) -> Option { - arr.into_iter().find(|el| el.is_true) + for el in arr { + if el.is_true { + return Some(el); + } + } + None } fn with_side_effects(arr: Vec) -> Option { diff --git a/tests/ui/manual_find_fixable.rs b/tests/ui/manual_find_fixable.rs index f5c6de37a257..7b670320ee33 100644 --- a/tests/ui/manual_find_fixable.rs +++ b/tests/ui/manual_find_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_find)] #![allow(unused)] #![allow(clippy::needless_return, clippy::uninlined_format_args)] diff --git a/tests/ui/manual_find_fixable.stderr b/tests/ui/manual_find_fixable.stderr index dbc4ff69a740..3236b44bfcca 100644 --- a/tests/ui/manual_find_fixable.stderr +++ b/tests/ui/manual_find_fixable.stderr @@ -1,4 +1,4 @@ -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:11:5 | LL | / for &v in ARRAY { @@ -9,9 +9,13 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `ARRAY.iter().find(|&&v| v == n).copied()` | - = note: `-D clippy::manual-find` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_find_fixable.rs:2:9 + | +LL | #![warn(clippy::manual_find)] + | ^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:20:5 | LL | / for (a, _) in arr { @@ -22,7 +26,7 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|(a, _)| a).find(|&a| a % 2 == 0)` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:33:5 | LL | / for el in arr { @@ -35,7 +39,7 @@ LL | | None | = note: you may need to dereference some variables -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:43:5 | LL | / for Tuple(a, _) in arr { @@ -46,7 +50,7 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|Tuple(a, _)| a).find(|&a| a >= 3)` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:58:5 | LL | / for el in arr { @@ -59,7 +63,7 @@ LL | | None | = note: you may need to dereference some variables -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:68:5 | LL | / for el in arr { @@ -70,7 +74,7 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|&el| f(el) == 20)` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:78:5 | LL | / for &el in arr.values() { @@ -81,7 +85,7 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `arr.values().find(|&&el| f(el)).copied()` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:87:5 | LL | / for el in arr { @@ -94,7 +98,7 @@ LL | | None | = note: you may need to dereference some variables -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:117:5 | LL | / for (_, &x) in v { @@ -105,7 +109,7 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `v.into_iter().map(|(_, &x)| x).find(|&x| x > 10)` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:126:5 | LL | / for &(_, &x) in v { @@ -116,7 +120,7 @@ LL | | } LL | | None | |________^ help: replace with an iterator: `v.iter().map(|&(_, &x)| x).find(|&x| x > 10)` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:135:5 | LL | / for x in arr { @@ -127,7 +131,7 @@ LL | | } LL | | return None; | |________________^ help: replace with an iterator: `arr.into_iter().find(|&x| x >= 5)` -error: manual implementation of `Iterator::find` +warning: manual implementation of `Iterator::find` --> $DIR/manual_find_fixable.rs:190:9 | LL | / for x in arr { @@ -138,5 +142,5 @@ LL | | } LL | | None | |____________^ help: replace with an iterator: `arr.into_iter().find(|&x| x < 1)` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/manual_find_map.fixed b/tests/ui/manual_find_map.fixed index 54302beceff6..554613a30a9e 100644 --- a/tests/ui/manual_find_map.fixed +++ b/tests/ui/manual_find_map.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::manual_find_map)] #![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure diff --git a/tests/ui/manual_find_map.rs b/tests/ui/manual_find_map.rs index afcc1825a9ac..d6245758f9d0 100644 --- a/tests/ui/manual_find_map.rs +++ b/tests/ui/manual_find_map.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::manual_find_map)] #![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure diff --git a/tests/ui/manual_find_map.stderr b/tests/ui/manual_find_map.stderr index c1ac499f7c60..853626100c01 100644 --- a/tests/ui/manual_find_map.stderr +++ b/tests/ui/manual_find_map.stderr @@ -1,24 +1,28 @@ -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:8:19 | LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))` | - = note: `-D clippy::manual-find-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_find_map.rs:3:9 + | +LL | #![warn(clippy::manual_find_map)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:11:19 | LL | let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:14:19 | LL | let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_res(a).ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:17:10 | LL | .find(|&x| to_ref(to_opt(x)).is_some()) @@ -26,7 +30,7 @@ LL | .find(|&x| to_ref(to_opt(x)).is_some()) LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:20:10 | LL | .find(|x| to_ref(to_opt(*x)).is_some()) @@ -34,7 +38,7 @@ LL | .find(|x| to_ref(to_opt(*x)).is_some()) LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:24:10 | LL | .find(|&x| to_ref(to_res(x)).is_ok()) @@ -42,7 +46,7 @@ LL | .find(|&x| to_ref(to_res(x)).is_ok()) LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:27:10 | LL | .find(|x| to_ref(to_res(*x)).is_ok()) @@ -50,91 +54,91 @@ LL | .find(|x| to_ref(to_res(*x)).is_ok()) LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:33:26 | LL | iter::>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x)` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:34:27 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| *x)` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:35:28 | LL | iter::<&&Option>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| **x)` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:36:27 | LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:37:28 | LL | iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:38:31 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:39:31 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:41:30 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:42:31 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:43:32 | LL | iter::<&&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:44:31 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:45:32 | LL | iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:46:35 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:47:35 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:95:10 | LL | .find(|f| f.option_field.is_some()) @@ -142,7 +146,7 @@ LL | .find(|f| f.option_field.is_some()) LL | | .map(|f| f.option_field.clone().unwrap()); | |_________________________________________________^ help: try: `find_map(|f| f.option_field.clone())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:100:10 | LL | .find(|f| f.ref_field.is_some()) @@ -150,7 +154,7 @@ LL | .find(|f| f.ref_field.is_some()) LL | | .map(|f| f.ref_field.cloned().unwrap()); | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.cloned())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:105:10 | LL | .find(|f| f.ref_field.is_some()) @@ -158,7 +162,7 @@ LL | .find(|f| f.ref_field.is_some()) LL | | .map(|f| f.ref_field.copied().unwrap()); | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.copied())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:110:10 | LL | .find(|f| f.result_field.is_ok()) @@ -166,7 +170,7 @@ LL | .find(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.clone().unwrap()); | |_________________________________________________^ help: try: `find_map(|f| f.result_field.clone().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:115:10 | LL | .find(|f| f.result_field.is_ok()) @@ -174,7 +178,7 @@ LL | .find(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_ref().unwrap()); | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_ref().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:120:10 | LL | .find(|f| f.result_field.is_ok()) @@ -182,7 +186,7 @@ LL | .find(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_deref().unwrap()); | |____________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:125:10 | LL | .find(|f| f.result_field.is_ok()) @@ -190,7 +194,7 @@ LL | .find(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_mut().unwrap()); | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_mut().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:130:10 | LL | .find(|f| f.result_field.is_ok()) @@ -198,7 +202,7 @@ LL | .find(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.as_deref_mut().unwrap()); | |________________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref_mut().ok())` -error: `find(..).map(..)` can be simplified as `find_map(..)` +warning: `find(..).map(..)` can be simplified as `find_map(..)` --> $DIR/manual_find_map.rs:135:10 | LL | .find(|f| f.result_field.is_ok()) @@ -206,5 +210,5 @@ LL | .find(|f| f.result_field.is_ok()) LL | | .map(|f| f.result_field.to_owned().unwrap()); | |____________________________________________________^ help: try: `find_map(|f| f.result_field.to_owned().ok())` -error: aborting due to 30 previous errors +warning: 30 warnings emitted diff --git a/tests/ui/manual_flatten.stderr b/tests/ui/manual_flatten.stderr index 180a6ff4e9a7..b7bc89feba2b 100644 --- a/tests/ui/manual_flatten.stderr +++ b/tests/ui/manual_flatten.stderr @@ -1,4 +1,4 @@ -error: unnecessary `if let` since only the `Some` variant of the iterator element is used +warning: unnecessary `if let` since only the `Some` variant of the iterator element is used --> $DIR/manual_flatten.rs:7:5 | LL | for n in x { @@ -18,9 +18,13 @@ LL | / if let Some(y) = n { LL | | println!("{}", y); LL | | } | |_________^ - = note: `-D clippy::manual-flatten` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_flatten.rs:1:9 + | +LL | #![warn(clippy::manual_flatten)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary `if let` since only the `Ok` variant of the iterator element is used +warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used --> $DIR/manual_flatten.rs:15:5 | LL | for n in y.clone() { @@ -41,7 +45,7 @@ LL | | println!("{}", n); LL | | }; | |_________^ -error: unnecessary `if let` since only the `Ok` variant of the iterator element is used +warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used --> $DIR/manual_flatten.rs:22:5 | LL | for n in &y { @@ -62,7 +66,7 @@ LL | | println!("{}", n); LL | | } | |_________^ -error: unnecessary `if let` since only the `Ok` variant of the iterator element is used +warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used --> $DIR/manual_flatten.rs:30:5 | LL | for n in z { @@ -83,7 +87,7 @@ LL | | println!("{}", n); LL | | } | |_________^ -error: unnecessary `if let` since only the `Some` variant of the iterator element is used +warning: unnecessary `if let` since only the `Some` variant of the iterator element is used --> $DIR/manual_flatten.rs:39:5 | LL | for n in z { @@ -104,7 +108,7 @@ LL | | println!("{}", m); LL | | } | |_________^ -error: unnecessary `if let` since only the `Some` variant of the iterator element is used +warning: unnecessary `if let` since only the `Some` variant of the iterator element is used --> $DIR/manual_flatten.rs:72:5 | LL | for n in &vec_of_ref { @@ -125,7 +129,7 @@ LL | | println!("{:?}", n); LL | | } | |_________^ -error: unnecessary `if let` since only the `Some` variant of the iterator element is used +warning: unnecessary `if let` since only the `Some` variant of the iterator element is used --> $DIR/manual_flatten.rs:79:5 | LL | for n in vec_of_ref { @@ -146,7 +150,7 @@ LL | | println!("{:?}", n); LL | | } | |_________^ -error: unnecessary `if let` since only the `Some` variant of the iterator element is used +warning: unnecessary `if let` since only the `Some` variant of the iterator element is used --> $DIR/manual_flatten.rs:86:5 | LL | for n in slice_of_ref { @@ -167,7 +171,7 @@ LL | | println!("{:?}", n); LL | | } | |_________^ -error: unnecessary `if let` since only the `Some` variant of the iterator element is used +warning: unnecessary `if let` since only the `Some` variant of the iterator element is used --> $DIR/manual_flatten.rs:116:5 | LL | / for n in vec![ @@ -195,5 +199,5 @@ LL + Some(3) LL ~ ].iter().flatten() { | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/manual_instant_elapsed.fixed b/tests/ui/manual_instant_elapsed.fixed index 85a91543c893..55073c3b57cf 100644 --- a/tests/ui/manual_instant_elapsed.fixed +++ b/tests/ui/manual_instant_elapsed.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_instant_elapsed)] #![allow(clippy::unnecessary_operation)] #![allow(clippy::unchecked_duration_subtraction)] diff --git a/tests/ui/manual_instant_elapsed.rs b/tests/ui/manual_instant_elapsed.rs index c98cb15b9164..c9029a049408 100644 --- a/tests/ui/manual_instant_elapsed.rs +++ b/tests/ui/manual_instant_elapsed.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_instant_elapsed)] #![allow(clippy::unnecessary_operation)] #![allow(clippy::unchecked_duration_subtraction)] diff --git a/tests/ui/manual_instant_elapsed.stderr b/tests/ui/manual_instant_elapsed.stderr index 4ce1f689107e..d63a70bedfec 100644 --- a/tests/ui/manual_instant_elapsed.stderr +++ b/tests/ui/manual_instant_elapsed.stderr @@ -1,16 +1,20 @@ -error: manual implementation of `Instant::elapsed` +warning: manual implementation of `Instant::elapsed` --> $DIR/manual_instant_elapsed.rs:18:20 | LL | let duration = Instant::now() - prev_instant; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `prev_instant.elapsed()` | - = note: `-D clippy::manual-instant-elapsed` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_instant_elapsed.rs:2:9 + | +LL | #![warn(clippy::manual_instant_elapsed)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `Instant::elapsed` +warning: manual implementation of `Instant::elapsed` --> $DIR/manual_instant_elapsed.rs:27:5 | LL | Instant::now() - *ref_to_instant; // to ensure parens are added correctly | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*ref_to_instant).elapsed()` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/manual_is_ascii_check.fixed b/tests/ui/manual_is_ascii_check.fixed index 5b2b44c2fdb2..87e866586683 100644 --- a/tests/ui/manual_is_ascii_check.fixed +++ b/tests/ui/manual_is_ascii_check.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, dead_code)] #![warn(clippy::manual_is_ascii_check)] diff --git a/tests/ui/manual_is_ascii_check.rs b/tests/ui/manual_is_ascii_check.rs index c9433f33a1b6..931f0f20276b 100644 --- a/tests/ui/manual_is_ascii_check.rs +++ b/tests/ui/manual_is_ascii_check.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, dead_code)] #![warn(clippy::manual_is_ascii_check)] diff --git a/tests/ui/manual_is_ascii_check.stderr b/tests/ui/manual_is_ascii_check.stderr index ee60188506d6..ae148c0db202 100644 --- a/tests/ui/manual_is_ascii_check.stderr +++ b/tests/ui/manual_is_ascii_check.stderr @@ -1,124 +1,128 @@ -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:7:13 | LL | assert!(matches!('x', 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_lowercase()` | - = note: `-D clippy::manual-is-ascii-check` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_is_ascii_check.rs:4:9 + | +LL | #![warn(clippy::manual_is_ascii_check)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:8:13 | LL | assert!(matches!('X', 'A'..='Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:9:13 | LL | assert!(matches!(b'x', b'a'..=b'z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'x'.is_ascii_lowercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:10:13 | LL | assert!(matches!(b'X', b'A'..=b'Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'X'.is_ascii_uppercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:13:13 | LL | assert!(matches!(num, '0'..='9')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.is_ascii_digit()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:14:13 | LL | assert!(matches!(b'1', b'0'..=b'9')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:15:13 | LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:19:5 | LL | (b'0'..=b'9').contains(&b'0'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'0'.is_ascii_digit()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:20:5 | LL | (b'a'..=b'z').contains(&b'a'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'a'.is_ascii_lowercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:21:5 | LL | (b'A'..=b'Z').contains(&b'A'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'A'.is_ascii_uppercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:23:5 | LL | ('0'..='9').contains(&'0'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'0'.is_ascii_digit()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:24:5 | LL | ('a'..='z').contains(&'a'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'a'.is_ascii_lowercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:25:5 | LL | ('A'..='Z').contains(&'A'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'A'.is_ascii_uppercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:28:5 | LL | ('0'..='9').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_digit()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:29:5 | LL | ('a'..='z').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_lowercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:30:5 | LL | ('A'..='Z').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_uppercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:42:13 | LL | assert!(matches!(b'1', b'0'..=b'9')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:43:13 | LL | assert!(matches!('X', 'A'..='Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:44:13 | LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()` -error: manual check for common ascii range +warning: manual check for common ascii range --> $DIR/manual_is_ascii_check.rs:54:23 | LL | const FOO: bool = matches!('x', '0'..='9'); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_digit()` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/manual_let_else.stderr b/tests/ui/manual_let_else.stderr index 52aac6bc673d..677cee9e0a7e 100644 --- a/tests/ui/manual_let_else.stderr +++ b/tests/ui/manual_let_else.stderr @@ -1,12 +1,16 @@ -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:18:5 | LL | let v = if let Some(v_some) = g() { v_some } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v_some) = g() else { return };` | - = note: `-D clippy::manual-let-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_let_else.rs:9:9 + | +LL | #![warn(clippy::manual_let_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:19:5 | LL | / let v = if let Some(v_some) = g() { @@ -23,7 +27,7 @@ LL + return; LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:25:5 | LL | / let v = if let Some(v) = g() { @@ -44,25 +48,25 @@ LL + return; LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:38:9 | LL | let v = if let Some(v_some) = g() { v_some } else { continue }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v_some) = g() else { continue };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:39:9 | LL | let v = if let Some(v_some) = g() { v_some } else { break }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v_some) = g() else { break };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:43:5 | LL | let v = if let Some(v_some) = g() { v_some } else { panic!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v_some) = g() else { panic!() };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:46:5 | LL | / let v = if let Some(v_some) = g() { @@ -79,7 +83,7 @@ LL + std::process::abort() LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:53:5 | LL | / let v = if let Some(v_some) = g() { @@ -96,7 +100,7 @@ LL + if true { return } else { panic!() } LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:60:5 | LL | / let v = if let Some(v_some) = g() { @@ -115,7 +119,7 @@ LL + panic!(); LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:70:5 | LL | / let v = if let Some(v_some) = g() { @@ -137,13 +141,13 @@ LL + } LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:80:5 | LL | let v = if let Some(v_some) = g() { v_some } else { if panic!() {} }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v_some) = g() else { if panic!() {} };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:83:5 | LL | / let v = if let Some(v_some) = g() { @@ -164,7 +168,7 @@ LL + } LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:92:5 | LL | / let v = if let Some(v_some) = g() { @@ -185,7 +189,7 @@ LL + panic!("diverge"); LL + } }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:101:5 | LL | / let v = if let Some(v_some) = g() { @@ -214,7 +218,7 @@ LL + } LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:118:5 | LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) { @@ -231,7 +235,7 @@ LL + return; LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:125:5 | LL | / let v = if let (Some(v_some), w_some) = (g(), 0) { @@ -248,7 +252,7 @@ LL + return; LL + }; | -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:134:13 | LL | let $n = if let Some(v) = $e { v } else { return }; @@ -257,9 +261,9 @@ LL | let $n = if let Some(v) = $e { v } else { return }; LL | create_binding_if_some!(w, g()); | ------------------------------- in this macro invocation | - = note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:247:5 | LL | / let _ = match ff { @@ -268,5 +272,5 @@ LL | | _ => macro_call!(), LL | | }; | |______^ help: consider writing: `let Some(value) = ff else { macro_call!() };` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/manual_let_else_match.stderr b/tests/ui/manual_let_else_match.stderr index 7abaa0b85d23..d9ca0866ce83 100644 --- a/tests/ui/manual_let_else_match.stderr +++ b/tests/ui/manual_let_else_match.stderr @@ -1,4 +1,4 @@ -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:32:5 | LL | / let v = match g() { @@ -7,9 +7,13 @@ LL | | None => return, LL | | }; | |______^ help: consider writing: `let Some(v_some) = g() else { return };` | - = note: `-D clippy::manual-let-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_let_else_match.rs:3:9 + | +LL | #![warn(clippy::manual_let_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:37:5 | LL | / let v = match g() { @@ -18,7 +22,7 @@ LL | | _ => return, LL | | }; | |______^ help: consider writing: `let Some(v_some) = g() else { return };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:44:9 | LL | / let v = match h() { @@ -27,7 +31,7 @@ LL | | (Some(_), Some(_)) | (None, None) => continue, LL | | }; | |__________^ help: consider writing: `let ((Some(v), None) | (None, Some(v))) = h() else { continue };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:49:9 | LL | / let v = match build_enum() { @@ -36,7 +40,7 @@ LL | | _ => continue, LL | | }; | |__________^ help: consider writing: `let (Variant::Bar(v) | Variant::Baz(v)) = build_enum() else { continue };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:57:5 | LL | / let v = match f() { @@ -45,7 +49,7 @@ LL | | Err(_) => return, LL | | }; | |______^ help: consider writing: `let Ok(v) = f() else { return };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:63:5 | LL | / let v = match f().map_err(|_| ()) { @@ -54,7 +58,7 @@ LL | | Err(()) => return, LL | | }; | |______^ help: consider writing: `let Ok(v) = f().map_err(|_| ()) else { return };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:70:5 | LL | / let _value = match f { @@ -63,7 +67,7 @@ LL | | _ => return, LL | | }; | |______^ help: consider writing: `let (Variant::Bar(_) | Variant::Baz(_)) = f else { return };` -error: this could be rewritten as `let...else` +warning: this could be rewritten as `let...else` --> $DIR/manual_let_else_match.rs:76:5 | LL | / let data = match data.as_slice() { @@ -72,5 +76,5 @@ LL | | _ => return, LL | | }; | |______^ help: consider writing: `let ([data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0]) = data.as_slice() else { return };` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/manual_map_option.fixed b/tests/ui/manual_map_option.fixed index e12ea7ec1450..e8ff65cad6aa 100644 --- a/tests/ui/manual_map_option.fixed +++ b/tests/ui/manual_map_option.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_map)] #![allow( diff --git a/tests/ui/manual_map_option.rs b/tests/ui/manual_map_option.rs index 325a6db06c4e..b06a96451ce7 100644 --- a/tests/ui/manual_map_option.rs +++ b/tests/ui/manual_map_option.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_map)] #![allow( diff --git a/tests/ui/manual_map_option.stderr b/tests/ui/manual_map_option.stderr index cdc2c0e62a9b..09c4a45306e0 100644 --- a/tests/ui/manual_map_option.stderr +++ b/tests/ui/manual_map_option.stderr @@ -1,4 +1,4 @@ -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:15:5 | LL | / match Some(0) { @@ -7,9 +7,13 @@ LL | | None:: => None, LL | | }; | |_____^ help: try this: `Some(0).map(|_| 2)` | - = note: `-D clippy::manual-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_map_option.rs:3:9 + | +LL | #![warn(clippy::manual_map)] + | ^^^^^^^^^^^^^^^^^^ -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:20:5 | LL | / match Some(0) { @@ -18,7 +22,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(0).map(|x| x + 1)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:25:5 | LL | / match Some("") { @@ -27,7 +31,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some("").map(|x| x.is_empty())` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:30:5 | LL | / if let Some(x) = Some(0) { @@ -37,7 +41,7 @@ LL | | None LL | | }; | |_____^ help: try this: `Some(0).map(|x| !x)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:37:5 | LL | / match Some(0) { @@ -46,7 +50,7 @@ LL | | None => { None } LL | | }; | |_____^ help: try this: `Some(0).map(std::convert::identity)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:42:5 | LL | / match Some(&String::new()) { @@ -55,7 +59,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(&String::new()).map(|x| str::len(x))` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:52:5 | LL | / match &Some([0, 1]) { @@ -64,7 +68,7 @@ LL | | &None => None, LL | | }; | |_____^ help: try this: `Some([0, 1]).as_ref().map(|x| x[0])` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:57:5 | LL | / match &Some(0) { @@ -73,7 +77,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(0).map(|x| x * 2)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:62:5 | LL | / match Some(String::new()) { @@ -82,7 +86,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:67:5 | LL | / match &&Some(String::new()) { @@ -91,7 +95,7 @@ LL | | _ => None, LL | | }; | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:72:5 | LL | / match &&Some(0) { @@ -100,7 +104,7 @@ LL | | &&_ => None, LL | | }; | |_____^ help: try this: `Some(0).map(|x| x + x)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:85:9 | LL | / match &mut Some(String::new()) { @@ -109,7 +113,7 @@ LL | | None => None, LL | | }; | |_________^ help: try this: `Some(String::new()).as_mut().map(|x| x.push_str(""))` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:91:5 | LL | / match &mut Some(String::new()) { @@ -118,7 +122,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:96:5 | LL | / match &mut &Some(String::new()) { @@ -127,7 +131,7 @@ LL | | &mut _ => None, LL | | }; | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:101:5 | LL | / match Some((0, 1, 2)) { @@ -136,7 +140,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:106:5 | LL | / match Some([1, 2, 3]) { @@ -145,7 +149,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some([1, 2, 3]).map(|[first, ..]| first)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:111:5 | LL | / match &Some((String::new(), "test")) { @@ -154,7 +158,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:169:5 | LL | / match Some(0) { @@ -163,7 +167,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(0).map(|x| vec![x])` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:174:5 | LL | / match option_env!("") { @@ -172,7 +176,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `option_env!("").map(String::from)` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:194:12 | LL | } else if let Some(x) = Some(0) { @@ -183,7 +187,7 @@ LL | | None LL | | }; | |_____^ help: try this: `{ Some(0).map(|x| x + 1) }` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option.rs:202:12 | LL | } else if let Some(x) = Some(0) { @@ -194,5 +198,5 @@ LL | | None LL | | }; | |_____^ help: try this: `{ Some(0).map(|x| x + 1) }` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/manual_map_option_2.fixed b/tests/ui/manual_map_option_2.fixed index ebf3f8cabd47..dc7228782487 100644 --- a/tests/ui/manual_map_option_2.fixed +++ b/tests/ui/manual_map_option_2.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_map)] #![allow(clippy::toplevel_ref_arg)] diff --git a/tests/ui/manual_map_option_2.rs b/tests/ui/manual_map_option_2.rs index 1382d9af0aa0..c495ab0fa6e0 100644 --- a/tests/ui/manual_map_option_2.rs +++ b/tests/ui/manual_map_option_2.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_map)] #![allow(clippy::toplevel_ref_arg)] diff --git a/tests/ui/manual_map_option_2.stderr b/tests/ui/manual_map_option_2.stderr index d35b6252fb87..ad8af941232a 100644 --- a/tests/ui/manual_map_option_2.stderr +++ b/tests/ui/manual_map_option_2.stderr @@ -1,4 +1,4 @@ -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option_2.rs:8:13 | LL | let _ = match Some(0) { @@ -11,7 +11,11 @@ LL | | None => None, LL | | }; | |_____^ | - = note: `-D clippy::manual-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_map_option_2.rs:3:9 + | +LL | #![warn(clippy::manual_map)] + | ^^^^^^^^^^^^^^^^^^ help: try this | LL ~ let _ = Some(0).map(|x| { @@ -20,7 +24,7 @@ LL + (x, y.0) LL ~ }); | -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option_2.rs:50:13 | LL | let _ = match &s { @@ -39,7 +43,7 @@ LL + if let Some(ref s) = s { (x.clone(), s) } else { panic!() } LL ~ }); | -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option_2.rs:62:17 | LL | let _ = match Some(0) { @@ -49,7 +53,7 @@ LL | | None => None, LL | | }; | |_________^ help: try this: `Some(0).map(|x| f(x))` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option_2.rs:67:13 | LL | let _ = match Some(0) { @@ -59,7 +63,7 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })` -error: manual implementation of `Option::map` +warning: manual implementation of `Option::map` --> $DIR/manual_map_option_2.rs:71:13 | LL | let _ = match Some(0) { @@ -69,5 +73,5 @@ LL | | None => None, LL | | }; | |_____^ help: try this: `Some(0).map(|x| unsafe { f(x) })` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/manual_memcpy/with_loop_counters.stderr b/tests/ui/manual_memcpy/with_loop_counters.stderr index 79d40c0bcb1d..f12719697ecd 100644 --- a/tests/ui/manual_memcpy/with_loop_counters.stderr +++ b/tests/ui/manual_memcpy/with_loop_counters.stderr @@ -1,4 +1,4 @@ -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:5:5 | LL | / for i in 3..src.len() { @@ -7,9 +7,13 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[3..src.len()].copy_from_slice(&src[..(src.len() - 3)]);` | - = note: `-D clippy::manual-memcpy` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/with_loop_counters.rs:1:38 + | +LL | #![warn(clippy::needless_range_loop, clippy::manual_memcpy)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:11:5 | LL | / for i in 3..src.len() { @@ -18,7 +22,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[..(src.len() - 3)].copy_from_slice(&src[3..]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:17:5 | LL | / for i in 0..src.len() { @@ -27,7 +31,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[3..(src.len() + 3)].copy_from_slice(&src[..]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:23:5 | LL | / for i in 0..src.len() { @@ -36,7 +40,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[3..(src.len() + 3)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:29:5 | LL | / for i in 3..(3 + src.len()) { @@ -45,7 +49,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[3..(3 + src.len())].copy_from_slice(&src[..(3 + src.len() - 3)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:35:5 | LL | / for i in 5..src.len() { @@ -54,7 +58,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[5..src.len()].copy_from_slice(&src[(3 - 2)..((src.len() - 2) + 3 - 5)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:41:5 | LL | / for i in 0..dst.len() { @@ -63,7 +67,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[2..(dst.len() + 2)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:47:5 | LL | / for i in 3..10 { @@ -72,7 +76,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[3..10].copy_from_slice(&src[5..(10 + 5 - 3)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:54:5 | LL | / for i in 0..src.len() { @@ -89,7 +93,7 @@ LL ~ dst[3..(src.len() + 3)].copy_from_slice(&src[..]); LL + dst2[30..(src.len() + 30)].copy_from_slice(&src[..]); | -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:64:5 | LL | / for i in 0..1 << 1 { @@ -98,7 +102,7 @@ LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[(0 << 1)..((1 << 1) + (0 << 1))].copy_from_slice(&src[2..((1 << 1) + 2)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/with_loop_counters.rs:71:5 | LL | / for i in 3..src.len() { @@ -107,5 +111,5 @@ LL | | count += 1 LL | | } | |_____^ help: try replacing the loop by: `dst[3..src.len()].copy_from_slice(&src[..(src.len() - 3)]);` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/manual_memcpy/without_loop_counters.stderr b/tests/ui/manual_memcpy/without_loop_counters.stderr index c163ae061dfc..61347c430603 100644 --- a/tests/ui/manual_memcpy/without_loop_counters.stderr +++ b/tests/ui/manual_memcpy/without_loop_counters.stderr @@ -1,4 +1,4 @@ -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:7:5 | LL | / for i in 0..src.len() { @@ -6,9 +6,13 @@ LL | | dst[i] = src[i]; LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[..]);` | - = note: `-D clippy::manual-memcpy` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/without_loop_counters.rs:1:38 + | +LL | #![warn(clippy::needless_range_loop, clippy::manual_memcpy)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:12:5 | LL | / for i in 0..src.len() { @@ -16,7 +20,7 @@ LL | | dst[i + 10] = src[i]; LL | | } | |_____^ help: try replacing the loop by: `dst[10..(src.len() + 10)].copy_from_slice(&src[..]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:17:5 | LL | / for i in 0..src.len() { @@ -24,7 +28,7 @@ LL | | dst[i] = src[i + 10]; LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[10..(src.len() + 10)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:22:5 | LL | / for i in 11..src.len() { @@ -32,7 +36,7 @@ LL | | dst[i] = src[i - 10]; LL | | } | |_____^ help: try replacing the loop by: `dst[11..src.len()].copy_from_slice(&src[(11 - 10)..(src.len() - 10)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:27:5 | LL | / for i in 0..dst.len() { @@ -40,7 +44,7 @@ LL | | dst[i] = src[i]; LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..dst.len()]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:40:5 | LL | / for i in 10..256 { @@ -55,7 +59,7 @@ LL ~ dst[10..256].copy_from_slice(&src[(10 - 5)..(256 - 5)]); LL + dst2[(10 + 500)..(256 + 500)].copy_from_slice(&src[10..256]); | -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:52:5 | LL | / for i in 10..LOOP_OFFSET { @@ -63,7 +67,7 @@ LL | | dst[i + LOOP_OFFSET] = src[i - some_var]; LL | | } | |_____^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].copy_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:65:5 | LL | / for i in 0..src_vec.len() { @@ -71,7 +75,7 @@ LL | | dst_vec[i] = src_vec[i]; LL | | } | |_____^ help: try replacing the loop by: `dst_vec[..src_vec.len()].copy_from_slice(&src_vec[..]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:94:5 | LL | / for i in from..from + src.len() { @@ -79,7 +83,7 @@ LL | | dst[i] = src[i - from]; LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + src.len())].copy_from_slice(&src[..(from + src.len() - from)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:98:5 | LL | / for i in from..from + 3 { @@ -87,7 +91,7 @@ LL | | dst[i] = src[i - from]; LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + 3)].copy_from_slice(&src[..(from + 3 - from)]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:103:5 | LL | / for i in 0..5 { @@ -95,7 +99,7 @@ LL | | dst[i - 0] = src[i]; LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src[..5]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:108:5 | LL | / for i in 0..0 { @@ -103,13 +107,19 @@ LL | | dst[i] = src[i]; LL | | } | |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);` -error: it looks like you're manually copying between slices +warning: it looks like you're manually copying between slices --> $DIR/without_loop_counters.rs:131:5 | LL | / for i in 0..src.len() { LL | | dst[i] = src[i].clone(); LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..]);` + | +note: the lint level is defined here + --> $DIR/without_loop_counters.rs:129:37 + | +LL | #[warn(clippy::needless_range_loop, clippy::manual_memcpy)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/manual_non_exhaustive_enum.stderr b/tests/ui/manual_non_exhaustive_enum.stderr index 087f766be70d..c4bd836b5d7f 100644 --- a/tests/ui/manual_non_exhaustive_enum.stderr +++ b/tests/ui/manual_non_exhaustive_enum.stderr @@ -1,4 +1,4 @@ -error: this seems like a manual implementation of the non-exhaustive pattern +warning: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_enum.rs:5:1 | LL | enum E { @@ -18,9 +18,13 @@ help: remove this variant | LL | _C, | ^^ - = note: `-D clippy::manual-non-exhaustive` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_non_exhaustive_enum.rs:2:9 + | +LL | #![warn(clippy::manual_non_exhaustive)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this seems like a manual implementation of the non-exhaustive pattern +warning: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_enum.rs:14:1 | LL | / enum Ep { @@ -37,5 +41,5 @@ help: remove this variant LL | _C, | ^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/manual_non_exhaustive_struct.stderr b/tests/ui/manual_non_exhaustive_struct.stderr index d0bed8e11211..c5c0c2f5bdb0 100644 --- a/tests/ui/manual_non_exhaustive_struct.stderr +++ b/tests/ui/manual_non_exhaustive_struct.stderr @@ -1,4 +1,4 @@ -error: this seems like a manual implementation of the non-exhaustive pattern +warning: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_struct.rs:5:5 | LL | struct S { @@ -17,9 +17,13 @@ help: remove this field | LL | _c: (), | ^^^^^^ - = note: `-D clippy::manual-non-exhaustive` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_non_exhaustive_struct.rs:1:9 + | +LL | #![warn(clippy::manual_non_exhaustive)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this seems like a manual implementation of the non-exhaustive pattern +warning: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_struct.rs:13:5 | LL | / struct Sp { @@ -35,7 +39,7 @@ help: remove this field LL | _c: (), | ^^^^^^ -error: this seems like a manual implementation of the non-exhaustive pattern +warning: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_struct.rs:54:5 | LL | struct T(pub i32, pub i32, ()); @@ -49,7 +53,7 @@ help: remove this field LL | struct T(pub i32, pub i32, ()); | ^^ -error: this seems like a manual implementation of the non-exhaustive pattern +warning: this seems like a manual implementation of the non-exhaustive pattern --> $DIR/manual_non_exhaustive_struct.rs:58:5 | LL | struct Tp(pub i32, pub i32, ()); @@ -61,5 +65,5 @@ help: remove this field LL | struct Tp(pub i32, pub i32, ()); | ^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/manual_ok_or.fixed b/tests/ui/manual_ok_or.fixed index fc8511626b3d..d8901dc3b037 100644 --- a/tests/ui/manual_ok_or.fixed +++ b/tests/ui/manual_ok_or.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_ok_or)] #![allow(clippy::or_fun_call)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/manual_ok_or.rs b/tests/ui/manual_ok_or.rs index b5303d33f5fd..7188a521357e 100644 --- a/tests/ui/manual_ok_or.rs +++ b/tests/ui/manual_ok_or.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_ok_or)] #![allow(clippy::or_fun_call)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/manual_ok_or.stderr b/tests/ui/manual_ok_or.stderr index b4a17f143e3f..e2371edf02c6 100644 --- a/tests/ui/manual_ok_or.stderr +++ b/tests/ui/manual_ok_or.stderr @@ -1,24 +1,28 @@ -error: this pattern reimplements `Option::ok_or` +warning: this pattern reimplements `Option::ok_or` --> $DIR/manual_ok_or.rs:12:5 | LL | foo.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` | - = note: `-D clippy::manual-ok-or` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_ok_or.rs:2:9 + | +LL | #![warn(clippy::manual_ok_or)] + | ^^^^^^^^^^^^^^^^^^^^ -error: this pattern reimplements `Option::ok_or` +warning: this pattern reimplements `Option::ok_or` --> $DIR/manual_ok_or.rs:15:5 | LL | foo.map_or(Err("error"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` -error: this pattern reimplements `Option::ok_or` +warning: this pattern reimplements `Option::ok_or` --> $DIR/manual_ok_or.rs:18:5 | LL | None::.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `None::.ok_or("error")` -error: this pattern reimplements `Option::ok_or` +warning: this pattern reimplements `Option::ok_or` --> $DIR/manual_ok_or.rs:22:5 | LL | / foo.map_or(Err::( @@ -37,5 +41,5 @@ LL + "{}{}{}{}{}{}{}", LL ~ "Alice", "Bob", "Sarah", "Marc", "Sandra", "Eric", "Jenifer")); | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/manual_rem_euclid.fixed b/tests/ui/manual_rem_euclid.fixed index 4cdc0546a744..76e52816e554 100644 --- a/tests/ui/manual_rem_euclid.fixed +++ b/tests/ui/manual_rem_euclid.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::manual_rem_euclid)] @@ -9,7 +9,7 @@ extern crate macro_rules; macro_rules! internal_rem_euclid { () => { let value: i32 = 5; - let _: i32 = value.rem_euclid(4); + let _: i32 = ((value % 4) + 4) % 4; }; } diff --git a/tests/ui/manual_rem_euclid.rs b/tests/ui/manual_rem_euclid.rs index 58a9e20f38b1..42b0bfaafbbc 100644 --- a/tests/ui/manual_rem_euclid.rs +++ b/tests/ui/manual_rem_euclid.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::manual_rem_euclid)] diff --git a/tests/ui/manual_rem_euclid.stderr b/tests/ui/manual_rem_euclid.stderr index e3122a588b64..94f4cd4ddd28 100644 --- a/tests/ui/manual_rem_euclid.stderr +++ b/tests/ui/manual_rem_euclid.stderr @@ -1,36 +1,40 @@ -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:19:18 | LL | let _: i32 = ((value % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` | - = note: `-D clippy::manual-rem-euclid` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_rem_euclid.rs:4:9 + | +LL | #![warn(clippy::manual_rem_euclid)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:20:18 | LL | let _: i32 = (4 + (value % 4)) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:21:18 | LL | let _: i32 = (value % 4 + 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:22:18 | LL | let _: i32 = (4 + value % 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:23:22 | LL | let _: i32 = 1 + (4 + value % 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:12:22 | LL | let _: i32 = ((value % 4) + 4) % 4; @@ -39,31 +43,31 @@ LL | let _: i32 = ((value % 4) + 4) % 4; LL | internal_rem_euclid!(); | ---------------------- in this macro invocation | - = note: this error originates in the macro `internal_rem_euclid` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `internal_rem_euclid` (in Nightly builds, run with -Z macro-backtrace for more info) -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:49:5 | LL | ((num % 4) + 4) % 4 | ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:54:5 | LL | ((num % 4) + 4) % 4 | ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:66:18 | LL | let _: i32 = ((x % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)` -error: manual `rem_euclid` implementation +warning: manual `rem_euclid` implementation --> $DIR/manual_rem_euclid.rs:79:18 | LL | let _: i32 = ((x % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/manual_retain.fixed b/tests/ui/manual_retain.fixed index 8f25fea678f1..d3cac6667630 100644 --- a/tests/ui/manual_retain.fixed +++ b/tests/ui/manual_retain.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_retain)] #![allow(unused, clippy::redundant_clone)] use std::collections::BTreeMap; diff --git a/tests/ui/manual_retain.rs b/tests/ui/manual_retain.rs index e6b3995a689b..34f0c4d5029e 100644 --- a/tests/ui/manual_retain.rs +++ b/tests/ui/manual_retain.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_retain)] #![allow(unused, clippy::redundant_clone)] use std::collections::BTreeMap; diff --git a/tests/ui/manual_retain.stderr b/tests/ui/manual_retain.stderr index 89316ce1d998..479087da3b9e 100644 --- a/tests/ui/manual_retain.stderr +++ b/tests/ui/manual_retain.stderr @@ -1,18 +1,22 @@ -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:51:5 | LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)` | - = note: `-D clippy::manual-retain` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_retain.rs:2:9 + | +LL | #![warn(clippy::manual_retain)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:52:5 | LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:53:5 | LL | / btree_map = btree_map @@ -21,37 +25,37 @@ LL | | .filter(|(k, v)| (k % 2 == 0) && (v % 2 == 0)) LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:75:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:76:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:77:5 | LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:107:5 | LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:108:5 | LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:109:5 | LL | / hash_map = hash_map @@ -60,65 +64,65 @@ LL | | .filter(|(k, v)| (k % 2 == 0) && (v % 2 == 0)) LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:130:5 | LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:131:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:132:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:161:5 | LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:173:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:174:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:175:5 | LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:197:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:198:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` -error: this expression can be written more simply using `.retain()` +warning: this expression can be written more simply using `.retain()` --> $DIR/manual_retain.rs:199:5 | LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/manual_saturating_arithmetic.fixed b/tests/ui/manual_saturating_arithmetic.fixed index c4f53c446c9f..7dd4521fa78e 100644 --- a/tests/ui/manual_saturating_arithmetic.fixed +++ b/tests/ui/manual_saturating_arithmetic.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_imports)] diff --git a/tests/ui/manual_saturating_arithmetic.rs b/tests/ui/manual_saturating_arithmetic.rs index cd83cf6e65e9..463ee0692899 100644 --- a/tests/ui/manual_saturating_arithmetic.rs +++ b/tests/ui/manual_saturating_arithmetic.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_imports)] diff --git a/tests/ui/manual_saturating_arithmetic.stderr b/tests/ui/manual_saturating_arithmetic.stderr index d985f2e754bc..25e4d5e930c3 100644 --- a/tests/ui/manual_saturating_arithmetic.stderr +++ b/tests/ui/manual_saturating_arithmetic.stderr @@ -1,24 +1,24 @@ -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:8:13 | LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u32.saturating_add(1)` | - = note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings` + = note: `#[warn(clippy::manual_saturating_arithmetic)]` on by default -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:9:13 | LL | let _ = 1u32.checked_add(1).unwrap_or(u32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u32.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:10:13 | LL | let _ = 1u8.checked_add(1).unwrap_or(255); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1u8.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:11:13 | LL | let _ = 1u128 @@ -27,49 +27,49 @@ LL | | .checked_add(1) LL | | .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455); | |_______________________________________________________________________^ help: try using `saturating_add`: `1u128.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:16:13 | LL | let _ = 1u32.checked_mul(1).unwrap_or(u32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_mul`: `1u32.saturating_mul(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:18:13 | LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1u32.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:19:13 | LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1u32.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:20:13 | LL | let _ = 1u8.checked_sub(1).unwrap_or(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1u8.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:24:13 | LL | let _ = 1i32.checked_add(1).unwrap_or(i32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:25:13 | LL | let _ = 1i32.checked_add(1).unwrap_or(i32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:26:13 | LL | let _ = 1i8.checked_add(1).unwrap_or(127); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i8.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:27:13 | LL | let _ = 1i128 @@ -78,25 +78,25 @@ LL | | .checked_add(1) LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); | |_______________________________________________________________________^ help: try using `saturating_add`: `1i128.saturating_add(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:30:13 | LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:31:13 | LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i32.saturating_add(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:32:13 | LL | let _ = 1i8.checked_add(-1).unwrap_or(-128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_add`: `1i8.saturating_add(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:33:13 | LL | let _ = 1i128 @@ -105,25 +105,25 @@ LL | | .checked_add(-1) LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); | |________________________________________________________________________^ help: try using `saturating_add`: `1i128.saturating_add(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:40:13 | LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:41:13 | LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:42:13 | LL | let _ = 1i8.checked_sub(1).unwrap_or(-128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i8.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:43:13 | LL | let _ = 1i128 @@ -132,25 +132,25 @@ LL | | .checked_sub(1) LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); | |________________________________________________________________________^ help: try using `saturating_sub`: `1i128.saturating_sub(1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:46:13 | LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:47:13 | LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i32.saturating_sub(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:48:13 | LL | let _ = 1i8.checked_sub(-1).unwrap_or(127); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `saturating_sub`: `1i8.saturating_sub(-1)` -error: manual saturating arithmetic +warning: manual saturating arithmetic --> $DIR/manual_saturating_arithmetic.rs:49:13 | LL | let _ = 1i128 @@ -159,5 +159,5 @@ LL | | .checked_sub(-1) LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); | |_______________________________________________________________________^ help: try using `saturating_sub`: `1i128.saturating_sub(-1)` -error: aborting due to 24 previous errors +warning: 24 warnings emitted diff --git a/tests/ui/manual_split_once.fixed b/tests/ui/manual_split_once.fixed index 50b02019cc27..e317c597109b 100644 --- a/tests/ui/manual_split_once.fixed +++ b/tests/ui/manual_split_once.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_split_once)] #![allow(unused, clippy::iter_skip_next, clippy::iter_nth_zero)] diff --git a/tests/ui/manual_split_once.rs b/tests/ui/manual_split_once.rs index e1e8b71a9def..7e2dc22bc466 100644 --- a/tests/ui/manual_split_once.rs +++ b/tests/ui/manual_split_once.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_split_once)] #![allow(unused, clippy::iter_skip_next, clippy::iter_nth_zero)] diff --git a/tests/ui/manual_split_once.stderr b/tests/ui/manual_split_once.stderr index 78da5a16cc52..6139a4afe430 100644 --- a/tests/ui/manual_split_once.stderr +++ b/tests/ui/manual_split_once.stderr @@ -1,84 +1,88 @@ -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:13:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1` | - = note: `-D clippy::manual-split-once` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_split_once.rs:3:9 + | +LL | #![warn(clippy::manual_split_once)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:14:13 | LL | let _ = "key=value".splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:15:18 | LL | let (_, _) = "key=value".splitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=')` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:18:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:21:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:24:13 | LL | let _ = s.splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:27:17 | LL | let _ = s.splitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=')?.1` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:28:17 | LL | let _ = s.splitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=')?.1` -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:29:17 | LL | let _ = s.rsplitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=')?.0` -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:30:17 | LL | let _ = s.rsplitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=')?.0` -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:38:13 | LL | let _ = "key=value".rsplitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".rsplit_once('=').unwrap().0` -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:39:18 | LL | let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))` -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:40:13 | LL | let _ = s.rsplitn(2, '=').nth(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=').map(|x| x.0)` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:44:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); @@ -103,7 +107,7 @@ LL - let r = iter.next().unwrap(); LL + | -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:48:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); @@ -128,7 +132,7 @@ LL - let r = iter.next()?; LL + | -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:52:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); @@ -153,7 +157,7 @@ LL - let l = iter.next().unwrap(); LL + | -error: manual implementation of `rsplit_once` +warning: manual implementation of `rsplit_once` --> $DIR/manual_split_once.rs:56:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); @@ -178,13 +182,13 @@ LL - let l = iter.next()?; LL + | -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:141:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1` -error: manual implementation of `split_once` +warning: manual implementation of `split_once` --> $DIR/manual_split_once.rs:143:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); @@ -209,5 +213,5 @@ LL - let b = iter.next().unwrap(); LL + | -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/manual_str_repeat.fixed b/tests/ui/manual_str_repeat.fixed index 3d56f2a0dedb..9468c3df9047 100644 --- a/tests/ui/manual_str_repeat.fixed +++ b/tests/ui/manual_str_repeat.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_str_repeat)] diff --git a/tests/ui/manual_str_repeat.rs b/tests/ui/manual_str_repeat.rs index e8240a949dbc..baa0a10260d4 100644 --- a/tests/ui/manual_str_repeat.rs +++ b/tests/ui/manual_str_repeat.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_str_repeat)] diff --git a/tests/ui/manual_str_repeat.stderr b/tests/ui/manual_str_repeat.stderr index bdfee7cab261..d95b120a2cc2 100644 --- a/tests/ui/manual_str_repeat.stderr +++ b/tests/ui/manual_str_repeat.stderr @@ -1,64 +1,68 @@ -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:9:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"test".repeat(10)` | - = note: `-D clippy::manual-str-repeat` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_str_repeat.rs:3:9 + | +LL | #![warn(clippy::manual_str_repeat)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:10:21 | LL | let _: String = std::iter::repeat('x').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"x".repeat(10)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:11:21 | -LL | let _: String = std::iter::repeat('/'').take(10).collect(); +LL | let _: String = std::iter::repeat('\'').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"'".repeat(10)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:12:21 | LL | let _: String = std::iter::repeat('"').take(10).collect(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"/"".repeat(10)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"\"".repeat(10)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:16:13 | LL | let _ = repeat(x).take(count + 2).collect::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count + 2)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:25:21 | LL | let _: String = repeat(*x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(*x).repeat(count)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:34:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:46:21 | LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `Cow::Borrowed("test").repeat(count)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:49:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count)` -error: manual implementation of `str::repeat` using iterators +warning: manual implementation of `str::repeat` using iterators --> $DIR/manual_str_repeat.rs:64:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"test".repeat(10)` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/manual_string_new.fixed b/tests/ui/manual_string_new.fixed index a376411bfbc8..0d1bab233046 100644 --- a/tests/ui/manual_string_new.fixed +++ b/tests/ui/manual_string_new.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_string_new)] diff --git a/tests/ui/manual_string_new.rs b/tests/ui/manual_string_new.rs index 6bfc52fb1bce..2392ebfc3229 100644 --- a/tests/ui/manual_string_new.rs +++ b/tests/ui/manual_string_new.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_string_new)] diff --git a/tests/ui/manual_string_new.stderr b/tests/ui/manual_string_new.stderr index e5ecfc61947a..fdd551f2e4cd 100644 --- a/tests/ui/manual_string_new.stderr +++ b/tests/ui/manual_string_new.stderr @@ -1,58 +1,62 @@ -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:15:13 | LL | let _ = "".to_string(); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` | - = note: `-D clippy::manual-string-new` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_string_new.rs:3:9 + | +LL | #![warn(clippy::manual_string_new)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:18:13 | LL | let _ = "".to_owned(); | ^^^^^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:21:21 | LL | let _: String = "".into(); | ^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:28:13 | LL | let _ = String::from(""); | ^^^^^^^^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:29:13 | LL | let _ = ::from(""); | ^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:34:13 | LL | let _ = String::try_from("").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:40:21 | LL | let _: String = From::from(""); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:45:21 | LL | let _: String = TryFrom::try_from("").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` -error: empty String is being created manually +warning: empty String is being created manually --> $DIR/manual_string_new.rs:48:21 | LL | let _: String = TryFrom::try_from("").expect("this should warn"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/manual_strip.stderr b/tests/ui/manual_strip.stderr index f592e898fc92..d8ba84f4e2cb 100644 --- a/tests/ui/manual_strip.stderr +++ b/tests/ui/manual_strip.stderr @@ -1,4 +1,4 @@ -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:7:24 | LL | str::to_string(&s["ab".len()..]); @@ -9,7 +9,11 @@ note: the prefix was tested here | LL | if s.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::manual-strip` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/manual_strip.rs:1:9 + | +LL | #![warn(clippy::manual_strip)] + | ^^^^^^^^^^^^^^^^^^^^ help: try using the `strip_prefix` method | LL ~ if let Some() = s.strip_prefix("ab") { @@ -20,7 +24,7 @@ LL ~ str::to_string(); LL ~ .to_string(); | -error: stripping a suffix manually +warning: stripping a suffix manually --> $DIR/manual_strip.rs:15:24 | LL | str::to_string(&s[..s.len() - "bc".len()]); @@ -41,7 +45,7 @@ LL ~ str::to_string(); LL ~ .to_string(); | -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:24:24 | LL | str::to_string(&s[1..]); @@ -59,7 +63,7 @@ LL ~ str::to_string(); LL ~ .to_string(); | -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:31:24 | LL | str::to_string(&s[prefix.len()..]); @@ -76,7 +80,7 @@ LL ~ if let Some() = s.strip_prefix(prefix) { LL ~ str::to_string(); | -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:37:24 | LL | str::to_string(&s[PREFIX.len()..]); @@ -94,7 +98,7 @@ LL ~ str::to_string(); LL ~ str::to_string(); | -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:44:24 | LL | str::to_string(&TARGET[prefix.len()..]); @@ -111,7 +115,7 @@ LL ~ if let Some() = TARGET.strip_prefix(prefix) { LL ~ str::to_string(); | -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:50:9 | LL | s1[2..].to_uppercase(); @@ -128,7 +132,7 @@ LL ~ if let Some() = s1.strip_prefix("ab") { LL ~ .to_uppercase(); | -error: stripping a prefix manually +warning: stripping a prefix manually --> $DIR/manual_strip.rs:80:9 | LL | s[1..].to_string(); @@ -145,5 +149,5 @@ LL ~ if let Some() = s.strip_prefix('a') { LL ~ .to_string(); | -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/manual_unwrap_or.fixed b/tests/ui/manual_unwrap_or.fixed index 7d68978216c9..c17634bffe30 100644 --- a/tests/ui/manual_unwrap_or.fixed +++ b/tests/ui/manual_unwrap_or.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![allow(unused_variables, clippy::unnecessary_wraps)] diff --git a/tests/ui/manual_unwrap_or.rs b/tests/ui/manual_unwrap_or.rs index b937fe6f977e..6d49a6949fa9 100644 --- a/tests/ui/manual_unwrap_or.rs +++ b/tests/ui/manual_unwrap_or.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![allow(unused_variables, clippy::unnecessary_wraps)] diff --git a/tests/ui/manual_unwrap_or.stderr b/tests/ui/manual_unwrap_or.stderr index 0e4cb798d455..232b99b90a63 100644 --- a/tests/ui/manual_unwrap_or.stderr +++ b/tests/ui/manual_unwrap_or.stderr @@ -1,4 +1,4 @@ -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:7:5 | LL | / match Some(1) { @@ -7,9 +7,9 @@ LL | | None => 42, LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(42)` | - = note: `-D clippy::manual-unwrap-or` implied by `-D warnings` + = note: `#[warn(clippy::manual_unwrap_or)]` on by default -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:13:5 | LL | / match Some(1) { @@ -18,7 +18,7 @@ LL | | Some(i) => i, LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(42)` -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:19:5 | LL | / match Some(1) { @@ -27,7 +27,7 @@ LL | | None => 1 + 42, LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(1 + 42)` -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:26:5 | LL | / match Some(1) { @@ -48,7 +48,7 @@ LL + + 42 + 42 + 42 LL ~ }); | -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:36:5 | LL | / match Some("Bob") { @@ -57,7 +57,7 @@ LL | | None => "Alice", LL | | }; | |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")` -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:86:5 | LL | / match Ok::(1) { @@ -66,7 +66,7 @@ LL | | Err(_) => 42, LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(42)` -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:93:5 | LL | / match a { @@ -75,7 +75,7 @@ LL | | Err(_) => 42, LL | | }; | |_____^ help: replace with: `a.unwrap_or(42)` -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:99:5 | LL | / match Ok(1) as Result { @@ -84,7 +84,7 @@ LL | | Err(_) => 42, LL | | }; | |_____^ help: replace with: `(Ok(1) as Result).unwrap_or(42)` -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:112:5 | LL | / match s.method() { @@ -93,7 +93,7 @@ LL | | None => 42, LL | | }; | |_____^ help: replace with: `s.method().unwrap_or(42)` -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:118:5 | LL | / match Ok::(1) { @@ -102,7 +102,7 @@ LL | | Ok(i) => i, LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(42)` -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:124:5 | LL | / match Ok::(1) { @@ -111,7 +111,7 @@ LL | | Err(_) => 1 + 42, LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(1 + 42)` -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:131:5 | LL | / match Ok::(1) { @@ -132,7 +132,7 @@ LL + + 42 + 42 + 42 LL ~ }); | -error: this pattern reimplements `Result::unwrap_or` +warning: this pattern reimplements `Result::unwrap_or` --> $DIR/manual_unwrap_or.rs:141:5 | LL | / match Ok::<&str, &str>("Bob") { @@ -141,7 +141,7 @@ LL | | Err(_) => "Alice", LL | | }; | |_____^ help: replace with: `Ok::<&str, &str>("Bob").unwrap_or("Alice")` -error: this pattern reimplements `Option::unwrap_or` +warning: this pattern reimplements `Option::unwrap_or` --> $DIR/manual_unwrap_or.rs:201:17 | LL | let _ = match some_macro!() { @@ -151,5 +151,5 @@ LL | | None => 0, LL | | }; | |_________^ help: replace with: `some_macro!().unwrap_or(0)` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/many_single_char_names.stderr b/tests/ui/many_single_char_names.stderr index ade0f84bc506..e5370e0b4871 100644 --- a/tests/ui/many_single_char_names.stderr +++ b/tests/ui/many_single_char_names.stderr @@ -1,4 +1,4 @@ -error: 5 bindings with single-character names in scope +warning: 5 bindings with single-character names in scope --> $DIR/many_single_char_names.rs:5:9 | LL | let a: i32; @@ -9,9 +9,13 @@ LL | let (b, c, d): (i32, i64, i16); LL | let e: i32; | ^ | - = note: `-D clippy::many-single-char-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/many_single_char_names.rs:2:9 + | +LL | #![warn(clippy::many_single_char_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: 6 bindings with single-character names in scope +warning: 6 bindings with single-character names in scope --> $DIR/many_single_char_names.rs:5:9 | LL | let a: i32; @@ -24,7 +28,7 @@ LL | let e: i32; LL | let f: i32; | ^ -error: 5 bindings with single-character names in scope +warning: 5 bindings with single-character names in scope --> $DIR/many_single_char_names.rs:5:9 | LL | let a: i32; @@ -35,17 +39,17 @@ LL | let (b, c, d): (i32, i64, i16); LL | e => panic!(), | ^ -error: 8 bindings with single-character names in scope +warning: 8 bindings with single-character names in scope --> $DIR/many_single_char_names.rs:30:13 | LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} | ^ ^ ^ ^ ^ ^ ^ ^ -error: 8 bindings with single-character names in scope +warning: 8 bindings with single-character names in scope --> $DIR/many_single_char_names.rs:33:10 | LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!(); | ^ ^ ^ ^ ^ ^ ^ ^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/map_clone.fixed b/tests/ui/map_clone.fixed index 0860dcf8e0dd..d7474f357191 100644 --- a/tests/ui/map_clone.fixed +++ b/tests/ui/map_clone.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_clone)] #![allow( clippy::clone_on_copy, diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index b6987336834b..74978ae8006d 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_clone)] #![allow( clippy::clone_on_copy, diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index d84a5bf8d4de..f895af01f1c4 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,40 +1,44 @@ -error: you are using an explicit closure for copying elements +warning: you are using an explicit closure for copying elements --> $DIR/map_clone.rs:11:22 | LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()` | - = note: `-D clippy::map-clone` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_clone.rs:2:9 + | +LL | #![warn(clippy::map_clone)] + | ^^^^^^^^^^^^^^^^^ -error: you are using an explicit closure for cloning elements +warning: you are using an explicit closure for cloning elements --> $DIR/map_clone.rs:12:26 | LL | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()` -error: you are using an explicit closure for copying elements +warning: you are using an explicit closure for copying elements --> $DIR/map_clone.rs:13:23 | LL | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()` -error: you are using an explicit closure for copying elements +warning: you are using an explicit closure for copying elements --> $DIR/map_clone.rs:15:26 | LL | let _: Option = Some(&16).map(|b| *b); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()` -error: you are using an explicit closure for copying elements +warning: you are using an explicit closure for copying elements --> $DIR/map_clone.rs:16:25 | LL | let _: Option = Some(&1).map(|x| x.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&1).copied()` -error: you are needlessly cloning iterator elements +warning: you are needlessly cloning iterator elements --> $DIR/map_clone.rs:27:29 | LL | let _ = std::env::args().map(|v| v.clone()); | ^^^^^^^^^^^^^^^^^^^ help: remove the `map` call -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/map_collect_result_unit.fixed b/tests/ui/map_collect_result_unit.fixed index e66c9cc24207..b00c2cf284ec 100644 --- a/tests/ui/map_collect_result_unit.fixed +++ b/tests/ui/map_collect_result_unit.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_collect_result_unit)] fn main() { diff --git a/tests/ui/map_collect_result_unit.rs b/tests/ui/map_collect_result_unit.rs index 6f08f4c3c535..ad2198ec1fe7 100644 --- a/tests/ui/map_collect_result_unit.rs +++ b/tests/ui/map_collect_result_unit.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_collect_result_unit)] fn main() { diff --git a/tests/ui/map_collect_result_unit.stderr b/tests/ui/map_collect_result_unit.stderr index 8b06e13baa6b..7241b1345193 100644 --- a/tests/ui/map_collect_result_unit.stderr +++ b/tests/ui/map_collect_result_unit.stderr @@ -1,16 +1,20 @@ -error: `.map().collect()` can be replaced with `.try_for_each()` +warning: `.map().collect()` can be replaced with `.try_for_each()` --> $DIR/map_collect_result_unit.rs:6:17 | LL | let _ = (0..3).map(|t| Err(t + 1)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(0..3).try_for_each(|t| Err(t + 1))` | - = note: `-D clippy::map-collect-result-unit` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_collect_result_unit.rs:2:9 + | +LL | #![warn(clippy::map_collect_result_unit)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `.map().collect()` can be replaced with `.try_for_each()` +warning: `.map().collect()` can be replaced with `.try_for_each()` --> $DIR/map_collect_result_unit.rs:7:32 | LL | let _: Result<(), _> = (0..3).map(|t| Err(t + 1)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(0..3).try_for_each(|t| Err(t + 1))` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/map_err.stderr b/tests/ui/map_err.stderr index d44403a84a56..3990329cdb4d 100644 --- a/tests/ui/map_err.stderr +++ b/tests/ui/map_err.stderr @@ -1,11 +1,15 @@ -error: `map_err(|_|...` wildcard pattern discards the original error +warning: `map_err(|_|...` wildcard pattern discards the original error --> $DIR/map_err.rs:22:32 | LL | println!("{:?}", x.map_err(|_| Errors::Ignored)); | ^^^ | = help: consider storing the original error as a source in the new error, or silence this warning using an ignored identifier (`.map_err(|_foo| ...`) - = note: `-D clippy::map-err-ignore` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_err.rs:1:9 + | +LL | #![warn(clippy::map_err_ignore)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index 4b2630d68584..fa8b634eff6b 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -1,4 +1,4 @@ -error: called `map(..).flatten()` on `Option` +warning: called `map(..).flatten()` on `Option` --> $DIR/map_flatten.rs:8:10 | LL | .map(|x| { @@ -11,7 +11,11 @@ LL | | }) LL | | .flatten(); | |__________________^ | - = note: `-D clippy::map-flatten` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_flatten.rs:1:9 + | +LL | #![warn(clippy::map_flatten)] + | ^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()` | LL ~ .and_then(|x| { @@ -23,7 +27,7 @@ LL + } LL ~ }); | -error: called `map(..).flatten()` on `Result` +warning: called `map(..).flatten()` on `Result` --> $DIR/map_flatten.rs:18:10 | LL | .map(|x| { @@ -47,7 +51,7 @@ LL + } LL ~ }); | -error: called `map(..).flatten()` on `Result` +warning: called `map(..).flatten()` on `Result` --> $DIR/map_flatten.rs:30:10 | LL | .map(|res| { @@ -72,7 +76,7 @@ LL + } LL ~ }); | -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten.rs:42:10 | LL | .map(|some_value| { @@ -96,5 +100,5 @@ LL + } LL + }) | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/map_flatten_fixable.fixed b/tests/ui/map_flatten_fixable.fixed index 8e2f11389f89..14816de1a636 100644 --- a/tests/ui/map_flatten_fixable.fixed +++ b/tests/ui/map_flatten_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::let_underscore_untyped)] diff --git a/tests/ui/map_flatten_fixable.rs b/tests/ui/map_flatten_fixable.rs index a783a99c4ffd..f38a00a59fac 100644 --- a/tests/ui/map_flatten_fixable.rs +++ b/tests/ui/map_flatten_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::let_underscore_untyped)] diff --git a/tests/ui/map_flatten_fixable.stderr b/tests/ui/map_flatten_fixable.stderr index c91f0b9ae94f..7ad0db3858a0 100644 --- a/tests/ui/map_flatten_fixable.stderr +++ b/tests/ui/map_flatten_fixable.stderr @@ -1,48 +1,53 @@ -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:18:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)` | - = note: `-D clippy::map-flatten` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_flatten_fixable.rs:3:9 + | +LL | #![warn(clippy::all, clippy::pedantic)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::map_flatten)]` implied by `#[warn(clippy::all)]` -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:19:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)` -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:20:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)` -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:21:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))` -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:24:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)` -error: called `map(..).flatten()` on `Option` +warning: called `map(..).flatten()` on `Option` --> $DIR/map_flatten_fixable.rs:27:40 | LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` -error: called `map(..).flatten()` on `Result` +warning: called `map(..).flatten()` on `Result` --> $DIR/map_flatten_fixable.rs:30:42 | LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` -error: called `map(..).flatten()` on `Iterator` +warning: called `map(..).flatten()` on `Iterator` --> $DIR/map_flatten_fixable.rs:39:10 | LL | .map(|n| match n { @@ -71,7 +76,7 @@ LL + n => [n], LL ~ }); | -error: called `map(..).flatten()` on `Option` +warning: called `map(..).flatten()` on `Option` --> $DIR/map_flatten_fixable.rs:59:10 | LL | .map(|_| { @@ -95,5 +100,5 @@ LL + // whitespace beforehand is important as well LL ~ }); | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/map_identity.fixed b/tests/ui/map_identity.fixed index 2256e51f2d09..7fb7d8c12188 100644 --- a/tests/ui/map_identity.fixed +++ b/tests/ui/map_identity.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_identity)] #![allow(clippy::needless_return)] diff --git a/tests/ui/map_identity.rs b/tests/ui/map_identity.rs index ccfdc9ea76d5..7891c2426283 100644 --- a/tests/ui/map_identity.rs +++ b/tests/ui/map_identity.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::map_identity)] #![allow(clippy::needless_return)] diff --git a/tests/ui/map_identity.stderr b/tests/ui/map_identity.stderr index b6a77281f6de..06aef26d6afd 100644 --- a/tests/ui/map_identity.stderr +++ b/tests/ui/map_identity.stderr @@ -1,30 +1,34 @@ -error: unnecessary map of the identity function +warning: unnecessary map of the identity function --> $DIR/map_identity.rs:8:47 | LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect(); | ^^^^^^^^^^^^^^^^^^ help: remove the call to `map` | - = note: `-D clippy::map-identity` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_identity.rs:2:9 + | +LL | #![warn(clippy::map_identity)] + | ^^^^^^^^^^^^^^^^^^^^ -error: unnecessary map of the identity function +warning: unnecessary map of the identity function --> $DIR/map_identity.rs:9:57 | LL | let _: Vec<_> = x.iter().map(std::convert::identity).map(|y| y).collect(); | ^^^^^^^^^^^ help: remove the call to `map` -error: unnecessary map of the identity function +warning: unnecessary map of the identity function --> $DIR/map_identity.rs:9:29 | LL | let _: Vec<_> = x.iter().map(std::convert::identity).map(|y| y).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` -error: unnecessary map of the identity function +warning: unnecessary map of the identity function --> $DIR/map_identity.rs:10:32 | LL | let _: Option = Some(3).map(|x| x); | ^^^^^^^^^^^ help: remove the call to `map` -error: unnecessary map of the identity function +warning: unnecessary map of the identity function --> $DIR/map_identity.rs:11:36 | LL | let _: Result = Ok(-3).map(|x| { @@ -33,11 +37,11 @@ LL | | return x; LL | | }); | |______^ help: remove the call to `map` -error: unnecessary map of the identity function +warning: unnecessary map of the identity function --> $DIR/map_identity.rs:21:36 | LL | let _: Result = Ok(1).map_err(|a| a); | ^^^^^^^^^^^^^^^ help: remove the call to `map_err` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/map_unwrap_or.rs b/tests/ui/map_unwrap_or.rs index 32631024ca5d..cb25d8567aa0 100644 --- a/tests/ui/map_unwrap_or.rs +++ b/tests/ui/map_unwrap_or.rs @@ -1,4 +1,4 @@ -// aux-build:option_helpers.rs +//@aux-build:option_helpers.rs #![warn(clippy::map_unwrap_or)] #![allow(clippy::uninlined_format_args, clippy::unnecessary_lazy_evaluations)] diff --git a/tests/ui/map_unwrap_or.stderr b/tests/ui/map_unwrap_or.stderr index 41781b050fa2..5d365bebe443 100644 --- a/tests/ui/map_unwrap_or.stderr +++ b/tests/ui/map_unwrap_or.stderr @@ -1,4 +1,4 @@ -error: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead +warning: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead --> $DIR/map_unwrap_or.rs:17:13 | LL | let _ = opt.map(|x| x + 1) @@ -7,14 +7,18 @@ LL | | // Should lint even though this call is on a separate line. LL | | .unwrap_or(0); | |_____________________^ | - = note: `-D clippy::map-unwrap-or` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_unwrap_or.rs:3:9 + | +LL | #![warn(clippy::map_unwrap_or)] + | ^^^^^^^^^^^^^^^^^^^^^ help: use `map_or(, )` instead | LL - let _ = opt.map(|x| x + 1) LL + let _ = opt.map_or(0, |x| x + 1); | -error: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead +warning: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead --> $DIR/map_unwrap_or.rs:21:13 | LL | let _ = opt.map(|x| { @@ -32,7 +36,7 @@ LL | } LL ~ ); | -error: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead +warning: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead --> $DIR/map_unwrap_or.rs:25:13 | LL | let _ = opt.map(|x| x + 1) @@ -49,7 +53,7 @@ LL + 0 LL ~ }, |x| x + 1); | -error: called `map().unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then()` instead +warning: called `map().unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then()` instead --> $DIR/map_unwrap_or.rs:30:13 | LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); @@ -61,7 +65,7 @@ LL - let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); LL + let _ = opt.and_then(|x| Some(x + 1)); | -error: called `map().unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then()` instead +warning: called `map().unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then()` instead --> $DIR/map_unwrap_or.rs:32:13 | LL | let _ = opt.map(|x| { @@ -79,7 +83,7 @@ LL | } LL ~ ); | -error: called `map().unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then()` instead +warning: called `map().unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then()` instead --> $DIR/map_unwrap_or.rs:36:13 | LL | let _ = opt @@ -94,7 +98,7 @@ LL - .map(|x| Some(x + 1)) LL + .and_then(|x| Some(x + 1)); | -error: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead +warning: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead --> $DIR/map_unwrap_or.rs:47:13 | LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id); @@ -106,7 +110,7 @@ LL - let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id); LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p)); | -error: called `map().unwrap_or_else()` on an `Option` value. This can be done more directly by calling `map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on an `Option` value. This can be done more directly by calling `map_or_else(, )` instead --> $DIR/map_unwrap_or.rs:51:13 | LL | let _ = opt.map(|x| { @@ -116,7 +120,7 @@ LL | | } LL | | ).unwrap_or_else(|| 0); | |__________________________^ -error: called `map().unwrap_or_else()` on an `Option` value. This can be done more directly by calling `map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on an `Option` value. This can be done more directly by calling `map_or_else(, )` instead --> $DIR/map_unwrap_or.rs:55:13 | LL | let _ = opt.map(|x| x + 1) @@ -126,7 +130,7 @@ LL | | 0 LL | | ); | |_________^ -error: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead --> $DIR/map_unwrap_or.rs:67:13 | LL | let _ = res.map(|x| { @@ -136,7 +140,7 @@ LL | | } LL | | ).unwrap_or_else(|_e| 0); | |____________________________^ -error: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead --> $DIR/map_unwrap_or.rs:71:13 | LL | let _ = res.map(|x| x + 1) @@ -146,11 +150,11 @@ LL | | 0 LL | | }); | |__________^ -error: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead --> $DIR/map_unwrap_or.rs:95:13 | LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `res.map_or_else(|_e| 0, |x| x + 1)` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/map_unwrap_or_fixable.fixed b/tests/ui/map_unwrap_or_fixable.fixed index bd5b4f7165a4..ea5b6a6691e5 100644 --- a/tests/ui/map_unwrap_or_fixable.fixed +++ b/tests/ui/map_unwrap_or_fixable.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:option_helpers.rs +//@run-rustfix +//@aux-build:option_helpers.rs #![warn(clippy::map_unwrap_or)] diff --git a/tests/ui/map_unwrap_or_fixable.rs b/tests/ui/map_unwrap_or_fixable.rs index 0b892caf20e8..f8bb9d8ca6a3 100644 --- a/tests/ui/map_unwrap_or_fixable.rs +++ b/tests/ui/map_unwrap_or_fixable.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:option_helpers.rs +//@run-rustfix +//@aux-build:option_helpers.rs #![warn(clippy::map_unwrap_or)] diff --git a/tests/ui/map_unwrap_or_fixable.stderr b/tests/ui/map_unwrap_or_fixable.stderr index 1837bc2ca3b8..6ce4ef765e29 100644 --- a/tests/ui/map_unwrap_or_fixable.stderr +++ b/tests/ui/map_unwrap_or_fixable.stderr @@ -1,4 +1,4 @@ -error: called `map().unwrap_or_else()` on an `Option` value. This can be done more directly by calling `map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on an `Option` value. This can be done more directly by calling `map_or_else(, )` instead --> $DIR/map_unwrap_or_fixable.rs:17:13 | LL | let _ = opt.map(|x| x + 1) @@ -7,9 +7,13 @@ LL | | // Should lint even though this call is on a separate line. LL | | .unwrap_or_else(|| 0); | |_____________________________^ help: try this: `opt.map_or_else(|| 0, |x| x + 1)` | - = note: `-D clippy::map-unwrap-or` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/map_unwrap_or_fixable.rs:4:9 + | +LL | #![warn(clippy::map_unwrap_or)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead +warning: called `map().unwrap_or_else()` on a `Result` value. This can be done more directly by calling `.map_or_else(, )` instead --> $DIR/map_unwrap_or_fixable.rs:47:13 | LL | let _ = res.map(|x| x + 1) @@ -18,5 +22,5 @@ LL | | // should lint even though this call is on a separate line LL | | .unwrap_or_else(|_e| 0); | |_______________________________^ help: try this: `res.map_or_else(|_e| 0, |x| x + 1)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/match_as_ref.fixed b/tests/ui/match_as_ref.fixed index ddfa1e741ada..8fa3f5325871 100644 --- a/tests/ui/match_as_ref.fixed +++ b/tests/ui/match_as_ref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::match_as_ref)] diff --git a/tests/ui/match_as_ref.rs b/tests/ui/match_as_ref.rs index 025d475ae13d..02a17791426c 100644 --- a/tests/ui/match_as_ref.rs +++ b/tests/ui/match_as_ref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::match_as_ref)] diff --git a/tests/ui/match_as_ref.stderr b/tests/ui/match_as_ref.stderr index c3b62849cb33..c6f0c739941c 100644 --- a/tests/ui/match_as_ref.stderr +++ b/tests/ui/match_as_ref.stderr @@ -1,4 +1,4 @@ -error: use `as_ref()` instead +warning: use `as_ref()` instead --> $DIR/match_as_ref.rs:8:33 | LL | let borrowed: Option<&()> = match owned { @@ -8,9 +8,13 @@ LL | | Some(ref v) => Some(v), LL | | }; | |_____^ help: try this: `owned.as_ref()` | - = note: `-D clippy::match-as-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_as_ref.rs:4:9 + | +LL | #![warn(clippy::match_as_ref)] + | ^^^^^^^^^^^^^^^^^^^^ -error: use `as_mut()` instead +warning: use `as_mut()` instead --> $DIR/match_as_ref.rs:14:39 | LL | let borrow_mut: Option<&mut ()> = match mut_owned { @@ -20,7 +24,7 @@ LL | | Some(ref mut v) => Some(v), LL | | }; | |_____^ help: try this: `mut_owned.as_mut()` -error: use `as_ref()` instead +warning: use `as_ref()` instead --> $DIR/match_as_ref.rs:30:13 | LL | / match self.source { @@ -29,5 +33,5 @@ LL | | None => None, LL | | } | |_____________^ help: try this: `self.source.as_ref().map(|x| x as _)` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/match_bool.rs b/tests/ui/match_bool.rs index bcc999a49428..96482cab59fc 100644 --- a/tests/ui/match_bool.rs +++ b/tests/ui/match_bool.rs @@ -1,4 +1,4 @@ -#![deny(clippy::match_bool)] +#![warn(clippy::match_bool)] fn match_bool() { let test: bool = true; @@ -29,6 +29,7 @@ fn match_bool() { }; match test && test { + //~^ ERROR: equal expressions as operands to `&&` false => { println!("Noooo!"); }, diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index 3fd0468e51de..6ab7ec08997e 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -1,12 +1,12 @@ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/match_bool.rs:31:11 | LL | match test && test { | ^^^^^^^^^^^^ help: try: `test` | - = note: `-D clippy::nonminimal-bool` implied by `-D warnings` + = note: `#[warn(clippy::nonminimal_bool)]` on by default -error: you seem to be trying to match on a boolean expression +warning: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:6:5 | LL | / match test { @@ -18,10 +18,10 @@ LL | | }; note: the lint level is defined here --> $DIR/match_bool.rs:1:9 | -LL | #![deny(clippy::match_bool)] +LL | #![warn(clippy::match_bool)] | ^^^^^^^^^^^^^^^^^^ -error: you seem to be trying to match on a boolean expression +warning: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:12:5 | LL | / match option == 1 { @@ -30,7 +30,7 @@ LL | | false => 0, LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if option == 1 { 1 } else { 0 }` -error: you seem to be trying to match on a boolean expression +warning: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:17:5 | LL | / match test { @@ -48,7 +48,7 @@ LL + println!("Noooo!"); LL ~ }; | -error: you seem to be trying to match on a boolean expression +warning: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:24:5 | LL | / match test { @@ -66,10 +66,11 @@ LL + println!("Noooo!"); LL ~ }; | -error: you seem to be trying to match on a boolean expression +warning: you seem to be trying to match on a boolean expression --> $DIR/match_bool.rs:31:5 | LL | / match test && test { +LL | | LL | | false => { LL | | println!("Noooo!"); LL | | }, @@ -92,8 +93,8 @@ LL | match test && test { | = note: `#[deny(clippy::eq_op)]` on by default -error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:38:5 +warning: you seem to be trying to match on a boolean expression + --> $DIR/match_bool.rs:39:5 | LL | / match test { LL | | false => { @@ -113,5 +114,5 @@ LL + println!("Noooo!"); LL ~ }; | -error: aborting due to 8 previous errors +error: aborting due to previous error; 7 warnings emitted diff --git a/tests/ui/match_expr_like_matches_macro.fixed b/tests/ui/match_expr_like_matches_macro.fixed index 55cd15bd5c38..afdf1069f5e4 100644 --- a/tests/ui/match_expr_like_matches_macro.fixed +++ b/tests/ui/match_expr_like_matches_macro.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_like_matches_macro)] #![allow( @@ -12,19 +12,31 @@ fn main() { let x = Some(5); // Lint - let _y = matches!(x, Some(0)); + let _y = match x { + Some(0) => true, + _ => false, + }; // Lint - let _w = matches!(x, Some(_)); + let _w = match x { + Some(_) => true, + _ => false, + }; // Turn into is_none - let _z = x.is_none(); + let _z = match x { + Some(_) => false, + None => true, + }; // Lint - let _zz = !matches!(x, Some(r) if r == 0); + let _zz = match x { + Some(r) if r == 0 => false, + _ => true, + }; // Lint - let _zzz = matches!(x, Some(5)); + let _zzz = if let Some(5) = x { true } else { false }; // No lint let _a = match x { @@ -48,17 +60,31 @@ fn main() { let x = E::A(2); { // lint - let _ans = matches!(x, E::A(_) | E::B(_)); + let _ans = match x { + E::A(_) => true, + E::B(_) => true, + _ => false, + }; } { // lint // skip rustfmt to prevent removing block for first pattern #[rustfmt::skip] - let _ans = matches!(x, E::A(_) | E::B(_)); + let _ans = match x { + E::A(_) => { + true + } + E::B(_) => true, + _ => false, + }; } { // lint - let _ans = !matches!(x, E::B(_) | E::C); + let _ans = match x { + E::B(_) => false, + E::C => false, + _ => true, + }; } { // no lint @@ -114,13 +140,19 @@ fn main() { { // should print "z" in suggestion (#6503) let z = &Some(3); - let _z = matches!(z, Some(3)); + let _z = match &z { + Some(3) => true, + _ => false, + }; } { // this could also print "z" in suggestion..? let z = Some(3); - let _z = matches!(&z, Some(3)); + let _z = match &z { + Some(3) => true, + _ => false, + }; } { @@ -134,7 +166,10 @@ fn main() { fn main() { let z = AnEnum::X; // we can't remove the reference here! - let _ = matches!(&z, AnEnum::X); + let _ = match &z { + AnEnum::X => true, + _ => false, + }; foo(z); } } @@ -145,7 +180,10 @@ fn main() { fn fun(_val: Option) {} let val = Some(S(42)); // we need the reference here because later val is consumed by fun() - let _res = matches!(&val, &Some(ref _a)); + let _res = match &val { + &Some(ref _a) => true, + _ => false, + }; fun(val); } @@ -154,7 +192,10 @@ fn main() { fn fun(_val: Option) {} let val = Some(S(42)); - let _res = matches!(&val, &Some(ref _a)); + let _res = match &val { + &Some(ref _a) => true, + _ => false, + }; fun(val); } @@ -209,5 +250,8 @@ fn msrv_1_41() { #[clippy::msrv = "1.42"] fn msrv_1_42() { - let _y = matches!(Some(5), Some(0)); + let _y = match Some(5) { + Some(0) => true, + _ => false, + }; } diff --git a/tests/ui/match_expr_like_matches_macro.rs b/tests/ui/match_expr_like_matches_macro.rs index 5d645e108e51..afdf1069f5e4 100644 --- a/tests/ui/match_expr_like_matches_macro.rs +++ b/tests/ui/match_expr_like_matches_macro.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_like_matches_macro)] #![allow( diff --git a/tests/ui/match_expr_like_matches_macro.stderr b/tests/ui/match_expr_like_matches_macro.stderr index 46f67ef4900f..bedf5b15b7c5 100644 --- a/tests/ui/match_expr_like_matches_macro.stderr +++ b/tests/ui/match_expr_like_matches_macro.stderr @@ -1,4 +1,4 @@ -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:15:14 | LL | let _y = match x { @@ -8,9 +8,13 @@ LL | | _ => false, LL | | }; | |_____^ help: try this: `matches!(x, Some(0))` | - = note: `-D clippy::match-like-matches-macro` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_expr_like_matches_macro.rs:3:9 + | +LL | #![warn(clippy::match_like_matches_macro)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:21:14 | LL | let _w = match x { @@ -20,7 +24,7 @@ LL | | _ => false, LL | | }; | |_____^ help: try this: `matches!(x, Some(_))` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/match_expr_like_matches_macro.rs:27:14 | LL | let _z = match x { @@ -30,9 +34,9 @@ LL | | None => true, LL | | }; | |_____^ help: try this: `x.is_none()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = note: `#[warn(clippy::redundant_pattern_matching)]` on by default -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:33:15 | LL | let _zz = match x { @@ -42,13 +46,13 @@ LL | | _ => true, LL | | }; | |_____^ help: try this: `!matches!(x, Some(r) if r == 0)` -error: if let .. else expression looks like `matches!` macro +warning: if let .. else expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:39:16 | LL | let _zzz = if let Some(5) = x { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `matches!(x, Some(5))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:63:20 | LL | let _ans = match x { @@ -59,7 +63,7 @@ LL | | _ => false, LL | | }; | |_________^ help: try this: `matches!(x, E::A(_) | E::B(_))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:73:20 | LL | let _ans = match x { @@ -72,7 +76,7 @@ LL | | _ => false, LL | | }; | |_________^ help: try this: `matches!(x, E::A(_) | E::B(_))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:83:20 | LL | let _ans = match x { @@ -83,7 +87,7 @@ LL | | _ => true, LL | | }; | |_________^ help: try this: `!matches!(x, E::B(_) | E::C)` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:143:18 | LL | let _z = match &z { @@ -93,7 +97,7 @@ LL | | _ => false, LL | | }; | |_________^ help: try this: `matches!(z, Some(3))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:152:18 | LL | let _z = match &z { @@ -103,7 +107,7 @@ LL | | _ => false, LL | | }; | |_________^ help: try this: `matches!(&z, Some(3))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:169:21 | LL | let _ = match &z { @@ -113,7 +117,7 @@ LL | | _ => false, LL | | }; | |_____________^ help: try this: `matches!(&z, AnEnum::X)` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:183:20 | LL | let _res = match &val { @@ -123,7 +127,7 @@ LL | | _ => false, LL | | }; | |_________^ help: try this: `matches!(&val, &Some(ref _a))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:195:20 | LL | let _res = match &val { @@ -133,7 +137,7 @@ LL | | _ => false, LL | | }; | |_________^ help: try this: `matches!(&val, &Some(ref _a))` -error: match expression looks like `matches!` macro +warning: match expression looks like `matches!` macro --> $DIR/match_expr_like_matches_macro.rs:253:14 | LL | let _y = match Some(5) { @@ -143,5 +147,5 @@ LL | | _ => false, LL | | }; | |_____^ help: try this: `matches!(Some(5), Some(0))` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/match_on_vec_items.stderr b/tests/ui/match_on_vec_items.stderr index 49446d715abe..61f5a860ebf0 100644 --- a/tests/ui/match_on_vec_items.stderr +++ b/tests/ui/match_on_vec_items.stderr @@ -1,52 +1,56 @@ -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:9:11 | LL | match arr[idx] { | ^^^^^^^^ help: try this: `arr.get(idx)` | - = note: `-D clippy::match-on-vec-items` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_on_vec_items.rs:1:9 + | +LL | #![warn(clippy::match_on_vec_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:16:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try this: `arr.get(range)` -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:29:11 | LL | match arr[idx] { | ^^^^^^^^ help: try this: `arr.get(idx)` -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:36:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try this: `arr.get(range)` -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:49:11 | LL | match arr[idx] { | ^^^^^^^^ help: try this: `arr.get(idx)` -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:56:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try this: `arr.get(range)` -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:69:11 | LL | match arr[idx] { | ^^^^^^^^ help: try this: `arr.get(idx)` -error: indexing into a vector may panic +warning: indexing into a vector may panic --> $DIR/match_on_vec_items.rs:76:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try this: `arr.get(range)` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index b98d4799e42c..ce227abe9e0b 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -1,4 +1,4 @@ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:12:9 | LL | 0..=10 => println!("0..=10"), @@ -9,9 +9,13 @@ note: overlaps with this | LL | 0..=11 => println!("0..=11"), | ^^^^^^ - = note: `-D clippy::match-overlapping-arm` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_overlapping_arm.rs:2:9 + | +LL | #![warn(clippy::match_overlapping_arm)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:18:9 | LL | 0..=5 => println!("0..=5"), @@ -23,7 +27,7 @@ note: overlaps with this LL | FOO..=11 => println!("FOO..=11"), | ^^^^^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:55:9 | LL | 0..11 => println!("0..11"), @@ -35,7 +39,7 @@ note: overlaps with this LL | 0..=11 => println!("0..=11"), | ^^^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:80:9 | LL | 0..=10 => println!("0..=10"), @@ -47,7 +51,7 @@ note: overlaps with this LL | 5..14 => println!("5..14"), | ^^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:85:9 | LL | 0..7 => println!("0..7"), @@ -59,7 +63,7 @@ note: overlaps with this LL | 0..=10 => println!("0..=10"), | ^^^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:97:9 | LL | ..=23 => println!("..=23"), @@ -71,7 +75,7 @@ note: overlaps with this LL | ..26 => println!("..26"), | ^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:106:9 | LL | 21..=30 => (), @@ -83,7 +87,7 @@ note: overlaps with this LL | 21..=40 => (), | ^^^^^^^ -error: some ranges overlap +warning: some ranges overlap --> $DIR/match_overlapping_arm.rs:120:9 | LL | 0..=0x0000_0000_0000_00ff => (), @@ -95,5 +99,5 @@ note: overlaps with this LL | 0..=0x0000_0000_0000_ffff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/match_ref_pats.fixed b/tests/ui/match_ref_pats.fixed index cf37fc6dc90a..5ed9c69a09a2 100644 --- a/tests/ui/match_ref_pats.fixed +++ b/tests/ui/match_ref_pats.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_ref_pats)] #![allow(dead_code, unused_variables)] #![allow(clippy::enum_variant_names, clippy::equatable_if_let, clippy::uninlined_format_args)] @@ -6,9 +6,9 @@ fn ref_pats() { { let v = &Some(0); - match *v { - Some(v) => println!("{:?}", v), - None => println!("none"), + match v { + &Some(v) => println!("{:?}", v), + &None => println!("none"), } match v { // This doesn't trigger; we have a different pattern. @@ -23,9 +23,9 @@ fn ref_pats() { } // Special case: using `&` both in expr and pats. let w = Some(0); - match w { - Some(v) => println!("{:?}", v), - None => println!("none"), + match &w { + &Some(v) => println!("{:?}", v), + &None => println!("none"), } // False positive: only wildcard pattern. let w = Some(0); @@ -100,10 +100,10 @@ mod issue_7740 { fn issue_7740() { // Issue #7740 - match *foobar_variant!(0) { - FooBar::Foo => println!("Foo"), - FooBar::Bar => println!("Bar"), - FooBar::FooBar => println!("FooBar"), + match foobar_variant!(0) { + &FooBar::Foo => println!("Foo"), + &FooBar::Bar => println!("Bar"), + &FooBar::FooBar => println!("FooBar"), _ => println!("Wild"), } diff --git a/tests/ui/match_ref_pats.rs b/tests/ui/match_ref_pats.rs index 3220b97d1b51..d29ddacc04ad 100644 --- a/tests/ui/match_ref_pats.rs +++ b/tests/ui/match_ref_pats.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_ref_pats)] #![allow(dead_code, unused_variables)] #![allow(clippy::enum_variant_names, clippy::equatable_if_let, clippy::uninlined_format_args)] diff --git a/tests/ui/match_ref_pats.stderr b/tests/ui/match_ref_pats.stderr index 7d9646c842ee..fef3e42842b8 100644 --- a/tests/ui/match_ref_pats.stderr +++ b/tests/ui/match_ref_pats.stderr @@ -1,4 +1,4 @@ -error: you don't need to add `&` to all patterns +warning: you don't need to add `&` to all patterns --> $DIR/match_ref_pats.rs:9:9 | LL | / match v { @@ -7,7 +7,11 @@ LL | | &None => println!("none"), LL | | } | |_________^ | - = note: `-D clippy::match-ref-pats` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_ref_pats.rs:2:9 + | +LL | #![warn(clippy::match_ref_pats)] + | ^^^^^^^^^^^^^^^^^^^^^^ help: instead of prefixing all patterns with `&`, you can dereference the expression | LL ~ match *v { @@ -15,7 +19,7 @@ LL ~ Some(v) => println!("{:?}", v), LL ~ None => println!("none"), | -error: you don't need to add `&` to both the expression and the patterns +warning: you don't need to add `&` to both the expression and the patterns --> $DIR/match_ref_pats.rs:26:5 | LL | / match &w { @@ -31,21 +35,21 @@ LL ~ Some(v) => println!("{:?}", v), LL ~ None => println!("none"), | -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/match_ref_pats.rs:38:12 | LL | if let &None = a { | -------^^^^^---- help: try this: `if a.is_none()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` + = note: `#[warn(clippy::redundant_pattern_matching)]` on by default -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/match_ref_pats.rs:43:12 | LL | if let &None = &b { | -------^^^^^----- help: try this: `if b.is_none()` -error: you don't need to add `&` to all patterns +warning: you don't need to add `&` to all patterns --> $DIR/match_ref_pats.rs:103:9 | LL | / match foobar_variant!(0) { @@ -64,5 +68,5 @@ LL ~ FooBar::Bar => println!("Bar"), LL ~ FooBar::FooBar => println!("FooBar"), | -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/match_result_ok.fixed b/tests/ui/match_result_ok.fixed index 8b91b9854a04..42b95118a804 100644 --- a/tests/ui/match_result_ok.fixed +++ b/tests/ui/match_result_ok.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_result_ok)] #![allow(dead_code)] #![allow(clippy::boxed_local, clippy::uninlined_format_args)] diff --git a/tests/ui/match_result_ok.rs b/tests/ui/match_result_ok.rs index bc2c4b50e272..eac382e1f623 100644 --- a/tests/ui/match_result_ok.rs +++ b/tests/ui/match_result_ok.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_result_ok)] #![allow(dead_code)] #![allow(clippy::boxed_local, clippy::uninlined_format_args)] diff --git a/tests/ui/match_result_ok.stderr b/tests/ui/match_result_ok.stderr index 98a95705ca59..70f6f24ded47 100644 --- a/tests/ui/match_result_ok.stderr +++ b/tests/ui/match_result_ok.stderr @@ -1,16 +1,20 @@ -error: matching on `Some` with `ok()` is redundant +warning: matching on `Some` with `ok()` is redundant --> $DIR/match_result_ok.rs:9:5 | LL | if let Some(y) = x.parse().ok() { y } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::match-result-ok` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_result_ok.rs:2:9 + | +LL | #![warn(clippy::match_result_ok)] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider matching on `Ok(y)` and removing the call to `ok` instead | LL | if let Ok(y) = x.parse() { y } else { 0 } | ~~~~~~~~~~~~~~~~~~~~~~~~ -error: matching on `Some` with `ok()` is redundant +warning: matching on `Some` with `ok()` is redundant --> $DIR/match_result_ok.rs:19:9 | LL | if let Some(y) = x . parse() . ok () { @@ -21,7 +25,7 @@ help: consider matching on `Ok(y)` and removing the call to `ok` instead LL | if let Ok(y) = x . parse() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: matching on `Some` with `ok()` is redundant +warning: matching on `Some` with `ok()` is redundant --> $DIR/match_result_ok.rs:45:5 | LL | while let Some(a) = wat.next().ok() { @@ -32,5 +36,5 @@ help: consider matching on `Ok(a)` and removing the call to `ok` instead LL | while let Ok(a) = wat.next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/match_same_arms.rs b/tests/ui/match_same_arms.rs index 0b9342c9c423..284391627140 100644 --- a/tests/ui/match_same_arms.rs +++ b/tests/ui/match_same_arms.rs @@ -1,4 +1,4 @@ -#![warn(clippy::match_same_arms)] +#![deny(clippy::match_same_arms)] pub enum Abc { A, @@ -8,29 +8,30 @@ pub enum Abc { fn match_same_arms() { let _ = match Abc::A { - Abc::A => 0, + Abc::A => 0, //~ ERROR: this match arm has an identical body to the `_` wildcard arm Abc::B => 1, - _ => 0, //~ ERROR match arms have same body + _ => 0, }; match (1, 2, 3) { - (1, .., 3) => 42, - (.., 3) => 42, //~ ERROR match arms have same body + (1, .., 3) => 42, //~ ERROR: this match arm has an identical body to another arm + (.., 3) => 42, _ => 0, }; let _ = match 42 { 42 => 1, - 51 => 1, //~ ERROR match arms have same body - 41 => 2, - 52 => 2, //~ ERROR match arms have same body + 51 => 1, //~ ERROR: this match arm has an identical body to another arm + 41 => 2, //~ ERROR: this match arm has an identical body to another arm + 52 => 2, _ => 0, }; let _ = match 42 { 1 => 2, - 2 => 2, //~ ERROR 2nd matched arms have same body - 3 => 2, //~ ERROR 3rd matched arms have same body + 2 => 2, //~ ERROR: this match arm has an identical body to another arm + //~^ ERROR: this match arm has an identical body to another arm + 3 => 2, //~ ERROR: this match arm has an identical body to another arm 4 => 3, _ => 0, }; @@ -48,6 +49,7 @@ mod issue4244 { match self { CommandInfo::BuiltIn { name, .. } => name.to_string(), CommandInfo::External { name, .. } => name.to_string(), + //~^ ERROR: this match arm has an identical body to another arm } } } diff --git a/tests/ui/match_same_arms.stderr b/tests/ui/match_same_arms.stderr index db85b5964e84..155db243fc88 100644 --- a/tests/ui/match_same_arms.stderr +++ b/tests/ui/match_same_arms.stderr @@ -8,9 +8,13 @@ LL | Abc::A => 0, note: `_` wildcard arm here --> $DIR/match_same_arms.rs:13:9 | -LL | _ => 0, //~ ERROR match arms have same body +LL | _ => 0, | ^^^^^^ - = note: `-D clippy::match-same-arms` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_same_arms.rs:1:9 + | +LL | #![deny(clippy::match_same_arms)] + | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm --> $DIR/match_same_arms.rs:17:9 @@ -24,13 +28,13 @@ LL | (1, .., 3) => 42, note: other arm here --> $DIR/match_same_arms.rs:18:9 | -LL | (.., 3) => 42, //~ ERROR match arms have same body +LL | (.., 3) => 42, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm --> $DIR/match_same_arms.rs:24:9 | -LL | 51 => 1, //~ ERROR match arms have same body +LL | 51 => 1, | --^^^^^ | | | help: try merging the arm patterns: `51 | 42` @@ -54,13 +58,13 @@ LL | 41 => 2, note: other arm here --> $DIR/match_same_arms.rs:26:9 | -LL | 52 => 2, //~ ERROR match arms have same body +LL | 52 => 2, | ^^^^^^^ error: this match arm has an identical body to another arm --> $DIR/match_same_arms.rs:32:9 | -LL | 2 => 2, //~ ERROR 2nd matched arms have same body +LL | 2 => 2, | -^^^^^ | | | help: try merging the arm patterns: `2 | 1` @@ -73,9 +77,9 @@ LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> $DIR/match_same_arms.rs:34:9 | -LL | 3 => 2, //~ ERROR 3rd matched arms have same body +LL | 3 => 2, | -^^^^^ | | | help: try merging the arm patterns: `3 | 1` @@ -90,20 +94,20 @@ LL | 1 => 2, error: this match arm has an identical body to another arm --> $DIR/match_same_arms.rs:32:9 | -LL | 2 => 2, //~ ERROR 2nd matched arms have same body +LL | 2 => 2, | -^^^^^ | | | help: try merging the arm patterns: `2 | 3` | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:33:9 + --> $DIR/match_same_arms.rs:34:9 | -LL | 3 => 2, //~ ERROR 3rd matched arms have same body +LL | 3 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:50:17 + --> $DIR/match_same_arms.rs:51:17 | LL | CommandInfo::External { name, .. } => name.to_string(), | ----------------------------------^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +116,7 @@ LL | CommandInfo::External { name, .. } => name.to_string(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:49:17 + --> $DIR/match_same_arms.rs:50:17 | LL | CommandInfo::BuiltIn { name, .. } => name.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms2.rs b/tests/ui/match_same_arms2.rs index 82b2c433d99e..cedaa60446ee 100644 --- a/tests/ui/match_same_arms2.rs +++ b/tests/ui/match_same_arms2.rs @@ -1,4 +1,4 @@ -#![warn(clippy::match_same_arms)] +#![deny(clippy::match_same_arms)] #![allow( clippy::disallowed_names, clippy::diverging_sub_expression, @@ -13,6 +13,7 @@ fn foo() -> bool { fn match_same_arms() { let _ = match 42 { 42 => { + //~^ ERROR: this match arm has an identical body to the `_` wildcard arm foo(); let mut a = 42 + [23].len() as i32; if true { @@ -22,7 +23,6 @@ fn match_same_arms() { a }, _ => { - //~ ERROR match arms have same body foo(); let mut a = 42 + [23].len() as i32; if true { @@ -35,13 +35,13 @@ fn match_same_arms() { let _ = match 42 { 42 => foo(), - 51 => foo(), //~ ERROR match arms have same body + 51 => foo(), //~ ERROR: this match arm has an identical body to another arm _ => true, }; let _ = match Some(42) { Some(_) => 24, - None => 24, //~ ERROR match arms have same body + None => 24, //~ ERROR: this match arm has an identical body to another arm }; let _ = match Some(42) { @@ -63,13 +63,13 @@ fn match_same_arms() { match (Some(42), Some(42)) { (Some(a), None) => bar(a), - (None, Some(a)) => bar(a), //~ ERROR match arms have same body + (None, Some(a)) => bar(a), //~ ERROR: this match arm has an identical body to another arm _ => (), } match (Some(42), Some(42)) { - (Some(a), ..) => bar(a), - (.., Some(a)) => bar(a), //~ ERROR match arms have same body + (Some(a), ..) => bar(a), //~ ERROR: this match arm has an identical body to another arm + (.., Some(a)) => bar(a), _ => (), } @@ -102,7 +102,7 @@ fn match_same_arms() { } match (x, Some(1i32)) { - (Ok(x), Some(_)) => println!("ok {}", x), + (Ok(x), Some(_)) => println!("ok {}", x), //~ ERROR: this match arm has an identical body to another arm (Ok(_), Some(x)) => println!("ok {}", x), _ => println!("err"), } @@ -118,7 +118,7 @@ fn match_same_arms() { match x { Ok(_tmp) => println!("ok"), Ok(3) => println!("ok"), - Ok(_) => println!("ok"), + Ok(_) => println!("ok"), //~ ERROR: this match arm has an identical body to another arm Err(_) => { unreachable!(); }, @@ -146,6 +146,7 @@ fn match_same_arms() { empty!(0); }, 1 => { + //~^ ERROR: this match arm has an identical body to another arm empty!(0); }, x => { @@ -195,7 +196,7 @@ fn main() { // Suggest moving `Foo::Z(_)` up. let _ = match Foo::X(0) { - Foo::X(0) => 1, + Foo::X(0) => 1, //~ ERROR: this match arm has an identical body to another arm Foo::X(_) | Foo::Y(_) => 2, Foo::Z(_) => 1, _ => 0, @@ -205,7 +206,7 @@ fn main() { let _ = match Foo::X(0) { Foo::X(0) => 1, Foo::Y(_) | Foo::Z(0) => 2, - Foo::Z(_) => 1, + Foo::Z(_) => 1, //~ ERROR: this match arm has an identical body to another arm _ => 0, }; @@ -228,7 +229,7 @@ fn main() { Some(Bar { x: 0, y: 5, .. }) => 1, Some(Bar { y: 10, z: 0, .. }) => 2, None => 50, - Some(Bar { y: 0, x: 5, .. }) => 1, + Some(Bar { y: 0, x: 5, .. }) => 1, //~ ERROR: this match arm has an identical body to another arm _ => 200, }; diff --git a/tests/ui/match_same_arms2.stderr b/tests/ui/match_same_arms2.stderr index 06cd4300054d..2356a93f3700 100644 --- a/tests/ui/match_same_arms2.stderr +++ b/tests/ui/match_same_arms2.stderr @@ -2,9 +2,9 @@ error: this match arm has an identical body to the `_` wildcard arm --> $DIR/match_same_arms2.rs:15:9 | LL | / 42 => { +LL | | LL | | foo(); LL | | let mut a = 42 + [23].len() as i32; -LL | | if true { ... | LL | | a LL | | }, @@ -12,22 +12,26 @@ LL | | }, | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms2.rs:24:9 + --> $DIR/match_same_arms2.rs:25:9 | LL | / _ => { -LL | | //~ ERROR match arms have same body LL | | foo(); LL | | let mut a = 42 + [23].len() as i32; +LL | | if true { ... | LL | | a LL | | }, | |_________^ - = note: `-D clippy::match-same-arms` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_same_arms2.rs:1:9 + | +LL | #![deny(clippy::match_same_arms)] + | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm --> $DIR/match_same_arms2.rs:38:9 | -LL | 51 => foo(), //~ ERROR match arms have same body +LL | 51 => foo(), | --^^^^^^^^^ | | | help: try merging the arm patterns: `51 | 42` @@ -42,7 +46,7 @@ LL | 42 => foo(), error: this match arm has an identical body to another arm --> $DIR/match_same_arms2.rs:44:9 | -LL | None => 24, //~ ERROR match arms have same body +LL | None => 24, | ----^^^^^^ | | | help: try merging the arm patterns: `None | Some(_)` @@ -57,7 +61,7 @@ LL | Some(_) => 24, error: this match arm has an identical body to another arm --> $DIR/match_same_arms2.rs:66:9 | -LL | (None, Some(a)) => bar(a), //~ ERROR match arms have same body +LL | (None, Some(a)) => bar(a), | ---------------^^^^^^^^^^ | | | help: try merging the arm patterns: `(None, Some(a)) | (Some(a), None)` @@ -81,7 +85,7 @@ LL | (Some(a), ..) => bar(a), note: other arm here --> $DIR/match_same_arms2.rs:72:9 | -LL | (.., Some(a)) => bar(a), //~ ERROR match arms have same body +LL | (.., Some(a)) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm @@ -121,6 +125,7 @@ LL | 1 => { | ^ help: try merging the arm patterns: `1 | 0` | _________| | | +LL | | LL | | empty!(0); LL | | }, | |_________^ @@ -134,8 +139,8 @@ LL | | empty!(0); LL | | }, | |_________^ -error: match expression looks like `matches!` macro - --> $DIR/match_same_arms2.rs:166:16 +warning: match expression looks like `matches!` macro + --> $DIR/match_same_arms2.rs:167:16 | LL | let _ans = match x { | ________________^ @@ -145,10 +150,10 @@ LL | | _ => true, LL | | }; | |_____^ help: try this: `!matches!(x, E::A | E::B)` | - = note: `-D clippy::match-like-matches-macro` implied by `-D warnings` + = note: `#[warn(clippy::match_like_matches_macro)]` on by default error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:198:9 + --> $DIR/match_same_arms2.rs:199:9 | LL | Foo::X(0) => 1, | ---------^^^^^ @@ -157,13 +162,13 @@ LL | Foo::X(0) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:200:9 + --> $DIR/match_same_arms2.rs:201:9 | LL | Foo::Z(_) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:208:9 + --> $DIR/match_same_arms2.rs:209:9 | LL | Foo::Z(_) => 1, | ---------^^^^^ @@ -172,13 +177,13 @@ LL | Foo::Z(_) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:206:9 + --> $DIR/match_same_arms2.rs:207:9 | LL | Foo::X(0) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:231:9 + --> $DIR/match_same_arms2.rs:232:9 | LL | Some(Bar { y: 0, x: 5, .. }) => 1, | ----------------------------^^^^^ @@ -187,10 +192,10 @@ LL | Some(Bar { y: 0, x: 5, .. }) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:228:9 + --> $DIR/match_same_arms2.rs:229:9 | LL | Some(Bar { x: 0, y: 5, .. }) => 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors; 1 warning emitted diff --git a/tests/ui/match_single_binding.fixed b/tests/ui/match_single_binding.fixed index 6cfb6661a039..fd66a5663059 100644 --- a/tests/ui/match_single_binding.fixed +++ b/tests/ui/match_single_binding.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_single_binding)] #![allow(unused_variables)] #![allow(clippy::toplevel_ref_arg, clippy::uninlined_format_args)] @@ -25,13 +25,15 @@ fn main() { let b = 2; let c = 3; // Lint - let (x, y, z) = (a, b, c); - { - println!("{} {} {}", x, y, z); + match (a, b, c) { + (x, y, z) => { + println!("{} {} {}", x, y, z); + }, } // Lint - let (x, y, z) = (a, b, c); - println!("{} {} {}", x, y, z); + match (a, b, c) { + (x, y, z) => println!("{} {} {}", x, y, z), + } // Ok foo!(a); // Ok @@ -61,30 +63,34 @@ fn main() { } // Lint let p = Point { x: 0, y: 7 }; - let Point { x, y } = p; - println!("Coords: ({}, {})", x, y); + match p { + Point { x, y } => println!("Coords: ({}, {})", x, y), + } // Lint - let Point { x: x1, y: y1 } = p; - println!("Coords: ({}, {})", x1, y1); + match p { + Point { x: x1, y: y1 } => println!("Coords: ({}, {})", x1, y1), + } // Lint let x = 5; - let ref r = x; - println!("Got a reference to {}", r); + match x { + ref r => println!("Got a reference to {}", r), + } // Lint let mut x = 5; - let ref mut mr = x; - println!("Got a mutable reference to {}", mr); + match x { + ref mut mr => println!("Got a mutable reference to {}", mr), + } // Lint - let Point { x, y } = coords(); - let product = x * y; + let product = match coords() { + Point { x, y } => x * y, + }; // Lint let v = vec![Some(1), Some(2), Some(3), Some(4)]; #[allow(clippy::let_and_return)] let _ = v .iter() - .map(|i| { - let unwrapped = i.unwrap(); - unwrapped + .map(|i| match i.unwrap() { + unwrapped => unwrapped, }) .collect::>(); // Ok @@ -116,10 +122,11 @@ fn main() { fn issue_8723() { let (mut val, idx) = ("a b", 1); - let (pre, suf) = val.split_at(idx); - val = { - println!("{}", pre); - suf + val = match val.split_at(idx) { + (pre, suf) => { + println!("{}", pre); + suf + }, }; let _ = val; @@ -128,21 +135,21 @@ fn issue_8723() { #[allow(dead_code)] fn issue_9575() { fn side_effects() {} - let _ = || { - side_effects(); - println!("Needs curlies"); + let _ = || match side_effects() { + _ => println!("Needs curlies"), }; } #[allow(dead_code)] fn issue_9725(r: Option) { - let x = r; - match x { - Some(_) => { - println!("Some"); - }, - None => { - println!("None"); + match r { + x => match x { + Some(_) => { + println!("Some"); + }, + None => { + println!("None"); + }, }, }; } diff --git a/tests/ui/match_single_binding.rs b/tests/ui/match_single_binding.rs index f188aeb5f2ff..d3d0b0159bb6 100644 --- a/tests/ui/match_single_binding.rs +++ b/tests/ui/match_single_binding.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_single_binding)] #![allow(unused_variables)] #![allow(clippy::toplevel_ref_arg, clippy::uninlined_format_args)] diff --git a/tests/ui/match_single_binding.stderr b/tests/ui/match_single_binding.stderr index e960d64ad2b0..afaaaf7abd08 100644 --- a/tests/ui/match_single_binding.stderr +++ b/tests/ui/match_single_binding.stderr @@ -1,4 +1,4 @@ -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:28:5 | LL | / match (a, b, c) { @@ -8,7 +8,11 @@ LL | | }, LL | | } | |_____^ | - = note: `-D clippy::match-single-binding` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_single_binding.rs:2:9 + | +LL | #![warn(clippy::match_single_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a `let` statement | LL ~ let (x, y, z) = (a, b, c); @@ -17,7 +21,7 @@ LL + println!("{} {} {}", x, y, z); LL + } | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:34:5 | LL | / match (a, b, c) { @@ -31,7 +35,7 @@ LL ~ let (x, y, z) = (a, b, c); LL + println!("{} {} {}", x, y, z); | -error: this match could be replaced by its body itself +warning: this match could be replaced by its body itself --> $DIR/match_single_binding.rs:51:5 | LL | / match a { @@ -39,7 +43,7 @@ LL | | _ => println!("whatever"), LL | | } | |_____^ help: consider using the match body instead: `println!("whatever");` -error: this match could be replaced by its body itself +warning: this match could be replaced by its body itself --> $DIR/match_single_binding.rs:55:5 | LL | / match a { @@ -58,7 +62,7 @@ LL + println!("x has a value of {}", x); LL + } | -error: this match could be replaced by its body itself +warning: this match could be replaced by its body itself --> $DIR/match_single_binding.rs:62:5 | LL | / match a { @@ -80,7 +84,7 @@ LL + } LL + } | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:72:5 | LL | / match p { @@ -94,7 +98,7 @@ LL ~ let Point { x, y } = p; LL + println!("Coords: ({}, {})", x, y); | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:76:5 | LL | / match p { @@ -108,7 +112,7 @@ LL ~ let Point { x: x1, y: y1 } = p; LL + println!("Coords: ({}, {})", x1, y1); | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:81:5 | LL | / match x { @@ -122,7 +126,7 @@ LL ~ let ref r = x; LL + println!("Got a reference to {}", r); | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:86:5 | LL | / match x { @@ -136,7 +140,7 @@ LL ~ let ref mut mr = x; LL + println!("Got a mutable reference to {}", mr); | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:90:5 | LL | / let product = match coords() { @@ -150,7 +154,7 @@ LL ~ let Point { x, y } = coords(); LL + let product = x * y; | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:98:18 | LL | .map(|i| match i.unwrap() { @@ -167,7 +171,7 @@ LL + unwrapped LL ~ }) | -error: this match could be replaced by its body itself +warning: this match could be replaced by its body itself --> $DIR/match_single_binding.rs:124:5 | LL | / match x { @@ -176,7 +180,7 @@ LL | | _ => println!("Not an array index start"), LL | | } | |_____^ help: consider using the match body instead: `println!("Not an array index start");` -error: this assignment could be simplified +warning: this assignment could be simplified --> $DIR/match_single_binding.rs:134:5 | LL | / val = match val.split_at(idx) { @@ -196,7 +200,7 @@ LL + suf LL ~ }; | -error: this match could be replaced by its scrutinee and body +warning: this match could be replaced by its scrutinee and body --> $DIR/match_single_binding.rs:147:16 | LL | let _ = || match side_effects() { @@ -213,7 +217,7 @@ LL + println!("Needs curlies"); LL ~ }; | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding.rs:154:5 | LL | / match r { @@ -238,5 +242,5 @@ LL + }, LL ~ }; | -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/match_single_binding2.fixed b/tests/ui/match_single_binding2.fixed index 6a7db67e311a..b5cfe3654a58 100644 --- a/tests/ui/match_single_binding2.fixed +++ b/tests/ui/match_single_binding2.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_single_binding)] #![allow(unused_variables)] #![allow(clippy::uninlined_format_args)] @@ -15,9 +15,8 @@ fn main() { #[allow(dead_code)] fn size_hint(iter: &AppendIter) -> (usize, Option) { match &iter.inner { - Some((iter, _item)) => { - let (min, max) = iter.size_hint(); - (min.saturating_add(1), max.and_then(|max| max.checked_add(1))) + Some((iter, _item)) => match iter.size_hint() { + (min, max) => (min.saturating_add(1), max.and_then(|max| max.checked_add(1))), }, None => (0, Some(0)), } @@ -29,8 +28,9 @@ fn main() { match opt { #[rustfmt::skip] Some((first, _second)) => { - let (a, b) = get_tup(); - println!("a {:?} and b {:?}", a, b); + match get_tup() { + (a, b) => println!("a {:?} and b {:?}", a, b), + } }, None => println!("nothing"), } @@ -39,15 +39,17 @@ fn main() { // Lint (scrutinee has side effects) // issue #7094 - side_effects(); - println!("Side effects"); + match side_effects() { + _ => println!("Side effects"), + } // Lint (scrutinee has side effects) // issue #7094 let x = 1; - match x { + match match x { 0 => 1, _ => 2, - }; - println!("Single branch"); + } { + _ => println!("Single branch"), + } } diff --git a/tests/ui/match_single_binding2.rs b/tests/ui/match_single_binding2.rs index 5a4bb8441fff..b5cfe3654a58 100644 --- a/tests/ui/match_single_binding2.rs +++ b/tests/ui/match_single_binding2.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_single_binding)] #![allow(unused_variables)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/match_single_binding2.stderr b/tests/ui/match_single_binding2.stderr index 22bf7d8be4a2..8aa369303d77 100644 --- a/tests/ui/match_single_binding2.stderr +++ b/tests/ui/match_single_binding2.stderr @@ -1,4 +1,4 @@ -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding2.rs:18:36 | LL | Some((iter, _item)) => match iter.size_hint() { @@ -7,7 +7,11 @@ LL | | (min, max) => (min.saturating_add(1), max.and_then(|max| LL | | }, | |_____________^ | - = note: `-D clippy::match-single-binding` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_single_binding2.rs:2:9 + | +LL | #![warn(clippy::match_single_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a `let` statement | LL ~ Some((iter, _item)) => { @@ -16,7 +20,7 @@ LL + (min.saturating_add(1), max.and_then(|max| max.checked_add( LL ~ }, | -error: this match could be written as a `let` statement +warning: this match could be written as a `let` statement --> $DIR/match_single_binding2.rs:31:13 | LL | / match get_tup() { @@ -30,7 +34,7 @@ LL ~ let (a, b) = get_tup(); LL + println!("a {:?} and b {:?}", a, b); | -error: this match could be replaced by its scrutinee and body +warning: this match could be replaced by its scrutinee and body --> $DIR/match_single_binding2.rs:42:5 | LL | / match side_effects() { @@ -44,7 +48,7 @@ LL ~ side_effects(); LL + println!("Side effects"); | -error: this match could be replaced by its scrutinee and body +warning: this match could be replaced by its scrutinee and body --> $DIR/match_single_binding2.rs:49:5 | LL | / match match x { @@ -64,5 +68,5 @@ LL + }; LL + println!("Single branch"); | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/match_str_case_mismatch.fixed b/tests/ui/match_str_case_mismatch.fixed index e436bcf495fd..cd53b1f06faa 100644 --- a/tests/ui/match_str_case_mismatch.fixed +++ b/tests/ui/match_str_case_mismatch.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_str_case_mismatch)] #![allow(dead_code)] diff --git a/tests/ui/match_str_case_mismatch.rs b/tests/ui/match_str_case_mismatch.rs index 92e2a000ade2..6885305662a2 100644 --- a/tests/ui/match_str_case_mismatch.rs +++ b/tests/ui/match_str_case_mismatch.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_str_case_mismatch)] #![allow(dead_code)] diff --git a/tests/ui/match_str_case_mismatch.stderr b/tests/ui/match_str_case_mismatch.stderr index 197520a3d608..7103342cad51 100644 --- a/tests/ui/match_str_case_mismatch.stderr +++ b/tests/ui/match_str_case_mismatch.stderr @@ -1,16 +1,20 @@ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:113:9 | LL | "Bar" => {}, | ^^^^^ | - = note: `-D clippy::match-str-case-mismatch` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_str_case_mismatch.rs:2:9 + | +LL | #![warn(clippy::match_str_case_mismatch)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the case of this arm to respect `to_ascii_lowercase` | LL | "bar" => {}, | ~~~~~ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:123:9 | LL | "~!@#$%^&*()-_=+Foo" => {}, @@ -21,7 +25,7 @@ help: consider changing the case of this arm to respect `to_ascii_lowercase` LL | "~!@#$%^&*()-_=+foo" => {}, | ~~~~~~~~~~~~~~~~~~~~ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:135:9 | LL | "Воды" => {}, @@ -32,7 +36,7 @@ help: consider changing the case of this arm to respect `to_lowercase` LL | "воды" => {}, | ~~~~~~ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:146:9 | LL | "barDz" => {}, @@ -43,7 +47,7 @@ help: consider changing the case of this arm to respect `to_lowercase` LL | "bardz" => {}, | ~~~~~~ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:156:9 | LL | "bARʁ" => {}, @@ -54,7 +58,7 @@ help: consider changing the case of this arm to respect `to_uppercase` LL | "BARʁ" => {}, | ~~~~~~ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:166:9 | LL | "Bar" => {}, @@ -65,7 +69,7 @@ help: consider changing the case of this arm to respect `to_ascii_lowercase` LL | "bar" => {}, | ~~~~~ -error: this `match` arm has a differing case than its expression +warning: this `match` arm has a differing case than its expression --> $DIR/match_str_case_mismatch.rs:181:9 | LL | "bAR" => {}, @@ -76,5 +80,5 @@ help: consider changing the case of this arm to respect `to_ascii_uppercase` LL | "BAR" => {}, | ~~~~~ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/match_wild_err_arm.stderr b/tests/ui/match_wild_err_arm.stderr index b016d682698c..cdc98c9327b5 100644 --- a/tests/ui/match_wild_err_arm.stderr +++ b/tests/ui/match_wild_err_arm.stderr @@ -1,13 +1,17 @@ -error: `Err(_)` matches all errors +warning: `Err(_)` matches all errors --> $DIR/match_wild_err_arm.rs:11:9 | LL | Err(_) => panic!("err"), | ^^^^^^ | = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable - = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_wild_err_arm.rs:3:9 + | +LL | #![warn(clippy::match_wild_err_arm)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `Err(_)` matches all errors +warning: `Err(_)` matches all errors --> $DIR/match_wild_err_arm.rs:17:9 | LL | Err(_) => panic!(), @@ -15,7 +19,7 @@ LL | Err(_) => panic!(), | = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable -error: `Err(_)` matches all errors +warning: `Err(_)` matches all errors --> $DIR/match_wild_err_arm.rs:23:9 | LL | Err(_) => { @@ -23,7 +27,7 @@ LL | Err(_) => { | = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable -error: `Err(_e)` matches all errors +warning: `Err(_e)` matches all errors --> $DIR/match_wild_err_arm.rs:31:9 | LL | Err(_e) => panic!(), @@ -31,5 +35,5 @@ LL | Err(_e) => panic!(), | = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/match_wildcard_for_single_variants.fixed b/tests/ui/match_wildcard_for_single_variants.fixed index 9fd3739b69c2..cff0c8960650 100644 --- a/tests/ui/match_wildcard_for_single_variants.fixed +++ b/tests/ui/match_wildcard_for_single_variants.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_wildcard_for_single_variants)] #![allow(dead_code)] @@ -21,7 +21,7 @@ impl Color { Self::Red => (), Self::Green => (), Self::Blue => (), - Self::Rgb(..) => (), + _ => (), }; } } @@ -31,7 +31,7 @@ fn main() { match f { Foo::A => {}, Foo::B => {}, - Foo::C => {}, + _ => {}, } let color = Color::Red; @@ -41,7 +41,7 @@ fn main() { Color::Red => {}, Color::Green => {}, Color::Rgb(_r, _g, _b) => {}, - Color::Blue => {}, + _ => {}, } // check exhaustive wild @@ -49,13 +49,13 @@ fn main() { Color::Red => {}, Color::Green => {}, Color::Rgb(..) => {}, - Color::Blue => {}, + _ => {}, } match color { Color::Red => {}, Color::Green => {}, Color::Rgb(_, _, _) => {}, - Color::Blue => {}, + _ => {}, } // shouldn't lint as there is one missing variant @@ -72,7 +72,7 @@ fn main() { &Color::Red => (), Color::Green => (), &Color::Rgb(..) => (), - Color::Blue => (), + &_ => (), } use self::Color as C; @@ -81,14 +81,14 @@ fn main() { C::Red => (), C::Green => (), C::Rgb(..) => (), - C::Blue => (), + _ => (), } match color { C::Red => (), Color::Green => (), Color::Rgb(..) => (), - Color::Blue => (), + _ => (), } match Some(0) { @@ -123,7 +123,7 @@ fn main() { Enum::A => (), Enum::B => (), Enum::C => (), - Enum::__Private => (), + _ => (), } match Enum::A { Enum::A => (), @@ -150,7 +150,7 @@ mod issue9993 { let _ = match Foo::B { _ if false => 0, Foo::A(_) => 1, - Foo::B => 2, + _ => 2, }; } } diff --git a/tests/ui/match_wildcard_for_single_variants.rs b/tests/ui/match_wildcard_for_single_variants.rs index 9a5c849e6ec9..cff0c8960650 100644 --- a/tests/ui/match_wildcard_for_single_variants.rs +++ b/tests/ui/match_wildcard_for_single_variants.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::match_wildcard_for_single_variants)] #![allow(dead_code)] diff --git a/tests/ui/match_wildcard_for_single_variants.stderr b/tests/ui/match_wildcard_for_single_variants.stderr index 105b4c4b41d1..6f3363af5396 100644 --- a/tests/ui/match_wildcard_for_single_variants.stderr +++ b/tests/ui/match_wildcard_for_single_variants.stderr @@ -1,64 +1,68 @@ -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:24:13 | LL | _ => (), | ^ help: try this: `Self::Rgb(..)` | - = note: `-D clippy::match-wildcard-for-single-variants` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/match_wildcard_for_single_variants.rs:3:9 + | +LL | #![warn(clippy::match_wildcard_for_single_variants)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:34:9 | LL | _ => {}, | ^ help: try this: `Foo::C` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:44:9 | LL | _ => {}, | ^ help: try this: `Color::Blue` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:52:9 | LL | _ => {}, | ^ help: try this: `Color::Blue` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:58:9 | LL | _ => {}, | ^ help: try this: `Color::Blue` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:75:9 | LL | &_ => (), | ^^ help: try this: `Color::Blue` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:84:9 | LL | _ => (), | ^ help: try this: `C::Blue` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:91:9 | LL | _ => (), | ^ help: try this: `Color::Blue` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:126:13 | LL | _ => (), | ^ help: try this: `Enum::__Private` -error: wildcard matches only a single variant and will also match any future added variants +warning: wildcard matches only a single variant and will also match any future added variants --> $DIR/match_wildcard_for_single_variants.rs:153:13 | LL | _ => 2, | ^ help: try this: `Foo::B` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index a90d8b1655dc..e87442672406 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -1,22 +1,26 @@ -error: usage of `mem::forget` on `Drop` type +warning: usage of `mem::forget` on `Drop` type --> $DIR/mem_forget.rs:14:5 | LL | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::mem-forget` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mem_forget.rs:7:8 + | +LL | #[warn(clippy::mem_forget)] + | ^^^^^^^^^^^^^^^^^^ -error: usage of `mem::forget` on `Drop` type +warning: usage of `mem::forget` on `Drop` type --> $DIR/mem_forget.rs:17:5 | LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of `mem::forget` on `Drop` type +warning: usage of `mem::forget` on `Drop` type --> $DIR/mem_forget.rs:20:5 | LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/mem_replace.fixed b/tests/ui/mem_replace.fixed index 874d55843303..92ea9ba2a934 100644 --- a/tests/ui/mem_replace.fixed +++ b/tests/ui/mem_replace.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn( diff --git a/tests/ui/mem_replace.rs b/tests/ui/mem_replace.rs index f4f3bff51446..698a78601072 100644 --- a/tests/ui/mem_replace.rs +++ b/tests/ui/mem_replace.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn( diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index caa127f76eef..ec2693ce97c9 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -1,126 +1,134 @@ -error: replacing an `Option` with `None` +warning: replacing an `Option` with `None` --> $DIR/mem_replace.rs:16:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` | - = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mem_replace.rs:7:5 + | +LL | clippy::mem_replace_option_with_none, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing an `Option` with `None` +warning: replacing an `Option` with `None` --> $DIR/mem_replace.rs:18:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:23:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` | - = note: `-D clippy::mem-replace-with-default` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mem_replace.rs:8:5 + | +LL | clippy::mem_replace_with_default + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:26:13 | LL | let _ = std::mem::replace(s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:27:13 | LL | let _ = std::mem::replace(s, Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:30:13 | LL | let _ = std::mem::replace(&mut v, Vec::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:31:13 | LL | let _ = std::mem::replace(&mut v, Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:32:13 | LL | let _ = std::mem::replace(&mut v, Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:33:13 | LL | let _ = std::mem::replace(&mut v, vec![]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:36:13 | LL | let _ = std::mem::replace(&mut hash_map, HashMap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_map)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:39:13 | LL | let _ = std::mem::replace(&mut btree_map, BTreeMap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_map)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:42:13 | LL | let _ = std::mem::replace(&mut vd, VecDeque::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut vd)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:45:13 | LL | let _ = std::mem::replace(&mut hash_set, HashSet::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_set)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:48:13 | LL | let _ = std::mem::replace(&mut btree_set, BTreeSet::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_set)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:51:13 | LL | let _ = std::mem::replace(&mut list, LinkedList::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut list)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:54:13 | LL | let _ = std::mem::replace(&mut binary_heap, BinaryHeap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut binary_heap)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:57:13 | LL | let _ = std::mem::replace(&mut tuple, (vec![], BinaryHeap::new())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut tuple)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:60:13 | LL | let _ = std::mem::replace(&mut refstr, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut refstr)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:63:13 | LL | let _ = std::mem::replace(&mut slice, &[]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut slice)` -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace.rs:91:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/mem_replace_macro.rs b/tests/ui/mem_replace_macro.rs index 0c09344b80d1..8dfbe130ab8a 100644 --- a/tests/ui/mem_replace_macro.rs +++ b/tests/ui/mem_replace_macro.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::mem_replace_with_default)] #[macro_use] diff --git a/tests/ui/mem_replace_macro.stderr b/tests/ui/mem_replace_macro.stderr index dd69ab8b5efb..d53fc941639e 100644 --- a/tests/ui/mem_replace_macro.stderr +++ b/tests/ui/mem_replace_macro.stderr @@ -1,4 +1,4 @@ -error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` +warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` --> $DIR/mem_replace_macro.rs:9:9 | LL | std::mem::replace($s, Default::default()) @@ -7,8 +7,12 @@ LL | std::mem::replace($s, Default::default()) LL | take!(s); | -------- in this macro invocation | - = note: `-D clippy::mem-replace-with-default` implied by `-D warnings` - = note: this error originates in the macro `take` (in Nightly builds, run with -Z macro-backtrace for more info) +note: the lint level is defined here + --> $DIR/mem_replace_macro.rs:2:9 + | +LL | #![warn(clippy::mem_replace_with_default)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this warning originates in the macro `take` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index 1519e4da9348..e0e2cac30a28 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -1,4 +1,4 @@ -// aux-build:option_helpers.rs +//@aux-build:option_helpers.rs #![warn(clippy::all, clippy::pedantic)] #![allow( diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 4643e09e2702..a2b4ab6acde9 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -1,4 +1,4 @@ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/methods.rs:105:5 | LL | / fn new() -> i32 { @@ -6,9 +6,14 @@ LL | | 0 LL | | } | |_____^ | - = note: `-D clippy::new-ret-no-self` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/methods.rs:3:9 + | +LL | #![warn(clippy::all, clippy::pedantic)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::new_ret_no_self)]` implied by `#[warn(clippy::all)]` -error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead +warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> $DIR/methods.rs:126:13 | LL | let _ = v.iter().filter(|&x| { @@ -18,7 +23,7 @@ LL | | } LL | | ).next(); | |___________________________^ | - = note: `-D clippy::filter-next` implied by `-D warnings` + = note: `#[warn(clippy::filter_next)]` implied by `#[warn(clippy::all)]` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/methods_fixable.fixed b/tests/ui/methods_fixable.fixed index ee7c1b0da6d9..dcbed5a4d997 100644 --- a/tests/ui/methods_fixable.fixed +++ b/tests/ui/methods_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::filter_next)] diff --git a/tests/ui/methods_fixable.rs b/tests/ui/methods_fixable.rs index 6d0f1b7bd514..3a976d235276 100644 --- a/tests/ui/methods_fixable.rs +++ b/tests/ui/methods_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::filter_next)] diff --git a/tests/ui/methods_fixable.stderr b/tests/ui/methods_fixable.stderr index 852f48e32d67..e763e6f54515 100644 --- a/tests/ui/methods_fixable.stderr +++ b/tests/ui/methods_fixable.stderr @@ -1,10 +1,14 @@ -error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead +warning: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead --> $DIR/methods_fixable.rs:10:13 | LL | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `v.iter().find(|&x| *x < 0)` | - = note: `-D clippy::filter-next` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/methods_fixable.rs:3:9 + | +LL | #![warn(clippy::filter_next)] + | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index 069d9068657e..9c0a4509481c 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,82 +1,87 @@ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:24:5 | LL | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::min-max` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/min_max.rs:1:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::min_max)]` implied by `#[warn(clippy::all)]` -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:25:5 | LL | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:26:5 | LL | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:27:5 | LL | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:29:5 | LL | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:39:5 | LL | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:40:5 | LL | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:45:5 | LL | x.min(1).max(3); | ^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:46:5 | LL | x.max(3).min(1); | ^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:47:5 | LL | f.max(3f32).min(1f32); | ^^^^^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:53:5 | LL | max(x.min(1), 3); | ^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:56:5 | LL | s.max("Zoo").min("Apple"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `min`/`max` combination leads to constant result +warning: this `min`/`max` combination leads to constant result --> $DIR/min_max.rs:57:5 | LL | s.min("Apple").max("Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/min_rust_version_attr.rs b/tests/ui/min_rust_version_attr.rs index 955e7eb72763..4770f62558b0 100644 --- a/tests/ui/min_rust_version_attr.rs +++ b/tests/ui/min_rust_version_attr.rs @@ -1,4 +1,5 @@ #![allow(clippy::redundant_clone)] +#![warn(clippy::approx_constant)] #![feature(custom_inner_attributes)] fn main() {} diff --git a/tests/ui/min_rust_version_attr.stderr b/tests/ui/min_rust_version_attr.stderr index 7e2135584efd..e41470b6292a 100644 --- a/tests/ui/min_rust_version_attr.stderr +++ b/tests/ui/min_rust_version_attr.stderr @@ -1,51 +1,55 @@ -error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:13:19 +warning: approximate value of `f{32, 64}::consts::LOG2_10` found + --> $DIR/min_rust_version_attr.rs:14:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ | = help: consider using the constant directly - = note: `#[deny(clippy::approx_constant)]` on by default +note: the lint level is defined here + --> $DIR/min_rust_version_attr.rs:2:9 + | +LL | #![warn(clippy::approx_constant)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:18:19 +warning: approximate value of `f{32, 64}::consts::LOG2_10` found + --> $DIR/min_rust_version_attr.rs:19:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:28:19 +warning: approximate value of `f{32, 64}::consts::LOG2_10` found + --> $DIR/min_rust_version_attr.rs:29:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:38:19 +warning: approximate value of `f{32, 64}::consts::LOG2_10` found + --> $DIR/min_rust_version_attr.rs:39:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:48:19 +warning: approximate value of `f{32, 64}::consts::LOG2_10` found + --> $DIR/min_rust_version_attr.rs:49:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ | = help: consider using the constant directly -error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:55:27 +warning: approximate value of `f{32, 64}::consts::LOG2_10` found + --> $DIR/min_rust_version_attr.rs:56:27 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ | = help: consider using the constant directly -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/min_rust_version_invalid_attr.rs b/tests/ui/min_rust_version_invalid_attr.rs index 02892f329af6..67182fb78cc9 100644 --- a/tests/ui/min_rust_version_invalid_attr.rs +++ b/tests/ui/min_rust_version_invalid_attr.rs @@ -1,18 +1,23 @@ #![feature(custom_inner_attributes)] #![clippy::msrv = "invalid.version"] +//~^ ERROR: is not a valid Rust version fn main() {} #[clippy::msrv = "invalid.version"] +//~^ ERROR: is not a valid Rust version fn outer_attr() {} mod multiple { #![clippy::msrv = "1.40"] #![clippy::msrv = "=1.35.0"] + //~^ ERROR: defined multiple times #![clippy::msrv = "1.10.1"] + //~^ ERROR: defined multiple times mod foo { #![clippy::msrv = "1"] #![clippy::msrv = "1.0.0"] + //~^ ERROR: defined multiple times } } diff --git a/tests/ui/min_rust_version_invalid_attr.stderr b/tests/ui/min_rust_version_invalid_attr.stderr index 675b78031525..8d4071e258eb 100644 --- a/tests/ui/min_rust_version_invalid_attr.stderr +++ b/tests/ui/min_rust_version_invalid_attr.stderr @@ -5,43 +5,43 @@ LL | #![clippy::msrv = "invalid.version"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `invalid.version` is not a valid Rust version - --> $DIR/min_rust_version_invalid_attr.rs:6:1 + --> $DIR/min_rust_version_invalid_attr.rs:7:1 | LL | #[clippy::msrv = "invalid.version"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:11:5 + --> $DIR/min_rust_version_invalid_attr.rs:13:5 | LL | #![clippy::msrv = "=1.35.0"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:10:5 + --> $DIR/min_rust_version_invalid_attr.rs:12:5 | LL | #![clippy::msrv = "1.40"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:12:5 + --> $DIR/min_rust_version_invalid_attr.rs:15:5 | LL | #![clippy::msrv = "1.10.1"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:10:5 + --> $DIR/min_rust_version_invalid_attr.rs:12:5 | LL | #![clippy::msrv = "1.40"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:16:9 + --> $DIR/min_rust_version_invalid_attr.rs:20:9 | LL | #![clippy::msrv = "1.0.0"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:15:9 + --> $DIR/min_rust_version_invalid_attr.rs:19:9 | LL | #![clippy::msrv = "1"] | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mismatched_target_os_non_unix.fixed b/tests/ui/mismatched_target_os_non_unix.fixed index f219a570e7fc..e00224f5ceb4 100644 --- a/tests/ui/mismatched_target_os_non_unix.fixed +++ b/tests/ui/mismatched_target_os_non_unix.fixed @@ -1,19 +1,19 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::mismatched_target_os)] #![allow(unused)] -#[cfg(target_os = "hermit")] +#[cfg(hermit)] fn hermit() {} -#[cfg(target_os = "wasi")] +#[cfg(wasi)] fn wasi() {} -#[cfg(target_os = "none")] +#[cfg(none)] fn none() {} // list with conditions -#[cfg(all(not(windows), target_os = "wasi"))] +#[cfg(all(not(windows), wasi))] fn list() {} // windows is a valid target family, should be ignored diff --git a/tests/ui/mismatched_target_os_non_unix.rs b/tests/ui/mismatched_target_os_non_unix.rs index 8a8ae756a4fc..e00224f5ceb4 100644 --- a/tests/ui/mismatched_target_os_non_unix.rs +++ b/tests/ui/mismatched_target_os_non_unix.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::mismatched_target_os)] #![allow(unused)] diff --git a/tests/ui/mismatched_target_os_non_unix.stderr b/tests/ui/mismatched_target_os_non_unix.stderr index 5f1b09083046..e62af3f43f72 100644 --- a/tests/ui/mismatched_target_os_non_unix.stderr +++ b/tests/ui/mismatched_target_os_non_unix.stderr @@ -1,4 +1,4 @@ -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_non_unix.rs:6:1 | LL | #[cfg(hermit)] @@ -6,9 +6,13 @@ LL | #[cfg(hermit)] | | | help: try: `target_os = "hermit"` | - = note: `-D clippy::mismatched-target-os` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mismatched_target_os_non_unix.rs:3:9 + | +LL | #![warn(clippy::mismatched_target_os)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_non_unix.rs:9:1 | LL | #[cfg(wasi)] @@ -16,7 +20,7 @@ LL | #[cfg(wasi)] | | | help: try: `target_os = "wasi"` -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_non_unix.rs:12:1 | LL | #[cfg(none)] @@ -24,7 +28,7 @@ LL | #[cfg(none)] | | | help: try: `target_os = "none"` -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_non_unix.rs:16:1 | LL | #[cfg(all(not(windows), wasi))] @@ -32,5 +36,5 @@ LL | #[cfg(all(not(windows), wasi))] | | | help: try: `target_os = "wasi"` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/mismatched_target_os_unix.fixed b/tests/ui/mismatched_target_os_unix.fixed index 7d9d406d99df..5a90019a2e4c 100644 --- a/tests/ui/mismatched_target_os_unix.fixed +++ b/tests/ui/mismatched_target_os_unix.fixed @@ -1,58 +1,58 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::mismatched_target_os)] #![allow(unused)] -#[cfg(target_os = "linux")] +#[cfg(linux)] fn linux() {} -#[cfg(target_os = "freebsd")] +#[cfg(freebsd)] fn freebsd() {} -#[cfg(target_os = "dragonfly")] +#[cfg(dragonfly)] fn dragonfly() {} -#[cfg(target_os = "openbsd")] +#[cfg(openbsd)] fn openbsd() {} -#[cfg(target_os = "netbsd")] +#[cfg(netbsd)] fn netbsd() {} -#[cfg(target_os = "macos")] +#[cfg(macos)] fn macos() {} -#[cfg(target_os = "ios")] +#[cfg(ios)] fn ios() {} -#[cfg(target_os = "android")] +#[cfg(android)] fn android() {} -#[cfg(target_os = "emscripten")] +#[cfg(emscripten)] fn emscripten() {} -#[cfg(target_os = "fuchsia")] +#[cfg(fuchsia)] fn fuchsia() {} -#[cfg(target_os = "haiku")] +#[cfg(haiku)] fn haiku() {} -#[cfg(target_os = "illumos")] +#[cfg(illumos)] fn illumos() {} -#[cfg(target_os = "l4re")] +#[cfg(l4re)] fn l4re() {} -#[cfg(target_os = "redox")] +#[cfg(redox)] fn redox() {} -#[cfg(target_os = "solaris")] +#[cfg(solaris)] fn solaris() {} -#[cfg(target_os = "vxworks")] +#[cfg(vxworks)] fn vxworks() {} // list with conditions -#[cfg(all(not(any(target_os = "solaris", target_os = "linux")), target_os = "freebsd"))] +#[cfg(all(not(any(solaris, linux)), freebsd))] fn list() {} // correct use, should be ignored diff --git a/tests/ui/mismatched_target_os_unix.rs b/tests/ui/mismatched_target_os_unix.rs index c1177f1eedc6..5a90019a2e4c 100644 --- a/tests/ui/mismatched_target_os_unix.rs +++ b/tests/ui/mismatched_target_os_unix.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::mismatched_target_os)] #![allow(unused)] diff --git a/tests/ui/mismatched_target_os_unix.stderr b/tests/ui/mismatched_target_os_unix.stderr index 9822c77c9dfe..ebab8bd15957 100644 --- a/tests/ui/mismatched_target_os_unix.stderr +++ b/tests/ui/mismatched_target_os_unix.stderr @@ -1,4 +1,4 @@ -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:6:1 | LL | #[cfg(linux)] @@ -7,9 +7,13 @@ LL | #[cfg(linux)] | help: try: `target_os = "linux"` | = help: did you mean `unix`? - = note: `-D clippy::mismatched-target-os` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mismatched_target_os_unix.rs:3:9 + | +LL | #![warn(clippy::mismatched_target_os)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:9:1 | LL | #[cfg(freebsd)] @@ -19,7 +23,7 @@ LL | #[cfg(freebsd)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:12:1 | LL | #[cfg(dragonfly)] @@ -29,7 +33,7 @@ LL | #[cfg(dragonfly)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:15:1 | LL | #[cfg(openbsd)] @@ -39,7 +43,7 @@ LL | #[cfg(openbsd)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:18:1 | LL | #[cfg(netbsd)] @@ -49,7 +53,7 @@ LL | #[cfg(netbsd)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:21:1 | LL | #[cfg(macos)] @@ -59,7 +63,7 @@ LL | #[cfg(macos)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:24:1 | LL | #[cfg(ios)] @@ -69,7 +73,7 @@ LL | #[cfg(ios)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:27:1 | LL | #[cfg(android)] @@ -79,7 +83,7 @@ LL | #[cfg(android)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:30:1 | LL | #[cfg(emscripten)] @@ -89,7 +93,7 @@ LL | #[cfg(emscripten)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:33:1 | LL | #[cfg(fuchsia)] @@ -99,7 +103,7 @@ LL | #[cfg(fuchsia)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:36:1 | LL | #[cfg(haiku)] @@ -109,7 +113,7 @@ LL | #[cfg(haiku)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:39:1 | LL | #[cfg(illumos)] @@ -119,7 +123,7 @@ LL | #[cfg(illumos)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:42:1 | LL | #[cfg(l4re)] @@ -129,7 +133,7 @@ LL | #[cfg(l4re)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:45:1 | LL | #[cfg(redox)] @@ -139,7 +143,7 @@ LL | #[cfg(redox)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:48:1 | LL | #[cfg(solaris)] @@ -149,7 +153,7 @@ LL | #[cfg(solaris)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:51:1 | LL | #[cfg(vxworks)] @@ -159,7 +163,7 @@ LL | #[cfg(vxworks)] | = help: did you mean `unix`? -error: operating system used in target family position +warning: operating system used in target family position --> $DIR/mismatched_target_os_unix.rs:55:1 | LL | #[cfg(all(not(any(solaris, linux)), freebsd))] @@ -179,5 +183,5 @@ help: try LL | #[cfg(all(not(any(solaris, linux)), target_os = "freebsd"))] | ~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/mismatching_type_param_order.stderr b/tests/ui/mismatching_type_param_order.stderr index 204d49905577..0a3d10c04f58 100644 --- a/tests/ui/mismatching_type_param_order.stderr +++ b/tests/ui/mismatching_type_param_order.stderr @@ -1,13 +1,17 @@ -error: `Foo` has a similarly named generic type parameter `B` in its declaration, but in a different order +warning: `Foo` has a similarly named generic type parameter `B` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:11:20 | LL | impl Foo {} | ^ | = help: try `A`, or a name that does not conflict with `Foo`'s generic params - = note: `-D clippy::mismatching-type-param-order` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mismatching_type_param_order.rs:1:9 + | +LL | #![warn(clippy::mismatching_type_param_order)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order +warning: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:11:23 | LL | impl Foo {} @@ -15,7 +19,7 @@ LL | impl Foo {} | = help: try `B`, or a name that does not conflict with `Foo`'s generic params -error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order +warning: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:14:23 | LL | impl Foo {} @@ -23,7 +27,7 @@ LL | impl Foo {} | = help: try `B`, or a name that does not conflict with `Foo`'s generic params -error: `FooLifetime` has a similarly named generic type parameter `B` in its declaration, but in a different order +warning: `FooLifetime` has a similarly named generic type parameter `B` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:25:44 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} @@ -31,7 +35,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | = help: try `A`, or a name that does not conflict with `FooLifetime`'s generic params -error: `FooLifetime` has a similarly named generic type parameter `A` in its declaration, but in a different order +warning: `FooLifetime` has a similarly named generic type parameter `A` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:25:47 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} @@ -39,7 +43,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | = help: try `B`, or a name that does not conflict with `FooLifetime`'s generic params -error: `FooEnum` has a similarly named generic type parameter `C` in its declaration, but in a different order +warning: `FooEnum` has a similarly named generic type parameter `C` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:41:27 | LL | impl FooEnum {} @@ -47,7 +51,7 @@ LL | impl FooEnum {} | = help: try `A`, or a name that does not conflict with `FooEnum`'s generic params -error: `FooEnum` has a similarly named generic type parameter `A` in its declaration, but in a different order +warning: `FooEnum` has a similarly named generic type parameter `A` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:41:30 | LL | impl FooEnum {} @@ -55,7 +59,7 @@ LL | impl FooEnum {} | = help: try `B`, or a name that does not conflict with `FooEnum`'s generic params -error: `FooEnum` has a similarly named generic type parameter `B` in its declaration, but in a different order +warning: `FooEnum` has a similarly named generic type parameter `B` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:41:33 | LL | impl FooEnum {} @@ -63,7 +67,7 @@ LL | impl FooEnum {} | = help: try `C`, or a name that does not conflict with `FooEnum`'s generic params -error: `FooUnion` has a similarly named generic type parameter `B` in its declaration, but in a different order +warning: `FooUnion` has a similarly named generic type parameter `B` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:52:31 | LL | impl FooUnion where A: Copy {} @@ -71,7 +75,7 @@ LL | impl FooUnion where A: Copy {} | = help: try `A`, or a name that does not conflict with `FooUnion`'s generic params -error: `FooUnion` has a similarly named generic type parameter `A` in its declaration, but in a different order +warning: `FooUnion` has a similarly named generic type parameter `A` in its declaration, but in a different order --> $DIR/mismatching_type_param_order.rs:52:34 | LL | impl FooUnion where A: Copy {} @@ -79,5 +83,5 @@ LL | impl FooUnion where A: Copy {} | = help: try `B`, or a name that does not conflict with `FooUnion`'s generic params -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/misnamed_getters.stderr b/tests/ui/misnamed_getters.stderr index 1e38a83d019a..0d85dfc8a862 100644 --- a/tests/ui/misnamed_getters.stderr +++ b/tests/ui/misnamed_getters.stderr @@ -1,4 +1,4 @@ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:11:5 | LL | / fn a(&self) -> &u8 { @@ -7,9 +7,13 @@ LL | | &self.b LL | | } | |_____^ | - = note: `-D clippy::misnamed-getters` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/misnamed_getters.rs:2:9 + | +LL | #![warn(clippy::misnamed_getters)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:14:5 | LL | / fn a_mut(&mut self) -> &mut u8 { @@ -18,7 +22,7 @@ LL | | &mut self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:18:5 | LL | / fn b(self) -> u8 { @@ -27,7 +31,7 @@ LL | | self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:22:5 | LL | / fn b_mut(&mut self) -> &mut u8 { @@ -36,7 +40,7 @@ LL | | &mut self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:26:5 | LL | / fn c(&self) -> &u8 { @@ -45,7 +49,7 @@ LL | | &self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:30:5 | LL | / fn c_mut(&mut self) -> &mut u8 { @@ -54,7 +58,7 @@ LL | | &mut self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:41:5 | LL | / unsafe fn a(&self) -> &u8 { @@ -63,7 +67,7 @@ LL | | &self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:44:5 | LL | / unsafe fn a_mut(&mut self) -> &mut u8 { @@ -72,7 +76,7 @@ LL | | &mut self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:48:5 | LL | / unsafe fn b(self) -> u8 { @@ -81,7 +85,7 @@ LL | | self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:52:5 | LL | / unsafe fn b_mut(&mut self) -> &mut u8 { @@ -90,7 +94,7 @@ LL | | &mut self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:64:5 | LL | / unsafe fn a_unchecked(&self) -> &u8 { @@ -99,7 +103,7 @@ LL | | &self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:67:5 | LL | / unsafe fn a_unchecked_mut(&mut self) -> &mut u8 { @@ -108,7 +112,7 @@ LL | | &mut self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:71:5 | LL | / unsafe fn b_unchecked(self) -> u8 { @@ -117,7 +121,7 @@ LL | | self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:75:5 | LL | / unsafe fn b_unchecked_mut(&mut self) -> &mut u8 { @@ -126,7 +130,7 @@ LL | | &mut self.a LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:107:5 | LL | / fn a(&self) -> &u8 { @@ -135,7 +139,7 @@ LL | | &self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:110:5 | LL | / fn a_mut(&mut self) -> &mut u8 { @@ -144,7 +148,7 @@ LL | | &mut self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:114:5 | LL | / fn d(&self) -> &u8 { @@ -153,7 +157,7 @@ LL | | &self.b LL | | } | |_____^ -error: getter function appears to return the wrong field +warning: getter function appears to return the wrong field --> $DIR/misnamed_getters.rs:117:5 | LL | / fn d_mut(&mut self) -> &mut u8 { @@ -162,5 +166,5 @@ LL | | &mut self.b LL | | } | |_____^ -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/missing_const_for_fn/cant_be_const.rs b/tests/ui/missing_const_for_fn/cant_be_const.rs index 75cace181675..6f5312126b49 100644 --- a/tests/ui/missing_const_for_fn/cant_be_const.rs +++ b/tests/ui/missing_const_for_fn/cant_be_const.rs @@ -2,8 +2,8 @@ //! compilation error. //! The .stderr output of this test should be empty. Otherwise it's a bug somewhere. -// aux-build:helper.rs -// aux-build:../../auxiliary/proc_macro_with_span.rs +//@aux-build:helper.rs +//@aux-build:../../auxiliary/proc_macro_with_span.rs:proc-macro #![warn(clippy::missing_const_for_fn)] #![feature(start)] @@ -44,7 +44,6 @@ static Y: u32 = 0; // refer to a static variable fn get_y() -> u32 { Y - //~^ ERROR E0013 } // Don't lint entrypoint functions diff --git a/tests/ui/missing_const_for_fn/could_be_const.stderr b/tests/ui/missing_const_for_fn/could_be_const.stderr index 955e1ed26340..37929671d858 100644 --- a/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -1,4 +1,4 @@ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:12:5 | LL | / pub fn new() -> Self { @@ -6,9 +6,13 @@ LL | | Self { guess: 42 } LL | | } | |_____^ | - = note: `-D clippy::missing-const-for-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/could_be_const.rs:1:9 + | +LL | #![warn(clippy::missing_const_for_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:16:5 | LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { @@ -16,7 +20,7 @@ LL | | b LL | | } | |_____^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:22:1 | LL | / fn one() -> i32 { @@ -24,7 +28,7 @@ LL | | 1 LL | | } | |_^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:27:1 | LL | / fn two() -> i32 { @@ -33,7 +37,7 @@ LL | | abc LL | | } | |_^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:33:1 | LL | / fn string() -> String { @@ -41,7 +45,7 @@ LL | | String::new() LL | | } | |_^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:38:1 | LL | / unsafe fn four() -> i32 { @@ -49,7 +53,7 @@ LL | | 4 LL | | } | |_^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:43:1 | LL | / fn generic(t: T) -> T { @@ -57,7 +61,7 @@ LL | | t LL | | } | |_^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:51:1 | LL | / fn generic_arr(t: [T; 1]) -> T { @@ -65,7 +69,7 @@ LL | | t[0] LL | | } | |_^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:64:9 | LL | / pub fn b(self, a: &A) -> B { @@ -73,7 +77,7 @@ LL | | B LL | | } | |_________^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:73:5 | LL | / fn const_fn_stabilized_before_msrv(byte: u8) { @@ -81,7 +85,7 @@ LL | | byte.is_ascii_digit(); LL | | } | |_____^ -error: this could be a `const fn` +warning: this could be a `const fn` --> $DIR/could_be_const.rs:84:1 | LL | / fn msrv_1_46() -> i32 { @@ -89,5 +93,5 @@ LL | | 46 LL | | } | |_^ -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/missing_doc.rs b/tests/ui/missing_doc.rs index 590ad63c90be..99a751aa454a 100644 --- a/tests/ui/missing_doc.rs +++ b/tests/ui/missing_doc.rs @@ -1,5 +1,5 @@ // needs-asm-support -// aux-build: proc_macro_with_span.rs +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::missing_docs_in_private_items)] // When denying at the crate level, be sure to not get random warnings from the diff --git a/tests/ui/missing_doc.stderr b/tests/ui/missing_doc.stderr index 4e8a49bf1cd7..cda288510ffb 100644 --- a/tests/ui/missing_doc.stderr +++ b/tests/ui/missing_doc.stderr @@ -1,24 +1,28 @@ -error: missing documentation for a type alias +warning: missing documentation for a type alias --> $DIR/missing_doc.rs:16:1 | LL | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_doc.rs:4:9 + | +LL | #![warn(clippy::missing_docs_in_private_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a module +warning: missing documentation for a module --> $DIR/missing_doc.rs:19:1 | LL | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a function +warning: missing documentation for a function --> $DIR/missing_doc.rs:25:1 | LL | fn foo3() {} | ^^^^^^^^^^^^ -error: missing documentation for an enum +warning: missing documentation for an enum --> $DIR/missing_doc.rs:39:1 | LL | / enum Baz { @@ -27,43 +31,43 @@ LL | | BarB, LL | | } | |_^ -error: missing documentation for a variant +warning: missing documentation for a variant --> $DIR/missing_doc.rs:40:5 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a struct field +warning: missing documentation for a struct field --> $DIR/missing_doc.rs:40:12 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ -error: missing documentation for a struct field +warning: missing documentation for a struct field --> $DIR/missing_doc.rs:40:22 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ -error: missing documentation for a variant +warning: missing documentation for a variant --> $DIR/missing_doc.rs:41:5 | LL | BarB, | ^^^^ -error: missing documentation for a constant +warning: missing documentation for a constant --> $DIR/missing_doc.rs:65:1 | LL | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a static +warning: missing documentation for a static --> $DIR/missing_doc.rs:74:1 | LL | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a module +warning: missing documentation for a module --> $DIR/missing_doc.rs:83:1 | LL | / mod internal_impl { @@ -75,17 +79,17 @@ LL | | } LL | | } | |_^ -error: missing documentation for a function +warning: missing documentation for a function --> $DIR/missing_doc.rs:88:5 | LL | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a function +warning: missing documentation for a function --> $DIR/missing_doc.rs:94:9 | LL | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/missing_doc_crate_missing.stderr b/tests/ui/missing_doc_crate_missing.stderr index 19516bf5fab0..627ecbd0b6cf 100644 --- a/tests/ui/missing_doc_crate_missing.stderr +++ b/tests/ui/missing_doc_crate_missing.stderr @@ -1,4 +1,4 @@ -error: missing documentation for the crate +warning: missing documentation for the crate --> $DIR/missing_doc_crate_missing.rs:1:1 | LL | / #![warn(clippy::missing_docs_in_private_items)] @@ -6,7 +6,11 @@ LL | | LL | | fn main() {} | |____________^ | - = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_doc_crate_missing.rs:1:9 + | +LL | #![warn(clippy::missing_docs_in_private_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/missing_doc_impl.rs b/tests/ui/missing_doc_impl.rs index 0396d1193ff5..62c94d8710f0 100644 --- a/tests/ui/missing_doc_impl.rs +++ b/tests/ui/missing_doc_impl.rs @@ -1,4 +1,4 @@ -// aux-build: proc_macro_with_span.rs +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::missing_docs_in_private_items)] #![allow(dead_code)] diff --git a/tests/ui/missing_doc_impl.stderr b/tests/ui/missing_doc_impl.stderr index 111d65469660..589763fea0f8 100644 --- a/tests/ui/missing_doc_impl.stderr +++ b/tests/ui/missing_doc_impl.stderr @@ -1,4 +1,4 @@ -error: missing documentation for a struct +warning: missing documentation for a struct --> $DIR/missing_doc_impl.rs:13:1 | LL | / struct Foo { @@ -7,27 +7,31 @@ LL | | b: isize, LL | | } | |_^ | - = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_doc_impl.rs:3:9 + | +LL | #![warn(clippy::missing_docs_in_private_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing documentation for a struct field +warning: missing documentation for a struct field --> $DIR/missing_doc_impl.rs:14:5 | LL | a: isize, | ^^^^^^^^ -error: missing documentation for a struct field +warning: missing documentation for a struct field --> $DIR/missing_doc_impl.rs:15:5 | LL | b: isize, | ^^^^^^^^ -error: missing documentation for a struct field +warning: missing documentation for a struct field --> $DIR/missing_doc_impl.rs:20:5 | LL | b: isize, | ^^^^^^^^ -error: missing documentation for an associated function +warning: missing documentation for an associated function --> $DIR/missing_doc_impl.rs:67:5 | LL | / pub fn new() -> Self { @@ -35,13 +39,13 @@ LL | | Foo { a: 0, b: 0 } LL | | } | |_____^ -error: missing documentation for an associated function +warning: missing documentation for an associated function --> $DIR/missing_doc_impl.rs:70:5 | LL | fn bar() {} | ^^^^^^^^^^^ -error: missing documentation for an associated function +warning: missing documentation for an associated function --> $DIR/missing_doc_impl.rs:78:5 | LL | / fn foo2() -> u32 { @@ -49,5 +53,5 @@ LL | | 1 LL | | } | |_____^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index 40b92b7647bf..6945075e1e07 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,40 +1,44 @@ -error: missing `#[inline]` for a function +warning: missing `#[inline]` for a function --> $DIR/missing_inline.rs:19:1 | LL | pub fn pub_foo() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_inline.rs:1:9 + | +LL | #![warn(clippy::missing_inline_in_public_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing `#[inline]` for a default trait method +warning: missing `#[inline]` for a default trait method --> $DIR/missing_inline.rs:35:5 | LL | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ -error: missing `#[inline]` for a method +warning: missing `#[inline]` for a method --> $DIR/missing_inline.rs:49:5 | LL | fn PubBar_a() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ -error: missing `#[inline]` for a method +warning: missing `#[inline]` for a method --> $DIR/missing_inline.rs:50:5 | LL | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ -error: missing `#[inline]` for a method +warning: missing `#[inline]` for a method --> $DIR/missing_inline.rs:51:5 | LL | fn PubBar_c() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ -error: missing `#[inline]` for a method +warning: missing `#[inline]` for a method --> $DIR/missing_inline.rs:61:5 | LL | pub fn PubFooImpl() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/missing_panics_doc.stderr b/tests/ui/missing_panics_doc.stderr index 183c262ce0b5..02c5a74af14f 100644 --- a/tests/ui/missing_panics_doc.stderr +++ b/tests/ui/missing_panics_doc.stderr @@ -1,4 +1,4 @@ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:6:1 | LL | pub fn unwrap() { @@ -9,9 +9,13 @@ note: first possible panic found here | LL | result.unwrap() | ^^^^^^^^^^^^^^^ - = note: `-D clippy::missing-panics-doc` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_panics_doc.rs:1:9 + | +LL | #![warn(clippy::missing_panics_doc)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:12:1 | LL | pub fn panic() { @@ -23,7 +27,7 @@ note: first possible panic found here LL | panic!("This function panics") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:17:1 | LL | pub fn todo() { @@ -35,7 +39,7 @@ note: first possible panic found here LL | todo!() | ^^^^^^^ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:22:1 | LL | pub fn inner_body(opt: Option) { @@ -47,7 +51,7 @@ note: first possible panic found here LL | panic!() | ^^^^^^^^ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:31:1 | LL | pub fn unreachable_and_panic() { @@ -59,7 +63,7 @@ note: first possible panic found here LL | if true { unreachable!() } else { panic!() } | ^^^^^^^^ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:36:1 | LL | pub fn assert_eq() { @@ -71,7 +75,7 @@ note: first possible panic found here LL | assert_eq!(x, 0); | ^^^^^^^^^^^^^^^^ -error: docs for function which may panic missing `# Panics` section +warning: docs for function which may panic missing `# Panics` section --> $DIR/missing_panics_doc.rs:42:1 | LL | pub fn assert_ne() { @@ -83,5 +87,5 @@ note: first possible panic found here LL | assert_ne!(x, 0); | ^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/missing_spin_loop.fixed b/tests/ui/missing_spin_loop.fixed index aa89e04d26eb..a15298dc37b2 100644 --- a/tests/ui/missing_spin_loop.fixed +++ b/tests/ui/missing_spin_loop.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::missing_spin_loop)] #![allow(clippy::bool_comparison)] #![allow(unused_braces)] diff --git a/tests/ui/missing_spin_loop.rs b/tests/ui/missing_spin_loop.rs index 88745e477324..be74581ecd03 100644 --- a/tests/ui/missing_spin_loop.rs +++ b/tests/ui/missing_spin_loop.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::missing_spin_loop)] #![allow(clippy::bool_comparison)] #![allow(unused_braces)] diff --git a/tests/ui/missing_spin_loop.stderr b/tests/ui/missing_spin_loop.stderr index 485da00dc640..92cd69c6c867 100644 --- a/tests/ui/missing_spin_loop.stderr +++ b/tests/ui/missing_spin_loop.stderr @@ -1,40 +1,44 @@ -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:11:37 | LL | while b.load(Ordering::Acquire) {} | ^^ help: try this: `{ std::hint::spin_loop() }` | - = note: `-D clippy::missing-spin-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_spin_loop.rs:2:9 + | +LL | #![warn(clippy::missing_spin_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:13:37 | LL | while !b.load(Ordering::SeqCst) {} | ^^ help: try this: `{ std::hint::spin_loop() }` -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:15:46 | LL | while b.load(Ordering::Acquire) == false {} | ^^ help: try this: `{ std::hint::spin_loop() }` -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:17:49 | LL | while { true == b.load(Ordering::Acquire) } {} | ^^ help: try this: `{ std::hint::spin_loop() }` -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:19:93 | LL | while b.compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed) != Ok(true) {} | ^^ help: try this: `{ std::hint::spin_loop() }` -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop.rs:21:94 | LL | while Ok(false) != b.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed) {} | ^^ help: try this: `{ std::hint::spin_loop() }` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/missing_spin_loop_no_std.fixed b/tests/ui/missing_spin_loop_no_std.fixed index bb4b4795516e..960e5c05fb63 100644 --- a/tests/ui/missing_spin_loop_no_std.fixed +++ b/tests/ui/missing_spin_loop_no_std.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::missing_spin_loop)] #![feature(lang_items, start, libc)] #![no_std] diff --git a/tests/ui/missing_spin_loop_no_std.rs b/tests/ui/missing_spin_loop_no_std.rs index a19bc72baf8d..e532ca62dc53 100644 --- a/tests/ui/missing_spin_loop_no_std.rs +++ b/tests/ui/missing_spin_loop_no_std.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::missing_spin_loop)] #![feature(lang_items, start, libc)] #![no_std] diff --git a/tests/ui/missing_spin_loop_no_std.stderr b/tests/ui/missing_spin_loop_no_std.stderr index 2b3b6873c3c4..8d527cfc1670 100644 --- a/tests/ui/missing_spin_loop_no_std.stderr +++ b/tests/ui/missing_spin_loop_no_std.stderr @@ -1,10 +1,14 @@ -error: busy-waiting loop should at least have a spin loop hint +warning: busy-waiting loop should at least have a spin loop hint --> $DIR/missing_spin_loop_no_std.rs:13:37 | LL | while b.load(Ordering::Acquire) {} | ^^ help: try this: `{ core::hint::spin_loop() }` | - = note: `-D clippy::missing-spin-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_spin_loop_no_std.rs:2:9 + | +LL | #![warn(clippy::missing_spin_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/missing_trait_methods.stderr b/tests/ui/missing_trait_methods.stderr index 0c5205e19657..667bacf8308b 100644 --- a/tests/ui/missing_trait_methods.stderr +++ b/tests/ui/missing_trait_methods.stderr @@ -1,4 +1,4 @@ -error: missing trait method provided by default: `provided` +warning: missing trait method provided by default: `provided` --> $DIR/missing_trait_methods.rs:22:1 | LL | impl A for Partial {} @@ -9,9 +9,13 @@ help: implement the method | LL | fn provided() {} | ^^^^^^^^^^^^^ - = note: `-D clippy::missing-trait-methods` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/missing_trait_methods.rs:2:9 + | +LL | #![warn(clippy::missing_trait_methods)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing trait method provided by default: `b` +warning: missing trait method provided by default: `b` --> $DIR/missing_trait_methods.rs:24:1 | LL | impl B for Partial { @@ -23,5 +27,5 @@ help: implement the method LL | fn b<'a, T: AsRef<[u8]>>(a: &'a T) -> &'a [u8] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/mistyped_literal_suffix.fixed b/tests/ui/mistyped_literal_suffix.fixed index becb9562a849..8aef3d04f994 100644 --- a/tests/ui/mistyped_literal_suffix.fixed +++ b/tests/ui/mistyped_literal_suffix.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro #![allow( dead_code, @@ -9,41 +9,42 @@ clippy::inconsistent_digit_grouping, clippy::unusual_byte_groupings )] +#![warn(clippy::mistyped_literal_suffixes)] extern crate proc_macro_with_span; use proc_macro_with_span::with_span; fn main() { - let fail14 = 2_i32; - let fail15 = 4_i64; - let fail16 = 7_i8; // - let fail17 = 23_i16; // + let fail14 = 2_32; + let fail15 = 4_64; + let fail16 = 7_8; // + let fail17 = 23_16; // let ok18 = 23_128; - let fail20 = 2_i8; // - let fail21 = 4_i16; // + let fail20 = 2__8; // + let fail21 = 4___16; // let ok24 = 12.34_64; - let fail25 = 1E2_f32; - let fail26 = 43E7_f64; - let fail27 = 243E17_f32; - let fail28 = 241_251_235E723_f64; + let fail25 = 1E2_32; + let fail26 = 43E7_64; + let fail27 = 243E17_32; + let fail28 = 241251235E723_64; let ok29 = 42279.911_32; // testing that the suggestion actually fits in its type - let fail30 = 127_i8; // should be i8 - let fail31 = 240_u8; // should be u8 + let fail30 = 127_8; // should be i8 + let fail31 = 240_8; // should be u8 let ok32 = 360_8; // doesnt fit in either, should be ignored - let fail33 = 0x1234_i16; - let fail34 = 0xABCD_u16; + let fail33 = 0x1234_16; + let fail34 = 0xABCD_16; let ok35 = 0x12345_16; - let fail36 = 0xFFFF_FFFF_FFFF_FFFF_u64; // u64 + let fail36 = 0xFFFF_FFFF_FFFF_FFFF_64; // u64 // issue #6129 let ok37 = 123_32.123; let ok38 = 124_64.0; - let _ = 1.123_45E1_f32; + let _ = 1.12345E1_32; let _ = with_span!(1 2_u32); } diff --git a/tests/ui/mistyped_literal_suffix.rs b/tests/ui/mistyped_literal_suffix.rs index ee841bcd7e4e..8aef3d04f994 100644 --- a/tests/ui/mistyped_literal_suffix.rs +++ b/tests/ui/mistyped_literal_suffix.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro #![allow( dead_code, @@ -9,6 +9,7 @@ clippy::inconsistent_digit_grouping, clippy::unusual_byte_groupings )] +#![warn(clippy::mistyped_literal_suffixes)] extern crate proc_macro_with_span; use proc_macro_with_span::with_span; diff --git a/tests/ui/mistyped_literal_suffix.stderr b/tests/ui/mistyped_literal_suffix.stderr index ef8e6a33d28f..e11f91059e56 100644 --- a/tests/ui/mistyped_literal_suffix.stderr +++ b/tests/ui/mistyped_literal_suffix.stderr @@ -1,100 +1,104 @@ -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:17:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:18:18 | LL | let fail14 = 2_32; | ^^^^ help: did you mean to write: `2_i32` | - = note: `#[deny(clippy::mistyped_literal_suffixes)]` on by default +note: the lint level is defined here + --> $DIR/mistyped_literal_suffix.rs:12:9 + | +LL | #![warn(clippy::mistyped_literal_suffixes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:18:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:19:18 | LL | let fail15 = 4_64; | ^^^^ help: did you mean to write: `4_i64` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:19:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:20:18 | LL | let fail16 = 7_8; // | ^^^ help: did you mean to write: `7_i8` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:20:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:21:18 | LL | let fail17 = 23_16; // | ^^^^^ help: did you mean to write: `23_i16` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:23:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:24:18 | LL | let fail20 = 2__8; // | ^^^^ help: did you mean to write: `2_i8` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:24:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:25:18 | LL | let fail21 = 4___16; // | ^^^^^^ help: did you mean to write: `4_i16` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:27:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:28:18 | LL | let fail25 = 1E2_32; | ^^^^^^ help: did you mean to write: `1E2_f32` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:28:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:29:18 | LL | let fail26 = 43E7_64; | ^^^^^^^ help: did you mean to write: `43E7_f64` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:29:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:30:18 | LL | let fail27 = 243E17_32; | ^^^^^^^^^ help: did you mean to write: `243E17_f32` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:30:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:31:18 | LL | let fail28 = 241251235E723_64; | ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:34:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:35:18 | LL | let fail30 = 127_8; // should be i8 | ^^^^^ help: did you mean to write: `127_i8` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:35:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:36:18 | LL | let fail31 = 240_8; // should be u8 | ^^^^^ help: did you mean to write: `240_u8` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:37:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:38:18 | LL | let fail33 = 0x1234_16; | ^^^^^^^^^ help: did you mean to write: `0x1234_i16` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:38:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:39:18 | LL | let fail34 = 0xABCD_16; | ^^^^^^^^^ help: did you mean to write: `0xABCD_u16` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:40:18 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:41:18 | LL | let fail36 = 0xFFFF_FFFF_FFFF_FFFF_64; // u64 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to write: `0xFFFF_FFFF_FFFF_FFFF_u64` -error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:46:13 +warning: mistyped literal suffix + --> $DIR/mistyped_literal_suffix.rs:47:13 | LL | let _ = 1.12345E1_32; | ^^^^^^^^^^^^ help: did you mean to write: `1.123_45E1_f32` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/mixed_read_write_in_expression.stderr b/tests/ui/mixed_read_write_in_expression.stderr index 8cc68b0ac7b4..1eb6c5109f6e 100644 --- a/tests/ui/mixed_read_write_in_expression.stderr +++ b/tests/ui/mixed_read_write_in_expression.stderr @@ -1,4 +1,4 @@ -error: unsequenced read of `x` +warning: unsequenced read of `x` --> $DIR/mixed_read_write_in_expression.rs:14:9 | LL | } + x; @@ -9,9 +9,13 @@ note: whether read occurs before this write depends on evaluation order | LL | x = 1; | ^^^^^ - = note: `-D clippy::mixed-read-write-in-expression` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mixed_read_write_in_expression.rs:1:8 + | +LL | #[warn(clippy::mixed_read_write_in_expression)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsequenced read of `x` +warning: unsequenced read of `x` --> $DIR/mixed_read_write_in_expression.rs:17:5 | LL | x += { @@ -23,7 +27,7 @@ note: whether read occurs before this write depends on evaluation order LL | x = 20; | ^^^^^^ -error: unsequenced read of `x` +warning: unsequenced read of `x` --> $DIR/mixed_read_write_in_expression.rs:30:12 | LL | a: x, @@ -35,7 +39,7 @@ note: whether read occurs before this write depends on evaluation order LL | x = 6; | ^^^^^ -error: unsequenced read of `x` +warning: unsequenced read of `x` --> $DIR/mixed_read_write_in_expression.rs:39:9 | LL | x += { @@ -47,5 +51,5 @@ note: whether read occurs before this write depends on evaluation order LL | x = 20; | ^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index 77564dce9eb4..6aea22d6f14e 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,4 +1,4 @@ -error: module has the same name as its containing module +warning: module has the same name as its containing module --> $DIR/module_inception.rs:5:9 | LL | / mod bar { @@ -6,9 +6,13 @@ LL | | mod foo {} LL | | } | |_________^ | - = note: `-D clippy::module-inception` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/module_inception.rs:1:9 + | +LL | #![warn(clippy::module_inception)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: module has the same name as its containing module +warning: module has the same name as its containing module --> $DIR/module_inception.rs:10:5 | LL | / mod foo { @@ -16,5 +20,5 @@ LL | | mod bar {} LL | | } | |_____^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/module_name_repetitions.rs b/tests/ui/module_name_repetitions.rs index ebaa77cc283e..fb2c7612343c 100644 --- a/tests/ui/module_name_repetitions.rs +++ b/tests/ui/module_name_repetitions.rs @@ -1,4 +1,4 @@ -// compile-flags: --test +//@compile-flags: --test #![warn(clippy::module_name_repetitions)] #![allow(dead_code)] diff --git a/tests/ui/module_name_repetitions.stderr b/tests/ui/module_name_repetitions.stderr index 277801194a1d..b53ca7867efd 100644 --- a/tests/ui/module_name_repetitions.stderr +++ b/tests/ui/module_name_repetitions.stderr @@ -1,34 +1,38 @@ -error: item name starts with its containing module's name +warning: item name starts with its containing module's name --> $DIR/module_name_repetitions.rs:8:12 | LL | pub fn foo_bar() {} | ^^^^^^^ | - = note: `-D clippy::module-name-repetitions` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/module_name_repetitions.rs:3:9 + | +LL | #![warn(clippy::module_name_repetitions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: item name ends with its containing module's name +warning: item name ends with its containing module's name --> $DIR/module_name_repetitions.rs:9:12 | LL | pub fn bar_foo() {} | ^^^^^^^ -error: item name starts with its containing module's name +warning: item name starts with its containing module's name --> $DIR/module_name_repetitions.rs:10:16 | LL | pub struct FooCake; | ^^^^^^^ -error: item name ends with its containing module's name +warning: item name ends with its containing module's name --> $DIR/module_name_repetitions.rs:11:14 | LL | pub enum CakeFoo {} | ^^^^^^^ -error: item name starts with its containing module's name +warning: item name starts with its containing module's name --> $DIR/module_name_repetitions.rs:12:16 | LL | pub struct Foo7Bar; | ^^^^^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/modulo_arithmetic_float.stderr b/tests/ui/modulo_arithmetic_float.stderr index 36106de31f0b..feffe779d103 100644 --- a/tests/ui/modulo_arithmetic_float.stderr +++ b/tests/ui/modulo_arithmetic_float.stderr @@ -1,13 +1,17 @@ -error: you are using modulo operator on constants with different signs: `-1.600 % 2.100` +warning: you are using modulo operator on constants with different signs: `-1.600 % 2.100` --> $DIR/modulo_arithmetic_float.rs:6:5 | LL | -1.6 % 2.1; | ^^^^^^^^^^ | = note: double check for expected result especially when interoperating with different languages - = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/modulo_arithmetic_float.rs:1:9 + | +LL | #![warn(clippy::modulo_arithmetic)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you are using modulo operator on constants with different signs: `1.600 % -2.100` +warning: you are using modulo operator on constants with different signs: `1.600 % -2.100` --> $DIR/modulo_arithmetic_float.rs:7:5 | LL | 1.6 % -2.1; @@ -15,7 +19,7 @@ LL | 1.6 % -2.1; | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on constants with different signs: `-1.200 % 3.400` +warning: you are using modulo operator on constants with different signs: `-1.200 % 3.400` --> $DIR/modulo_arithmetic_float.rs:8:5 | LL | (1.1 - 2.3) % (1.1 + 2.3); @@ -23,7 +27,7 @@ LL | (1.1 - 2.3) % (1.1 + 2.3); | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on constants with different signs: `3.400 % -1.200` +warning: you are using modulo operator on constants with different signs: `3.400 % -1.200` --> $DIR/modulo_arithmetic_float.rs:9:5 | LL | (1.1 + 2.3) % (1.1 - 2.3); @@ -31,7 +35,7 @@ LL | (1.1 + 2.3) % (1.1 - 2.3); | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_float.rs:14:5 | LL | a_f32 % b_f32; @@ -39,7 +43,7 @@ LL | a_f32 % b_f32; | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_float.rs:15:5 | LL | b_f32 % a_f32; @@ -47,7 +51,7 @@ LL | b_f32 % a_f32; | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_float.rs:16:5 | LL | b_f32 %= a_f32; @@ -55,7 +59,7 @@ LL | b_f32 %= a_f32; | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_float.rs:20:5 | LL | a_f64 % b_f64; @@ -63,7 +67,7 @@ LL | a_f64 % b_f64; | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_float.rs:21:5 | LL | b_f64 % a_f64; @@ -71,7 +75,7 @@ LL | b_f64 % a_f64; | = note: double check for expected result especially when interoperating with different languages -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_float.rs:22:5 | LL | b_f64 %= a_f64; @@ -79,5 +83,5 @@ LL | b_f64 %= a_f64; | = note: double check for expected result especially when interoperating with different languages -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/modulo_arithmetic_integral.stderr b/tests/ui/modulo_arithmetic_integral.stderr index 9ff676ff6bcb..4d3716eb6e8a 100644 --- a/tests/ui/modulo_arithmetic_integral.stderr +++ b/tests/ui/modulo_arithmetic_integral.stderr @@ -1,4 +1,4 @@ -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:8:5 | LL | a % b; @@ -6,9 +6,13 @@ LL | a % b; | = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function - = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/modulo_arithmetic_integral.rs:1:9 + | +LL | #![warn(clippy::modulo_arithmetic)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:9:5 | LL | b % a; @@ -17,7 +21,7 @@ LL | b % a; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:10:5 | LL | b %= a; @@ -26,7 +30,7 @@ LL | b %= a; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:14:5 | LL | a_i8 % b_i8; @@ -35,7 +39,7 @@ LL | a_i8 % b_i8; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:15:5 | LL | b_i8 %= a_i8; @@ -44,7 +48,7 @@ LL | b_i8 %= a_i8; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:19:5 | LL | a_i16 % b_i16; @@ -53,7 +57,7 @@ LL | a_i16 % b_i16; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:20:5 | LL | b_i16 %= a_i16; @@ -62,7 +66,7 @@ LL | b_i16 %= a_i16; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:24:5 | LL | a_i32 % b_i32; @@ -71,7 +75,7 @@ LL | a_i32 % b_i32; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:25:5 | LL | b_i32 %= a_i32; @@ -80,7 +84,7 @@ LL | b_i32 %= a_i32; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:29:5 | LL | a_i64 % b_i64; @@ -89,7 +93,7 @@ LL | a_i64 % b_i64; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:30:5 | LL | b_i64 %= a_i64; @@ -98,7 +102,7 @@ LL | b_i64 %= a_i64; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:34:5 | LL | a_i128 % b_i128; @@ -107,7 +111,7 @@ LL | a_i128 % b_i128; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:35:5 | LL | b_i128 %= a_i128; @@ -116,7 +120,7 @@ LL | b_i128 %= a_i128; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:39:5 | LL | a_isize % b_isize; @@ -125,7 +129,7 @@ LL | a_isize % b_isize; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:40:5 | LL | b_isize %= a_isize; @@ -134,7 +138,7 @@ LL | b_isize %= a_isize; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:44:5 | LL | a % b; @@ -143,7 +147,7 @@ LL | a % b; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on types that might have different signs +warning: you are using modulo operator on types that might have different signs --> $DIR/modulo_arithmetic_integral.rs:45:5 | LL | b %= a; @@ -152,5 +156,5 @@ LL | b %= a; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/modulo_arithmetic_integral_const.stderr b/tests/ui/modulo_arithmetic_integral_const.stderr index 1453d44f488f..e0ed8138034f 100644 --- a/tests/ui/modulo_arithmetic_integral_const.stderr +++ b/tests/ui/modulo_arithmetic_integral_const.stderr @@ -1,4 +1,4 @@ -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:11:5 | LL | -1 % 2; @@ -6,9 +6,13 @@ LL | -1 % 2; | = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function - = note: `-D clippy::modulo-arithmetic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/modulo_arithmetic_integral_const.rs:1:9 + | +LL | #![warn(clippy::modulo_arithmetic)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:12:5 | LL | 1 % -2; @@ -17,7 +21,7 @@ LL | 1 % -2; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 3` +warning: you are using modulo operator on constants with different signs: `-1 % 3` --> $DIR/modulo_arithmetic_integral_const.rs:13:5 | LL | (1 - 2) % (1 + 2); @@ -26,7 +30,7 @@ LL | (1 - 2) % (1 + 2); = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `3 % -1` +warning: you are using modulo operator on constants with different signs: `3 % -1` --> $DIR/modulo_arithmetic_integral_const.rs:14:5 | LL | (1 + 2) % (1 - 2); @@ -35,7 +39,7 @@ LL | (1 + 2) % (1 - 2); = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-35 % 300000` +warning: you are using modulo operator on constants with different signs: `-35 % 300000` --> $DIR/modulo_arithmetic_integral_const.rs:15:5 | LL | 35 * (7 - 4 * 2) % (-500 * -600); @@ -44,7 +48,7 @@ LL | 35 * (7 - 4 * 2) % (-500 * -600); = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:17:5 | LL | -1i8 % 2i8; @@ -53,7 +57,7 @@ LL | -1i8 % 2i8; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:18:5 | LL | 1i8 % -2i8; @@ -62,7 +66,7 @@ LL | 1i8 % -2i8; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:19:5 | LL | -1i16 % 2i16; @@ -71,7 +75,7 @@ LL | -1i16 % 2i16; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:20:5 | LL | 1i16 % -2i16; @@ -80,7 +84,7 @@ LL | 1i16 % -2i16; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:21:5 | LL | -1i32 % 2i32; @@ -89,7 +93,7 @@ LL | -1i32 % 2i32; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:22:5 | LL | 1i32 % -2i32; @@ -98,7 +102,7 @@ LL | 1i32 % -2i32; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:23:5 | LL | -1i64 % 2i64; @@ -107,7 +111,7 @@ LL | -1i64 % 2i64; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:24:5 | LL | 1i64 % -2i64; @@ -116,7 +120,7 @@ LL | 1i64 % -2i64; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:25:5 | LL | -1i128 % 2i128; @@ -125,7 +129,7 @@ LL | -1i128 % 2i128; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:26:5 | LL | 1i128 % -2i128; @@ -134,7 +138,7 @@ LL | 1i128 % -2i128; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `-1 % 2` +warning: you are using modulo operator on constants with different signs: `-1 % 2` --> $DIR/modulo_arithmetic_integral_const.rs:27:5 | LL | -1isize % 2isize; @@ -143,7 +147,7 @@ LL | -1isize % 2isize; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: you are using modulo operator on constants with different signs: `1 % -2` +warning: you are using modulo operator on constants with different signs: `1 % -2` --> $DIR/modulo_arithmetic_integral_const.rs:28:5 | LL | 1isize % -2isize; @@ -152,5 +156,5 @@ LL | 1isize % -2isize; = note: double check for expected result especially when interoperating with different languages = note: or consider using `rem_euclid` or similar function -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/modulo_one.rs b/tests/ui/modulo_one.rs index adff08e5d1e8..21ceea0b62cc 100644 --- a/tests/ui/modulo_one.rs +++ b/tests/ui/modulo_one.rs @@ -1,4 +1,4 @@ -#![warn(clippy::modulo_one)] +#![warn(clippy::modulo_one, unconditional_panic)] #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::identity_op)] static STATIC_ONE: usize = 2 - 1; diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 04ecdef5e994..74b8e47c1b26 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -1,60 +1,68 @@ -error: this operation will panic at runtime +warning: this operation will panic at runtime --> $DIR/modulo_one.rs:11:5 | LL | i32::MIN % (-1); // also caught by rustc | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow | - = note: `#[deny(unconditional_panic)]` on by default +note: the lint level is defined here + --> $DIR/modulo_one.rs:1:29 + | +LL | #![warn(clippy::modulo_one, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime +warning: this operation will panic at runtime --> $DIR/modulo_one.rs:21:5 | LL | INT_MIN % NEG_ONE; // also caught by rustc | ^^^^^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime +warning: this operation will panic at runtime --> $DIR/modulo_one.rs:22:5 | LL | INT_MIN % STATIC_NEG_ONE; // ONLY caught by rustc | ^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow -error: any number modulo 1 will be 0 +warning: any number modulo 1 will be 0 --> $DIR/modulo_one.rs:8:5 | LL | 10 % 1; | ^^^^^^ | - = note: `-D clippy::modulo-one` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/modulo_one.rs:1:9 + | +LL | #![warn(clippy::modulo_one, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^ -error: any number modulo -1 will panic/overflow or result in 0 +warning: any number modulo -1 will panic/overflow or result in 0 --> $DIR/modulo_one.rs:9:5 | LL | 10 % -1; | ^^^^^^^ -error: any number modulo -1 will panic/overflow or result in 0 +warning: any number modulo -1 will panic/overflow or result in 0 --> $DIR/modulo_one.rs:11:5 | LL | i32::MIN % (-1); // also caught by rustc | ^^^^^^^^^^^^^^^ -error: any number modulo 1 will be 0 +warning: any number modulo 1 will be 0 --> $DIR/modulo_one.rs:17:5 | LL | 2 % ONE; | ^^^^^^^ -error: any number modulo -1 will panic/overflow or result in 0 +warning: any number modulo -1 will panic/overflow or result in 0 --> $DIR/modulo_one.rs:19:5 | LL | 2 % NEG_ONE; | ^^^^^^^^^^^ -error: any number modulo -1 will panic/overflow or result in 0 +warning: any number modulo -1 will panic/overflow or result in 0 --> $DIR/modulo_one.rs:21:5 | LL | INT_MIN % NEG_ONE; // also caught by rustc | ^^^^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/multi_assignments.stderr b/tests/ui/multi_assignments.stderr index d6c42bb698cf..588e7aa27a39 100644 --- a/tests/ui/multi_assignments.stderr +++ b/tests/ui/multi_assignments.stderr @@ -1,40 +1,44 @@ -error: assignments don't nest intuitively +warning: assignments don't nest intuitively --> $DIR/multi_assignments.rs:4:5 | LL | a = b = c; | ^^^^^^^^^ | - = note: `-D clippy::multi-assignments` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/multi_assignments.rs:1:9 + | +LL | #![warn(clippy::multi_assignments)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: assignments don't nest intuitively +warning: assignments don't nest intuitively --> $DIR/multi_assignments.rs:5:5 | LL | a = b = c = d; | ^^^^^^^^^^^^^ -error: assignments don't nest intuitively +warning: assignments don't nest intuitively --> $DIR/multi_assignments.rs:5:9 | LL | a = b = c = d; | ^^^^^^^^^ -error: assignments don't nest intuitively +warning: assignments don't nest intuitively --> $DIR/multi_assignments.rs:6:5 | LL | a = b = { c }; | ^^^^^^^^^^^^^ -error: assignments don't nest intuitively +warning: assignments don't nest intuitively --> $DIR/multi_assignments.rs:7:5 | LL | a = { b = c }; | ^^^^^^^^^^^^^ -error: assignments don't nest intuitively +warning: assignments don't nest intuitively --> $DIR/multi_assignments.rs:8:5 | LL | a = (b = c); | ^^^^^^^^^^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/multiple_unsafe_ops_per_block.rs b/tests/ui/multiple_unsafe_ops_per_block.rs index 5073685c9f06..b8e392486c86 100644 --- a/tests/ui/multiple_unsafe_ops_per_block.rs +++ b/tests/ui/multiple_unsafe_ops_per_block.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![allow(unused)] #![allow(deref_nullptr)] #![allow(clippy::unnecessary_operation)] diff --git a/tests/ui/multiple_unsafe_ops_per_block.stderr b/tests/ui/multiple_unsafe_ops_per_block.stderr index e0c1d3801f7c..e761b29929c4 100644 --- a/tests/ui/multiple_unsafe_ops_per_block.stderr +++ b/tests/ui/multiple_unsafe_ops_per_block.stderr @@ -1,4 +1,4 @@ -error: this `unsafe` block contains 2 unsafe operations, expected only one +warning: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:36:5 | LL | / unsafe { @@ -17,9 +17,13 @@ note: unsafe function call occurs here | LL | not_very_safe(); | ^^^^^^^^^^^^^^^ - = note: `-D clippy::multiple-unsafe-ops-per-block` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/multiple_unsafe_ops_per_block.rs:6:9 + | +LL | #![warn(clippy::multiple_unsafe_ops_per_block)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this `unsafe` block contains 2 unsafe operations, expected only one +warning: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:45:5 | LL | / unsafe { @@ -39,7 +43,7 @@ note: raw pointer dereference occurs here LL | *raw_ptr(); | ^^^^^^^^^^ -error: this `unsafe` block contains 3 unsafe operations, expected only one +warning: this `unsafe` block contains 3 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:52:5 | LL | / unsafe { @@ -65,7 +69,7 @@ note: modification of a mutable static occurs here LL | STATIC = 0; | ^^^^^^^^^^ -error: this `unsafe` block contains 6 unsafe operations, expected only one +warning: this `unsafe` block contains 6 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:61:5 | LL | / unsafe { @@ -108,7 +112,7 @@ note: inline assembly used here LL | asm!("nop"); | ^^^^^^^^^^^ -error: this `unsafe` block contains 2 unsafe operations, expected only one +warning: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:105:5 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } @@ -125,7 +129,7 @@ note: raw pointer dereference occurs here LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^ -error: this `unsafe` block contains 2 unsafe operations, expected only one +warning: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:120:5 | LL | / unsafe { @@ -145,7 +149,7 @@ note: unsafe function call occurs here LL | x(); | ^^^ -error: this `unsafe` block contains 2 unsafe operations, expected only one +warning: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:131:9 | LL | / unsafe { @@ -165,7 +169,7 @@ note: unsafe function call occurs here LL | T::X(); | ^^^^^^ -error: this `unsafe` block contains 2 unsafe operations, expected only one +warning: this `unsafe` block contains 2 unsafe operations, expected only one --> $DIR/multiple_unsafe_ops_per_block.rs:141:5 | LL | / unsafe { @@ -185,5 +189,5 @@ note: unsafe function call occurs here LL | x.0(); | ^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/must_use_candidates.fixed b/tests/ui/must_use_candidates.fixed index bbbb3cf621e4..0c275504d36b 100644 --- a/tests/ui/must_use_candidates.fixed +++ b/tests/ui/must_use_candidates.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(never_type)] #![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)] #![warn(clippy::must_use_candidate)] diff --git a/tests/ui/must_use_candidates.rs b/tests/ui/must_use_candidates.rs index 94d3c83bdb93..d1c9267732fa 100644 --- a/tests/ui/must_use_candidates.rs +++ b/tests/ui/must_use_candidates.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(never_type)] #![allow(unused_mut, unused_tuple_struct_fields, clippy::redundant_allocation)] #![warn(clippy::must_use_candidate)] diff --git a/tests/ui/must_use_candidates.stderr b/tests/ui/must_use_candidates.stderr index 0fa3849d03bf..ce21e7637aee 100644 --- a/tests/ui/must_use_candidates.stderr +++ b/tests/ui/must_use_candidates.stderr @@ -1,34 +1,38 @@ -error: this function could have a `#[must_use]` attribute +warning: this function could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:12:1 | LL | pub fn pure(i: u8) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8` | - = note: `-D clippy::must-use-candidate` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/must_use_candidates.rs:4:9 + | +LL | #![warn(clippy::must_use_candidate)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this method could have a `#[must_use]` attribute +warning: this method could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:17:5 | LL | pub fn inherent_pure(&self) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8` -error: this function could have a `#[must_use]` attribute +warning: this function could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:48:1 | LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool` -error: this function could have a `#[must_use]` attribute +warning: this function could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:60:1 | LL | pub fn rcd(_x: Rc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc) -> bool` -error: this function could have a `#[must_use]` attribute +warning: this function could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:68:1 | LL | pub fn arcd(_x: Arc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc) -> bool` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/must_use_unit.fixed b/tests/ui/must_use_unit.fixed deleted file mode 100644 index 6c9aa434ac01..000000000000 --- a/tests/ui/must_use_unit.fixed +++ /dev/null @@ -1,26 +0,0 @@ -//run-rustfix -// aux-build:macro_rules.rs - -#![warn(clippy::must_use_unit)] -#![allow(clippy::unused_unit)] - -#[macro_use] -extern crate macro_rules; - - -pub fn must_use_default() {} - - -pub fn must_use_unit() -> () {} - - -pub fn must_use_with_note() {} - -fn main() { - must_use_default(); - must_use_unit(); - must_use_with_note(); - - // We should not lint in external macros - must_use_unit!(); -} diff --git a/tests/ui/must_use_unit.rs b/tests/ui/must_use_unit.rs index 8a395dc284db..c57057fcdc06 100644 --- a/tests/ui/must_use_unit.rs +++ b/tests/ui/must_use_unit.rs @@ -1,5 +1,5 @@ //run-rustfix -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::must_use_unit)] #![allow(clippy::unused_unit)] diff --git a/tests/ui/must_use_unit.stderr b/tests/ui/must_use_unit.stderr index 15e0906b66b5..0ef0dcfb6c5d 100644 --- a/tests/ui/must_use_unit.stderr +++ b/tests/ui/must_use_unit.stderr @@ -1,4 +1,4 @@ -error: this unit-returning function has a `#[must_use]` attribute +warning: this unit-returning function has a `#[must_use]` attribute --> $DIR/must_use_unit.rs:11:1 | LL | #[must_use] @@ -6,9 +6,13 @@ LL | #[must_use] LL | pub fn must_use_default() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::must-use-unit` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/must_use_unit.rs:4:9 + | +LL | #![warn(clippy::must_use_unit)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: this unit-returning function has a `#[must_use]` attribute +warning: this unit-returning function has a `#[must_use]` attribute --> $DIR/must_use_unit.rs:14:1 | LL | #[must_use] @@ -16,7 +20,7 @@ LL | #[must_use] LL | pub fn must_use_unit() -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this unit-returning function has a `#[must_use]` attribute +warning: this unit-returning function has a `#[must_use]` attribute --> $DIR/must_use_unit.rs:17:1 | LL | #[must_use = "With note"] @@ -24,5 +28,5 @@ LL | #[must_use = "With note"] LL | pub fn must_use_with_note() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index c20ff54bf949..38e0b7c5d9b7 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -1,4 +1,4 @@ -error: mutable borrow from immutable input(s) +warning: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:7:39 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { @@ -9,9 +9,13 @@ note: immutable borrow here | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ - = note: `-D clippy::mut-from-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mut_from_ref.rs:2:9 + | +LL | #![warn(clippy::mut_from_ref)] + | ^^^^^^^^^^^^^^^^^^^^ -error: mutable borrow from immutable input(s) +warning: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:13:25 | LL | fn ouch(x: &Foo) -> &mut Foo; @@ -23,7 +27,7 @@ note: immutable borrow here LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ -error: mutable borrow from immutable input(s) +warning: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:22:21 | LL | fn fail(x: &u32) -> &mut u16 { @@ -35,7 +39,7 @@ note: immutable borrow here LL | fn fail(x: &u32) -> &mut u16 { | ^^^^ -error: mutable borrow from immutable input(s) +warning: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:26:50 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { @@ -47,7 +51,7 @@ note: immutable borrow here LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ -error: mutable borrow from immutable input(s) +warning: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:30:67 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { @@ -59,7 +63,7 @@ note: immutable borrow here LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ -error: mutable borrow from immutable input(s) +warning: mutable borrow from immutable input(s) --> $DIR/mut_from_ref.rs:44:35 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { @@ -71,5 +75,5 @@ note: immutable borrow here LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/mut_key.stderr b/tests/ui/mut_key.stderr index 25dd029b16ee..bc64e6a90b84 100644 --- a/tests/ui/mut_key.stderr +++ b/tests/ui/mut_key.stderr @@ -1,106 +1,106 @@ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:30:32 | LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::mutable-key-type` implied by `-D warnings` + = note: `#[warn(clippy::mutable_key_type)]` on by default -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:30:72 | LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { | ^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:31:5 | LL | let _other: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:58:22 | LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:70:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:71:5 | LL | let _map = HashMap::<&mut Cell, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:72:5 | LL | let _map = HashMap::<&mut usize, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:74:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:75:5 | LL | let _map = HashMap::, ()>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:76:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:77:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:78:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:79:5 | LL | let _map = HashMap::>>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:80:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:82:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:83:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mutable key type +warning: mutable key type --> $DIR/mut_key.rs:84:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index ee3a856566cc..f77cbc2a4d0d 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::mut_mut)] #![allow(unused)] #![allow(clippy::no_effect, clippy::uninlined_format_args, clippy::unnecessary_operation)] diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index 6820a85aa543..9f7b4df330cf 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,18 +1,22 @@ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:9:11 | LL | fn fun(x: &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ | - = note: `-D clippy::mut-mut` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mut_mut.rs:2:9 + | +LL | #![warn(clippy::mut_mut)] + | ^^^^^^^^^^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:25:17 | LL | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:19:9 | LL | &mut $p @@ -21,43 +25,43 @@ LL | &mut $p LL | let mut z = mut_ptr!(&mut 3u32); | ------------------- in this macro invocation | - = note: this error originates in the macro `mut_ptr` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `mut_ptr` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this expression mutably borrows a mutable reference. Consider reborrowing +warning: this expression mutably borrows a mutable reference. Consider reborrowing --> $DIR/mut_mut.rs:27:21 | LL | let mut y = &mut x; | ^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:31:32 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:31:16 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:36:37 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:36:16 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^^^ -error: generally you want to avoid `&mut &mut _` if possible +warning: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:36:21 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/mut_mutex_lock.fixed b/tests/ui/mut_mutex_lock.fixed index ecad10a82903..567a0b59e703 100644 --- a/tests/ui/mut_mutex_lock.fixed +++ b/tests/ui/mut_mutex_lock.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_mut)] #![warn(clippy::mut_mutex_lock)] @@ -8,7 +8,7 @@ fn mut_mutex_lock() { let mut value_rc = Arc::new(Mutex::new(42_u8)); let value_mutex = Arc::get_mut(&mut value_rc).unwrap(); - let mut value = value_mutex.get_mut().unwrap(); + let mut value = value_mutex.lock().unwrap(); *value += 1; } diff --git a/tests/ui/mut_mutex_lock.rs b/tests/ui/mut_mutex_lock.rs index f2b1d6fbfbc3..567a0b59e703 100644 --- a/tests/ui/mut_mutex_lock.rs +++ b/tests/ui/mut_mutex_lock.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_mut)] #![warn(clippy::mut_mutex_lock)] diff --git a/tests/ui/mut_mutex_lock.stderr b/tests/ui/mut_mutex_lock.stderr index 21c1b3486cac..ea1d71775d9e 100644 --- a/tests/ui/mut_mutex_lock.stderr +++ b/tests/ui/mut_mutex_lock.stderr @@ -1,10 +1,14 @@ -error: calling `&mut Mutex::lock` unnecessarily locks an exclusive (mutable) reference +warning: calling `&mut Mutex::lock` unnecessarily locks an exclusive (mutable) reference --> $DIR/mut_mutex_lock.rs:11:33 | LL | let mut value = value_mutex.lock().unwrap(); | ^^^^ help: change this to: `get_mut` | - = note: `-D clippy::mut-mutex-lock` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mut_mutex_lock.rs:3:9 + | +LL | #![warn(clippy::mut_mutex_lock)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index b679b7a0aaf8..0eb728c71303 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -1,13 +1,13 @@ -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:8:9 | LL | m = 5; | ^ | = note: the range of the loop is unchanged - = note: `-D clippy::mut-range-bound` implied by `-D warnings` + = note: `#[warn(clippy::mut_range_bound)]` on by default -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:15:9 | LL | m *= 2; @@ -15,7 +15,7 @@ LL | m *= 2; | = note: the range of the loop is unchanged -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:23:9 | LL | m = 5; @@ -23,7 +23,7 @@ LL | m = 5; | = note: the range of the loop is unchanged -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:24:9 | LL | n = 7; @@ -31,7 +31,7 @@ LL | n = 7; | = note: the range of the loop is unchanged -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:38:22 | LL | let n = &mut m; // warning @@ -39,7 +39,7 @@ LL | let n = &mut m; // warning | = note: the range of the loop is unchanged -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:70:9 | LL | m = 2; // warning because it is not immediately followed by break @@ -47,7 +47,7 @@ LL | m = 2; // warning because it is not immediately followed by break | = note: the range of the loop is unchanged -error: attempt to mutate range bound within loop +warning: attempt to mutate range bound within loop --> $DIR/mut_range_bound.rs:79:13 | LL | n = 1; // FIXME: warning because it is not immediately followed by break @@ -55,5 +55,5 @@ LL | n = 1; // FIXME: warning because it is not immediately followed | = note: the range of the loop is unchanged -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 062d30b262c1..87a38c65f0ca 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,22 +1,26 @@ -error: the function `takes_an_immutable_reference` doesn't need a mutable reference +warning: the function `takes_an_immutable_reference` doesn't need a mutable reference --> $DIR/mut_reference.rs:17:34 | LL | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | - = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mut_reference.rs:14:8 + | +LL | #[warn(clippy::unnecessary_mut_passed)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the function `as_ptr` doesn't need a mutable reference +warning: the function `as_ptr` doesn't need a mutable reference --> $DIR/mut_reference.rs:19:12 | LL | as_ptr(&mut 42); | ^^^^^^^ -error: the method `takes_an_immutable_reference` doesn't need a mutable reference +warning: the method `takes_an_immutable_reference` doesn't need a mutable reference --> $DIR/mut_reference.rs:23:44 | LL | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 262028a8723a..d102cca13672 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,48 +1,56 @@ -error: consider using an `AtomicBool` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicBool` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:8:5 | LL | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::mutex-atomic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mutex_atomic.rs:3:9 + | +LL | #![warn(clippy::mutex_atomic)] + | ^^^^^^^^^^^^^^^^^^^^ -error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:9:5 | LL | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ -error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:10:5 | LL | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ -error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:12:5 | LL | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:13:5 | LL | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:14:5 | LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::mutex-integer` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mutex_atomic.rs:2:9 + | +LL | #![warn(clippy::mutex_integer)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` +warning: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` --> $DIR/mutex_atomic.rs:15:5 | LL | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/needless_arbitrary_self_type.fixed b/tests/ui/needless_arbitrary_self_type.fixed index 9da21eb6b29b..d7eb1a047ed3 100644 --- a/tests/ui/needless_arbitrary_self_type.fixed +++ b/tests/ui/needless_arbitrary_self_type.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_arbitrary_self_type)] #![allow(unused_mut, clippy::needless_lifetimes)] diff --git a/tests/ui/needless_arbitrary_self_type.rs b/tests/ui/needless_arbitrary_self_type.rs index 17aeaaf97ac7..85a2a957f29a 100644 --- a/tests/ui/needless_arbitrary_self_type.rs +++ b/tests/ui/needless_arbitrary_self_type.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_arbitrary_self_type)] #![allow(unused_mut, clippy::needless_lifetimes)] diff --git a/tests/ui/needless_arbitrary_self_type.stderr b/tests/ui/needless_arbitrary_self_type.stderr index f4c645d35c8f..2a2e029de1b1 100644 --- a/tests/ui/needless_arbitrary_self_type.stderr +++ b/tests/ui/needless_arbitrary_self_type.stderr @@ -1,40 +1,44 @@ -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:12:16 | LL | pub fn bad(self: Self) { | ^^^^^^^^^^ help: consider to change this parameter to: `self` | - = note: `-D clippy::needless-arbitrary-self-type` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_arbitrary_self_type.rs:3:9 + | +LL | #![warn(clippy::needless_arbitrary_self_type)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:20:20 | LL | pub fn mut_bad(mut self: Self) { | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `mut self` -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:28:20 | LL | pub fn ref_bad(self: &Self) { | ^^^^^^^^^^^ help: consider to change this parameter to: `&self` -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:36:38 | LL | pub fn ref_bad_with_lifetime<'a>(self: &'a Self) { | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a self` -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:44:24 | LL | pub fn mut_ref_bad(self: &mut Self) { | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type.rs:52:42 | LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) { | ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/needless_arbitrary_self_type_unfixable.rs b/tests/ui/needless_arbitrary_self_type_unfixable.rs index 02b43cce2bd4..876f16a3854d 100644 --- a/tests/ui/needless_arbitrary_self_type_unfixable.rs +++ b/tests/ui/needless_arbitrary_self_type_unfixable.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_attr.rs +//@aux-build:proc_macro_attr.rs:proc-macro #![warn(clippy::needless_arbitrary_self_type)] diff --git a/tests/ui/needless_arbitrary_self_type_unfixable.stderr b/tests/ui/needless_arbitrary_self_type_unfixable.stderr index b2edbfe4323e..450adedd6670 100644 --- a/tests/ui/needless_arbitrary_self_type_unfixable.stderr +++ b/tests/ui/needless_arbitrary_self_type_unfixable.stderr @@ -1,10 +1,14 @@ -error: the type of the `self` parameter does not need to be arbitrary +warning: the type of the `self` parameter does not need to be arbitrary --> $DIR/needless_arbitrary_self_type_unfixable.rs:42:31 | LL | fn call_with_mut_self(self: &mut Self) {} | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'_ mut self` | - = note: `-D clippy::needless-arbitrary-self-type` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_arbitrary_self_type_unfixable.rs:3:9 + | +LL | #![warn(clippy::needless_arbitrary_self_type)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/needless_bitwise_bool.fixed b/tests/ui/needless_bitwise_bool.fixed index 5e1ea663a107..7543ab72ca21 100644 --- a/tests/ui/needless_bitwise_bool.fixed +++ b/tests/ui/needless_bitwise_bool.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_bitwise_bool)] diff --git a/tests/ui/needless_bitwise_bool.rs b/tests/ui/needless_bitwise_bool.rs index f3075fba0a2d..2cea701dce63 100644 --- a/tests/ui/needless_bitwise_bool.rs +++ b/tests/ui/needless_bitwise_bool.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_bitwise_bool)] diff --git a/tests/ui/needless_bitwise_bool.stderr b/tests/ui/needless_bitwise_bool.stderr index 63c88ef63f52..2a40c49fc9a3 100644 --- a/tests/ui/needless_bitwise_bool.stderr +++ b/tests/ui/needless_bitwise_bool.stderr @@ -1,10 +1,14 @@ -error: use of bitwise operator instead of lazy operator between booleans +warning: use of bitwise operator instead of lazy operator between booleans --> $DIR/needless_bitwise_bool.rs:24:8 | LL | if y & !x { | ^^^^^^ help: try: `y && !x` | - = note: `-D clippy::needless-bitwise-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_bitwise_bool.rs:3:9 + | +LL | #![warn(clippy::needless_bitwise_bool)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/needless_bool/fixable.fixed b/tests/ui/needless_bool/fixable.fixed index 89dc13fd5b13..f860852e7b7b 100644 --- a/tests/ui/needless_bool/fixable.fixed +++ b/tests/ui/needless_bool/fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_bool)] #![allow( diff --git a/tests/ui/needless_bool/fixable.rs b/tests/ui/needless_bool/fixable.rs index c11d9472e8d0..6680dab5b6dd 100644 --- a/tests/ui/needless_bool/fixable.rs +++ b/tests/ui/needless_bool/fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_bool)] #![allow( diff --git a/tests/ui/needless_bool/fixable.stderr b/tests/ui/needless_bool/fixable.stderr index d2c48376f766..3c00303896dd 100644 --- a/tests/ui/needless_bool/fixable.stderr +++ b/tests/ui/needless_bool/fixable.stderr @@ -1,4 +1,4 @@ -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:41:5 | LL | / if x { @@ -8,9 +8,13 @@ LL | | false LL | | }; | |_____^ help: you can reduce it to: `x` | - = note: `-D clippy::needless-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/fixable.rs:3:9 + | +LL | #![warn(clippy::needless_bool)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:46:5 | LL | / if x { @@ -20,7 +24,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `!x` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:51:5 | LL | / if x && y { @@ -30,7 +34,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `!(x && y)` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:59:5 | LL | / if a == b { @@ -40,7 +44,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `a != b` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:64:5 | LL | / if a != b { @@ -50,7 +54,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `a == b` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:69:5 | LL | / if a < b { @@ -60,7 +64,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `a >= b` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:74:5 | LL | / if a <= b { @@ -70,7 +74,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `a > b` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:79:5 | LL | / if a > b { @@ -80,7 +84,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `a <= b` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:84:5 | LL | / if a >= b { @@ -90,7 +94,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `a < b` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:105:5 | LL | / if x { @@ -100,7 +104,7 @@ LL | | return false; LL | | }; | |_____^ help: you can reduce it to: `return x` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:113:5 | LL | / if x { @@ -110,7 +114,7 @@ LL | | return true; LL | | }; | |_____^ help: you can reduce it to: `return !x` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:121:5 | LL | / if x && y { @@ -120,7 +124,7 @@ LL | | return false; LL | | }; | |_____^ help: you can reduce it to: `return x && y` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:129:5 | LL | / if x && y { @@ -130,33 +134,33 @@ LL | | return true; LL | | }; | |_____^ help: you can reduce it to: `return !(x && y)` -error: equality checks against true are unnecessary +warning: equality checks against true are unnecessary --> $DIR/fixable.rs:137:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` | - = note: `-D clippy::bool-comparison` implied by `-D warnings` + = note: `#[warn(clippy::bool_comparison)]` on by default -error: equality checks against false can be replaced by a negation +warning: equality checks against false can be replaced by a negation --> $DIR/fixable.rs:141:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` -error: equality checks against true are unnecessary +warning: equality checks against true are unnecessary --> $DIR/fixable.rs:151:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` -error: equality checks against false can be replaced by a negation +warning: equality checks against false can be replaced by a negation --> $DIR/fixable.rs:152:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:161:12 | LL | } else if returns_bool() { @@ -167,7 +171,7 @@ LL | | true LL | | }; | |_____^ help: you can reduce it to: `{ !returns_bool() }` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:174:5 | LL | / if unsafe { no(4) } & 1 != 0 { @@ -177,17 +181,17 @@ LL | | false LL | | }; | |_____^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:179:30 | LL | let _brackets_unneeded = if unsafe { no(4) } & 1 != 0 { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `unsafe { no(4) } & 1 != 0` -error: this if-then-else expression returns a bool literal +warning: this if-then-else expression returns a bool literal --> $DIR/fixable.rs:182:9 | LL | if unsafe { no(4) } & 1 != 0 { true } else { false } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/needless_bool/simple.stderr b/tests/ui/needless_bool/simple.stderr index 0ccc9416bcd5..0a86730e6302 100644 --- a/tests/ui/needless_bool/simple.stderr +++ b/tests/ui/needless_bool/simple.stderr @@ -1,4 +1,4 @@ -error: this if-then-else expression will always return true +warning: this if-then-else expression will always return true --> $DIR/simple.rs:14:5 | LL | / if x { @@ -8,9 +8,13 @@ LL | | true LL | | }; | |_____^ | - = note: `-D clippy::needless-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/simple.rs:1:9 + | +LL | #![warn(clippy::needless_bool)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: this if-then-else expression will always return false +warning: this if-then-else expression will always return false --> $DIR/simple.rs:19:5 | LL | / if x { @@ -20,7 +24,7 @@ LL | | false LL | | }; | |_____^ -error: this if-then-else expression will always return true +warning: this if-then-else expression will always return true --> $DIR/simple.rs:34:5 | LL | / if x { @@ -30,7 +34,7 @@ LL | | return true; LL | | }; | |_____^ -error: this if-then-else expression will always return false +warning: this if-then-else expression will always return false --> $DIR/simple.rs:42:5 | LL | / if x { @@ -40,5 +44,5 @@ LL | | return false; LL | | }; | |_____^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/needless_borrow.fixed b/tests/ui/needless_borrow.fixed index 4cb7f6b687f1..425e6eb6200e 100644 --- a/tests/ui/needless_borrow.fixed +++ b/tests/ui/needless_borrow.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![allow( unused, diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index 9a01190ed8db..3f7fa4a9d7dc 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![allow( unused, diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index d26c317124b8..41bcd783b996 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,220 +1,224 @@ -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:15:15 | LL | let _ = x(&&a); // warn | ^^^ help: change this to: `&a` | - = note: `-D clippy::needless-borrow` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_borrow.rs:9:9 + | +LL | #![warn(clippy::needless_borrow)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:19:13 | LL | mut_ref(&mut &mut b); // warn | ^^^^^^^^^^^ help: change this to: `&mut b` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:31:13 | LL | &&a | ^^^ help: change this to: `&a` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:33:15 | LL | 46 => &&a, | ^^^ help: change this to: `&a` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:39:27 | LL | break &ref_a; | ^^^^^^ help: change this to: `ref_a` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:46:15 | LL | let _ = x(&&&a); | ^^^^ help: change this to: `&a` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:47:15 | LL | let _ = x(&mut &&a); | ^^^^^^^^ help: change this to: `&a` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:48:15 | LL | let _ = x(&&&mut b); | ^^^^^^^^ help: change this to: `&mut b` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:49:15 | LL | let _ = x(&&ref_a); | ^^^^^^^ help: change this to: `ref_a` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:52:11 | LL | x(&b); | ^^ help: change this to: `b` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:59:13 | LL | mut_ref(&mut x); | ^^^^^^ help: change this to: `x` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:60:13 | LL | mut_ref(&mut &mut x); | ^^^^^^^^^^^ help: change this to: `x` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:61:23 | LL | let y: &mut i32 = &mut x; | ^^^^^^ help: change this to: `x` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:62:23 | LL | let y: &mut i32 = &mut &mut x; | ^^^^^^^^^^^ help: change this to: `x` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:71:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:77:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` -error: this expression borrows a value the compiler would automatically borrow +warning: this expression borrows a value the compiler would automatically borrow --> $DIR/needless_borrow.rs:89:13 | LL | let _ = (&x).0; | ^^^^ help: change this to: `x` -error: this expression borrows a value the compiler would automatically borrow +warning: this expression borrows a value the compiler would automatically borrow --> $DIR/needless_borrow.rs:91:22 | LL | let _ = unsafe { (&*x).0 }; | ^^^^^ help: change this to: `(*x)` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:101:5 | LL | (&&()).foo(); | ^^^^^^ help: change this to: `(&())` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:110:5 | LL | (&&5).foo(); | ^^^^^ help: change this to: `(&5)` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:135:51 | LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:136:44 | LL | let _ = std::path::Path::new(".").join(&&"."); | ^^^^^ help: change this to: `"."` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:137:23 | LL | deref_target_is_x(&X); | ^^ help: change this to: `X` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:138:26 | LL | multiple_constraints(&[[""]]); | ^^^^^^^ help: change this to: `[[""]]` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:139:45 | LL | multiple_constraints_normalizes_to_same(&X, X); | ^^ help: change this to: `X` -error: this expression creates a reference which is immediately dereferenced by the compiler +warning: this expression creates a reference which is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:140:32 | LL | let _ = Some("").unwrap_or(&""); | ^^^ help: change this to: `""` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:141:33 | LL | let _ = std::fs::write("x", &"".to_string()); | ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()` -error: this expression borrows a value the compiler would automatically borrow +warning: this expression borrows a value the compiler would automatically borrow --> $DIR/needless_borrow.rs:190:13 | LL | (&self.f)() | ^^^^^^^^^ help: change this to: `(self.f)` -error: this expression borrows a value the compiler would automatically borrow +warning: this expression borrows a value the compiler would automatically borrow --> $DIR/needless_borrow.rs:199:13 | LL | (&mut self.f)() | ^^^^^^^^^^^^^ help: change this to: `(self.f)` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:283:20 | LL | takes_iter(&mut x) | ^^^^^^ help: change this to: `x` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:297:55 | LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:335:37 | LL | let _ = std::fs::write("x", &arg); | ^^^^ help: change this to: `arg` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:336:37 | LL | let _ = std::fs::write("x", &loc); | ^^^^ help: change this to: `loc` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:354:15 | LL | debug(&x); | ^^ help: change this to: `x` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:363:15 | LL | use_x(&x); | ^^ help: change this to: `x` -error: the borrowed expression implements the required traits +warning: the borrowed expression implements the required traits --> $DIR/needless_borrow.rs:457:13 | LL | foo(&a); | ^^ help: change this to: `a` -error: aborting due to 36 previous errors +warning: 36 warnings emitted diff --git a/tests/ui/needless_borrow_pat.stderr b/tests/ui/needless_borrow_pat.stderr index db3b52b8850e..227c0b331c45 100644 --- a/tests/ui/needless_borrow_pat.stderr +++ b/tests/ui/needless_borrow_pat.stderr @@ -1,12 +1,16 @@ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:59:14 | LL | Some(ref x) => x, | ^^^^^ help: try this: `x` | - = note: `-D clippy::needless-borrow` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_borrow_pat.rs:3:9 + | +LL | #![warn(clippy::needless_borrow)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:65:14 | LL | Some(ref x) => *x, @@ -17,7 +21,7 @@ help: try this LL | Some(x) => x, | ~ ~ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:71:14 | LL | Some(ref x) => { @@ -30,19 +34,19 @@ LL | f1(x); LL ~ f1(x); | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:81:14 | LL | Some(ref x) => m1!(x), | ^^^^^ help: try this: `x` -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:86:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ help: try this: `x` -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:91:10 | LL | let (ref y,) = (&x,); @@ -54,13 +58,13 @@ LL ~ let (y,) = (&x,); LL ~ let _: &String = y; | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:101:14 | LL | Some(ref x) => x.0, | ^^^^^ help: try this: `x` -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:111:14 | LL | E::A(ref x) | E::B(ref x) => *x, @@ -71,13 +75,13 @@ help: try this LL | E::A(x) | E::B(x) => x, | ~ ~ ~ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:117:21 | LL | if let Some(ref x) = Some(&String::new()); | ^^^^^ help: try this: `x` -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:125:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { @@ -90,13 +94,13 @@ LL | let _: &String = x; LL ~ x | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:132:11 | LL | fn f(&ref x: &&String) { | ^^^^^ help: try this: `x` -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/needless_borrow_pat.rs:140:11 | LL | fn f(&ref x: &&String) { @@ -108,5 +112,5 @@ LL ~ fn f(&x: &&String) { LL ~ let _: &String = x; | -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/needless_borrowed_ref.fixed b/tests/ui/needless_borrowed_ref.fixed index 0c47ceb7b679..6663520da8a1 100644 --- a/tests/ui/needless_borrowed_ref.fixed +++ b/tests/ui/needless_borrowed_ref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_borrowed_reference)] #![allow( diff --git a/tests/ui/needless_borrowed_ref.rs b/tests/ui/needless_borrowed_ref.rs index f883bb0c8891..6c8efd2ce180 100644 --- a/tests/ui/needless_borrowed_ref.rs +++ b/tests/ui/needless_borrowed_ref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_borrowed_reference)] #![allow( diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index 8d0f0c258dd2..abe76dca1be1 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -1,17 +1,21 @@ -error: this pattern takes a reference on something that is being dereferenced +warning: this pattern takes a reference on something that is being dereferenced --> $DIR/needless_borrowed_ref.rs:31:34 | LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ | - = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_borrowed_ref.rs:3:9 + | +LL | #![warn(clippy::needless_borrowed_reference)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the `&ref` part | LL - let _ = v.iter_mut().filter(|&ref a| a.is_empty()); LL + let _ = v.iter_mut().filter(|a| a.is_empty()); | -error: this pattern takes a reference on something that is being dereferenced +warning: this pattern takes a reference on something that is being dereferenced --> $DIR/needless_borrowed_ref.rs:35:17 | LL | if let Some(&ref v) = thingy {} @@ -23,7 +27,7 @@ LL - if let Some(&ref v) = thingy {} LL + if let Some(v) = thingy {} | -error: this pattern takes a reference on something that is being dereferenced +warning: this pattern takes a reference on something that is being dereferenced --> $DIR/needless_borrowed_ref.rs:37:14 | LL | if let &[&ref a, ref b] = slice_of_refs {} @@ -35,7 +39,7 @@ LL - if let &[&ref a, ref b] = slice_of_refs {} LL + if let &[a, ref b] = slice_of_refs {} | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:39:9 | LL | let &[ref a, ..] = &array; @@ -47,7 +51,7 @@ LL - let &[ref a, ..] = &array; LL + let [a, ..] = &array; | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:40:9 | LL | let &[ref a, ref b, ..] = &array; @@ -59,7 +63,7 @@ LL - let &[ref a, ref b, ..] = &array; LL + let [a, b, ..] = &array; | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:42:12 | LL | if let &[ref a, ref b] = slice {} @@ -71,7 +75,7 @@ LL - if let &[ref a, ref b] = slice {} LL + if let [a, b] = slice {} | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:43:12 | LL | if let &[ref a, ref b] = &vec[..] {} @@ -83,7 +87,7 @@ LL - if let &[ref a, ref b] = &vec[..] {} LL + if let [a, b] = &vec[..] {} | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:45:12 | LL | if let &[ref a, ref b, ..] = slice {} @@ -95,7 +99,7 @@ LL - if let &[ref a, ref b, ..] = slice {} LL + if let [a, b, ..] = slice {} | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:46:12 | LL | if let &[ref a, .., ref b] = slice {} @@ -107,7 +111,7 @@ LL - if let &[ref a, .., ref b] = slice {} LL + if let [a, .., b] = slice {} | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:47:12 | LL | if let &[.., ref a, ref b] = slice {} @@ -119,7 +123,7 @@ LL - if let &[.., ref a, ref b] = slice {} LL + if let [.., a, b] = slice {} | -error: dereferencing a slice pattern where every element takes a reference +warning: dereferencing a slice pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:49:12 | LL | if let &[ref a, _] = slice {} @@ -131,7 +135,7 @@ LL - if let &[ref a, _] = slice {} LL + if let [a, _] = slice {} | -error: dereferencing a tuple pattern where every element takes a reference +warning: dereferencing a tuple pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:51:12 | LL | if let &(ref a, ref b, ref c) = &tuple {} @@ -143,7 +147,7 @@ LL - if let &(ref a, ref b, ref c) = &tuple {} LL + if let (a, b, c) = &tuple {} | -error: dereferencing a tuple pattern where every element takes a reference +warning: dereferencing a tuple pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:52:12 | LL | if let &(ref a, _, ref c) = &tuple {} @@ -155,7 +159,7 @@ LL - if let &(ref a, _, ref c) = &tuple {} LL + if let (a, _, c) = &tuple {} | -error: dereferencing a tuple pattern where every element takes a reference +warning: dereferencing a tuple pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:53:12 | LL | if let &(ref a, ..) = &tuple {} @@ -167,7 +171,7 @@ LL - if let &(ref a, ..) = &tuple {} LL + if let (a, ..) = &tuple {} | -error: dereferencing a tuple pattern where every element takes a reference +warning: dereferencing a tuple pattern where every element takes a reference --> $DIR/needless_borrowed_ref.rs:55:12 | LL | if let &TupleStruct(ref a, ..) = &tuple_struct {} @@ -179,7 +183,7 @@ LL - if let &TupleStruct(ref a, ..) = &tuple_struct {} LL + if let TupleStruct(a, ..) = &tuple_struct {} | -error: dereferencing a struct pattern where every field's pattern takes a reference +warning: dereferencing a struct pattern where every field's pattern takes a reference --> $DIR/needless_borrowed_ref.rs:57:12 | LL | if let &Struct { @@ -198,7 +202,7 @@ LL ~ b: b, LL ~ c: renamed, | -error: dereferencing a struct pattern where every field's pattern takes a reference +warning: dereferencing a struct pattern where every field's pattern takes a reference --> $DIR/needless_borrowed_ref.rs:64:12 | LL | if let &Struct { ref a, b: _, .. } = &s {} @@ -210,5 +214,5 @@ LL - if let &Struct { ref a, b: _, .. } = &s {} LL + if let Struct { a, b: _, .. } = &s {} | -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/needless_collect.fixed b/tests/ui/needless_collect.fixed index 2659ad384885..024c22de225d 100644 --- a/tests/ui/needless_collect.fixed +++ b/tests/ui/needless_collect.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::suspicious_map, clippy::iter_count)] diff --git a/tests/ui/needless_collect.rs b/tests/ui/needless_collect.rs index 535ec82982b1..7ed7babec307 100644 --- a/tests/ui/needless_collect.rs +++ b/tests/ui/needless_collect.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::suspicious_map, clippy::iter_count)] diff --git a/tests/ui/needless_collect.stderr b/tests/ui/needless_collect.stderr index 584d2a1d8356..d7daf4d27001 100644 --- a/tests/ui/needless_collect.stderr +++ b/tests/ui/needless_collect.stderr @@ -1,94 +1,98 @@ -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:11:29 | LL | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` | - = note: `-D clippy::needless-collect` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_collect.rs:7:8 + | +LL | #[warn(clippy::needless_collect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:12:22 | LL | if sample.iter().collect::>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:15:28 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == 1)` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:20:35 | LL | sample.iter().map(|x| (x, x)).collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:21:35 | LL | sample.iter().map(|x| (x, x)).collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:28:19 | LL | sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:29:19 | LL | sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:30:28 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == 1)` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:31:19 | LL | sample.iter().collect::>().contains(&&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &1)` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:34:19 | LL | sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:35:19 | LL | sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:40:27 | LL | let _ = sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:41:27 | LL | let _ = sample.iter().collect::>().contains(&&0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &0)` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:63:27 | LL | let _ = sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect.rs:64:27 | LL | let _ = sample.iter().collect::>().contains(&&0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &0)` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/needless_collect_indirect.stderr b/tests/ui/needless_collect_indirect.stderr index 790d725907f3..76983e31dc38 100644 --- a/tests/ui/needless_collect_indirect.stderr +++ b/tests/ui/needless_collect_indirect.stderr @@ -1,4 +1,4 @@ -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:8:39 | LL | let indirect_iter = sample.iter().collect::>(); @@ -6,14 +6,18 @@ LL | let indirect_iter = sample.iter().collect::>(); LL | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::>(); | ------------------------- the iterator could be used here instead | - = note: `-D clippy::needless-collect` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_collect_indirect.rs:2:9 + | +LL | #![warn(clippy::needless_collect)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the original Iterator instead of collecting it and then producing a new one | LL ~ LL ~ sample.iter().map(|x| (x, x + 1)).collect::>(); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:10:38 | LL | let indirect_len = sample.iter().collect::>(); @@ -27,7 +31,7 @@ LL ~ LL ~ sample.iter().count(); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:12:40 | LL | let indirect_empty = sample.iter().collect::>(); @@ -41,7 +45,7 @@ LL ~ LL ~ sample.iter().next().is_none(); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:14:43 | LL | let indirect_contains = sample.iter().collect::>(); @@ -55,7 +59,7 @@ LL ~ LL ~ sample.iter().any(|x| x == &5); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:26:48 | LL | let non_copy_contains = sample.into_iter().collect::>(); @@ -69,7 +73,7 @@ LL ~ LL ~ sample.into_iter().any(|x| x == a); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:55:51 | LL | let buffer: Vec<&str> = string.split('/').collect(); @@ -83,7 +87,7 @@ LL ~ LL ~ string.split('/').count() | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:60:55 | LL | let indirect_len: VecDeque<_> = sample.iter().collect(); @@ -97,7 +101,7 @@ LL ~ LL ~ sample.iter().count() | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:65:57 | LL | let indirect_len: LinkedList<_> = sample.iter().collect(); @@ -111,7 +115,7 @@ LL ~ LL ~ sample.iter().count() | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:70:57 | LL | let indirect_len: BinaryHeap<_> = sample.iter().collect(); @@ -125,7 +129,7 @@ LL ~ LL ~ sample.iter().count() | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:130:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); @@ -142,7 +146,7 @@ LL | // Do lint LL ~ vec.iter().map(|k| k * k).any(|x| x == i); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:155:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); @@ -159,7 +163,7 @@ LL | // Do lint LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:184:63 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); @@ -176,7 +180,7 @@ LL | // Do lint LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:220:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); @@ -194,7 +198,7 @@ LL | // Do lint LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:245:26 | LL | let w = v.iter().collect::>(); @@ -210,7 +214,7 @@ LL | // Do lint LL ~ for _ in 0..v.iter().count() { | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:267:30 | LL | let mut w = v.iter().collect::>(); @@ -226,7 +230,7 @@ LL | // Do lint LL ~ while 1 == v.iter().count() { | -error: avoid using `collect()` when not needed +warning: avoid using `collect()` when not needed --> $DIR/needless_collect_indirect.rs:289:30 | LL | let mut w = v.iter().collect::>(); @@ -242,5 +246,5 @@ LL | // Do lint LL ~ while let Some(i) = Some(v.iter().count()) { | -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index d99989b54fc2..fc26ac7ce25e 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -1,4 +1,4 @@ -error: this `else` block is redundant +warning: this `else` block is redundant --> $DIR/needless_continue.rs:30:16 | LL | } else { @@ -32,9 +32,13 @@ LL | | } } println!("bleh"); } - = note: `-D clippy::needless-continue` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_continue.rs:1:9 + | +LL | #![warn(clippy::needless_continue)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: there is no need for an explicit `else` block for this `if` expression +warning: there is no need for an explicit `else` block for this `if` expression --> $DIR/needless_continue.rs:45:9 | LL | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { @@ -54,7 +58,7 @@ LL | | } println!("Jabber"); } -error: this `continue` expression is redundant +warning: this `continue` expression is redundant --> $DIR/needless_continue.rs:58:9 | LL | continue; // should lint here @@ -62,7 +66,7 @@ LL | continue; // should lint here | = help: consider dropping the `continue` expression -error: this `continue` expression is redundant +warning: this `continue` expression is redundant --> $DIR/needless_continue.rs:65:9 | LL | continue; // should lint here @@ -70,7 +74,7 @@ LL | continue; // should lint here | = help: consider dropping the `continue` expression -error: this `continue` expression is redundant +warning: this `continue` expression is redundant --> $DIR/needless_continue.rs:72:9 | LL | continue // should lint here @@ -78,7 +82,7 @@ LL | continue // should lint here | = help: consider dropping the `continue` expression -error: this `continue` expression is redundant +warning: this `continue` expression is redundant --> $DIR/needless_continue.rs:80:9 | LL | continue // should lint here @@ -86,7 +90,7 @@ LL | continue // should lint here | = help: consider dropping the `continue` expression -error: this `else` block is redundant +warning: this `else` block is redundant --> $DIR/needless_continue.rs:130:24 | LL | } else { @@ -109,7 +113,7 @@ LL | | } println!("bar-6"); } -error: there is no need for an explicit `else` block for this `if` expression +warning: there is no need for an explicit `else` block for this `if` expression --> $DIR/needless_continue.rs:136:17 | LL | / if condition() { @@ -127,5 +131,5 @@ LL | | } println!("bar-5"); } -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/needless_doc_main.stderr b/tests/ui/needless_doc_main.stderr index 05c7f9d33a79..f2ccf8cf3524 100644 --- a/tests/ui/needless_doc_main.stderr +++ b/tests/ui/needless_doc_main.stderr @@ -1,28 +1,28 @@ -error: needless `fn main` in doctest +warning: needless `fn main` in doctest --> $DIR/needless_doc_main.rs:7:4 | LL | /// fn main() { | ^^^^^^^^^^^^ | - = note: `-D clippy::needless-doctest-main` implied by `-D warnings` + = note: `#[warn(clippy::needless_doctest_main)]` on by default -error: needless `fn main` in doctest +warning: needless `fn main` in doctest --> $DIR/needless_doc_main.rs:14:4 | LL | /// fn main() -> () { | ^^^^^^^^^^^^^^^^^^ -error: needless `fn main` in doctest +warning: needless `fn main` in doctest --> $DIR/needless_doc_main.rs:21:4 | LL | /// fn main() { | ^^^^^^^^^^^^ -error: needless `fn main` in doctest +warning: needless `fn main` in doctest --> $DIR/needless_doc_main.rs:28:4 | LL | /// fn main() { | ^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/needless_for_each_fixable.fixed b/tests/ui/needless_for_each_fixable.fixed index 09e671b88e1a..a04f9ec651ed 100644 --- a/tests/ui/needless_for_each_fixable.fixed +++ b/tests/ui/needless_for_each_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_for_each)] #![allow(unused)] #![allow( diff --git a/tests/ui/needless_for_each_fixable.rs b/tests/ui/needless_for_each_fixable.rs index abb4045b9197..4975c7050810 100644 --- a/tests/ui/needless_for_each_fixable.rs +++ b/tests/ui/needless_for_each_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_for_each)] #![allow(unused)] #![allow( diff --git a/tests/ui/needless_for_each_fixable.stderr b/tests/ui/needless_for_each_fixable.stderr index aebb762cc228..77e0db1199e8 100644 --- a/tests/ui/needless_for_each_fixable.stderr +++ b/tests/ui/needless_for_each_fixable.stderr @@ -1,4 +1,4 @@ -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:16:5 | LL | / v.iter().for_each(|elem| { @@ -6,7 +6,11 @@ LL | | acc += elem; LL | | }); | |_______^ | - = note: `-D clippy::needless-for-each` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_for_each_fixable.rs:2:9 + | +LL | #![warn(clippy::needless_for_each)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | LL ~ for elem in v.iter() { @@ -14,7 +18,7 @@ LL + acc += elem; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:19:5 | LL | / v.into_iter().for_each(|elem| { @@ -29,7 +33,7 @@ LL + acc += elem; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:23:5 | LL | / [1, 2, 3].iter().for_each(|elem| { @@ -44,7 +48,7 @@ LL + acc += elem; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:28:5 | LL | / hash_map.iter().for_each(|(k, v)| { @@ -59,7 +63,7 @@ LL + acc += k + v; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:31:5 | LL | / hash_map.iter_mut().for_each(|(k, v)| { @@ -74,7 +78,7 @@ LL + acc += *k + *v; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:34:5 | LL | / hash_map.keys().for_each(|k| { @@ -89,7 +93,7 @@ LL + acc += k; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:37:5 | LL | / hash_map.values().for_each(|v| { @@ -104,7 +108,7 @@ LL + acc += v; LL + } | -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_fixable.rs:44:5 | LL | / my_vec().iter().for_each(|elem| { @@ -119,5 +123,5 @@ LL + acc += elem; LL + } | -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/needless_for_each_unfixable.stderr b/tests/ui/needless_for_each_unfixable.stderr index 7893ff31a6fd..5522eef66d42 100644 --- a/tests/ui/needless_for_each_unfixable.stderr +++ b/tests/ui/needless_for_each_unfixable.stderr @@ -1,4 +1,4 @@ -error: needless use of `for_each` +warning: needless use of `for_each` --> $DIR/needless_for_each_unfixable.rs:7:5 | LL | / v.iter().for_each(|v| { @@ -10,7 +10,11 @@ LL | | } LL | | }); | |_______^ | - = note: `-D clippy::needless-for-each` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_for_each_unfixable.rs:1:9 + | +LL | #![warn(clippy::needless_for_each)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | LL ~ for v in v.iter() { @@ -26,5 +30,5 @@ help: ...and replace `return` with `continue` LL | continue; | ~~~~~~~~ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/needless_late_init.fixed b/tests/ui/needless_late_init.fixed index 17f2227ba91c..cad7823ccbae 100644 --- a/tests/ui/needless_late_init.fixed +++ b/tests/ui/needless_late_init.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(let_chains)] #![allow(unused)] #![allow( @@ -37,36 +37,36 @@ fn simple() { } fn main() { - + let a; let n = 1; - let a = match n { - 1 => "one", + match n { + 1 => a = "one", _ => { - "two" + a = "two"; }, - }; + } - - let b = if n == 3 { - "four" + let b; + if n == 3 { + b = "four"; } else { - "five" - }; + b = "five" + } - - let d = if true { + let d; + if true { let temp = 5; - temp + d = temp; } else { - 15 - }; + d = 15; + } - - let e = if true { - format!("{} {}", a, b) + let e; + if true { + e = format!("{} {}", a, b); } else { - format!("{}", n) - }; + e = format!("{}", n); + } let f = match 1 { @@ -74,12 +74,12 @@ fn main() { _ => return, }; // has semi - - let g: usize = if true { - 5 + let g: usize; + if true { + g = 5; } else { panic!(); - }; + } // Drop order only matters if both are significant @@ -109,14 +109,14 @@ async fn in_async() -> &'static str { "one" } - + let a; let n = 1; - let a = match n { - 1 => f().await, + match n { + 1 => a = f().await, _ => { - "two" + a = "two"; }, - }; + } a } @@ -126,14 +126,14 @@ const fn in_const() -> &'static str { "one" } - + let a; let n = 1; - let a = match n { - 1 => f(), + match n { + 1 => a = f(), _ => { - "two" + a = "two"; }, - }; + } a } diff --git a/tests/ui/needless_late_init.rs b/tests/ui/needless_late_init.rs index d84457a29875..3997c6d59a54 100644 --- a/tests/ui/needless_late_init.rs +++ b/tests/ui/needless_late_init.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(let_chains)] #![allow(unused)] #![allow( diff --git a/tests/ui/needless_late_init.stderr b/tests/ui/needless_late_init.stderr index 0a256fb4a131..8f66d6774254 100644 --- a/tests/ui/needless_late_init.stderr +++ b/tests/ui/needless_late_init.stderr @@ -1,4 +1,4 @@ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:24:5 | LL | let a; @@ -6,13 +6,13 @@ LL | let a; LL | a = "zero"; | ^^^^^^^^^^ initialised here | - = note: `-D clippy::needless-late-init` implied by `-D warnings` + = note: `#[warn(clippy::needless_late_init)]` on by default help: declare `a` here | LL | let a = "zero"; | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:27:5 | LL | let b; @@ -26,7 +26,7 @@ help: declare `b` here LL | let b = 1; | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:28:5 | LL | let c; @@ -40,7 +40,7 @@ help: declare `c` here LL | let c = 2; | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:32:5 | LL | let d: usize; @@ -53,7 +53,7 @@ help: declare `d` here LL | let d: usize = 1; | ~~~~~~~~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:35:5 | LL | let e; @@ -66,7 +66,7 @@ help: declare `e` here LL | let e = format!("{}", d); | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:40:5 | LL | let a; @@ -87,7 +87,7 @@ help: add a semicolon after the `match` expression LL | }; | + -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:49:5 | LL | let b; @@ -108,7 +108,7 @@ help: add a semicolon after the `if` expression LL | }; | + -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:56:5 | LL | let d; @@ -129,7 +129,7 @@ help: add a semicolon after the `if` expression LL | }; | + -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:64:5 | LL | let e; @@ -150,7 +150,7 @@ help: add a semicolon after the `if` expression LL | }; | + -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:71:5 | LL | let f; @@ -166,7 +166,7 @@ LL - 1 => f = "three", LL + 1 => "three", | -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:77:5 | LL | let g: usize; @@ -186,7 +186,7 @@ help: add a semicolon after the `if` expression LL | }; | + -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:85:5 | LL | let x; @@ -200,7 +200,7 @@ help: declare `x` here LL | let x = 1; | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:89:5 | LL | let x; @@ -214,7 +214,7 @@ help: declare `x` here LL | let x = SignificantDrop; | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:93:5 | LL | let x; @@ -228,7 +228,7 @@ help: declare `x` here LL | let x = SignificantDrop; | ~~~~~ -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:112:5 | LL | let a; @@ -249,7 +249,7 @@ help: add a semicolon after the `match` expression LL | }; | + -error: unneeded late initialization +warning: unneeded late initialization --> $DIR/needless_late_init.rs:129:5 | LL | let a; @@ -270,5 +270,5 @@ help: add a semicolon after the `match` expression LL | }; | + -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/needless_lifetimes.fixed b/tests/ui/needless_lifetimes.fixed index f0f1f9298ac6..c3a8087ba8f6 100644 --- a/tests/ui/needless_lifetimes.fixed +++ b/tests/ui/needless_lifetimes.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::needless_lifetimes)] #![allow( diff --git a/tests/ui/needless_lifetimes.rs b/tests/ui/needless_lifetimes.rs index ddfd10430038..d34181a8aca0 100644 --- a/tests/ui/needless_lifetimes.rs +++ b/tests/ui/needless_lifetimes.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::needless_lifetimes)] #![allow( diff --git a/tests/ui/needless_lifetimes.stderr b/tests/ui/needless_lifetimes.stderr index 4e3c8f20d8c5..1e2cd9fc703d 100644 --- a/tests/ui/needless_lifetimes.stderr +++ b/tests/ui/needless_lifetimes.stderr @@ -1,17 +1,21 @@ -error: the following explicit lifetimes could be elided: 'a, 'b +warning: the following explicit lifetimes could be elided: 'a, 'b --> $DIR/needless_lifetimes.rs:18:1 | LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::needless-lifetimes` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_lifetimes.rs:4:9 + | +LL | #![warn(clippy::needless_lifetimes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: elide the lifetimes | LL - fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} LL + fn distinct_lifetimes(_x: &u8, _y: &u8, _z: u8) {} | -error: the following explicit lifetimes could be elided: 'a, 'b +warning: the following explicit lifetimes could be elided: 'a, 'b --> $DIR/needless_lifetimes.rs:20:1 | LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} @@ -23,7 +27,7 @@ LL - fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} LL + fn distinct_and_static(_x: &u8, _y: &u8, _z: &'static u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:30:1 | LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { @@ -35,7 +39,7 @@ LL - fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { LL + fn in_and_out(x: &u8, _y: u8) -> &u8 { | -error: the following explicit lifetimes could be elided: 'b +warning: the following explicit lifetimes could be elided: 'b --> $DIR/needless_lifetimes.rs:42:1 | LL | fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { @@ -47,7 +51,7 @@ LL - fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { LL + fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:49:1 | LL | fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 { @@ -59,7 +63,7 @@ LL - fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 { LL + fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 { | -error: the following explicit lifetimes could be elided: 'b +warning: the following explicit lifetimes could be elided: 'b --> $DIR/needless_lifetimes.rs:66:1 | LL | fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { @@ -71,7 +75,7 @@ LL - fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { LL + fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:73:1 | LL | fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> { @@ -83,7 +87,7 @@ LL - fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> { LL + fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:82:1 | LL | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { @@ -95,7 +99,7 @@ LL - fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { LL + fn deep_reference_3(x: &u8, _y: u8) -> Result<&u8, ()> { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:87:1 | LL | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> @@ -107,7 +111,7 @@ LL - fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> LL + fn where_clause_without_lt(x: &u8, _y: u8) -> Result<&u8, ()> | -error: the following explicit lifetimes could be elided: 'a, 'b +warning: the following explicit lifetimes could be elided: 'a, 'b --> $DIR/needless_lifetimes.rs:99:1 | LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} @@ -119,7 +123,7 @@ LL - fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} LL + fn lifetime_param_2(_x: Ref<'_>, _y: &u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:123:1 | LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> @@ -131,7 +135,7 @@ LL - fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> LL + fn fn_bound_2(_m: Lt<'_, I>, _f: F) -> Lt<'_, I> | -error: the following explicit lifetimes could be elided: 's +warning: the following explicit lifetimes could be elided: 's --> $DIR/needless_lifetimes.rs:153:5 | LL | fn self_and_out<'s>(&'s self) -> &'s u8 { @@ -143,7 +147,7 @@ LL - fn self_and_out<'s>(&'s self) -> &'s u8 { LL + fn self_and_out(&self) -> &u8 { | -error: the following explicit lifetimes could be elided: 't +warning: the following explicit lifetimes could be elided: 't --> $DIR/needless_lifetimes.rs:160:5 | LL | fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { @@ -155,7 +159,7 @@ LL - fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { LL + fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 { | -error: the following explicit lifetimes could be elided: 's +warning: the following explicit lifetimes could be elided: 's --> $DIR/needless_lifetimes.rs:167:5 | LL | fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 { @@ -167,7 +171,7 @@ LL - fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 { LL + fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 { | -error: the following explicit lifetimes could be elided: 's, 't +warning: the following explicit lifetimes could be elided: 's, 't --> $DIR/needless_lifetimes.rs:171:5 | LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} @@ -179,7 +183,7 @@ LL - fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} LL + fn distinct_self_and_in(&self, _x: &u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:190:1 | LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { @@ -191,7 +195,7 @@ LL - fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { LL + fn struct_with_lt(_foo: Foo<'_>) -> &str { | -error: the following explicit lifetimes could be elided: 'b +warning: the following explicit lifetimes could be elided: 'b --> $DIR/needless_lifetimes.rs:208:1 | LL | fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { @@ -203,7 +207,7 @@ LL - fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { LL + fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:216:1 | LL | fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str { @@ -215,7 +219,7 @@ LL - fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str { LL + fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:231:1 | LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { @@ -227,7 +231,7 @@ LL - fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { LL + fn trait_obj_elided2(_arg: &dyn Drop) -> &str { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:237:1 | LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { @@ -239,7 +243,7 @@ LL - fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { LL + fn alias_with_lt(_foo: FooAlias<'_>) -> &str { | -error: the following explicit lifetimes could be elided: 'b +warning: the following explicit lifetimes could be elided: 'b --> $DIR/needless_lifetimes.rs:255:1 | LL | fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { @@ -251,7 +255,7 @@ LL - fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { LL + fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:263:1 | LL | fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str { @@ -263,7 +267,7 @@ LL - fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str { LL + fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:267:1 | LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { @@ -275,7 +279,7 @@ LL - fn named_input_elided_output<'a>(_arg: &'a str) -> &str { LL + fn named_input_elided_output(_arg: &str) -> &str { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:275:1 | LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { @@ -287,7 +291,7 @@ LL - fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { LL + fn trait_bound_ok>(_: &u8, _: T) { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:311:1 | LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { @@ -299,7 +303,7 @@ LL - fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { LL + fn out_return_type_lts(e: &str) -> Cow<'_> { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:318:9 | LL | fn needless_lt<'a>(x: &'a u8) {} @@ -311,7 +315,7 @@ LL - fn needless_lt<'a>(x: &'a u8) {} LL + fn needless_lt(x: &u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:322:9 | LL | fn needless_lt<'a>(_x: &'a u8) {} @@ -323,7 +327,7 @@ LL - fn needless_lt<'a>(_x: &'a u8) {} LL + fn needless_lt(_x: &u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:335:9 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { @@ -335,7 +339,7 @@ LL - fn baz<'a>(&'a self) -> impl Foo + 'a { LL + fn baz(&self) -> impl Foo + '_ { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:367:5 | LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 { @@ -347,7 +351,7 @@ LL - fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: im LL + fn impl_trait_elidable_nested_anonymous_lifetimes(i: &i32, f: impl Fn(&i32) -> &i32) -> &i32 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:376:5 | LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 { @@ -359,7 +363,7 @@ LL - fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a LL + fn generics_elidable &i32>(i: &i32, f: T) -> &i32 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:388:5 | LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32 @@ -371,7 +375,7 @@ LL - fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32 LL + fn where_clause_elidadable(i: &i32, f: T) -> &i32 | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:403:5 | LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 { @@ -383,7 +387,7 @@ LL - fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 LL + fn pointer_fn_elidable(i: &i32, f: fn(&i32) -> &i32) -> &i32 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:416:5 | LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { @@ -395,7 +399,7 @@ LL - fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { LL + fn nested_fn_pointer_3(_: &i32) -> fn(fn(&i32) -> &i32) -> i32 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:419:5 | LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { @@ -407,7 +411,7 @@ LL - fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { LL + fn nested_fn_pointer_4(_: &i32) -> impl Fn(fn(&i32)) { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:441:9 | LL | fn implicit<'a>(&'a self) -> &'a () { @@ -419,7 +423,7 @@ LL - fn implicit<'a>(&'a self) -> &'a () { LL + fn implicit(&self) -> &() { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:444:9 | LL | fn implicit_mut<'a>(&'a mut self) -> &'a () { @@ -431,7 +435,7 @@ LL - fn implicit_mut<'a>(&'a mut self) -> &'a () { LL + fn implicit_mut(&mut self) -> &() { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:455:9 | LL | fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a () { @@ -443,7 +447,7 @@ LL - fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a () LL + fn lifetime_elsewhere(self: Box, here: &()) -> &() { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:461:9 | LL | fn implicit<'a>(&'a self) -> &'a (); @@ -455,7 +459,7 @@ LL - fn implicit<'a>(&'a self) -> &'a (); LL + fn implicit(&self) -> &(); | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:462:9 | LL | fn implicit_provided<'a>(&'a self) -> &'a () { @@ -467,7 +471,7 @@ LL - fn implicit_provided<'a>(&'a self) -> &'a () { LL + fn implicit_provided(&self) -> &() { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:471:9 | LL | fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a (); @@ -479,7 +483,7 @@ LL - fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a (); LL + fn lifetime_elsewhere(self: Box, here: &()) -> &(); | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:472:9 | LL | fn lifetime_elsewhere_provided<'a>(self: Box, here: &'a ()) -> &'a () { @@ -491,7 +495,7 @@ LL - fn lifetime_elsewhere_provided<'a>(self: Box, here: &'a ()) - LL + fn lifetime_elsewhere_provided(self: Box, here: &()) -> &() { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:481:5 | LL | fn foo<'a>(x: &'a u8, y: &'_ u8) {} @@ -503,7 +507,7 @@ LL - fn foo<'a>(x: &'a u8, y: &'_ u8) {} LL + fn foo(x: &u8, y: &'_ u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:483:5 | LL | fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {} @@ -515,7 +519,7 @@ LL - fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {} LL + fn bar(x: &u8, y: &'_ u8, z: &'_ u8) {} | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:490:5 | LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { @@ -527,7 +531,7 @@ LL - fn one_input<'a>(x: &'a u8) -> &'a u8 { LL + fn one_input(x: &u8) -> &u8 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:495:5 | LL | fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: &'b u8) -> &'b u8 { @@ -539,7 +543,7 @@ LL - fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: & LL + fn multiple_inputs_output_not_elided<'b>(x: &u8, y: &'b u8, z: &'b u8) -> &'b u8 { | -error: the following explicit lifetimes could be elided: 'a +warning: the following explicit lifetimes could be elided: 'a --> $DIR/needless_lifetimes.rs:508:13 | LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { @@ -548,12 +552,12 @@ LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { LL | local_one_input_macro!(); | ------------------------ in this macro invocation | - = note: this error originates in the macro `local_one_input_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `local_one_input_macro` (in Nightly builds, run with -Z macro-backtrace for more info) help: elide the lifetimes | LL - fn one_input<'a>(x: &'a u8) -> &'a u8 { LL + fn one_input(x: &u8) -> &u8 { | -error: aborting due to 46 previous errors +warning: 46 warnings emitted diff --git a/tests/ui/needless_match.fixed b/tests/ui/needless_match.fixed index 7e47406798cf..d8a0400a4f0d 100644 --- a/tests/ui/needless_match.fixed +++ b/tests/ui/needless_match.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_match)] #![allow(clippy::manual_map)] #![allow(dead_code)] diff --git a/tests/ui/needless_match.rs b/tests/ui/needless_match.rs index 809c694bf400..3de9bd6d7a1f 100644 --- a/tests/ui/needless_match.rs +++ b/tests/ui/needless_match.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_match)] #![allow(clippy::manual_map)] #![allow(dead_code)] diff --git a/tests/ui/needless_match.stderr b/tests/ui/needless_match.stderr index 28e78441c252..bcdcbadf920b 100644 --- a/tests/ui/needless_match.stderr +++ b/tests/ui/needless_match.stderr @@ -1,4 +1,4 @@ -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:16:18 | LL | let _: i32 = match i { @@ -10,9 +10,13 @@ LL | | _ => i, LL | | }; | |_____^ help: replace it with: `i` | - = note: `-D clippy::needless-match` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_match.rs:2:9 + | +LL | #![warn(clippy::needless_match)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:23:19 | LL | let _: &str = match s { @@ -23,7 +27,7 @@ LL | | s => s, LL | | }; | |_____^ help: replace it with: `s` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:32:21 | LL | let _: Simple = match se { @@ -35,7 +39,7 @@ LL | | Simple::D => Simple::D, LL | | }; | |_____^ help: replace it with: `se` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:54:26 | LL | let _: Option = match x { @@ -45,7 +49,7 @@ LL | | None => None, LL | | }; | |_____^ help: replace it with: `x` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:70:31 | LL | let _: Result = match Ok(1) { @@ -55,7 +59,7 @@ LL | | Err(err) => Err(err), LL | | }; | |_____^ help: replace it with: `Ok(1)` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:74:31 | LL | let _: Result = match func_ret_err(0_i32) { @@ -65,25 +69,25 @@ LL | | Ok(a) => Ok(a), LL | | }; | |_____^ help: replace it with: `func_ret_err(0_i32)` -error: this if-let expression is unnecessary +warning: this if-let expression is unnecessary --> $DIR/needless_match.rs:87:13 | LL | let _ = if let Some(a) = Some(1) { Some(a) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)` -error: this if-let expression is unnecessary +warning: this if-let expression is unnecessary --> $DIR/needless_match.rs:122:31 | LL | let _: Result = if let Err(e) = x { Err(e) } else { x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x` -error: this if-let expression is unnecessary +warning: this if-let expression is unnecessary --> $DIR/needless_match.rs:123:31 | LL | let _: Result = if let Ok(val) = x { Ok(val) } else { x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x` -error: this if-let expression is unnecessary +warning: this if-let expression is unnecessary --> $DIR/needless_match.rs:130:21 | LL | let _: Simple = if let Simple::A = x { @@ -96,7 +100,7 @@ LL | | x LL | | }; | |_____^ help: replace it with: `x` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:169:26 | LL | let _: Complex = match ce { @@ -109,7 +113,7 @@ LL | | Complex::D(E::VariantB(ea, eb), b) => Complex::D(E::VariantB( LL | | }; | |_________^ help: replace it with: `ce` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:253:17 | LL | let _ = match e { @@ -119,7 +123,7 @@ LL | | _ => e, LL | | }; | |_________^ help: replace it with: `e` -error: this match expression is unnecessary +warning: this match expression is unnecessary --> $DIR/needless_match.rs:259:17 | LL | let _ = match e { @@ -130,5 +134,5 @@ LL | | _ => e, LL | | }; | |_________^ help: replace it with: `e` -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/needless_option_as_deref.fixed b/tests/ui/needless_option_as_deref.fixed index acd22c6bb433..70015fccf9ee 100644 --- a/tests/ui/needless_option_as_deref.fixed +++ b/tests/ui/needless_option_as_deref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::needless_option_as_deref)] diff --git a/tests/ui/needless_option_as_deref.rs b/tests/ui/needless_option_as_deref.rs index 61eda5052a21..e2e35360cb36 100644 --- a/tests/ui/needless_option_as_deref.rs +++ b/tests/ui/needless_option_as_deref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::needless_option_as_deref)] diff --git a/tests/ui/needless_option_as_deref.stderr b/tests/ui/needless_option_as_deref.stderr index bc07db5b38ed..41bbf45d965f 100644 --- a/tests/ui/needless_option_as_deref.stderr +++ b/tests/ui/needless_option_as_deref.stderr @@ -1,22 +1,26 @@ -error: derefed type is same as origin +warning: derefed type is same as origin --> $DIR/needless_option_as_deref.rs:8:29 | LL | let _: Option<&usize> = Some(&1).as_deref(); | ^^^^^^^^^^^^^^^^^^^ help: try this: `Some(&1)` | - = note: `-D clippy::needless-option-as-deref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_option_as_deref.rs:4:9 + | +LL | #![warn(clippy::needless_option_as_deref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: derefed type is same as origin +warning: derefed type is same as origin --> $DIR/needless_option_as_deref.rs:9:33 | LL | let _: Option<&mut usize> = Some(&mut 1).as_deref_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `Some(&mut 1)` -error: derefed type is same as origin +warning: derefed type is same as origin --> $DIR/needless_option_as_deref.rs:13:13 | LL | let _ = x.as_deref_mut(); | ^^^^^^^^^^^^^^^^ help: try this: `x` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/needless_option_take.fixed b/tests/ui/needless_option_take.fixed index 29691e81666f..bfc6d20d5a32 100644 --- a/tests/ui/needless_option_take.fixed +++ b/tests/ui/needless_option_take.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix fn main() { println!("Testing non erroneous option_take_on_temporary"); diff --git a/tests/ui/needless_option_take.rs b/tests/ui/needless_option_take.rs index 9f4109eb4635..697eeab42074 100644 --- a/tests/ui/needless_option_take.rs +++ b/tests/ui/needless_option_take.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix fn main() { println!("Testing non erroneous option_take_on_temporary"); diff --git a/tests/ui/needless_option_take.stderr b/tests/ui/needless_option_take.stderr index cb3bf015b369..7c334dac0ec0 100644 --- a/tests/ui/needless_option_take.stderr +++ b/tests/ui/needless_option_take.stderr @@ -1,10 +1,10 @@ -error: called `Option::take()` on a temporary value +warning: called `Option::take()` on a temporary value --> $DIR/needless_option_take.rs:14:5 | LL | x.as_ref().take(); | ^^^^^^^^^^^^^^^^^ help: try: `x.as_ref()` | - = note: `-D clippy::needless-option-take` implied by `-D warnings` + = note: `#[warn(clippy::needless_option_take)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/needless_parens_on_range_literals.fixed b/tests/ui/needless_parens_on_range_literals.fixed index f11330a8916d..9b98f6ea7f79 100644 --- a/tests/ui/needless_parens_on_range_literals.fixed +++ b/tests/ui/needless_parens_on_range_literals.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// edition:2018 +//@run-rustfix +//@edition:2018 #![warn(clippy::needless_parens_on_range_literals)] #![allow(clippy::almost_complete_range)] diff --git a/tests/ui/needless_parens_on_range_literals.rs b/tests/ui/needless_parens_on_range_literals.rs index 671c0009e23b..088e7b2b98f0 100644 --- a/tests/ui/needless_parens_on_range_literals.rs +++ b/tests/ui/needless_parens_on_range_literals.rs @@ -1,5 +1,5 @@ -// run-rustfix -// edition:2018 +//@run-rustfix +//@edition:2018 #![warn(clippy::needless_parens_on_range_literals)] #![allow(clippy::almost_complete_range)] diff --git a/tests/ui/needless_parens_on_range_literals.stderr b/tests/ui/needless_parens_on_range_literals.stderr index 505f7ac916dd..a3190a649b71 100644 --- a/tests/ui/needless_parens_on_range_literals.stderr +++ b/tests/ui/needless_parens_on_range_literals.stderr @@ -1,40 +1,44 @@ -error: needless parenthesis on range literals can be removed +warning: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:8:13 | LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'a'` | - = note: `-D clippy::needless-parens-on-range-literals` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_parens_on_range_literals.rs:4:9 + | +LL | #![warn(clippy::needless_parens_on_range_literals)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: needless parenthesis on range literals can be removed +warning: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:8:21 | LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'z'` -error: needless parenthesis on range literals can be removed +warning: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:9:18 | LL | let _ = 'a'..('z'); | ^^^^^ help: try: `'z'` -error: needless parenthesis on range literals can be removed +warning: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:11:19 | LL | let _ = (1.)..(2.); | ^^^^ help: try: `2.` -error: needless parenthesis on range literals can be removed +warning: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:12:13 | LL | let _ = ('a')..; | ^^^^^ help: try: `'a'` -error: needless parenthesis on range literals can be removed +warning: needless parenthesis on range literals can be removed --> $DIR/needless_parens_on_range_literals.rs:13:15 | LL | let _ = ..('z'); | ^^^^^ help: try: `'z'` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 0e660a77dc0c..ab5607d008f9 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,60 +1,64 @@ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:18:23 | LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` | - = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_pass_by_value.rs:1:9 + | +LL | #![warn(clippy::needless_pass_by_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:32:11 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:32:22 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:38:71 | LL | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:50:18 | LL | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option>` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:63:24 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:63:36 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:79:49 | LL | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:81:18 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:81:29 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { @@ -69,13 +73,13 @@ help: change `t.clone()` to LL | let _ = t.to_string(); | ~~~~~~~~~~~~~ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:81:40 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:81:53 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { @@ -90,31 +94,31 @@ help: change `v.clone()` to LL | let _ = v.to_owned(); | ~~~~~~~~~~~~ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:94:12 | LL | s: String, | ^^^^^^ help: consider changing the type to: `&str` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:95:12 | LL | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:104:23 | LL | fn baz(&self, _u: U, _s: Self) {} | ^ help: consider taking a reference instead: `&U` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:104:30 | LL | fn baz(&self, _u: U, _s: Self) {} | ^^^^ help: consider taking a reference instead: `&Self` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:126:24 | LL | fn bar_copy(x: u32, y: CopyWrapper) { @@ -126,7 +130,7 @@ help: consider marking this type as `Copy` LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:132:29 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { @@ -138,7 +142,7 @@ help: consider marking this type as `Copy` LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:132:45 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { @@ -150,7 +154,7 @@ help: consider marking this type as `Copy` LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:132:61 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { @@ -162,17 +166,17 @@ help: consider marking this type as `Copy` LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:144:40 | LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {} | ^ help: consider taking a reference instead: `&S` -error: this argument is passed by value, but not consumed in the function body +warning: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:149:20 | LL | fn more_fun(_item: impl Club<'static, i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` -error: aborting due to 22 previous errors +warning: 22 warnings emitted diff --git a/tests/ui/needless_question_mark.fixed b/tests/ui/needless_question_mark.fixed index 7eaca571992f..679b73d404a6 100644 --- a/tests/ui/needless_question_mark.fixed +++ b/tests/ui/needless_question_mark.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_question_mark)] #![allow( diff --git a/tests/ui/needless_question_mark.rs b/tests/ui/needless_question_mark.rs index 960bc7b78983..a993d3ec35d8 100644 --- a/tests/ui/needless_question_mark.rs +++ b/tests/ui/needless_question_mark.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::needless_question_mark)] #![allow( diff --git a/tests/ui/needless_question_mark.stderr b/tests/ui/needless_question_mark.stderr index d1f89e326c67..abc950496712 100644 --- a/tests/ui/needless_question_mark.stderr +++ b/tests/ui/needless_question_mark.stderr @@ -1,72 +1,76 @@ -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:22:12 | LL | return Some(to.magic?); | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` | - = note: `-D clippy::needless-question-mark` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_question_mark.rs:3:9 + | +LL | #![warn(clippy::needless_question_mark)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:30:12 | LL | return Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:35:5 | LL | Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:40:21 | LL | to.and_then(|t| Some(t.magic?)) | ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:49:9 | LL | Some(t.magic?) | ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:54:12 | LL | return Ok(tr.magic?); | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:61:12 | LL | return Ok(tr.magic?) | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:65:5 | LL | Ok(tr.magic?) | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:69:21 | LL | tr.and_then(|t| Ok(t.magic?)) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:77:9 | LL | Ok(t.magic?) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:84:16 | LL | return Ok(t.magic?); | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:119:27 | LL | || -> Option<_> { Some(Some($expr)?) }() @@ -75,19 +79,19 @@ LL | || -> Option<_> { Some(Some($expr)?) }() LL | let _x = some_and_qmark_in_macro!(x?); | ---------------------------- in this macro invocation | - = note: this error originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:130:5 | LL | Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` -error: question mark operator is useless here +warning: question mark operator is useless here --> $DIR/needless_question_mark.rs:138:5 | LL | Ok(s.magic?) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `s.magic` -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index cffa19bec3a6..5b3d590d068a 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -1,16 +1,20 @@ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:11:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ | - = note: `-D clippy::needless-range-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_range_loop.rs:1:9 + | +LL | #![warn(clippy::needless_range_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using an iterator | LL | for in &vec { | ~~~~~~ ~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:20:14 | LL | for i in 0..vec.len() { @@ -21,7 +25,7 @@ help: consider using an iterator LL | for in &vec { | ~~~~~~ ~~~~ -error: the loop variable `j` is only used to index `STATIC` +warning: the loop variable `j` is only used to index `STATIC` --> $DIR/needless_range_loop.rs:25:14 | LL | for j in 0..4 { @@ -32,7 +36,7 @@ help: consider using an iterator LL | for in &STATIC { | ~~~~~~ ~~~~~~~ -error: the loop variable `j` is only used to index `CONST` +warning: the loop variable `j` is only used to index `CONST` --> $DIR/needless_range_loop.rs:29:14 | LL | for j in 0..4 { @@ -43,7 +47,7 @@ help: consider using an iterator LL | for in &CONST { | ~~~~~~ ~~~~~~ -error: the loop variable `i` is used to index `vec` +warning: the loop variable `i` is used to index `vec` --> $DIR/needless_range_loop.rs:33:14 | LL | for i in 0..vec.len() { @@ -54,7 +58,7 @@ help: consider using an iterator and enumerate() LL | for (i, ) in vec.iter().enumerate() { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec2` +warning: the loop variable `i` is only used to index `vec2` --> $DIR/needless_range_loop.rs:41:14 | LL | for i in 0..vec.len() { @@ -65,7 +69,7 @@ help: consider using an iterator LL | for in vec2.iter().take(vec.len()) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:45:14 | LL | for i in 5..vec.len() { @@ -76,7 +80,7 @@ help: consider using an iterator LL | for in vec.iter().skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:49:14 | LL | for i in 0..MAX_LEN { @@ -87,7 +91,7 @@ help: consider using an iterator LL | for in vec.iter().take(MAX_LEN) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:53:14 | LL | for i in 0..=MAX_LEN { @@ -98,7 +102,7 @@ help: consider using an iterator LL | for in vec.iter().take(MAX_LEN + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:57:14 | LL | for i in 5..10 { @@ -109,7 +113,7 @@ help: consider using an iterator LL | for in vec.iter().take(10).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop.rs:61:14 | LL | for i in 5..=10 { @@ -120,7 +124,7 @@ help: consider using an iterator LL | for in vec.iter().take(10 + 1).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is used to index `vec` +warning: the loop variable `i` is used to index `vec` --> $DIR/needless_range_loop.rs:65:14 | LL | for i in 5..vec.len() { @@ -131,7 +135,7 @@ help: consider using an iterator and enumerate() LL | for (i, ) in vec.iter().enumerate().skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is used to index `vec` +warning: the loop variable `i` is used to index `vec` --> $DIR/needless_range_loop.rs:69:14 | LL | for i in 5..10 { @@ -142,7 +146,7 @@ help: consider using an iterator and enumerate() LL | for (i, ) in vec.iter().enumerate().take(10).skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is used to index `vec` +warning: the loop variable `i` is used to index `vec` --> $DIR/needless_range_loop.rs:74:14 | LL | for i in 0..vec.len() { @@ -153,5 +157,5 @@ help: consider using an iterator and enumerate() LL | for (i, ) in vec.iter_mut().enumerate() { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/needless_range_loop2.stderr b/tests/ui/needless_range_loop2.stderr index 1e6ec5e667aa..62e2667cff23 100644 --- a/tests/ui/needless_range_loop2.stderr +++ b/tests/ui/needless_range_loop2.stderr @@ -1,16 +1,20 @@ -error: the loop variable `i` is only used to index `ns` +warning: the loop variable `i` is only used to index `ns` --> $DIR/needless_range_loop2.rs:10:14 | LL | for i in 3..10 { | ^^^^^ | - = note: `-D clippy::needless-range-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_range_loop2.rs:1:9 + | +LL | #![warn(clippy::needless_range_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using an iterator | LL | for in ns.iter().take(10).skip(3) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `ms` +warning: the loop variable `i` is only used to index `ms` --> $DIR/needless_range_loop2.rs:31:14 | LL | for i in 0..ms.len() { @@ -21,7 +25,7 @@ help: consider using an iterator LL | for in &mut ms { | ~~~~~~ ~~~~~~~ -error: the loop variable `i` is only used to index `ms` +warning: the loop variable `i` is only used to index `ms` --> $DIR/needless_range_loop2.rs:37:14 | LL | for i in 0..ms.len() { @@ -32,7 +36,7 @@ help: consider using an iterator LL | for in &mut ms { | ~~~~~~ ~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop2.rs:61:14 | LL | for i in x..x + 4 { @@ -43,7 +47,7 @@ help: consider using an iterator LL | for in vec.iter_mut().skip(x).take(4) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `vec` +warning: the loop variable `i` is only used to index `vec` --> $DIR/needless_range_loop2.rs:68:14 | LL | for i in x..=x + 4 { @@ -54,7 +58,7 @@ help: consider using an iterator LL | for in vec.iter_mut().skip(x).take(4 + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `arr` +warning: the loop variable `i` is only used to index `arr` --> $DIR/needless_range_loop2.rs:74:14 | LL | for i in 0..3 { @@ -65,7 +69,7 @@ help: consider using an iterator LL | for in &arr { | ~~~~~~ ~~~~ -error: the loop variable `i` is only used to index `arr` +warning: the loop variable `i` is only used to index `arr` --> $DIR/needless_range_loop2.rs:78:14 | LL | for i in 0..2 { @@ -76,7 +80,7 @@ help: consider using an iterator LL | for in arr.iter().take(2) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ -error: the loop variable `i` is only used to index `arr` +warning: the loop variable `i` is only used to index `arr` --> $DIR/needless_range_loop2.rs:82:14 | LL | for i in 1..3 { @@ -87,5 +91,5 @@ help: consider using an iterator LL | for in arr.iter().skip(1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/needless_return.fixed b/tests/ui/needless_return.fixed index 0f525dd294c9..1d38b8fb29d7 100644 --- a/tests/ui/needless_return.fixed +++ b/tests/ui/needless_return.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![feature(yeet_expr)] diff --git a/tests/ui/needless_return.rs b/tests/ui/needless_return.rs index a1db8375d95b..80961cfff8f6 100644 --- a/tests/ui/needless_return.rs +++ b/tests/ui/needless_return.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(lint_reasons)] #![feature(yeet_expr)] diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 87d0cd3e14cf..e9a6b55a1ab7 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -1,13 +1,17 @@ -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:27:5 | LL | return true; | ^^^^^^^^^^^ | - = note: `-D clippy::needless-return` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_return.rs:12:9 + | +LL | #![warn(clippy::needless_return)] + | ^^^^^^^^^^^^^^^^^^^^^^^ = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:31:5 | LL | return true; @@ -15,7 +19,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:36:5 | LL | return true;;; @@ -23,7 +27,7 @@ LL | return true;;; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:41:5 | LL | return true;; ; ; @@ -31,7 +35,7 @@ LL | return true;; ; ; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:46:9 | LL | return true; @@ -39,7 +43,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:48:9 | LL | return false; @@ -47,7 +51,7 @@ LL | return false; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:54:17 | LL | true => return false, @@ -55,7 +59,7 @@ LL | true => return false, | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:56:13 | LL | return true; @@ -63,7 +67,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:63:9 | LL | return true; @@ -71,7 +75,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:65:16 | LL | let _ = || return true; @@ -79,7 +83,7 @@ LL | let _ = || return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:69:5 | LL | return the_answer!(); @@ -87,7 +91,7 @@ LL | return the_answer!(); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:72:21 | LL | fn test_void_fun() { @@ -97,7 +101,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:77:11 | LL | if b { @@ -107,7 +111,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:79:13 | LL | } else { @@ -117,7 +121,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:87:14 | LL | _ => return, @@ -125,7 +129,7 @@ LL | _ => return, | = help: replace `return` with a unit value -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:95:24 | LL | let _ = 42; @@ -135,7 +139,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:98:14 | LL | _ => return, @@ -143,7 +147,7 @@ LL | _ => return, | = help: replace `return` with a unit value -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:111:9 | LL | return String::from("test"); @@ -151,7 +155,7 @@ LL | return String::from("test"); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:113:9 | LL | return String::new(); @@ -159,7 +163,7 @@ LL | return String::new(); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:135:32 | LL | bar.unwrap_or_else(|_| return) @@ -167,7 +171,7 @@ LL | bar.unwrap_or_else(|_| return) | = help: replace `return` with an empty block -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:139:21 | LL | let _ = || { @@ -177,7 +181,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:142:20 | LL | let _ = || return; @@ -185,7 +189,7 @@ LL | let _ = || return; | = help: replace `return` with an empty block -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:148:32 | LL | res.unwrap_or_else(|_| return Foo) @@ -193,7 +197,7 @@ LL | res.unwrap_or_else(|_| return Foo) | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:157:5 | LL | return true; @@ -201,7 +205,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:161:5 | LL | return true; @@ -209,7 +213,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:166:9 | LL | return true; @@ -217,7 +221,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:168:9 | LL | return false; @@ -225,7 +229,7 @@ LL | return false; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:174:17 | LL | true => return false, @@ -233,7 +237,7 @@ LL | true => return false, | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:176:13 | LL | return true; @@ -241,7 +245,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:183:9 | LL | return true; @@ -249,7 +253,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:185:16 | LL | let _ = || return true; @@ -257,7 +261,7 @@ LL | let _ = || return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:189:5 | LL | return the_answer!(); @@ -265,7 +269,7 @@ LL | return the_answer!(); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:192:33 | LL | async fn async_test_void_fun() { @@ -275,7 +279,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:197:11 | LL | if b { @@ -285,7 +289,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:199:13 | LL | } else { @@ -295,7 +299,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:207:14 | LL | _ => return, @@ -303,7 +307,7 @@ LL | _ => return, | = help: replace `return` with a unit value -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:220:9 | LL | return String::from("test"); @@ -311,7 +315,7 @@ LL | return String::from("test"); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:222:9 | LL | return String::new(); @@ -319,7 +323,7 @@ LL | return String::new(); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:238:5 | LL | return format!("Hello {}", "world!"); @@ -327,7 +331,7 @@ LL | return format!("Hello {}", "world!"); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:249:9 | LL | return true; @@ -335,7 +339,7 @@ LL | return true; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:251:9 | LL | return false; @@ -343,7 +347,7 @@ LL | return false; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:258:13 | LL | return 10; @@ -351,7 +355,7 @@ LL | return 10; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:261:13 | LL | return 100; @@ -359,7 +363,7 @@ LL | return 100; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:269:9 | LL | return 0; @@ -367,7 +371,7 @@ LL | return 0; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:276:13 | LL | return *(x as *const isize); @@ -375,7 +379,7 @@ LL | return *(x as *const isize); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:278:13 | LL | return !*(x as *const isize); @@ -383,7 +387,7 @@ LL | return !*(x as *const isize); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:285:20 | LL | let _ = 42; @@ -394,7 +398,7 @@ LL | | return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:292:20 | LL | let _ = 42; return; @@ -402,7 +406,7 @@ LL | let _ = 42; return; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:304:9 | LL | return Ok(format!("ok!")); @@ -410,7 +414,7 @@ LL | return Ok(format!("ok!")); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:306:9 | LL | return Err(format!("err!")); @@ -418,7 +422,7 @@ LL | return Err(format!("err!")); | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:312:9 | LL | return if true { 1 } else { 2 }; @@ -426,7 +430,7 @@ LL | return if true { 1 } else { 2 }; | = help: remove `return` -error: unneeded `return` statement +warning: unneeded `return` statement --> $DIR/needless_return.rs:316:9 | LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 }; @@ -434,5 +438,5 @@ LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 | = help: remove `return` and wrap the sequence with parentheses -error: aborting due to 52 previous errors +warning: 52 warnings emitted diff --git a/tests/ui/needless_splitn.fixed b/tests/ui/needless_splitn.fixed index 5496031fefab..30a038312c87 100644 --- a/tests/ui/needless_splitn.fixed +++ b/tests/ui/needless_splitn.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// edition:2018 +//@run-rustfix +//@edition:2018 #![warn(clippy::needless_splitn)] #![allow(clippy::iter_skip_next, clippy::iter_nth_zero, clippy::manual_split_once)] diff --git a/tests/ui/needless_splitn.rs b/tests/ui/needless_splitn.rs index 35c2465bae13..1b0b9a5981a1 100644 --- a/tests/ui/needless_splitn.rs +++ b/tests/ui/needless_splitn.rs @@ -1,5 +1,5 @@ -// run-rustfix -// edition:2018 +//@run-rustfix +//@edition:2018 #![warn(clippy::needless_splitn)] #![allow(clippy::iter_skip_next, clippy::iter_nth_zero, clippy::manual_split_once)] diff --git a/tests/ui/needless_splitn.stderr b/tests/ui/needless_splitn.stderr index f607d8e1ab5f..58c0f0305938 100644 --- a/tests/ui/needless_splitn.stderr +++ b/tests/ui/needless_splitn.stderr @@ -1,82 +1,86 @@ -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:14:13 | LL | let _ = str.splitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')` | - = note: `-D clippy::needless-splitn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_splitn.rs:4:9 + | +LL | #![warn(clippy::needless_splitn)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:15:13 | LL | let _ = str.splitn(2, '=').nth(0); | ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')` -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:18:18 | LL | let (_, _) = str.splitn(3, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')` -error: unnecessary use of `rsplitn` +warning: unnecessary use of `rsplitn` --> $DIR/needless_splitn.rs:21:13 | LL | let _ = str.rsplitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^^ help: try this: `str.rsplit('=')` -error: unnecessary use of `rsplitn` +warning: unnecessary use of `rsplitn` --> $DIR/needless_splitn.rs:22:13 | LL | let _ = str.rsplitn(2, '=').nth(0); | ^^^^^^^^^^^^^^^^^^^ help: try this: `str.rsplit('=')` -error: unnecessary use of `rsplitn` +warning: unnecessary use of `rsplitn` --> $DIR/needless_splitn.rs:25:18 | LL | let (_, _) = str.rsplitn(3, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: try this: `str.rsplit('=')` -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:27:13 | LL | let _ = str.splitn(5, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')` -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:28:13 | LL | let _ = str.splitn(5, '=').nth(3); | ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')` -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:34:13 | LL | let _ = s.splitn(2, '=').next()?; | ^^^^^^^^^^^^^^^^ help: try this: `s.split('=')` -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:35:13 | LL | let _ = s.splitn(2, '=').nth(0)?; | ^^^^^^^^^^^^^^^^ help: try this: `s.split('=')` -error: unnecessary use of `rsplitn` +warning: unnecessary use of `rsplitn` --> $DIR/needless_splitn.rs:36:13 | LL | let _ = s.rsplitn(2, '=').next()?; | ^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit('=')` -error: unnecessary use of `rsplitn` +warning: unnecessary use of `rsplitn` --> $DIR/needless_splitn.rs:37:13 | LL | let _ = s.rsplitn(2, '=').nth(0)?; | ^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit('=')` -error: unnecessary use of `splitn` +warning: unnecessary use of `splitn` --> $DIR/needless_splitn.rs:45:13 | LL | let _ = "key=value".splitn(2, '=').nth(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split('=')` -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index b154b3b306dd..ea2d6a08f881 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,10 +1,14 @@ -error: struct update has no effect, all the fields in the struct have already been specified +warning: struct update has no effect, all the fields in the struct have already been specified --> $DIR/needless_update.rs:19:23 | LL | S { a: 1, b: 1, ..base }; | ^^^^ | - = note: `-D clippy::needless-update` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/needless_update.rs:1:9 + | +LL | #![warn(clippy::needless_update)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index c78560007217..91033805765a 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,28 +1,32 @@ -error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable +warning: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable --> $DIR/neg_cmp_op_on_partial_ord.rs:16:21 | LL | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/neg_cmp_op_on_partial_ord.rs:8:8 + | +LL | #[warn(clippy::neg_cmp_op_on_partial_ord)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable +warning: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable --> $DIR/neg_cmp_op_on_partial_ord.rs:19:30 | LL | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable +warning: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable --> $DIR/neg_cmp_op_on_partial_ord.rs:22:24 | LL | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable +warning: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable --> $DIR/neg_cmp_op_on_partial_ord.rs:25:33 | LL | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/neg_multiply.fixed b/tests/ui/neg_multiply.fixed index 58ab9e856783..e07e7c88d684 100644 --- a/tests/ui/neg_multiply.fixed +++ b/tests/ui/neg_multiply.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::neg_multiply)] #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::precedence)] #![allow(unused)] diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs index 581290dc72e4..2887af7b4218 100644 --- a/tests/ui/neg_multiply.rs +++ b/tests/ui/neg_multiply.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::neg_multiply)] #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::precedence)] #![allow(unused)] diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index 388ef29eb856..8277a3bd81d2 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -1,52 +1,56 @@ -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:29:5 | LL | x * -1; | ^^^^^^ help: consider using: `-x` | - = note: `-D clippy::neg-multiply` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/neg_multiply.rs:2:9 + | +LL | #![warn(clippy::neg_multiply)] + | ^^^^^^^^^^^^^^^^^^^^ -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:31:5 | LL | -1 * x; | ^^^^^^ help: consider using: `-x` -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:33:11 | LL | 100 + x * -1; | ^^^^^^ help: consider using: `-x` -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:35:5 | LL | (100 + x) * -1; | ^^^^^^^^^^^^^^ help: consider using: `-(100 + x)` -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:37:5 | LL | -1 * 17; | ^^^^^^^ help: consider using: `-17` -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:39:14 | LL | 0xcafe | 0xff00 * -1; | ^^^^^^^^^^^ help: consider using: `-0xff00` -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:41:5 | LL | 3_usize as i32 * -1; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)` -error: this multiplication by -1 can be written more succinctly +warning: this multiplication by -1 can be written more succinctly --> $DIR/neg_multiply.rs:42:5 | LL | (3_usize as i32) * -1; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index 29821ff96fc0..69ada103fe09 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -4,6 +4,7 @@ unused_variables, clippy::while_immutable_condition )] +#![warn(clippy::never_loop)] fn test1() { let mut x = 0; diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 704d448644e2..7479419f31ff 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,5 +1,5 @@ -error: this loop never actually loops - --> $DIR/never_loop.rs:10:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:11:5 | LL | / loop { LL | | // clippy::never_loop @@ -10,10 +10,14 @@ LL | | break; LL | | } | |_____^ | - = note: `#[deny(clippy::never_loop)]` on by default +note: the lint level is defined here + --> $DIR/never_loop.rs:7:9 + | +LL | #![warn(clippy::never_loop)] + | ^^^^^^^^^^^^^^^^^^ -error: this loop never actually loops - --> $DIR/never_loop.rs:32:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:33:5 | LL | / loop { LL | | // never loops @@ -22,8 +26,8 @@ LL | | break; LL | | } | |_____^ -error: this loop never actually loops - --> $DIR/never_loop.rs:52:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:53:5 | LL | / loop { LL | | // never loops @@ -34,8 +38,8 @@ LL | | return; LL | | } | |_____^ -error: this loop never actually loops - --> $DIR/never_loop.rs:54:9 +warning: this loop never actually loops + --> $DIR/never_loop.rs:55:9 | LL | / while i == 0 { LL | | // never loops @@ -43,8 +47,8 @@ LL | | break; LL | | } | |_________^ -error: this loop never actually loops - --> $DIR/never_loop.rs:66:9 +warning: this loop never actually loops + --> $DIR/never_loop.rs:67:9 | LL | / loop { LL | | // never loops @@ -55,8 +59,8 @@ LL | | continue 'outer; LL | | } | |_________^ -error: this loop never actually loops - --> $DIR/never_loop.rs:102:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:103:5 | LL | / while let Some(y) = x { LL | | // never loops @@ -64,8 +68,8 @@ LL | | return; LL | | } | |_____^ -error: this loop never actually loops - --> $DIR/never_loop.rs:109:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:110:5 | LL | / for x in 0..10 { LL | | // never loops @@ -81,8 +85,8 @@ help: if you need the first element of the iterator, try writing LL | if let Some(x) = (0..10).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: this loop never actually loops - --> $DIR/never_loop.rs:157:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:158:5 | LL | / 'outer: while a { LL | | // never loops @@ -93,16 +97,16 @@ LL | | break 'outer; LL | | } | |_____^ -error: this loop never actually loops - --> $DIR/never_loop.rs:172:9 +warning: this loop never actually loops + --> $DIR/never_loop.rs:173:9 | LL | / while false { LL | | break 'label; LL | | } | |_________^ -error: this loop never actually loops - --> $DIR/never_loop.rs:223:13 +warning: this loop never actually loops + --> $DIR/never_loop.rs:224:13 | LL | let _ = loop { | _____________^ @@ -114,8 +118,8 @@ LL | | break x; LL | | }; | |_____^ -error: this loop never actually loops - --> $DIR/never_loop.rs:244:5 +warning: this loop never actually loops + --> $DIR/never_loop.rs:245:5 | LL | / 'a: loop { LL | | 'b: { @@ -126,8 +130,8 @@ LL | | } LL | | } | |_____^ -error: this loop never actually loops - --> $DIR/never_loop.rs:278:13 +warning: this loop never actually loops + --> $DIR/never_loop.rs:279:13 | LL | / for _ in 0..20 { LL | | break 'block; @@ -139,5 +143,5 @@ help: if you need the first element of the iterator, try writing LL | if let Some(_) = (0..20).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/new_ret_no_self.stderr b/tests/ui/new_ret_no_self.stderr index 2eaebfb5cac5..9798bb1b086c 100644 --- a/tests/ui/new_ret_no_self.stderr +++ b/tests/ui/new_ret_no_self.stderr @@ -1,4 +1,4 @@ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:50:5 | LL | / pub fn new(_: String) -> impl R { @@ -6,9 +6,13 @@ LL | | S3 LL | | } | |_____^ | - = note: `-D clippy::new-ret-no-self` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/new_ret_no_self.rs:2:9 + | +LL | #![warn(clippy::new_ret_no_self)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:82:5 | LL | / pub fn new() -> u32 { @@ -16,7 +20,7 @@ LL | | unimplemented!(); LL | | } | |_____^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:91:5 | LL | / pub fn new(_: String) -> u32 { @@ -24,7 +28,7 @@ LL | | unimplemented!(); LL | | } | |_____^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:127:5 | LL | / pub fn new() -> (u32, u32) { @@ -32,7 +36,7 @@ LL | | unimplemented!(); LL | | } | |_____^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:154:5 | LL | / pub fn new() -> *mut V { @@ -40,7 +44,7 @@ LL | | unimplemented!(); LL | | } | |_____^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:172:5 | LL | / pub fn new() -> Option { @@ -48,19 +52,19 @@ LL | | unimplemented!(); LL | | } | |_____^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:225:9 | LL | fn new() -> String; | ^^^^^^^^^^^^^^^^^^^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:237:9 | LL | fn new(_: String) -> String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:272:9 | LL | / fn new() -> (u32, u32) { @@ -68,7 +72,7 @@ LL | | unimplemented!(); LL | | } | |_________^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:299:9 | LL | / fn new() -> *mut V { @@ -76,7 +80,7 @@ LL | | unimplemented!(); LL | | } | |_________^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:369:9 | LL | / fn new(t: T) -> impl Into { @@ -84,7 +88,7 @@ LL | | 1 LL | | } | |_________^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:390:9 | LL | / fn new(t: T) -> impl Trait2<(), i32> { @@ -92,7 +96,7 @@ LL | | unimplemented!() LL | | } | |_________^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:410:9 | LL | / pub fn new() -> impl PartialOrd { @@ -100,7 +104,7 @@ LL | | 0i32 LL | | } | |_________^ -error: methods called `new` usually return `Self` +warning: methods called `new` usually return `Self` --> $DIR/new_ret_no_self.rs:421:9 | LL | / pub fn new() -> X { @@ -108,5 +112,5 @@ LL | | 0i32 LL | | } | |_________^ -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 583dd327d6a5..e7c4ecfa27f7 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,4 +1,4 @@ -error: you should consider adding a `Default` implementation for `Foo` +warning: you should consider adding a `Default` implementation for `Foo` --> $DIR/new_without_default.rs:12:5 | LL | / pub fn new() -> Foo { @@ -6,7 +6,11 @@ LL | | Foo LL | | } | |_____^ | - = note: `-D clippy::new-without-default` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/new_without_default.rs:7:9 + | +LL | #![warn(clippy::new_without_default)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding this | LL + impl Default for Foo { @@ -16,7 +20,7 @@ LL + } LL + } | -error: you should consider adding a `Default` implementation for `Bar` +warning: you should consider adding a `Default` implementation for `Bar` --> $DIR/new_without_default.rs:20:5 | LL | / pub fn new() -> Self { @@ -33,7 +37,7 @@ LL + } LL + } | -error: you should consider adding a `Default` implementation for `LtKo<'c>` +warning: you should consider adding a `Default` implementation for `LtKo<'c>` --> $DIR/new_without_default.rs:84:5 | LL | / pub fn new() -> LtKo<'c> { @@ -50,7 +54,7 @@ LL + } LL + } | -error: you should consider adding a `Default` implementation for `NewNotEqualToDerive` +warning: you should consider adding a `Default` implementation for `NewNotEqualToDerive` --> $DIR/new_without_default.rs:177:5 | LL | / pub fn new() -> Self { @@ -67,7 +71,7 @@ LL + } LL + } | -error: you should consider adding a `Default` implementation for `FooGenerics` +warning: you should consider adding a `Default` implementation for `FooGenerics` --> $DIR/new_without_default.rs:185:5 | LL | / pub fn new() -> Self { @@ -84,7 +88,7 @@ LL + } LL + } | -error: you should consider adding a `Default` implementation for `BarGenerics` +warning: you should consider adding a `Default` implementation for `BarGenerics` --> $DIR/new_without_default.rs:192:5 | LL | / pub fn new() -> Self { @@ -101,7 +105,7 @@ LL + } LL + } | -error: you should consider adding a `Default` implementation for `Foo` +warning: you should consider adding a `Default` implementation for `Foo` --> $DIR/new_without_default.rs:203:9 | LL | / pub fn new() -> Self { @@ -120,5 +124,5 @@ LL + LL ~ impl Foo { | -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 6a1e636f9a61..fd6ce0815a05 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,186 +1,190 @@ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:92:5 | LL | 0; | ^^ | - = note: `-D clippy::no-effect` implied by `-D warnings` + = note: `#[warn(clippy::no_effect)]` on by default -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:93:5 | LL | s2; | ^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:94:5 | LL | Unit; | ^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:95:5 | LL | Tuple(0); | ^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:96:5 | LL | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:97:5 | LL | Struct { ..s }; | ^^^^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:98:5 | LL | Union { a: 0 }; | ^^^^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:99:5 | LL | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:100:5 | LL | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:101:5 | LL | 5 + 6; | ^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:102:5 | LL | *&42; | ^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:103:5 | LL | &6; | ^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:104:5 | LL | (5, 6, 7); | ^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:105:5 | LL | box 42; | ^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:106:5 | LL | ..; | ^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:107:5 | LL | 5..; | ^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:108:5 | LL | ..5; | ^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:109:5 | LL | 5..6; | ^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:110:5 | LL | 5..=6; | ^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:111:5 | LL | [42, 55]; | ^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:112:5 | LL | [42, 55][1]; | ^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:113:5 | LL | (42, 55).1; | ^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:114:5 | LL | [42; 55]; | ^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:115:5 | LL | [42; 55][13]; | ^^^^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:117:5 | LL | || x += 5; | ^^^^^^^^^^ -error: statement with no effect +warning: statement with no effect --> $DIR/no_effect.rs:119:5 | LL | FooString { s: s }; | ^^^^^^^^^^^^^^^^^^^ -error: binding to `_` prefixed variable with no side-effect +warning: binding to `_` prefixed variable with no side-effect --> $DIR/no_effect.rs:120:5 | LL | let _unused = 1; | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::no-effect-underscore-binding` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/no_effect.rs:2:9 + | +LL | #![warn(clippy::no_effect_underscore_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: binding to `_` prefixed variable with no side-effect +warning: binding to `_` prefixed variable with no side-effect --> $DIR/no_effect.rs:121:5 | LL | let _penguin = || println!("Some helpful closure"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: binding to `_` prefixed variable with no side-effect +warning: binding to `_` prefixed variable with no side-effect --> $DIR/no_effect.rs:122:5 | LL | let _duck = Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: binding to `_` prefixed variable with no side-effect +warning: binding to `_` prefixed variable with no side-effect --> $DIR/no_effect.rs:123:5 | LL | let _cat = [2, 4, 6, 8][2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 30 previous errors +warning: 30 warnings emitted diff --git a/tests/ui/no_effect_replace.stderr b/tests/ui/no_effect_replace.stderr index 53a28aa73b70..b96bdce8a12a 100644 --- a/tests/ui/no_effect_replace.stderr +++ b/tests/ui/no_effect_replace.stderr @@ -1,52 +1,56 @@ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:4:13 | LL | let _ = "12345".replace('1', "1"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::no-effect-replace` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/no_effect_replace.rs:1:9 + | +LL | #![warn(clippy::no_effect_replace)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:5:13 | LL | let _ = "12345".replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:6:13 | LL | let _ = String::new().replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:8:13 | LL | let _ = "12345".replacen('1', "1", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:9:13 | LL | let _ = "12345".replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:10:13 | LL | let _ = String::new().replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:16:13 | LL | let _ = "hello".replace(&x.f(), &x.f()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing text with itself +warning: replacing text with itself --> $DIR/no_effect_replace.rs:19:13 | LL | let _ = "hello".replace(&y(), &y()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/no_mangle_with_rust_abi.fixed b/tests/ui/no_mangle_with_rust_abi.fixed index d18dec22a8bb..fbe1e496d703 100644 --- a/tests/ui/no_mangle_with_rust_abi.fixed +++ b/tests/ui/no_mangle_with_rust_abi.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::no_mangle_with_rust_abi)] diff --git a/tests/ui/no_mangle_with_rust_abi.rs b/tests/ui/no_mangle_with_rust_abi.rs index 481e1b6d9619..1a78045c1bc5 100644 --- a/tests/ui/no_mangle_with_rust_abi.rs +++ b/tests/ui/no_mangle_with_rust_abi.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::no_mangle_with_rust_abi)] diff --git a/tests/ui/no_mangle_with_rust_abi.stderr b/tests/ui/no_mangle_with_rust_abi.stderr index 71517d318095..9ed975f16ebe 100644 --- a/tests/ui/no_mangle_with_rust_abi.stderr +++ b/tests/ui/no_mangle_with_rust_abi.stderr @@ -1,30 +1,34 @@ -error: attribute #[no_mangle] set on a Rust ABI function +warning: attribute #[no_mangle] set on a Rust ABI function --> $DIR/no_mangle_with_rust_abi.rs:7:1 | LL | fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `extern "C" fn rust_abi_fn_one(arg_one: u32, arg_two: usize)` | - = note: `-D clippy::no-mangle-with-rust-abi` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/no_mangle_with_rust_abi.rs:4:9 + | +LL | #![warn(clippy::no_mangle_with_rust_abi)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: attribute #[no_mangle] set on a Rust ABI function +warning: attribute #[no_mangle] set on a Rust ABI function --> $DIR/no_mangle_with_rust_abi.rs:10:1 | LL | pub fn rust_abi_fn_two(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `pub extern "C" fn rust_abi_fn_two(arg_one: u32, arg_two: usize)` -error: attribute #[no_mangle] set on a Rust ABI function +warning: attribute #[no_mangle] set on a Rust ABI function --> $DIR/no_mangle_with_rust_abi.rs:15:1 | LL | pub unsafe fn rust_abi_fn_three(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `pub unsafe extern "C" fn rust_abi_fn_three(arg_one: u32, arg_two: usize)` -error: attribute #[no_mangle] set on a Rust ABI function +warning: attribute #[no_mangle] set on a Rust ABI function --> $DIR/no_mangle_with_rust_abi.rs:20:1 | LL | unsafe fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unsafe extern "C" fn rust_abi_fn_four(arg_one: u32, arg_two: usize)` -error: attribute #[no_mangle] set on a Rust ABI function +warning: attribute #[no_mangle] set on a Rust ABI function --> $DIR/no_mangle_with_rust_abi.rs:23:1 | LL | / fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lines( @@ -41,5 +45,5 @@ LL + arg_two: usize, LL ~ ) -> u32 { | -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 583096ac054a..d0fea7ee242a 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -1,5 +1,6 @@ #![warn(clippy::all)] #![allow(unused, clippy::println_empty_string, non_snake_case, clippy::let_unit_value)] +#![deny(clippy::just_underscores_and_digits)] #[derive(Clone, Debug)] enum MaybeInst { @@ -25,9 +26,9 @@ impl MaybeInst { } fn underscores_and_numbers() { - let _1 = 1; //~ERROR Consider a more descriptive name - let ____1 = 1; //~ERROR Consider a more descriptive name - let __1___2 = 12; //~ERROR Consider a more descriptive name + let _1 = 1; //~ERROR: consider choosing a more descriptive name + let ____1 = 1; //~ERROR: consider choosing a more descriptive name + let __1___2 = 12; //~ERROR: consider choosing a more descriptive name let _1_ok = 1; } @@ -48,9 +49,9 @@ struct Bar; impl Bar { fn bar() { - let _1 = 1; - let ____1 = 1; - let __1___2 = 12; + let _1 = 1; //~ERROR: consider choosing a more descriptive name + let ____1 = 1; //~ERROR: consider choosing a more descriptive name + let __1___2 = 12; //~ERROR: consider choosing a more descriptive name let _1_ok = 1; } } diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 116d5da8729c..465999f839f9 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,37 +1,41 @@ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:28:9 + --> $DIR/non_expressive_names.rs:29:9 | -LL | let _1 = 1; //~ERROR Consider a more descriptive name +LL | let _1 = 1; | ^^ | - = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/non_expressive_names.rs:3:9 + | +LL | #![deny(clippy::just_underscores_and_digits)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:29:9 + --> $DIR/non_expressive_names.rs:30:9 | -LL | let ____1 = 1; //~ERROR Consider a more descriptive name +LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:30:9 + --> $DIR/non_expressive_names.rs:31:9 | -LL | let __1___2 = 12; //~ERROR Consider a more descriptive name +LL | let __1___2 = 12; | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:51:13 + --> $DIR/non_expressive_names.rs:52:13 | LL | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:52:13 + --> $DIR/non_expressive_names.rs:53:13 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:53:13 + --> $DIR/non_expressive_names.rs:54:13 | LL | let __1___2 = 12; | ^^^^^^^ diff --git a/tests/ui/non_octal_unix_permissions.fixed b/tests/ui/non_octal_unix_permissions.fixed index a9b2dcfb0856..5d0da8dce670 100644 --- a/tests/ui/non_octal_unix_permissions.fixed +++ b/tests/ui/non_octal_unix_permissions.fixed @@ -1,5 +1,5 @@ -// ignore-windows -// run-rustfix +//@ignore-target-windows +//@run-rustfix #![warn(clippy::non_octal_unix_permissions)] use std::fs::{DirBuilder, File, OpenOptions, Permissions}; use std::os::unix::fs::{DirBuilderExt, OpenOptionsExt, PermissionsExt}; diff --git a/tests/ui/non_octal_unix_permissions.rs b/tests/ui/non_octal_unix_permissions.rs index 7d2922f494e1..04a3643050e6 100644 --- a/tests/ui/non_octal_unix_permissions.rs +++ b/tests/ui/non_octal_unix_permissions.rs @@ -1,5 +1,5 @@ -// ignore-windows -// run-rustfix +//@ignore-target-windows +//@run-rustfix #![warn(clippy::non_octal_unix_permissions)] use std::fs::{DirBuilder, File, OpenOptions, Permissions}; use std::os::unix::fs::{DirBuilderExt, OpenOptionsExt, PermissionsExt}; diff --git a/tests/ui/non_octal_unix_permissions.stderr b/tests/ui/non_octal_unix_permissions.stderr index 32845d065941..7bb3972608ce 100644 --- a/tests/ui/non_octal_unix_permissions.stderr +++ b/tests/ui/non_octal_unix_permissions.stderr @@ -1,28 +1,32 @@ -error: using a non-octal value to set unix file permissions +warning: using a non-octal value to set unix file permissions --> $DIR/non_octal_unix_permissions.rs:12:18 | LL | options.mode(440); | ^^^ help: consider using an octal literal instead: `0o440` | - = note: `-D clippy::non-octal-unix-permissions` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/non_octal_unix_permissions.rs:3:9 + | +LL | #![warn(clippy::non_octal_unix_permissions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: using a non-octal value to set unix file permissions +warning: using a non-octal value to set unix file permissions --> $DIR/non_octal_unix_permissions.rs:17:47 | LL | let _permissions = Permissions::from_mode(647); | ^^^ help: consider using an octal literal instead: `0o647` -error: using a non-octal value to set unix file permissions +warning: using a non-octal value to set unix file permissions --> $DIR/non_octal_unix_permissions.rs:26:26 | LL | permissions.set_mode(644); | ^^^ help: consider using an octal literal instead: `0o644` -error: using a non-octal value to set unix file permissions +warning: using a non-octal value to set unix file permissions --> $DIR/non_octal_unix_permissions.rs:31:18 | LL | builder.mode(755); | ^^^ help: consider using an octal literal instead: `0o755` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/non_send_fields_in_send_ty.stderr b/tests/ui/non_send_fields_in_send_ty.stderr index e912b59a6e7b..4ad46e89dc26 100644 --- a/tests/ui/non_send_fields_in_send_ty.stderr +++ b/tests/ui/non_send_fields_in_send_ty.stderr @@ -1,4 +1,4 @@ -error: some fields in `RingBuffer` are not safe to be sent to another thread +warning: some fields in `RingBuffer` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:17:1 | LL | unsafe impl Send for RingBuffer {} @@ -10,9 +10,13 @@ note: it is not safe to send field `data` to another thread LL | data: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Vec>: Send` - = note: `-D clippy::non-send-fields-in-send-ty` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/non_send_fields_in_send_ty.rs:1:9 + | +LL | #![warn(clippy::non_send_fields_in_send_ty)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: some fields in `MvccRwLock` are not safe to be sent to another thread +warning: some fields in `MvccRwLock` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:25:1 | LL | unsafe impl Send for MvccRwLock {} @@ -25,7 +29,7 @@ LL | lock: Mutex>, | ^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Mutex>: Send` -error: some fields in `ArcGuard` are not safe to be sent to another thread +warning: some fields in `ArcGuard` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:33:1 | LL | unsafe impl Send for ArcGuard {} @@ -38,7 +42,7 @@ LL | head: Arc, | ^^^^^^^^^^^^^ = help: add bounds on type parameter `RC` that satisfy `Arc: Send` -error: some fields in `DeviceHandle` are not safe to be sent to another thread +warning: some fields in `DeviceHandle` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:49:1 | LL | unsafe impl Send for DeviceHandle {} @@ -51,7 +55,7 @@ LL | context: T, | ^^^^^^^^^^ = help: add `T: Send` bound in `Send` impl -error: some fields in `NoGeneric` are not safe to be sent to another thread +warning: some fields in `NoGeneric` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:56:1 | LL | unsafe impl Send for NoGeneric {} @@ -64,7 +68,7 @@ LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` -error: some fields in `MultiField` are not safe to be sent to another thread +warning: some fields in `MultiField` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:64:1 | LL | unsafe impl Send for MultiField {} @@ -89,7 +93,7 @@ LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl -error: some fields in `MyOption` are not safe to be sent to another thread +warning: some fields in `MyOption` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:71:1 | LL | unsafe impl Send for MyOption {} @@ -102,7 +106,7 @@ LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl -error: some fields in `MultiParam` are not safe to be sent to another thread +warning: some fields in `MultiParam` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:83:1 | LL | unsafe impl Send for MultiParam {} @@ -115,7 +119,7 @@ LL | vec: Vec<(A, B)>, | ^^^^^^^^^^^^^^^^ = help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send` -error: some fields in `HeuristicTest` are not safe to be sent to another thread +warning: some fields in `HeuristicTest` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:101:1 | LL | unsafe impl Send for HeuristicTest {} @@ -128,7 +132,7 @@ LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` -error: some fields in `AttrTest3` are not safe to be sent to another thread +warning: some fields in `AttrTest3` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:120:1 | LL | unsafe impl Send for AttrTest3 {} @@ -141,7 +145,7 @@ LL | Enum2(T), | ^ = help: add `T: Send` bound in `Send` impl -error: some fields in `Complex` are not safe to be sent to another thread +warning: some fields in `Complex` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:128:1 | LL | unsafe impl

Send for Complex {} @@ -154,7 +158,7 @@ LL | field1: A, | ^^^^^^^^^ = help: add `P: Send` bound in `Send` impl -error: some fields in `Complex>` are not safe to be sent to another thread +warning: some fields in `Complex>` are not safe to be sent to another thread --> $DIR/non_send_fields_in_send_ty.rs:131:1 | LL | unsafe impl Send for Complex> {} @@ -167,5 +171,5 @@ LL | field2: B, | ^^^^^^^^^ = help: use a thread-safe type that implements `Send` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr index 91b5805aa97a..4575d4d78e1b 100644 --- a/tests/ui/nonminimal_bool.stderr +++ b/tests/ui/nonminimal_bool.stderr @@ -1,48 +1,52 @@ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:11:13 | LL | let _ = !true; | ^^^^^ help: try: `false` | - = note: `-D clippy::nonminimal-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/nonminimal_bool.rs:3:9 + | +LL | #![warn(clippy::nonminimal_bool)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:12:13 | LL | let _ = !false; | ^^^^^^ help: try: `true` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:13:13 | LL | let _ = !!a; | ^^^ help: try: `a` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:14:13 | LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:18:13 | LL | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `a || !b` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:19:13 | LL | let _ = !(!a || b); | ^^^^^^^^^^ help: try: `a && !b` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:20:13 | LL | let _ = !a && !(b && c); | ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:28:13 | LL | let _ = a == b && c == 5 && a == b; @@ -55,7 +59,7 @@ LL | let _ = !(a != b || c != 5); LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:29:13 | LL | let _ = a == b || c == 5 || a == b; @@ -68,7 +72,7 @@ LL | let _ = !(a != b && c != 5); LL | let _ = a == b || c == 5; | ~~~~~~~~~~~~~~~~ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:30:13 | LL | let _ = a == b && c == 5 && b == a; @@ -81,7 +85,7 @@ LL | let _ = !(a != b || c != 5); LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:31:13 | LL | let _ = a != b || !(a != b || c == d); @@ -94,7 +98,7 @@ LL | let _ = !(a == b && c == d); LL | let _ = a != b || c != d; | ~~~~~~~~~~~~~~~~ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:32:13 | LL | let _ = a != b && !(a != b && c == d); @@ -107,11 +111,11 @@ LL | let _ = !(a == b || c == d); LL | let _ = a != b && c != d; | ~~~~~~~~~~~~~~~~ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool.rs:62:8 | LL | if matches!(true, true) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)` -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/nonminimal_bool_methods.fixed b/tests/ui/nonminimal_bool_methods.fixed index aad44089de49..968c4b82b49e 100644 --- a/tests/ui/nonminimal_bool_methods.fixed +++ b/tests/ui/nonminimal_bool_methods.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::diverging_sub_expression)] #![warn(clippy::nonminimal_bool)] @@ -14,8 +14,8 @@ fn methods_with_negation() { let _ = b.is_ok(); let _ = b.is_err(); let c = false; - let _ = a.is_none() || c; - let _ = a.is_none() && c; + let _ = !(a.is_some() && !c); + let _ = !(a.is_some() || !c); let _ = !(!c ^ c) || a.is_none(); let _ = (!c ^ c) || a.is_none(); let _ = !c ^ c || a.is_none(); diff --git a/tests/ui/nonminimal_bool_methods.rs b/tests/ui/nonminimal_bool_methods.rs index b9074da84270..cd5b576fa07e 100644 --- a/tests/ui/nonminimal_bool_methods.rs +++ b/tests/ui/nonminimal_bool_methods.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::diverging_sub_expression)] #![warn(clippy::nonminimal_bool)] diff --git a/tests/ui/nonminimal_bool_methods.stderr b/tests/ui/nonminimal_bool_methods.stderr index 21b84db85890..439e2f6ec29a 100644 --- a/tests/ui/nonminimal_bool_methods.stderr +++ b/tests/ui/nonminimal_bool_methods.stderr @@ -1,82 +1,86 @@ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:9:13 | LL | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` | - = note: `-D clippy::nonminimal-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/nonminimal_bool_methods.rs:3:9 + | +LL | #![warn(clippy::nonminimal_bool)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:11:13 | LL | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:13:13 | LL | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:15:13 | LL | let _ = !b.is_ok(); | ^^^^^^^^^^ help: try: `b.is_err()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:17:13 | LL | let _ = !(a.is_some() && !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:18:13 | LL | let _ = !(a.is_some() || !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:19:26 | LL | let _ = !(!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:20:25 | LL | let _ = (!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:21:23 | LL | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:93:8 | LL | if !res.is_ok() {} | ^^^^^^^^^^^^ help: try: `res.is_err()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:94:8 | LL | if !res.is_err() {} | ^^^^^^^^^^^^^ help: try: `res.is_ok()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:97:8 | LL | if !res.is_some() {} | ^^^^^^^^^^^^^^ help: try: `res.is_none()` -error: this boolean expression can be simplified +warning: this boolean expression can be simplified --> $DIR/nonminimal_bool_methods.rs:98:8 | LL | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/numbered_fields.fixed b/tests/ui/numbered_fields.fixed deleted file mode 100644 index 68c987eb4c67..000000000000 --- a/tests/ui/numbered_fields.fixed +++ /dev/null @@ -1,39 +0,0 @@ -//run-rustfix -#![warn(clippy::init_numbered_fields)] -#![allow(unused_tuple_struct_fields)] - -#[derive(Default)] -struct TupleStruct(u32, u32, u8); - -// This shouldn't lint because it's in a macro -macro_rules! tuple_struct_init { - () => { - TupleStruct { 0: 0, 1: 1, 2: 2 } - }; -} - -fn main() { - let tuple_struct = TupleStruct::default(); - - // This should lint - let _ = TupleStruct(1u32, 42, 23u8); - - // This should also lint and order the fields correctly - let _ = TupleStruct(1u32, 3u32, 2u8); - - // Ok because of default initializer - let _ = TupleStruct { 0: 42, ..tuple_struct }; - - let _ = TupleStruct { - 1: 23, - ..TupleStruct::default() - }; - - // Ok because it's in macro - let _ = tuple_struct_init!(); - - type Alias = TupleStruct; - - // Aliases can't be tuple constructed #8638 - let _ = Alias { 0: 0, 1: 1, 2: 2 }; -} diff --git a/tests/ui/numbered_fields.stderr b/tests/ui/numbered_fields.stderr index 60c0d7898063..a3b1a405e551 100644 --- a/tests/ui/numbered_fields.stderr +++ b/tests/ui/numbered_fields.stderr @@ -1,4 +1,4 @@ -error: used a field initializer for a tuple struct +warning: used a field initializer for a tuple struct --> $DIR/numbered_fields.rs:19:13 | LL | let _ = TupleStruct { @@ -9,9 +9,13 @@ LL | | 2: 23u8, LL | | }; | |_____^ help: try this instead: `TupleStruct(1u32, 42, 23u8)` | - = note: `-D clippy::init-numbered-fields` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/numbered_fields.rs:2:9 + | +LL | #![warn(clippy::init_numbered_fields)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used a field initializer for a tuple struct +warning: used a field initializer for a tuple struct --> $DIR/numbered_fields.rs:26:13 | LL | let _ = TupleStruct { @@ -22,5 +26,5 @@ LL | | 1: 3u32, LL | | }; | |_____^ help: try this instead: `TupleStruct(1u32, 3u32, 2u8)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/obfuscated_if_else.fixed b/tests/ui/obfuscated_if_else.fixed index 62d932c2c6b7..9e4f97253f84 100644 --- a/tests/ui/obfuscated_if_else.fixed +++ b/tests/ui/obfuscated_if_else.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::obfuscated_if_else)] diff --git a/tests/ui/obfuscated_if_else.rs b/tests/ui/obfuscated_if_else.rs index 273be9092a74..c2351d64c1c5 100644 --- a/tests/ui/obfuscated_if_else.rs +++ b/tests/ui/obfuscated_if_else.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::obfuscated_if_else)] diff --git a/tests/ui/obfuscated_if_else.stderr b/tests/ui/obfuscated_if_else.stderr index e4180c288693..6e5eb4b5f660 100644 --- a/tests/ui/obfuscated_if_else.stderr +++ b/tests/ui/obfuscated_if_else.stderr @@ -1,10 +1,14 @@ -error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` +warning: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` --> $DIR/obfuscated_if_else.rs:6:5 | LL | true.then_some("a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` | - = note: `-D clippy::obfuscated-if-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/obfuscated_if_else.rs:3:9 + | +LL | #![warn(clippy::obfuscated_if_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/octal_escapes.stderr b/tests/ui/octal_escapes.stderr index 295dc1798e36..eaa175cf3dc5 100644 --- a/tests/ui/octal_escapes.stderr +++ b/tests/ui/octal_escapes.stderr @@ -1,131 +1,135 @@ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:4:17 | -LL | let _bad1 = "/033[0m"; +LL | let _bad1 = "\033[0m"; | ^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character - = note: `-D clippy::octal-escapes` implied by `-D warnings` + = help: octal escapes are not supported, `\0` is always a null character +note: the lint level is defined here + --> $DIR/octal_escapes.rs:1:9 + | +LL | #![warn(clippy::octal_escapes)] + | ^^^^^^^^^^^^^^^^^^^^^ help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad1 = "/x1b[0m"; +LL | let _bad1 = "\x1b[0m"; | ~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad1 = "/x0033[0m"; +LL | let _bad1 = "\x0033[0m"; | ~~~~~~~~~~~ -error: octal-looking escape in byte string literal +warning: octal-looking escape in byte string literal --> $DIR/octal_escapes.rs:5:17 | -LL | let _bad2 = b"/033[0m"; +LL | let _bad2 = b"\033[0m"; | ^^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null byte + = help: octal escapes are not supported, `\0` is always a null byte help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad2 = b"/x1b[0m"; +LL | let _bad2 = b"\x1b[0m"; | ~~~~~~~~~~ help: if the null byte is intended, disambiguate using | -LL | let _bad2 = b"/x0033[0m"; +LL | let _bad2 = b"\x0033[0m"; | ~~~~~~~~~~~~ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:6:17 | -LL | let _bad3 = "//033[0m"; +LL | let _bad3 = "\\\033[0m"; | ^^^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character + = help: octal escapes are not supported, `\0` is always a null character help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad3 = "//x1b[0m"; +LL | let _bad3 = "\\\x1b[0m"; | ~~~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad3 = "//x0033[0m"; +LL | let _bad3 = "\\\x0033[0m"; | ~~~~~~~~~~~~~ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:8:17 | -LL | let _bad4 = "/01234567"; +LL | let _bad4 = "\01234567"; | ^^^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character + = help: octal escapes are not supported, `\0` is always a null character help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad4 = "/x0a34567"; +LL | let _bad4 = "\x0a34567"; | ~~~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad4 = "/x001234567"; +LL | let _bad4 = "\x001234567"; | ~~~~~~~~~~~~~ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:10:17 | -LL | let _bad6 = "Text-/055/077-MoreText"; +LL | let _bad6 = "Text-\055\077-MoreText"; | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character + = help: octal escapes are not supported, `\0` is always a null character help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad6 = "Text-/x2d/x3f-MoreText"; +LL | let _bad6 = "Text-\x2d\x3f-MoreText"; | ~~~~~~~~~~~~~~~~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad6 = "Text-/x0055/x0077-MoreText"; +LL | let _bad6 = "Text-\x0055\x0077-MoreText"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:11:17 | -LL | let _bad7 = "EvenMoreText-/01/02-ShortEscapes"; +LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character + = help: octal escapes are not supported, `\0` is always a null character help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad7 = "EvenMoreText-/x01/x02-ShortEscapes"; +LL | let _bad7 = "EvenMoreText-\x01\x02-ShortEscapes"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad7 = "EvenMoreText-/x001/x002-ShortEscapes"; +LL | let _bad7 = "EvenMoreText-\x001\x002-ShortEscapes"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:12:17 | -LL | let _bad8 = "锈/01锈"; +LL | let _bad8 = "锈\01锈"; | ^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character + = help: octal escapes are not supported, `\0` is always a null character help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad8 = "锈/x01锈"; +LL | let _bad8 = "锈\x01锈"; | ~~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad8 = "锈/x001锈"; +LL | let _bad8 = "锈\x001锈"; | ~~~~~~~~~~~ -error: octal-looking escape in string literal +warning: octal-looking escape in string literal --> $DIR/octal_escapes.rs:13:17 | -LL | let _bad9 = "锈/011锈"; +LL | let _bad9 = "锈\011锈"; | ^^^^^^^^^^ | - = help: octal escapes are not supported, `/0` is always a null character + = help: octal escapes are not supported, `\0` is always a null character help: if an octal escape was intended, use the hexadecimal representation instead | -LL | let _bad9 = "锈/x09锈"; +LL | let _bad9 = "锈\x09锈"; | ~~~~~~~~~~ help: if the null character is intended, disambiguate using | -LL | let _bad9 = "锈/x0011锈"; +LL | let _bad9 = "锈\x0011锈"; | ~~~~~~~~~~~~ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index 6c40adbb53dc..49238ff71b7d 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -1,13 +1,13 @@ -error: called `ok().expect()` on a `Result` value +warning: called `ok().expect()` on a `Result` value --> $DIR/ok_expect.rs:14:5 | LL | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: you can call `expect()` directly on the `Result` - = note: `-D clippy::ok-expect` implied by `-D warnings` + = note: `#[warn(clippy::ok_expect)]` on by default -error: called `ok().expect()` on a `Result` value +warning: called `ok().expect()` on a `Result` value --> $DIR/ok_expect.rs:20:5 | LL | res3.ok().expect("whoof"); @@ -15,7 +15,7 @@ LL | res3.ok().expect("whoof"); | = help: you can call `expect()` directly on the `Result` -error: called `ok().expect()` on a `Result` value +warning: called `ok().expect()` on a `Result` value --> $DIR/ok_expect.rs:22:5 | LL | res4.ok().expect("argh"); @@ -23,7 +23,7 @@ LL | res4.ok().expect("argh"); | = help: you can call `expect()` directly on the `Result` -error: called `ok().expect()` on a `Result` value +warning: called `ok().expect()` on a `Result` value --> $DIR/ok_expect.rs:24:5 | LL | res5.ok().expect("oops"); @@ -31,7 +31,7 @@ LL | res5.ok().expect("oops"); | = help: you can call `expect()` directly on the `Result` -error: called `ok().expect()` on a `Result` value +warning: called `ok().expect()` on a `Result` value --> $DIR/ok_expect.rs:26:5 | LL | res6.ok().expect("meh"); @@ -39,5 +39,5 @@ LL | res6.ok().expect("meh"); | = help: you can call `expect()` directly on the `Result` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/only_used_in_recursion.stderr b/tests/ui/only_used_in_recursion.stderr index 571e5c4b5faa..3a808986e1f3 100644 --- a/tests/ui/only_used_in_recursion.stderr +++ b/tests/ui/only_used_in_recursion.stderr @@ -1,4 +1,4 @@ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:11:27 | LL | fn _one_unused(flag: u32, a: usize) -> usize { @@ -9,9 +9,13 @@ note: parameter used here | LL | if flag == 0 { 0 } else { _one_unused(flag - 1, a) } | ^ - = note: `-D clippy::only-used-in-recursion` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/only_used_in_recursion.rs:1:9 + | +LL | #![warn(clippy::only_used_in_recursion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:15:27 | LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { @@ -23,7 +27,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:15:35 | LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { @@ -35,7 +39,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:19:26 | LL | fn _with_calc(flag: u32, a: i64) -> usize { @@ -47,7 +51,7 @@ note: parameter used here LL | _with_calc(flag - 1, (-a + 10) * 5) | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:32:33 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { @@ -59,7 +63,7 @@ note: parameter used here LL | _used_with_unused(flag - 1, -a, a + b) | ^ ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:32:41 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { @@ -71,7 +75,7 @@ note: parameter used here LL | _used_with_unused(flag - 1, -a, a + b) | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:40:35 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { @@ -83,7 +87,7 @@ note: parameter used here LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:40:43 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { @@ -95,7 +99,7 @@ note: parameter used here LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:48:30 | LL | fn _not_primitive(flag: u32, b: String) -> usize { @@ -107,7 +111,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { _not_primitive(flag - 1, b) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:55:29 | LL | fn _method(flag: usize, a: usize) -> usize { @@ -119,7 +123,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { Self::_method(flag - 1, a) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:59:22 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { @@ -131,7 +135,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^^^^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:59:41 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { @@ -143,7 +147,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:70:26 | LL | fn method(flag: u32, a: usize) -> usize { @@ -155,7 +159,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:74:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { @@ -167,7 +171,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:100:26 | LL | fn method(flag: u32, a: usize) -> usize { @@ -179,7 +183,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion.rs:104:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { @@ -191,5 +195,5 @@ note: parameter used here LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/only_used_in_recursion2.stderr b/tests/ui/only_used_in_recursion2.stderr index 8dcbfdd612ef..bb85be568805 100644 --- a/tests/ui/only_used_in_recursion2.stderr +++ b/tests/ui/only_used_in_recursion2.stderr @@ -1,4 +1,4 @@ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion2.rs:3:35 | LL | fn _with_inner(flag: u32, a: u32, b: u32) -> usize { @@ -9,9 +9,13 @@ note: parameter used here | LL | if flag == 0 { 0 } else { _with_inner(flag, a, b + x) } | ^ - = note: `-D clippy::only-used-in-recursion` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/only_used_in_recursion2.rs:1:9 + | +LL | #![warn(clippy::only_used_in_recursion)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion2.rs:4:25 | LL | fn inner(flag: u32, a: u32) -> u32 { @@ -23,7 +27,7 @@ note: parameter used here LL | if flag == 0 { 0 } else { inner(flag, a) } | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion2.rs:12:34 | LL | fn _with_closure(a: Option, b: u32, f: impl Fn(u32, u32) -> Option) -> u32 { @@ -35,7 +39,7 @@ note: parameter used here LL | _with_closure(Some(x), b, f) | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion2.rs:62:37 | LL | fn overwritten_param(flag: u32, mut a: usize) -> usize { @@ -47,7 +51,7 @@ note: parameter used here LL | overwritten_param(flag, a) | ^ -error: parameter is only used in recursion +warning: parameter is only used in recursion --> $DIR/only_used_in_recursion2.rs:73:32 | LL | fn field_direct(flag: u32, mut a: (usize,)) -> usize { @@ -59,5 +63,5 @@ note: parameter used here LL | field_direct(flag - 1, a) | ^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index fe36c01166ff..c7ff22503165 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -1,16 +1,20 @@ -error: needlessly taken reference of both operands +warning: needlessly taken reference of both operands --> $DIR/op_ref.rs:11:15 | LL | let foo = &5 - &6; | ^^^^^^^ | - = note: `-D clippy::op-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/op_ref.rs:2:9 + | +LL | #![warn(clippy::op_ref)] + | ^^^^^^^^^^^^^^ help: use the values directly | LL | let foo = 5 - 6; | ~ ~ -error: taken reference of right operand +warning: taken reference of right operand --> $DIR/op_ref.rs:56:13 | LL | let z = x & &y; @@ -18,7 +22,7 @@ LL | let z = x & &y; | | | help: use the right value directly: `y` -error: taken reference of right operand +warning: taken reference of right operand --> $DIR/op_ref.rs:89:17 | LL | let _ = one * &self; @@ -26,7 +30,7 @@ LL | let _ = one * &self; | | | help: use the right value directly: `self` -error: taken reference of right operand +warning: taken reference of right operand --> $DIR/op_ref.rs:90:17 | LL | let _ = two + &three; @@ -34,5 +38,5 @@ LL | let _ = two + &three; | | | help: use the right value directly: `three` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 26fe9f6fb206..4b9fe9c123ab 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,46 +1,50 @@ -error: file opened with `truncate` and `read` +warning: file opened with `truncate` and `read` --> $DIR/open_options.rs:6:5 | LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/open_options.rs:4:8 + | +LL | #[warn(clippy::nonsensical_open_options)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: file opened with `append` and `truncate` +warning: file opened with `append` and `truncate` --> $DIR/open_options.rs:7:5 | LL | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the method `read` is called more than once +warning: the method `read` is called more than once --> $DIR/open_options.rs:9:5 | LL | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the method `create` is called more than once +warning: the method `create` is called more than once --> $DIR/open_options.rs:10:5 | LL | OpenOptions::new().create(true).create(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the method `write` is called more than once +warning: the method `write` is called more than once --> $DIR/open_options.rs:11:5 | LL | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the method `append` is called more than once +warning: the method `append` is called more than once --> $DIR/open_options.rs:12:5 | LL | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the method `truncate` is called more than once +warning: the method `truncate` is called more than once --> $DIR/open_options.rs:13:5 | LL | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/option_as_ref_deref.fixed b/tests/ui/option_as_ref_deref.fixed index d124d133faa2..e1c0fa3f7fd3 100644 --- a/tests/ui/option_as_ref_deref.fixed +++ b/tests/ui/option_as_ref_deref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::redundant_clone)] #![warn(clippy::option_as_ref_deref)] diff --git a/tests/ui/option_as_ref_deref.rs b/tests/ui/option_as_ref_deref.rs index 86e354c6716b..6f4917fd149c 100644 --- a/tests/ui/option_as_ref_deref.rs +++ b/tests/ui/option_as_ref_deref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::redundant_clone)] #![warn(clippy::option_as_ref_deref)] diff --git a/tests/ui/option_as_ref_deref.stderr b/tests/ui/option_as_ref_deref.stderr index e471b56eea81..32f2a8b3ebdb 100644 --- a/tests/ui/option_as_ref_deref.stderr +++ b/tests/ui/option_as_ref_deref.stderr @@ -1,12 +1,16 @@ -error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead +warning: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead --> $DIR/option_as_ref_deref.rs:13:13 | LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.clone().as_deref()` | - = note: `-D clippy::option-as-ref-deref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/option_as_ref_deref.rs:4:9 + | +LL | #![warn(clippy::option_as_ref_deref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead +warning: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead --> $DIR/option_as_ref_deref.rs:16:13 | LL | let _ = opt.clone() @@ -16,101 +20,101 @@ LL | | Deref::deref LL | | ) | |_________^ help: try using as_deref instead: `opt.clone().as_deref()` -error: called `.as_mut().map(DerefMut::deref_mut)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead +warning: called `.as_mut().map(DerefMut::deref_mut)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead --> $DIR/option_as_ref_deref.rs:22:13 | LL | let _ = opt.as_mut().map(DerefMut::deref_mut); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()` -error: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead +warning: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead --> $DIR/option_as_ref_deref.rs:24:13 | LL | let _ = opt.as_ref().map(String::as_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` -error: called `.as_ref().map(|x| x.as_str())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead +warning: called `.as_ref().map(|x| x.as_str())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead --> $DIR/option_as_ref_deref.rs:25:13 | LL | let _ = opt.as_ref().map(|x| x.as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` -error: called `.as_mut().map(String::as_mut_str)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead +warning: called `.as_mut().map(String::as_mut_str)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead --> $DIR/option_as_ref_deref.rs:26:13 | LL | let _ = opt.as_mut().map(String::as_mut_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()` -error: called `.as_mut().map(|x| x.as_mut_str())` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead +warning: called `.as_mut().map(|x| x.as_mut_str())` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead --> $DIR/option_as_ref_deref.rs:27:13 | LL | let _ = opt.as_mut().map(|x| x.as_mut_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()` -error: called `.as_ref().map(CString::as_c_str)` on an Option value. This can be done more directly by calling `Some(CString::new(vec![]).unwrap()).as_deref()` instead +warning: called `.as_ref().map(CString::as_c_str)` on an Option value. This can be done more directly by calling `Some(CString::new(vec![]).unwrap()).as_deref()` instead --> $DIR/option_as_ref_deref.rs:28:13 | LL | let _ = Some(CString::new(vec![]).unwrap()).as_ref().map(CString::as_c_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(CString::new(vec![]).unwrap()).as_deref()` -error: called `.as_ref().map(OsString::as_os_str)` on an Option value. This can be done more directly by calling `Some(OsString::new()).as_deref()` instead +warning: called `.as_ref().map(OsString::as_os_str)` on an Option value. This can be done more directly by calling `Some(OsString::new()).as_deref()` instead --> $DIR/option_as_ref_deref.rs:29:13 | LL | let _ = Some(OsString::new()).as_ref().map(OsString::as_os_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(OsString::new()).as_deref()` -error: called `.as_ref().map(PathBuf::as_path)` on an Option value. This can be done more directly by calling `Some(PathBuf::new()).as_deref()` instead +warning: called `.as_ref().map(PathBuf::as_path)` on an Option value. This can be done more directly by calling `Some(PathBuf::new()).as_deref()` instead --> $DIR/option_as_ref_deref.rs:30:13 | LL | let _ = Some(PathBuf::new()).as_ref().map(PathBuf::as_path); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(PathBuf::new()).as_deref()` -error: called `.as_ref().map(Vec::as_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref()` instead +warning: called `.as_ref().map(Vec::as_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref()` instead --> $DIR/option_as_ref_deref.rs:31:13 | LL | let _ = Some(Vec::<()>::new()).as_ref().map(Vec::as_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(Vec::<()>::new()).as_deref()` -error: called `.as_mut().map(Vec::as_mut_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref_mut()` instead +warning: called `.as_mut().map(Vec::as_mut_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref_mut()` instead --> $DIR/option_as_ref_deref.rs:32:13 | LL | let _ = Some(Vec::<()>::new()).as_mut().map(Vec::as_mut_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `Some(Vec::<()>::new()).as_deref_mut()` -error: called `.as_ref().map(|x| x.deref())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead +warning: called `.as_ref().map(|x| x.deref())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead --> $DIR/option_as_ref_deref.rs:34:13 | LL | let _ = opt.as_ref().map(|x| x.deref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` -error: called `.as_mut().map(|x| x.deref_mut())` on an Option value. This can be done more directly by calling `opt.clone().as_deref_mut()` instead +warning: called `.as_mut().map(|x| x.deref_mut())` on an Option value. This can be done more directly by calling `opt.clone().as_deref_mut()` instead --> $DIR/option_as_ref_deref.rs:35:13 | LL | let _ = opt.clone().as_mut().map(|x| x.deref_mut()).map(|x| x.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.clone().as_deref_mut()` -error: called `.as_ref().map(|x| &**x)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead +warning: called `.as_ref().map(|x| &**x)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead --> $DIR/option_as_ref_deref.rs:42:13 | LL | let _ = opt.as_ref().map(|x| &**x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` -error: called `.as_mut().map(|x| &mut **x)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead +warning: called `.as_mut().map(|x| &mut **x)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead --> $DIR/option_as_ref_deref.rs:43:13 | LL | let _ = opt.as_mut().map(|x| &mut **x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()` -error: called `.as_ref().map(std::ops::Deref::deref)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead +warning: called `.as_ref().map(std::ops::Deref::deref)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead --> $DIR/option_as_ref_deref.rs:46:13 | LL | let _ = opt.as_ref().map(std::ops::Deref::deref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` -error: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead +warning: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead --> $DIR/option_as_ref_deref.rs:58:13 | LL | let _ = opt.as_ref().map(String::as_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/option_env_unwrap.rs b/tests/ui/option_env_unwrap.rs index 0141fb7856d0..341241584858 100644 --- a/tests/ui/option_env_unwrap.rs +++ b/tests/ui/option_env_unwrap.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::option_env_unwrap)] #![allow(clippy::map_flatten)] diff --git a/tests/ui/option_env_unwrap.stderr b/tests/ui/option_env_unwrap.stderr index bc188a07e9e0..5fb42f20d3a4 100644 --- a/tests/ui/option_env_unwrap.stderr +++ b/tests/ui/option_env_unwrap.stderr @@ -1,13 +1,17 @@ -error: this will panic at run-time if the environment variable doesn't exist at compile-time +warning: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:18:13 | LL | let _ = option_env!("PATH").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using the `env!` macro instead - = note: `-D clippy::option-env-unwrap` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/option_env_unwrap.rs:2:9 + | +LL | #![warn(clippy::option_env_unwrap)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this will panic at run-time if the environment variable doesn't exist at compile-time +warning: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:19:13 | LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set"); @@ -15,7 +19,7 @@ LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set | = help: consider using the `env!` macro instead -error: this will panic at run-time if the environment variable doesn't exist at compile-time +warning: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:10:9 | LL | option_env!($env).unwrap() @@ -25,9 +29,9 @@ LL | let _ = option_env_unwrap!("PATH"); | -------------------------- in this macro invocation | = help: consider using the `env!` macro instead - = note: this error originates in the macro `option_env_unwrap` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `option_env_unwrap` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this will panic at run-time if the environment variable doesn't exist at compile-time +warning: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:13:9 | LL | option_env!($env).expect($message) @@ -37,25 +41,25 @@ LL | let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set | ----------------------------------------------------------------- in this macro invocation | = help: consider using the `env!` macro instead - = note: this error originates in the macro `option_env_unwrap` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `option_env_unwrap` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this will panic at run-time if the environment variable doesn't exist at compile-time +warning: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:22:13 | LL | let _ = option_env_unwrap_external!("PATH"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using the `env!` macro instead - = note: this error originates in the macro `option_env_unwrap_external` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `option_env_unwrap_external` (in Nightly builds, run with -Z macro-backtrace for more info) -error: this will panic at run-time if the environment variable doesn't exist at compile-time +warning: this will panic at run-time if the environment variable doesn't exist at compile-time --> $DIR/option_env_unwrap.rs:23:13 | LL | let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using the `env!` macro instead - = note: this error originates in the macro `option_env_unwrap_external` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `option_env_unwrap_external` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/option_filter_map.fixed b/tests/ui/option_filter_map.fixed index b20f73f3110d..93c250cfa735 100644 --- a/tests/ui/option_filter_map.fixed +++ b/tests/ui/option_filter_map.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::option_filter_map)] #![allow(clippy::map_flatten)] diff --git a/tests/ui/option_filter_map.rs b/tests/ui/option_filter_map.rs index 7abaaa0fb83b..2c5f03250b98 100644 --- a/tests/ui/option_filter_map.rs +++ b/tests/ui/option_filter_map.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::option_filter_map)] #![allow(clippy::map_flatten)] diff --git a/tests/ui/option_filter_map.stderr b/tests/ui/option_filter_map.stderr index 4a030ac9ab04..a2b3e92ae40a 100644 --- a/tests/ui/option_filter_map.stderr +++ b/tests/ui/option_filter_map.stderr @@ -1,42 +1,46 @@ -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:6:27 | LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` | - = note: `-D clippy::option-filter-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/option_filter_map.rs:2:9 + | +LL | #![warn(clippy::option_filter_map)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:7:27 | LL | let _ = Some(Some(1)).filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:8:35 | LL | let _ = Some(1).map(odds_out).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:9:35 | LL | let _ = Some(1).map(odds_out).filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:11:39 | LL | let _ = vec![Some(1)].into_iter().filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:12:39 | LL | let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:16:10 | LL | .filter(Option::is_some) @@ -44,7 +48,7 @@ LL | .filter(Option::is_some) LL | | .map(Option::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` -error: `filter` for `Some` followed by `unwrap` +warning: `filter` for `Some` followed by `unwrap` --> $DIR/option_filter_map.rs:21:10 | LL | .filter(|o| o.is_some()) @@ -52,5 +56,5 @@ LL | .filter(|o| o.is_some()) LL | | .map(|o| o.unwrap()); | |____________________________^ help: consider using `flatten` instead: `flatten()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/option_if_let_else.fixed b/tests/ui/option_if_let_else.fixed index 0456005dce49..1534572f6a2c 100644 --- a/tests/ui/option_if_let_else.fixed +++ b/tests/ui/option_if_let_else.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::option_if_let_else)] #![allow( unused_tuple_struct_fields, @@ -9,7 +9,11 @@ )] fn bad1(string: Option<&str>) -> (bool, &str) { - string.map_or((false, "hello"), |x| (true, x)) + if let Some(x) = string { + (true, x) + } else { + (false, "hello") + } } fn else_if_option(string: Option<&str>) -> Option<(bool, &str)> { @@ -23,28 +27,36 @@ fn else_if_option(string: Option<&str>) -> Option<(bool, &str)> { } fn unop_bad(string: &Option<&str>, mut num: Option) { - let _ = string.map_or(0, |s| s.len()); - let _ = num.as_ref().map_or(&0, |s| s); - let _ = num.as_mut().map_or(&mut 0, |s| { + let _ = if let Some(s) = *string { s.len() } else { 0 }; + let _ = if let Some(s) = &num { s } else { &0 }; + let _ = if let Some(s) = &mut num { *s += 1; s - }); - let _ = num.as_ref().map_or(&0, |s| s); - let _ = num.map_or(0, |mut s| { + } else { + &mut 0 + }; + let _ = if let Some(ref s) = num { s } else { &0 }; + let _ = if let Some(mut s) = num { s += 1; s - }); - let _ = num.as_mut().map_or(&mut 0, |s| { + } else { + 0 + }; + let _ = if let Some(ref mut s) = num { *s += 1; s - }); + } else { + &mut 0 + }; } fn longer_body(arg: Option) -> u32 { - arg.map_or(13, |x| { + if let Some(x) = arg { let y = x * x; y * y - }) + } else { + 13 + } } fn impure_else(arg: Option) { @@ -52,16 +64,23 @@ fn impure_else(arg: Option) { println!("return 1"); 1 }; - let _ = arg.map_or_else(|| side_effect(), |x| x); + let _ = if let Some(x) = arg { + x + } else { + // map_or_else must be suggested + side_effect() + }; } fn test_map_or_else(arg: Option) { - let _ = arg.map_or_else(|| { + let _ = if let Some(x) = arg { + x * x * x * x + } else { let mut y = 1; y = (y + 2 / y) / 2; y = (y + 2 / y) / 2; y - }, |x| x * x * x * x); + }; } fn negative_tests(arg: Option) -> u32 { @@ -87,7 +106,11 @@ fn pattern_to_vec(pattern: &str) -> Vec { .trim_matches('/') .split('/') .flat_map(|s| { - s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()]) + if let Some(idx) = s.find('.') { + vec![s[..idx].to_string(), s[idx..].to_string()] + } else { + vec![s.to_string()] + } }) .collect::>() } @@ -107,7 +130,7 @@ fn complex_subpat() -> DummyEnum { fn main() { let optional = Some(5); - let _ = optional.map_or(5, |x| x + 2); + let _ = if let Some(x) = optional { x + 2 } else { 5 }; let _ = bad1(None); let _ = else_if_option(None); unop_bad(&None, None); @@ -116,11 +139,15 @@ fn main() { let _ = negative_tests(None); let _ = impure_else(None); - let _ = Some(0).map_or(0, |x| loop { + let _ = if let Some(x) = Some(0) { + loop { if x == 0 { break x; } - }); + } + } else { + 0 + }; // #7576 const fn _f(x: Option) -> u32 { @@ -140,14 +167,16 @@ fn main() { let s = String::new(); // Lint, both branches immutably borrow `s`. - let _ = Some(0).map_or(s.len(), |x| s.len() + x); + let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; let s = String::new(); // Lint, `Some` branch consumes `s`, but else branch doesn't use `s`. - let _ = Some(0).map_or(1, |x| { + let _ = if let Some(x) = Some(0) { let s = s; s.len() + x - }); + } else { + 1 + }; let s = Some(String::new()); // Don't lint, `Some` branch borrows `s`, but else branch consumes `s` @@ -181,13 +210,25 @@ fn main() { let _ = complex_subpat(); // issue #8492 - let _ = s.map_or(1, |string| string.len()); - let _ = Some(10).map_or(5, |a| a + 1); + let _ = match s { + Some(string) => string.len(), + None => 1, + }; + let _ = match Some(10) { + Some(a) => a + 1, + None => 5, + }; let res: Result = Ok(5); - let _ = res.map_or(1, |a| a + 1); - let _ = res.map_or(1, |a| a + 1); - let _ = res.map_or(5, |a| a + 1); + let _ = match res { + Ok(a) => a + 1, + _ => 1, + }; + let _ = match res { + Err(_) => 1, + Ok(a) => a + 1, + }; + let _ = if let Ok(a) = res { a + 1 } else { 5 }; } #[allow(dead_code)] diff --git a/tests/ui/option_if_let_else.rs b/tests/ui/option_if_let_else.rs index 23b148752cbf..1534572f6a2c 100644 --- a/tests/ui/option_if_let_else.rs +++ b/tests/ui/option_if_let_else.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::option_if_let_else)] #![allow( unused_tuple_struct_fields, diff --git a/tests/ui/option_if_let_else.stderr b/tests/ui/option_if_let_else.stderr index a5dbf6e1f221..205295b5a055 100644 --- a/tests/ui/option_if_let_else.stderr +++ b/tests/ui/option_if_let_else.stderr @@ -1,4 +1,4 @@ -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:12:5 | LL | / if let Some(x) = string { @@ -8,21 +8,25 @@ LL | | (false, "hello") LL | | } | |_____^ help: try: `string.map_or((false, "hello"), |x| (true, x))` | - = note: `-D clippy::option-if-let-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/option_if_let_else.rs:2:9 + | +LL | #![warn(clippy::option_if_let_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:30:13 | LL | let _ = if let Some(s) = *string { s.len() } else { 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:31:13 | LL | let _ = if let Some(s) = &num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:32:13 | LL | let _ = if let Some(s) = &mut num { @@ -42,13 +46,13 @@ LL + s LL ~ }); | -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:38:13 | LL | let _ = if let Some(ref s) = num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:39:13 | LL | let _ = if let Some(mut s) = num { @@ -68,7 +72,7 @@ LL + s LL ~ }); | -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:45:13 | LL | let _ = if let Some(ref mut s) = num { @@ -88,7 +92,7 @@ LL + s LL ~ }); | -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:54:5 | LL | / if let Some(x) = arg { @@ -107,7 +111,7 @@ LL + y * y LL + }) | -error: use Option::map_or_else instead of an if let/else +warning: use Option::map_or_else instead of an if let/else --> $DIR/option_if_let_else.rs:67:13 | LL | let _ = if let Some(x) = arg { @@ -119,7 +123,7 @@ LL | | side_effect() LL | | }; | |_____^ help: try: `arg.map_or_else(|| side_effect(), |x| x)` -error: use Option::map_or_else instead of an if let/else +warning: use Option::map_or_else instead of an if let/else --> $DIR/option_if_let_else.rs:76:13 | LL | let _ = if let Some(x) = arg { @@ -142,7 +146,7 @@ LL + y LL ~ }, |x| x * x * x * x); | -error: use Option::map_or_else instead of an if let/else +warning: use Option::map_or_else instead of an if let/else --> $DIR/option_if_let_else.rs:109:13 | LL | / if let Some(idx) = s.find('.') { @@ -152,13 +156,13 @@ LL | | vec![s.to_string()] LL | | } | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:133:13 | LL | let _ = if let Some(x) = optional { x + 2 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:142:13 | LL | let _ = if let Some(x) = Some(0) { @@ -180,13 +184,13 @@ LL + } LL ~ }); | -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:170:13 | LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:174:13 | LL | let _ = if let Some(x) = Some(0) { @@ -206,7 +210,7 @@ LL + s.len() + x LL ~ }); | -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:213:13 | LL | let _ = match s { @@ -216,7 +220,7 @@ LL | | None => 1, LL | | }; | |_____^ help: try: `s.map_or(1, |string| string.len())` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:217:13 | LL | let _ = match Some(10) { @@ -226,7 +230,7 @@ LL | | None => 5, LL | | }; | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:223:13 | LL | let _ = match res { @@ -236,7 +240,7 @@ LL | | _ => 1, LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:227:13 | LL | let _ = match res { @@ -246,11 +250,11 @@ LL | | Ok(a) => a + 1, LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` -error: use Option::map_or instead of an if let/else +warning: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:231:13 | LL | let _ = if let Ok(a) = res { a + 1 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/option_map_or_none.fixed b/tests/ui/option_map_or_none.fixed index 04bfac7735fa..501757647bfb 100644 --- a/tests/ui/option_map_or_none.fixed +++ b/tests/ui/option_map_or_none.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::bind_instead_of_map)] diff --git a/tests/ui/option_map_or_none.rs b/tests/ui/option_map_or_none.rs index bb84f8a48f45..4d8704e737da 100644 --- a/tests/ui/option_map_or_none.rs +++ b/tests/ui/option_map_or_none.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::bind_instead_of_map)] diff --git a/tests/ui/option_map_or_none.stderr b/tests/ui/option_map_or_none.stderr index 7befcb890863..8c1eb52ae14e 100644 --- a/tests/ui/option_map_or_none.stderr +++ b/tests/ui/option_map_or_none.stderr @@ -1,12 +1,12 @@ -error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead +warning: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead --> $DIR/option_map_or_none.rs:12:26 | LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `map` instead: `opt.map(|x| x + 1)` | - = note: `-D clippy::option-map-or-none` implied by `-D warnings` + = note: `#[warn(clippy::option_map_or_none)]` on by default -error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead +warning: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `map(..)` instead --> $DIR/option_map_or_none.rs:15:26 | LL | let _: Option = opt.map_or(None, |x| { @@ -15,13 +15,13 @@ LL | | Some(x + 1) LL | | }); | |_________________________^ help: try using `map` instead: `opt.map(|x| x + 1)` -error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead +warning: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead --> $DIR/option_map_or_none.rs:19:26 | LL | let _: Option = opt.map_or(None, bar); | ^^^^^^^^^^^^^^^^^^^^^ help: try using `and_then` instead: `opt.and_then(bar)` -error: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead +warning: called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling `and_then(..)` instead --> $DIR/option_map_or_none.rs:20:26 | LL | let _: Option = opt.map_or(None, |x| { @@ -41,13 +41,13 @@ LL + Some(offset + height) LL ~ }); | -error: called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling `ok()` instead +warning: called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling `ok()` instead --> $DIR/option_map_or_none.rs:27:26 | LL | let _: Option = r.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^ help: try using `ok` instead: `r.ok()` | - = note: `-D clippy::result-map-or-into-option` implied by `-D warnings` + = note: `#[warn(clippy::result_map_or_into_option)]` on by default -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/option_map_unit_fn_fixable.fixed b/tests/ui/option_map_unit_fn_fixable.fixed index 00264dcceaa8..8f64451edf36 100644 --- a/tests/ui/option_map_unit_fn_fixable.fixed +++ b/tests/ui/option_map_unit_fn_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::option_map_unit_fn)] #![allow(unused)] #![allow(clippy::uninlined_format_args, clippy::unnecessary_wraps)] diff --git a/tests/ui/option_map_unit_fn_fixable.rs b/tests/ui/option_map_unit_fn_fixable.rs index f3363ebce54e..2bf7a8e0f7d4 100644 --- a/tests/ui/option_map_unit_fn_fixable.rs +++ b/tests/ui/option_map_unit_fn_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::option_map_unit_fn)] #![allow(unused)] #![allow(clippy::uninlined_format_args, clippy::unnecessary_wraps)] diff --git a/tests/ui/option_map_unit_fn_fixable.stderr b/tests/ui/option_map_unit_fn_fixable.stderr index 0305387b9f8a..0c27a09d251a 100644 --- a/tests/ui/option_map_unit_fn_fixable.stderr +++ b/tests/ui/option_map_unit_fn_fixable.stderr @@ -1,4 +1,4 @@ -error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:38:5 | LL | x.field.map(do_nothing); @@ -6,9 +6,13 @@ LL | x.field.map(do_nothing); | | | help: try this: `if let Some(x_field) = x.field { do_nothing(x_field) }` | - = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/option_map_unit_fn_fixable.rs:2:9 + | +LL | #![warn(clippy::option_map_unit_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:40:5 | LL | x.field.map(do_nothing); @@ -16,7 +20,7 @@ LL | x.field.map(do_nothing); | | | help: try this: `if let Some(x_field) = x.field { do_nothing(x_field) }` -error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:42:5 | LL | x.field.map(diverge); @@ -24,7 +28,7 @@ LL | x.field.map(diverge); | | | help: try this: `if let Some(x_field) = x.field { diverge(x_field) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:48:5 | LL | x.field.map(|value| x.do_option_nothing(value + captured)); @@ -32,7 +36,7 @@ LL | x.field.map(|value| x.do_option_nothing(value + captured)); | | | help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:50:5 | LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); @@ -40,7 +44,7 @@ LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | | | help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:53:5 | LL | x.field.map(|value| do_nothing(value + captured)); @@ -48,7 +52,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:55:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); @@ -56,7 +60,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:57:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); @@ -64,7 +68,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:59:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); @@ -72,7 +76,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:62:5 | LL | x.field.map(|value| diverge(value + captured)); @@ -80,7 +84,7 @@ LL | x.field.map(|value| diverge(value + captured)); | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:64:5 | LL | x.field.map(|value| { diverge(value + captured) }); @@ -88,7 +92,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:66:5 | LL | x.field.map(|value| { diverge(value + captured); }); @@ -96,7 +100,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | | | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:68:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); @@ -104,7 +108,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | | | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:73:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); @@ -112,7 +116,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | | | help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:75:5 | LL | x.field.map(|value| { plus_one(value + captured); }); @@ -120,7 +124,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | | | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:77:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); @@ -128,7 +132,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | | | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:80:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); @@ -136,7 +140,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | | | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` -error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:82:5 | LL | option().map(do_nothing); @@ -144,7 +148,7 @@ LL | option().map(do_nothing); | | | help: try this: `if let Some(a) = option() { do_nothing(a) }` -error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` --> $DIR/option_map_unit_fn_fixable.rs:84:5 | LL | option().map(|value| println!("{:?}", value)); @@ -152,5 +156,5 @@ LL | option().map(|value| println!("{:?}", value)); | | | help: try this: `if let Some(value) = option() { println!("{:?}", value) }` -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/option_map_unit_fn_unfixable.rs b/tests/ui/option_map_unit_fn_unfixable.rs index 20e6c15b18d5..f35520c3b0f9 100644 --- a/tests/ui/option_map_unit_fn_unfixable.rs +++ b/tests/ui/option_map_unit_fn_unfixable.rs @@ -14,17 +14,17 @@ fn plus_one(value: usize) -> usize { #[rustfmt::skip] fn option_map_unit_fn() { - x.field.map(|value| { do_nothing(value); do_nothing(value) }); + x.field.map(|value| { do_nothing(value); do_nothing(value) }); //~ ERROR: cannot find - x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); + x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); //~ ERROR: cannot find // Suggestion for the let block should be `{ ... }` as it's too difficult to build a // proper suggestion for these cases - x.field.map(|value| { + x.field.map(|value| { //~ ERROR: cannot find do_nothing(value); do_nothing(value) }); - x.field.map(|value| { do_nothing(value); do_nothing(value); }); + x.field.map(|value| { do_nothing(value); do_nothing(value); }); //~ ERROR: cannot find // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them Some(42).map(diverge); diff --git a/tests/ui/option_option.rs b/tests/ui/option_option.rs index 2faab9e035d9..0be2253ffa04 100644 --- a/tests/ui/option_option.rs +++ b/tests/ui/option_option.rs @@ -1,4 +1,4 @@ -#![deny(clippy::option_option)] +#![warn(clippy::option_option)] #![allow(clippy::unnecessary_wraps)] const C: Option> = None; diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index a925bb35b04d..6a7240f389bd 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,4 +1,4 @@ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:4:10 | LL | const C: Option> = None; @@ -7,74 +7,74 @@ LL | const C: Option> = None; note: the lint level is defined here --> $DIR/option_option.rs:1:9 | -LL | #![deny(clippy::option_option)] +LL | #![warn(clippy::option_option)] | ^^^^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:5:11 | LL | static S: Option> = None; | ^^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:7:13 | LL | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:9:16 | LL | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:13:27 | LL | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:18:30 | LL | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:23:8 | LL | x: Option>, | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:27:23 | LL | fn struct_fn() -> Option> { | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:33:22 | LL | fn trait_fn() -> Option>; | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:37:11 | LL | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:38:17 | LL | Struct { x: Option> }, | ^^^^^^^^^^^^^^^^^^ -error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases +warning: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases --> $DIR/option_option.rs:79:14 | LL | foo: Option>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/or_fun_call.fixed b/tests/ui/or_fun_call.fixed index be9a65506e13..7e5ff49719b7 100644 --- a/tests/ui/or_fun_call.fixed +++ b/tests/ui/or_fun_call.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::or_fun_call)] #![allow(dead_code)] #![allow(clippy::borrow_as_ptr, clippy::uninlined_format_args, clippy::unnecessary_wraps)] @@ -45,19 +45,19 @@ fn or_fun_call() { with_const_fn.unwrap_or(Duration::from_secs(5)); let with_constructor = Some(vec![1]); - with_constructor.unwrap_or_else(make); + with_constructor.unwrap_or(make()); let with_new = Some(vec![1]); with_new.unwrap_or_default(); let with_const_args = Some(vec![1]); - with_const_args.unwrap_or_else(|| Vec::with_capacity(12)); + with_const_args.unwrap_or(Vec::with_capacity(12)); let with_err: Result<_, ()> = Ok(vec![1]); - with_err.unwrap_or_else(|_| make()); + with_err.unwrap_or(make()); let with_err_args: Result<_, ()> = Ok(vec![1]); - with_err_args.unwrap_or_else(|_| Vec::with_capacity(12)); + with_err_args.unwrap_or(Vec::with_capacity(12)); let with_default_trait = Some(1); with_default_trait.unwrap_or_default(); @@ -66,7 +66,7 @@ fn or_fun_call() { with_default_type.unwrap_or_default(); let self_default = None::; - self_default.unwrap_or_else(::default); + self_default.unwrap_or(::default()); let real_default = None::; real_default.unwrap_or_default(); @@ -75,7 +75,7 @@ fn or_fun_call() { with_vec.unwrap_or_default(); let without_default = Some(Foo); - without_default.unwrap_or_else(Foo::new); + without_default.unwrap_or(Foo::new()); let mut map = HashMap::::new(); map.entry(42).or_default(); @@ -98,9 +98,9 @@ fn or_fun_call() { // index let map = HashMap::::new(); - let _ = Some(1).unwrap_or_else(|| map[&1]); + let _ = Some(1).unwrap_or(map[&1]); let map = BTreeMap::::new(); - let _ = Some(1).unwrap_or_else(|| map[&1]); + let _ = Some(1).unwrap_or(map[&1]); // don't lint index vec let vec = vec![1]; let _ = Some(1).unwrap_or(vec[1]); @@ -124,7 +124,7 @@ fn test_or_with_ctors() { let _ = opt.or(Some(2)); let _ = opt.or(Some(two)); - let _ = Some("a".to_string()).or_else(|| Some("b".to_string())); + let _ = Some("a".to_string()).or(Some("b".to_string())); let b = "b".to_string(); let _ = Some(Bar("a".to_string(), Duration::from_secs(1))) @@ -163,15 +163,15 @@ mod issue6675 { unsafe fn foo() { let s = "test".to_owned(); let s = &s as *const _; - None.unwrap_or_else(|| ptr_to_ref(s)); + None.unwrap_or(ptr_to_ref(s)); } fn bar() { let s = "test".to_owned(); let s = &s as *const _; - None.unwrap_or_else(|| unsafe { ptr_to_ref(s) }); + None.unwrap_or(unsafe { ptr_to_ref(s) }); #[rustfmt::skip] - None.unwrap_or_else(|| unsafe { ptr_to_ref(s) }); + None.unwrap_or( unsafe { ptr_to_ref(s) } ); } } @@ -246,8 +246,8 @@ mod issue8993 { } fn test_map_or() { - let _ = Some(4).map_or_else(g, |v| v); - let _ = Some(4).map_or_else(g, f); + let _ = Some(4).map_or(g(), |v| v); + let _ = Some(4).map_or(g(), f); let _ = Some(4).map_or(0, f); } } diff --git a/tests/ui/or_fun_call.rs b/tests/ui/or_fun_call.rs index 628c97046389..61ef6e27f322 100644 --- a/tests/ui/or_fun_call.rs +++ b/tests/ui/or_fun_call.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::or_fun_call)] #![allow(dead_code)] #![allow(clippy::borrow_as_ptr, clippy::uninlined_format_args, clippy::unnecessary_wraps)] diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr index ba3001db7a5f..82a3e759f803 100644 --- a/tests/ui/or_fun_call.stderr +++ b/tests/ui/or_fun_call.stderr @@ -1,172 +1,176 @@ -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:48:22 | LL | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)` | - = note: `-D clippy::or-fun-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/or_fun_call.rs:2:9 + | +LL | #![warn(clippy::or_fun_call)] + | ^^^^^^^^^^^^^^^^^^^ -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:51:14 | LL | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:54:21 | LL | with_const_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:57:14 | LL | with_err.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:60:19 | LL | with_err_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))` -error: use of `unwrap_or` followed by a call to `default` +warning: use of `unwrap_or` followed by a call to `default` --> $DIR/or_fun_call.rs:63:24 | LL | with_default_trait.unwrap_or(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a call to `default` +warning: use of `unwrap_or` followed by a call to `default` --> $DIR/or_fun_call.rs:66:23 | LL | with_default_type.unwrap_or(u64::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:69:18 | LL | self_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(::default)` -error: use of `unwrap_or` followed by a call to `default` +warning: use of `unwrap_or` followed by a call to `default` --> $DIR/or_fun_call.rs:72:18 | LL | real_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:75:14 | LL | with_vec.unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:78:21 | LL | without_default.unwrap_or(Foo::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)` -error: use of `or_insert` followed by a call to `new` +warning: use of `or_insert` followed by a call to `new` --> $DIR/or_fun_call.rs:81:19 | LL | map.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_default()` -error: use of `or_insert` followed by a call to `new` +warning: use of `or_insert` followed by a call to `new` --> $DIR/or_fun_call.rs:84:23 | LL | map_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try this: `or_default()` -error: use of `or_insert` followed by a call to `new` +warning: use of `or_insert` followed by a call to `new` --> $DIR/or_fun_call.rs:87:21 | LL | btree.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_default()` -error: use of `or_insert` followed by a call to `new` +warning: use of `or_insert` followed by a call to `new` --> $DIR/or_fun_call.rs:90:25 | LL | btree_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try this: `or_default()` -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:93:21 | LL | let _ = stringy.unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:101:21 | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:103:21 | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| map[&1])` -error: use of `or` followed by a function call +warning: use of `or` followed by a function call --> $DIR/or_fun_call.rs:127:35 | LL | let _ = Some("a".to_string()).or(Some("b".to_string())); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:166:14 | LL | None.unwrap_or(ptr_to_ref(s)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| ptr_to_ref(s))` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:172:14 | LL | None.unwrap_or(unsafe { ptr_to_ref(s) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/or_fun_call.rs:174:14 | LL | None.unwrap_or( unsafe { ptr_to_ref(s) } ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:188:14 | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:201:14 | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:213:14 | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `unwrap_or` followed by a call to `new` +warning: use of `unwrap_or` followed by a call to `new` --> $DIR/or_fun_call.rs:224:10 | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_default()` -error: use of `map_or` followed by a function call +warning: use of `map_or` followed by a function call --> $DIR/or_fun_call.rs:249:25 | LL | let _ = Some(4).map_or(g(), |v| v); | ^^^^^^^^^^^^^^^^^^ help: try this: `map_or_else(g, |v| v)` -error: use of `map_or` followed by a function call +warning: use of `map_or` followed by a function call --> $DIR/or_fun_call.rs:250:25 | LL | let _ = Some(4).map_or(g(), f); | ^^^^^^^^^^^^^^ help: try this: `map_or_else(g, f)` -error: aborting due to 28 previous errors +warning: 28 warnings emitted diff --git a/tests/ui/or_then_unwrap.fixed b/tests/ui/or_then_unwrap.fixed index 844cc4b7a092..40badac4424a 100644 --- a/tests/ui/or_then_unwrap.fixed +++ b/tests/ui/or_then_unwrap.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::or_then_unwrap)] #![allow(clippy::map_identity, clippy::let_unit_value)] diff --git a/tests/ui/or_then_unwrap.rs b/tests/ui/or_then_unwrap.rs index 1528ef9be964..76c9942fe6c1 100644 --- a/tests/ui/or_then_unwrap.rs +++ b/tests/ui/or_then_unwrap.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::or_then_unwrap)] #![allow(clippy::map_identity, clippy::let_unit_value)] diff --git a/tests/ui/or_then_unwrap.stderr b/tests/ui/or_then_unwrap.stderr index da88154c59f7..1b2c8cfb67ea 100644 --- a/tests/ui/or_then_unwrap.stderr +++ b/tests/ui/or_then_unwrap.stderr @@ -1,22 +1,26 @@ -error: found `.or(Some(…)).unwrap()` +warning: found `.or(Some(…)).unwrap()` --> $DIR/or_then_unwrap.rs:24:20 | LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")` | - = note: `-D clippy::or-then-unwrap` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/or_then_unwrap.rs:3:9 + | +LL | #![warn(clippy::or_then_unwrap)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: found `.or(Ok(…)).unwrap()` +warning: found `.or(Ok(…)).unwrap()` --> $DIR/or_then_unwrap.rs:27:20 | LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")` -error: found `.or(Some(…)).unwrap()` +warning: found `.or(Some(…)).unwrap()` --> $DIR/or_then_unwrap.rs:31:31 | LL | let _ = option.map(|v| v).or(Some("fallback")).unwrap().to_string().chars(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/out_of_bounds_indexing/issue-3102.stderr b/tests/ui/out_of_bounds_indexing/issue-3102.stderr index 516c1df40be0..93dd282016b5 100644 --- a/tests/ui/out_of_bounds_indexing/issue-3102.stderr +++ b/tests/ui/out_of_bounds_indexing/issue-3102.stderr @@ -1,16 +1,20 @@ -error: range is out of bounds +warning: range is out of bounds --> $DIR/issue-3102.rs:9:13 | LL | &x[num..10]; // should trigger out of bounds error | ^^ | - = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/issue-3102.rs:1:9 + | +LL | #![warn(clippy::out_of_bounds_indexing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/issue-3102.rs:10:8 | LL | &x[10..num]; // should trigger out of bounds error | ^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/out_of_bounds_indexing/simple.stderr b/tests/ui/out_of_bounds_indexing/simple.stderr index 3d95afcdab23..f7166eec63f5 100644 --- a/tests/ui/out_of_bounds_indexing/simple.stderr +++ b/tests/ui/out_of_bounds_indexing/simple.stderr @@ -1,40 +1,44 @@ -error: range is out of bounds +warning: range is out of bounds --> $DIR/simple.rs:7:11 | LL | &x[..=4]; | ^ | - = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/simple.rs:1:9 + | +LL | #![warn(clippy::out_of_bounds_indexing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/simple.rs:8:11 | LL | &x[1..5]; | ^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/simple.rs:9:8 | LL | &x[5..]; | ^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/simple.rs:10:10 | LL | &x[..5]; | ^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/simple.rs:11:8 | LL | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ -error: range is out of bounds +warning: range is out of bounds --> $DIR/simple.rs:12:12 | LL | &x[0..=4]; | ^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index 1b8b146b60ae..68a43ba057bd 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,52 +1,56 @@ -error: you are trying to use classic C overflow conditions that will fail in Rust +warning: you are trying to use classic C overflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:7:8 | LL | if a + b < a {} | ^^^^^^^^^ | - = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/overflow_check_conditional.rs:1:9 + | +LL | #![warn(clippy::overflow_check_conditional)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: you are trying to use classic C overflow conditions that will fail in Rust +warning: you are trying to use classic C overflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:8:8 | LL | if a > a + b {} | ^^^^^^^^^ -error: you are trying to use classic C overflow conditions that will fail in Rust +warning: you are trying to use classic C overflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:9:8 | LL | if a + b < b {} | ^^^^^^^^^ -error: you are trying to use classic C overflow conditions that will fail in Rust +warning: you are trying to use classic C overflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:10:8 | LL | if b > a + b {} | ^^^^^^^^^ -error: you are trying to use classic C underflow conditions that will fail in Rust +warning: you are trying to use classic C underflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:11:8 | LL | if a - b > b {} | ^^^^^^^^^ -error: you are trying to use classic C underflow conditions that will fail in Rust +warning: you are trying to use classic C underflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:12:8 | LL | if b < a - b {} | ^^^^^^^^^ -error: you are trying to use classic C underflow conditions that will fail in Rust +warning: you are trying to use classic C underflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:13:8 | LL | if a - b > a {} | ^^^^^^^^^ -error: you are trying to use classic C underflow conditions that will fail in Rust +warning: you are trying to use classic C underflow conditions that will fail in Rust --> $DIR/overflow_check_conditional.rs:14:8 | LL | if a < a - b {} | ^^^^^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/overly_complex_bool_expr.stderr b/tests/ui/overly_complex_bool_expr.stderr index e989f2ece308..8f5f9ab6c9a3 100644 --- a/tests/ui/overly_complex_bool_expr.stderr +++ b/tests/ui/overly_complex_bool_expr.stderr @@ -1,4 +1,4 @@ -error: this boolean expression contains a logic bug +warning: this boolean expression contains a logic bug --> $DIR/overly_complex_bool_expr.rs:11:13 | LL | let _ = a && b || a; @@ -9,9 +9,13 @@ help: this expression can be optimized out by applying boolean operations to the | LL | let _ = a && b || a; | ^ - = note: `-D clippy::overly-complex-bool-expr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/overly_complex_bool_expr.rs:3:9 + | +LL | #![warn(clippy::overly_complex_bool_expr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this boolean expression contains a logic bug +warning: this boolean expression contains a logic bug --> $DIR/overly_complex_bool_expr.rs:13:13 | LL | let _ = false && a; @@ -23,7 +27,7 @@ help: this expression can be optimized out by applying boolean operations to the LL | let _ = false && a; | ^ -error: this boolean expression contains a logic bug +warning: this boolean expression contains a logic bug --> $DIR/overly_complex_bool_expr.rs:23:13 | LL | let _ = a == b && a != b; @@ -35,7 +39,7 @@ help: this expression can be optimized out by applying boolean operations to the LL | let _ = a == b && a != b; | ^^^^^^ -error: this boolean expression contains a logic bug +warning: this boolean expression contains a logic bug --> $DIR/overly_complex_bool_expr.rs:24:13 | LL | let _ = a < b && a >= b; @@ -47,7 +51,7 @@ help: this expression can be optimized out by applying boolean operations to the LL | let _ = a < b && a >= b; | ^^^^^ -error: this boolean expression contains a logic bug +warning: this boolean expression contains a logic bug --> $DIR/overly_complex_bool_expr.rs:25:13 | LL | let _ = a > b && a <= b; @@ -59,5 +63,5 @@ help: this expression can be optimized out by applying boolean operations to the LL | let _ = a > b && a <= b; | ^^^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/panic_in_result_fn.stderr b/tests/ui/panic_in_result_fn.stderr index 97787bc84e2c..6e8e4a464271 100644 --- a/tests/ui/panic_in_result_fn.stderr +++ b/tests/ui/panic_in_result_fn.stderr @@ -1,4 +1,4 @@ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:6:5 | LL | / fn result_with_panic() -> Result // should emit lint @@ -13,9 +13,13 @@ note: return Err() instead of panicking | LL | panic!("error"); | ^^^^^^^^^^^^^^^ - = note: `-D clippy::panic-in-result-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/panic_in_result_fn.rs:1:9 + | +LL | #![warn(clippy::panic_in_result_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:11:5 | LL | / fn result_with_unimplemented() -> Result // should emit lint @@ -31,7 +35,7 @@ note: return Err() instead of panicking LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:16:5 | LL | / fn result_with_unreachable() -> Result // should emit lint @@ -47,7 +51,7 @@ note: return Err() instead of panicking LL | unreachable!(); | ^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:21:5 | LL | / fn result_with_todo() -> Result // should emit lint @@ -63,7 +67,7 @@ note: return Err() instead of panicking LL | todo!("Finish this"); | ^^^^^^^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:52:1 | LL | / fn function_result_with_panic() -> Result // should emit lint @@ -79,7 +83,7 @@ note: return Err() instead of panicking LL | panic!("error"); | ^^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn.rs:67:1 | LL | / fn main() -> Result<(), String> { @@ -95,5 +99,5 @@ note: return Err() instead of panicking LL | todo!("finish main method"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/panic_in_result_fn_assertions.stderr b/tests/ui/panic_in_result_fn_assertions.stderr index eb0aacbb6a44..b22f07c19fac 100644 --- a/tests/ui/panic_in_result_fn_assertions.stderr +++ b/tests/ui/panic_in_result_fn_assertions.stderr @@ -1,4 +1,4 @@ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn_assertions.rs:7:5 | LL | / fn result_with_assert_with_message(x: i32) -> Result // should emit lint @@ -14,9 +14,13 @@ note: return Err() instead of panicking | LL | assert!(x == 5, "wrong argument"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::panic-in-result-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/panic_in_result_fn_assertions.rs:1:9 + | +LL | #![warn(clippy::panic_in_result_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn_assertions.rs:13:5 | LL | / fn result_with_assert_eq(x: i32) -> Result // should emit lint @@ -33,7 +37,7 @@ note: return Err() instead of panicking LL | assert_eq!(x, 5); | ^^^^^^^^^^^^^^^^ -error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` +warning: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result` --> $DIR/panic_in_result_fn_assertions.rs:19:5 | LL | / fn result_with_assert_ne(x: i32) -> Result // should emit lint @@ -50,5 +54,5 @@ note: return Err() instead of panicking LL | assert_ne!(x, 1); | ^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/panicking_macros.stderr b/tests/ui/panicking_macros.stderr index 4ceb6d1440f6..d051554453bc 100644 --- a/tests/ui/panicking_macros.stderr +++ b/tests/ui/panicking_macros.stderr @@ -1,106 +1,122 @@ -error: `panic` should not be present in production code +warning: `panic` should not be present in production code --> $DIR/panicking_macros.rs:23:5 | LL | panic!(); | ^^^^^^^^ | - = note: `-D clippy::panic` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/panicking_macros.rs:3:67 + | +LL | #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)] + | ^^^^^^^^^^^^^ -error: `panic` should not be present in production code +warning: `panic` should not be present in production code --> $DIR/panicking_macros.rs:24:5 | LL | panic!("message"); | ^^^^^^^^^^^^^^^^^ -error: `panic` should not be present in production code +warning: `panic` should not be present in production code --> $DIR/panicking_macros.rs:25:5 | LL | panic!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `todo` should not be present in production code +warning: `todo` should not be present in production code --> $DIR/panicking_macros.rs:31:5 | LL | todo!(); | ^^^^^^^ | - = note: `-D clippy::todo` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/panicking_macros.rs:3:53 + | +LL | #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)] + | ^^^^^^^^^^^^ -error: `todo` should not be present in production code +warning: `todo` should not be present in production code --> $DIR/panicking_macros.rs:32:5 | LL | todo!("message"); | ^^^^^^^^^^^^^^^^ -error: `todo` should not be present in production code +warning: `todo` should not be present in production code --> $DIR/panicking_macros.rs:33:5 | LL | todo!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `unimplemented` should not be present in production code +warning: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:39:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unimplemented` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/panicking_macros.rs:3:9 + | +LL | #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: `unimplemented` should not be present in production code +warning: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:40:5 | LL | unimplemented!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `unimplemented` should not be present in production code +warning: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:41:5 | LL | unimplemented!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of the `unreachable!` macro +warning: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:47:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ | - = note: `-D clippy::unreachable` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/panicking_macros.rs:3:32 + | +LL | #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)] + | ^^^^^^^^^^^^^^^^^^^ -error: usage of the `unreachable!` macro +warning: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:48:5 | LL | unreachable!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of the `unreachable!` macro +warning: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:49:5 | LL | unreachable!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `panic` should not be present in production code +warning: `panic` should not be present in production code --> $DIR/panicking_macros.rs:55:5 | LL | panic!(); | ^^^^^^^^ -error: `todo` should not be present in production code +warning: `todo` should not be present in production code --> $DIR/panicking_macros.rs:56:5 | LL | todo!(); | ^^^^^^^ -error: `unimplemented` should not be present in production code +warning: `unimplemented` should not be present in production code --> $DIR/panicking_macros.rs:57:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ -error: usage of the `unreachable!` macro +warning: usage of the `unreachable!` macro --> $DIR/panicking_macros.rs:58:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/partial_pub_fields.stderr b/tests/ui/partial_pub_fields.stderr index 84cfc1a91940..60a5ba23bba2 100644 --- a/tests/ui/partial_pub_fields.stderr +++ b/tests/ui/partial_pub_fields.stderr @@ -1,13 +1,17 @@ -error: mixed usage of pub and non-pub fields +warning: mixed usage of pub and non-pub fields --> $DIR/partial_pub_fields.rs:10:9 | LL | pub paths: HashMap, | ^^^ | = help: consider using private field here - = note: `-D clippy::partial-pub-fields` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/partial_pub_fields.rs:2:9 + | +LL | #![warn(clippy::partial_pub_fields)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: mixed usage of pub and non-pub fields +warning: mixed usage of pub and non-pub fields --> $DIR/partial_pub_fields.rs:16:9 | LL | b: u8, @@ -15,7 +19,7 @@ LL | b: u8, | = help: consider using public field here -error: mixed usage of pub and non-pub fields +warning: mixed usage of pub and non-pub fields --> $DIR/partial_pub_fields.rs:19:27 | LL | pub struct Point(i32, pub i32); @@ -23,7 +27,7 @@ LL | pub struct Point(i32, pub i32); | = help: consider using private field here -error: mixed usage of pub and non-pub fields +warning: mixed usage of pub and non-pub fields --> $DIR/partial_pub_fields.rs:23:9 | LL | pub pos: u32, @@ -31,5 +35,5 @@ LL | pub pos: u32, | = help: consider using private field here -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index b92da4511b48..a3ab1eb69d21 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -1,4 +1,4 @@ -error: re-implementing `PartialEq::ne` is unnecessary +warning: re-implementing `PartialEq::ne` is unnecessary --> $DIR/partialeq_ne_impl.rs:9:5 | LL | / fn ne(&self, _: &Foo) -> bool { @@ -6,7 +6,7 @@ LL | | false LL | | } | |_____^ | - = note: `-D clippy::partialeq-ne-impl` implied by `-D warnings` + = note: `#[warn(clippy::partialeq_ne_impl)]` on by default -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/partialeq_to_none.fixed b/tests/ui/partialeq_to_none.fixed index 4644ea8f51da..81a716bd276c 100644 --- a/tests/ui/partialeq_to_none.fixed +++ b/tests/ui/partialeq_to_none.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::partialeq_to_none)] struct Foobar; diff --git a/tests/ui/partialeq_to_none.rs b/tests/ui/partialeq_to_none.rs index 61011b3a8c55..f454715fa30f 100644 --- a/tests/ui/partialeq_to_none.rs +++ b/tests/ui/partialeq_to_none.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::partialeq_to_none)] struct Foobar; diff --git a/tests/ui/partialeq_to_none.stderr b/tests/ui/partialeq_to_none.stderr index d06ab7aee558..03ca9106ff3a 100644 --- a/tests/ui/partialeq_to_none.stderr +++ b/tests/ui/partialeq_to_none.stderr @@ -1,60 +1,64 @@ -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:14:8 | LL | if f != None { "yay" } else { "nay" } | ^^^^^^^^^ help: use `Option::is_some()` instead: `f.is_some()` | - = note: `-D clippy::partialeq-to-none` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/partialeq_to_none.rs:2:9 + | +LL | #![warn(clippy::partialeq_to_none)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:44:13 | LL | let _ = x == None; | ^^^^^^^^^ help: use `Option::is_none()` instead: `x.is_none()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:45:13 | LL | let _ = x != None; | ^^^^^^^^^ help: use `Option::is_some()` instead: `x.is_some()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:46:13 | LL | let _ = None == x; | ^^^^^^^^^ help: use `Option::is_none()` instead: `x.is_none()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:47:13 | LL | let _ = None != x; | ^^^^^^^^^ help: use `Option::is_some()` instead: `x.is_some()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:49:8 | LL | if foobar() == None {} | ^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `foobar().is_none()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:51:8 | LL | if bar().ok() != None {} | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `bar().ok().is_some()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:53:13 | LL | let _ = Some(1 + 2) != None; | ^^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `Some(1 + 2).is_some()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:55:13 | LL | let _ = { Some(0) } == None; | ^^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `{ Some(0) }.is_none()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:57:13 | LL | let _ = { @@ -76,35 +80,35 @@ LL + Some(1) LL ~ }.is_some(); | -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:67:13 | LL | let _ = optref() == &&None; | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `optref().is_none()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:68:13 | LL | let _ = &&None != optref(); | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `optref().is_some()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:69:13 | LL | let _ = **optref() == None; | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `optref().is_none()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:70:13 | LL | let _ = &None != *optref(); | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `optref().is_some()` -error: binary comparison to literal `Option::None` +warning: binary comparison to literal `Option::None` --> $DIR/partialeq_to_none.rs:73:13 | LL | let _ = None != *x; | ^^^^^^^^^^ help: use `Option::is_some()` instead: `(*x).is_some()` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/path_buf_push_overwrite.fixed b/tests/ui/path_buf_push_overwrite.fixed index ef8856830fc9..393fc6e1c693 100644 --- a/tests/ui/path_buf_push_overwrite.fixed +++ b/tests/ui/path_buf_push_overwrite.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use std::path::PathBuf; #[warn(clippy::all, clippy::path_buf_push_overwrite)] diff --git a/tests/ui/path_buf_push_overwrite.rs b/tests/ui/path_buf_push_overwrite.rs index 6e2d483f4541..18de6e064126 100644 --- a/tests/ui/path_buf_push_overwrite.rs +++ b/tests/ui/path_buf_push_overwrite.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix use std::path::PathBuf; #[warn(clippy::all, clippy::path_buf_push_overwrite)] diff --git a/tests/ui/path_buf_push_overwrite.stderr b/tests/ui/path_buf_push_overwrite.stderr index bb8dce2bbba4..24995b7f1742 100644 --- a/tests/ui/path_buf_push_overwrite.stderr +++ b/tests/ui/path_buf_push_overwrite.stderr @@ -1,10 +1,14 @@ -error: calling `push` with '/' or '/' (file system root) will overwrite the previous path definition +warning: calling `push` with '/' or '\' (file system root) will overwrite the previous path definition --> $DIR/path_buf_push_overwrite.rs:7:12 | LL | x.push("/bar"); | ^^^^^^ help: try: `"bar"` | - = note: `-D clippy::path-buf-push-overwrite` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/path_buf_push_overwrite.rs:4:21 + | +LL | #[warn(clippy::all, clippy::path_buf_push_overwrite)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/pattern_type_mismatch/mutability.stderr b/tests/ui/pattern_type_mismatch/mutability.stderr index 87fb243b65ef..8491e9331890 100644 --- a/tests/ui/pattern_type_mismatch/mutability.stderr +++ b/tests/ui/pattern_type_mismatch/mutability.stderr @@ -1,13 +1,17 @@ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/mutability.rs:9:9 | LL | Some(_) => (), | ^^^^^^^ | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings - = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/mutability.rs:2:9 + | +LL | #![warn(clippy::pattern_type_mismatch)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/mutability.rs:15:9 | LL | Some(_) => (), @@ -15,5 +19,5 @@ LL | Some(_) => (), | = help: use `*` to dereference the match expression or explicitly match against a `&mut _` pattern and adjust the enclosed variable bindings -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr b/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr index a91b5ac6cf74..f2de042e2c57 100644 --- a/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_alternatives.stderr @@ -1,13 +1,17 @@ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_alternatives.rs:15:12 | LL | if let Value::B | Value::A(_) = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings - = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/pattern_alternatives.rs:2:9 + | +LL | #![warn(clippy::pattern_type_mismatch)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_alternatives.rs:16:34 | LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} @@ -15,7 +19,7 @@ LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_alternatives.rs:17:32 | LL | if let Value::B | Value::A(Some(_)) = *ref_value {} @@ -23,5 +27,5 @@ LL | if let Value::B | Value::A(Some(_)) = *ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/pattern_type_mismatch/pattern_structs.stderr b/tests/ui/pattern_type_mismatch/pattern_structs.stderr index 8bc5c63baab5..c57b740a22db 100644 --- a/tests/ui/pattern_type_mismatch/pattern_structs.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_structs.stderr @@ -1,13 +1,17 @@ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:13:9 | LL | let Struct { .. } = ref_value; | ^^^^^^^^^^^^^ | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings - = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/pattern_structs.rs:2:9 + | +LL | #![warn(clippy::pattern_type_mismatch)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:14:33 | LL | if let &Struct { ref_inner: Some(_) } = ref_value {} @@ -15,7 +19,7 @@ LL | if let &Struct { ref_inner: Some(_) } = ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:15:32 | LL | if let Struct { ref_inner: Some(_) } = *ref_value {} @@ -23,7 +27,7 @@ LL | if let Struct { ref_inner: Some(_) } = *ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:32:12 | LL | if let StructEnum::Var { .. } = ref_value {} @@ -31,7 +35,7 @@ LL | if let StructEnum::Var { .. } = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:33:12 | LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} @@ -39,7 +43,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:34:42 | LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} @@ -47,7 +51,7 @@ LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:35:41 | LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} @@ -55,7 +59,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_structs.rs:36:12 | LL | if let StructEnum::Empty = ref_value {} @@ -63,5 +67,5 @@ LL | if let StructEnum::Empty = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr index a1ef540d2831..feed01434818 100644 --- a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr @@ -1,13 +1,17 @@ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:11:9 | LL | let TupleStruct(_) = ref_value; | ^^^^^^^^^^^^^^ | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings - = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/pattern_tuples.rs:2:9 + | +LL | #![warn(clippy::pattern_type_mismatch)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:12:25 | LL | if let &TupleStruct(Some(_)) = ref_value {} @@ -15,7 +19,7 @@ LL | if let &TupleStruct(Some(_)) = ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:13:24 | LL | if let TupleStruct(Some(_)) = *ref_value {} @@ -23,7 +27,7 @@ LL | if let TupleStruct(Some(_)) = *ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:30:12 | LL | if let TupleEnum::Var(_) = ref_value {} @@ -31,7 +35,7 @@ LL | if let TupleEnum::Var(_) = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:31:28 | LL | if let &TupleEnum::Var(Some(_)) = ref_value {} @@ -39,7 +43,7 @@ LL | if let &TupleEnum::Var(Some(_)) = ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:32:27 | LL | if let TupleEnum::Var(Some(_)) = *ref_value {} @@ -47,7 +51,7 @@ LL | if let TupleEnum::Var(Some(_)) = *ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:33:12 | LL | if let TupleEnum::Empty = ref_value {} @@ -55,7 +59,7 @@ LL | if let TupleEnum::Empty = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:48:9 | LL | let (_a, _b) = ref_value; @@ -63,7 +67,7 @@ LL | let (_a, _b) = ref_value; | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:49:18 | LL | if let &(_a, Some(_)) = ref_value {} @@ -71,7 +75,7 @@ LL | if let &(_a, Some(_)) = ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/pattern_tuples.rs:50:17 | LL | if let (_a, Some(_)) = *ref_value {} @@ -79,5 +83,5 @@ LL | if let (_a, Some(_)) = *ref_value {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/pattern_type_mismatch/syntax.stderr b/tests/ui/pattern_type_mismatch/syntax.stderr index f56a3a893801..15d325f1de74 100644 --- a/tests/ui/pattern_type_mismatch/syntax.stderr +++ b/tests/ui/pattern_type_mismatch/syntax.stderr @@ -1,13 +1,17 @@ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:11:9 | LL | Some(_) => (), | ^^^^^^^ | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings - = note: `-D clippy::pattern-type-mismatch` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/syntax.rs:2:9 + | +LL | #![warn(clippy::pattern_type_mismatch)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:30:12 | LL | if let Some(_) = ref_value {} @@ -15,7 +19,7 @@ LL | if let Some(_) = ref_value {} | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:41:15 | LL | while let Some(_) = ref_value { @@ -23,7 +27,7 @@ LL | while let Some(_) = ref_value { | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:59:9 | LL | for (_a, _b) in slice.iter() {} @@ -31,7 +35,7 @@ LL | for (_a, _b) in slice.iter() {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:69:9 | LL | let (_n, _m) = ref_value; @@ -39,7 +43,7 @@ LL | let (_n, _m) = ref_value; | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:78:12 | LL | fn foo((_a, _b): &(i32, i32)) {} @@ -47,7 +51,7 @@ LL | fn foo((_a, _b): &(i32, i32)) {} | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:92:10 | LL | foo(|(_a, _b)| ()); @@ -55,7 +59,7 @@ LL | foo(|(_a, _b)| ()); | = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:108:9 | LL | Some(_) => (), @@ -63,7 +67,7 @@ LL | Some(_) => (), | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings -error: type of pattern does not match the expression type +warning: type of pattern does not match the expression type --> $DIR/syntax.rs:128:17 | LL | Some(_) => (), @@ -73,7 +77,7 @@ LL | matching_macro!(value); | ---------------------- in this macro invocation | = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings - = note: this error originates in the macro `matching_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `matching_macro` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/patterns.fixed b/tests/ui/patterns.fixed index cd69014326eb..a1da47d84fd5 100644 --- a/tests/ui/patterns.fixed +++ b/tests/ui/patterns.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![allow(unused)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/patterns.rs b/tests/ui/patterns.rs index 9128da420c0d..399066b813e3 100644 --- a/tests/ui/patterns.rs +++ b/tests/ui/patterns.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![allow(unused)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index 2c46b4eb593e..f474e526bd7e 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -1,22 +1,27 @@ -error: the `y @ _` pattern can be written as just `y` +warning: the `y @ _` pattern can be written as just `y` --> $DIR/patterns.rs:11:9 | LL | y @ _ => (), | ^^^^^ help: try: `y` | - = note: `-D clippy::redundant-pattern` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/patterns.rs:2:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::redundant_pattern)]` implied by `#[warn(clippy::all)]` -error: the `x @ _` pattern can be written as just `x` +warning: the `x @ _` pattern can be written as just `x` --> $DIR/patterns.rs:26:9 | LL | ref mut x @ _ => { | ^^^^^^^^^^^^^ help: try: `ref mut x` -error: the `x @ _` pattern can be written as just `x` +warning: the `x @ _` pattern can be written as just `x` --> $DIR/patterns.rs:34:9 | LL | ref x @ _ => println!("vec: {:?}", x), | ^^^^^^^^^ help: try: `ref x` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/permissions_set_readonly_false.stderr b/tests/ui/permissions_set_readonly_false.stderr index e7a8ee6cb19b..c9e23d2e9ffb 100644 --- a/tests/ui/permissions_set_readonly_false.stderr +++ b/tests/ui/permissions_set_readonly_false.stderr @@ -1,4 +1,4 @@ -error: call to `set_readonly` with argument `false` +warning: call to `set_readonly` with argument `false` --> $DIR/permissions_set_readonly_false.rs:19:5 | LL | permissions.set_readonly(false); @@ -7,7 +7,11 @@ LL | permissions.set_readonly(false); = note: on Unix platforms this results in the file being world writable = help: you can set the desired permissions using `PermissionsExt`. For more information, see https://doc.rust-lang.org/std/os/unix/fs/trait.PermissionsExt.html - = note: `-D clippy::permissions-set-readonly-false` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/permissions_set_readonly_false.rs:2:9 + | +LL | #![warn(clippy::permissions_set_readonly_false)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/precedence.fixed b/tests/ui/precedence.fixed index 163bd044c178..af4d5636b616 100644 --- a/tests/ui/precedence.fixed +++ b/tests/ui/precedence.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::precedence)] #![allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)] #![allow(clippy::identity_op)] diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index 8c849e3209b0..e23ae9127866 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::precedence)] #![allow(unused_must_use, clippy::no_effect, clippy::unnecessary_operation)] #![allow(clippy::identity_op)] diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 03d585b39750..c7f354e70bf2 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,76 +1,80 @@ -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:17:5 | LL | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` | - = note: `-D clippy::precedence` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/precedence.rs:2:9 + | +LL | #![warn(clippy::precedence)] + | ^^^^^^^^^^^^^^^^^^ -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:18:5 | LL | 1 + 2 << 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:19:5 | LL | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:20:5 | LL | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:21:5 | LL | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:22:5 | LL | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` -error: operator precedence can trip the unwary +warning: operator precedence can trip the unwary --> $DIR/precedence.rs:23:5 | LL | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` -error: unary minus has lower precedence than method call +warning: unary minus has lower precedence than method call --> $DIR/precedence.rs:24:5 | LL | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` -error: unary minus has lower precedence than method call +warning: unary minus has lower precedence than method call --> $DIR/precedence.rs:25:5 | LL | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` -error: unary minus has lower precedence than method call +warning: unary minus has lower precedence than method call --> $DIR/precedence.rs:52:13 | LL | let _ = -1.0_f64.cos().cos(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().cos())` -error: unary minus has lower precedence than method call +warning: unary minus has lower precedence than method call --> $DIR/precedence.rs:53:13 | LL | let _ = -1.0_f64.cos().sin(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().sin())` -error: unary minus has lower precedence than method call +warning: unary minus has lower precedence than method call --> $DIR/precedence.rs:54:13 | LL | let _ = -1.0_f64.sin().cos(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.sin().cos())` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 1754c418381a..c051b4a8f761 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -1,54 +1,62 @@ -error: use of `Debug`-based formatting +warning: use of `Debug`-based formatting --> $DIR/print.rs:11:20 | LL | write!(f, "{:?}", 43.1415) | ^^^^ | - = note: `-D clippy::use-debug` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print.rs:2:31 + | +LL | #![warn(clippy::print_stdout, clippy::use_debug)] + | ^^^^^^^^^^^^^^^^^ -error: use of `println!` +warning: use of `println!` --> $DIR/print.rs:23:5 | LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::print-stdout` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print.rs:2:9 + | +LL | #![warn(clippy::print_stdout, clippy::use_debug)] + | ^^^^^^^^^^^^^^^^^^^^ -error: use of `print!` +warning: use of `print!` --> $DIR/print.rs:24:5 | LL | print!("Hello"); | ^^^^^^^^^^^^^^^ -error: use of `print!` +warning: use of `print!` --> $DIR/print.rs:26:5 | LL | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `print!` +warning: use of `print!` --> $DIR/print.rs:28:5 | LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `Debug`-based formatting +warning: use of `Debug`-based formatting --> $DIR/print.rs:28:19 | LL | print!("Hello {:?}", "World"); | ^^^^ -error: use of `print!` +warning: use of `print!` --> $DIR/print.rs:30:5 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `Debug`-based formatting +warning: use of `Debug`-based formatting --> $DIR/print.rs:30:19 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/print_in_format_impl.stderr b/tests/ui/print_in_format_impl.stderr index 63b7179bca7d..595d4893b7e2 100644 --- a/tests/ui/print_in_format_impl.stderr +++ b/tests/ui/print_in_format_impl.stderr @@ -1,46 +1,50 @@ -error: use of `print!` in `Debug` impl +warning: use of `print!` in `Debug` impl --> $DIR/print_in_format_impl.rs:20:9 | LL | print!("{}", 1); | ^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` | - = note: `-D clippy::print-in-format-impl` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print_in_format_impl.rs:2:9 + | +LL | #![warn(clippy::print_in_format_impl)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `println!` in `Debug` impl +warning: use of `println!` in `Debug` impl --> $DIR/print_in_format_impl.rs:21:9 | LL | println!("{}", 2); | ^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` -error: use of `eprint!` in `Debug` impl +warning: use of `eprint!` in `Debug` impl --> $DIR/print_in_format_impl.rs:22:9 | LL | eprint!("{}", 3); | ^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` -error: use of `eprintln!` in `Debug` impl +warning: use of `eprintln!` in `Debug` impl --> $DIR/print_in_format_impl.rs:23:9 | LL | eprintln!("{}", 4); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` -error: use of `println!` in `Debug` impl +warning: use of `println!` in `Debug` impl --> $DIR/print_in_format_impl.rs:25:13 | LL | println!("nested"); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` -error: use of `print!` in `Display` impl +warning: use of `print!` in `Display` impl --> $DIR/print_in_format_impl.rs:38:9 | LL | print!("Display"); | ^^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` -error: use of `println!` in `Debug` impl +warning: use of `println!` in `Debug` impl --> $DIR/print_in_format_impl.rs:48:9 | LL | println!("UnnamedFormatter"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(..)` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index 6404dacdafa5..8542de4e87b0 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,17 +1,21 @@ -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:27:24 | LL | print!("Hello {}", "world"); | ^^^^^^^ | - = note: `-D clippy::print-literal` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print_literal.rs:1:9 + | +LL | #![warn(clippy::print_literal)] + | ^^^^^^^^^^^^^^^^^^^^^ help: try this | LL - print!("Hello {}", "world"); LL + print!("Hello world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:28:36 | LL | println!("Hello {} {}", world, "world"); @@ -23,7 +27,7 @@ LL - println!("Hello {} {}", world, "world"); LL + println!("Hello {} world", world); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:29:26 | LL | println!("Hello {}", "world"); @@ -35,7 +39,7 @@ LL - println!("Hello {}", "world"); LL + println!("Hello world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:30:26 | LL | println!("{} {:.4}", "a literal", 5); @@ -47,7 +51,7 @@ LL - println!("{} {:.4}", "a literal", 5); LL + println!("a literal {:.4}", 5); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:35:25 | LL | println!("{0} {1}", "hello", "world"); @@ -59,7 +63,7 @@ LL - println!("{0} {1}", "hello", "world"); LL + println!("hello {1}", "world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:35:34 | LL | println!("{0} {1}", "hello", "world"); @@ -71,7 +75,7 @@ LL - println!("{0} {1}", "hello", "world"); LL + println!("{0} world", "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:36:34 | LL | println!("{1} {0}", "hello", "world"); @@ -83,7 +87,7 @@ LL - println!("{1} {0}", "hello", "world"); LL + println!("world {0}", "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:36:25 | LL | println!("{1} {0}", "hello", "world"); @@ -95,7 +99,7 @@ LL - println!("{1} {0}", "hello", "world"); LL + println!("{1} hello", "world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:39:35 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); @@ -107,7 +111,7 @@ LL - println!("{foo} {bar}", foo = "hello", bar = "world"); LL + println!("hello {bar}", bar = "world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:39:50 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); @@ -119,7 +123,7 @@ LL - println!("{foo} {bar}", foo = "hello", bar = "world"); LL + println!("{foo} world", foo = "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:40:50 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); @@ -131,7 +135,7 @@ LL - println!("{bar} {foo}", foo = "hello", bar = "world"); LL + println!("world {foo}", foo = "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/print_literal.rs:40:35 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); @@ -143,5 +147,5 @@ LL - println!("{bar} {foo}", foo = "hello", bar = "world"); LL + println!("{bar} hello", bar = "world"); | -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/print_stderr.stderr b/tests/ui/print_stderr.stderr index 5af735af6576..63495ca1a82c 100644 --- a/tests/ui/print_stderr.stderr +++ b/tests/ui/print_stderr.stderr @@ -1,16 +1,20 @@ -error: use of `eprintln!` +warning: use of `eprintln!` --> $DIR/print_stderr.rs:4:5 | LL | eprintln!("Hello"); | ^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::print-stderr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print_stderr.rs:1:9 + | +LL | #![warn(clippy::print_stderr)] + | ^^^^^^^^^^^^^^^^^^^^ -error: use of `eprint!` +warning: use of `eprint!` --> $DIR/print_stderr.rs:6:5 | LL | eprint!("World"); | ^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/print_stdout_build_script.rs b/tests/ui/print_stdout_build_script.rs index 997ebef8a699..91448cb0faf8 100644 --- a/tests/ui/print_stdout_build_script.rs +++ b/tests/ui/print_stdout_build_script.rs @@ -1,4 +1,4 @@ -// compile-flags: --crate-name=build_script_build +//@compile-flags: --crate-name=build_script_build #![warn(clippy::print_stdout)] diff --git a/tests/ui/print_with_newline.fixed b/tests/ui/print_with_newline.fixed new file mode 100644 index 000000000000..6098dea39911 --- /dev/null +++ b/tests/ui/print_with_newline.fixed @@ -0,0 +1,58 @@ +// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 +//@run-rustfix + +#![allow(clippy::print_literal)] +#![warn(clippy::print_with_newline)] + +fn main() { + println!("Hello"); + println!("Hello {}", "world"); + println!("Hello {} {}", "world", "#2"); + println!("{}", 1265); + println!(); + + // these are all fine + print!(""); + print!("Hello"); + println!("Hello"); + println!("Hello\n"); + println!("Hello {}\n", "world"); + print!("Issue\n{}", 1265); + print!("{}", 1265); + print!("\n{}", 1275); + print!("\n\n"); + print!("like eof\n\n"); + print!("Hello {} {}\n\n", "world", "#2"); + println!("\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126 + println!("\nbla\n\n"); // #3126 + + // Escaping + print!("\\n"); // #3514 + println!("\\"); // should fail + print!("\\\\n"); + + // Raw strings + print!(r"\n"); // #3778 + + // Literal newlines should also fail + println!( + + ); + println!( + + ); + + // Don't warn on CRLF (#4208) + print!("\r\n"); + print!("foo\r\n"); + println!("\\r"); // should fail + print!("foo\rbar\n"); + + // Ignore expanded format strings + macro_rules! newline { + () => { + "\n" + }; + } + print!(newline!()); +} diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs index b8c29d207ada..0c4c80b9fc1a 100644 --- a/tests/ui/print_with_newline.rs +++ b/tests/ui/print_with_newline.rs @@ -1,5 +1,5 @@ // FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 -// // run-rustfix +//@run-rustfix #![allow(clippy::print_literal)] #![warn(clippy::print_with_newline)] @@ -47,7 +47,7 @@ fn main() { // Don't warn on CRLF (#4208) print!("\r\n"); print!("foo\r\n"); - print!("\\r\n"); //~ ERROR + print!("\\r\n"); // should fail print!("foo\rbar\n"); // Ignore expanded format strings diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index b9f5675faec7..c3f29e4b1bee 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,77 +1,81 @@ -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:8:5 | -LL | print!("Hello/n"); +LL | print!("Hello\n"); | ^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::print-with-newline` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/print_with_newline.rs:5:9 + | +LL | #![warn(clippy::print_with_newline)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `println!` instead | -LL - print!("Hello/n"); +LL - print!("Hello\n"); LL + println!("Hello"); | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:9:5 | -LL | print!("Hello {}/n", "world"); +LL | print!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `println!` instead | -LL - print!("Hello {}/n", "world"); +LL - print!("Hello {}\n", "world"); LL + println!("Hello {}", "world"); | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:10:5 | -LL | print!("Hello {} {}/n", "world", "#2"); +LL | print!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `println!` instead | -LL - print!("Hello {} {}/n", "world", "#2"); +LL - print!("Hello {} {}\n", "world", "#2"); LL + println!("Hello {} {}", "world", "#2"); | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:11:5 | -LL | print!("{}/n", 1265); +LL | print!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^ | help: use `println!` instead | -LL - print!("{}/n", 1265); +LL - print!("{}\n", 1265); LL + println!("{}", 1265); | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:12:5 | -LL | print!("/n"); +LL | print!("\n"); | ^^^^^^^^^^^^ | help: use `println!` instead | -LL - print!("/n"); +LL - print!("\n"); LL + println!(); | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:31:5 | -LL | print!("//n"); // should fail +LL | print!("\\\n"); // should fail | ^^^^^^^^^^^^^^ | help: use `println!` instead | -LL - print!("//n"); // should fail -LL + println!("/"); // should fail +LL - print!("\\\n"); // should fail +LL + println!("\\"); // should fail | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:38:5 | LL | / print!( @@ -86,7 +90,7 @@ LL ~ println!( LL ~ | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:42:5 | LL | / print!( @@ -101,17 +105,17 @@ LL ~ println!( LL ~ | -error: using `print!()` with a format string that ends in a single newline +warning: using `print!()` with a format string that ends in a single newline --> $DIR/print_with_newline.rs:50:5 | -LL | print!("/r/n"); //~ ERROR +LL | print!("\\r\n"); // should fail | ^^^^^^^^^^^^^^^ | help: use `println!` instead | -LL - print!("/r/n"); //~ ERROR -LL + println!("/r"); //~ ERROR +LL - print!("\\r\n"); // should fail +LL + println!("\\r"); // should fail | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/println_empty_string.fixed b/tests/ui/println_empty_string.fixed index 9760680927a6..abf951ae22d6 100644 --- a/tests/ui/println_empty_string.fixed +++ b/tests/ui/println_empty_string.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::match_single_binding)] fn main() { diff --git a/tests/ui/println_empty_string.rs b/tests/ui/println_empty_string.rs index 80fdb3e6e210..fd86e2543cc1 100644 --- a/tests/ui/println_empty_string.rs +++ b/tests/ui/println_empty_string.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::match_single_binding)] fn main() { diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index 3cc8bb947bd3..a79477d0d5c3 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -1,4 +1,4 @@ -error: empty string literal in `println!` +warning: empty string literal in `println!` --> $DIR/println_empty_string.rs:6:5 | LL | println!(""); @@ -6,9 +6,9 @@ LL | println!(""); | | | help: remove the empty string | - = note: `-D clippy::println-empty-string` implied by `-D warnings` + = note: `#[warn(clippy::println_empty_string)]` on by default -error: empty string literal in `println!` +warning: empty string literal in `println!` --> $DIR/println_empty_string.rs:9:14 | LL | _ => println!(""), @@ -16,7 +16,7 @@ LL | _ => println!(""), | | | help: remove the empty string -error: empty string literal in `eprintln!` +warning: empty string literal in `eprintln!` --> $DIR/println_empty_string.rs:13:5 | LL | eprintln!(""); @@ -24,7 +24,7 @@ LL | eprintln!(""); | | | help: remove the empty string -error: empty string literal in `eprintln!` +warning: empty string literal in `eprintln!` --> $DIR/println_empty_string.rs:16:14 | LL | _ => eprintln!(""), @@ -32,5 +32,5 @@ LL | _ => eprintln!(""), | | | help: remove the empty string -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/proc_macro.rs b/tests/ui/proc_macro.rs index 59914b8b8f62..c846ac7f6182 100644 --- a/tests/ui/proc_macro.rs +++ b/tests/ui/proc_macro.rs @@ -7,7 +7,7 @@ use proc_macro::TokenStream; #[allow(dead_code)] fn f() { - let _x = 3.14; + let _x = 3.14; //~ ERROR: approximate value of } #[proc_macro] diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index 6b4de98ce88c..b51c2d80ef14 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,48 +1,52 @@ -error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do +warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:8:14 | LL | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` | - = note: `-D clippy::ptr-arg` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ptr_arg.rs:3:9 + | +LL | #![warn(clippy::ptr_arg)] + | ^^^^^^^^^^^^^^^ -error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do +warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:12:18 | LL | fn do_vec_mut(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` -error: writing `&String` instead of `&str` involves a new object where a slice will do +warning: writing `&String` instead of `&str` involves a new object where a slice will do --> $DIR/ptr_arg.rs:16:14 | LL | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` -error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do +warning: writing `&mut String` instead of `&mut str` involves a new object where a slice will do --> $DIR/ptr_arg.rs:20:18 | LL | fn do_str_mut(x: &mut String) { | ^^^^^^^^^^^ help: change this to: `&mut str` -error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do +warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do --> $DIR/ptr_arg.rs:24:15 | LL | fn do_path(x: &PathBuf) { | ^^^^^^^^ help: change this to: `&Path` -error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do +warning: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do --> $DIR/ptr_arg.rs:28:19 | LL | fn do_path_mut(x: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` -error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do +warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:36:18 | LL | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` -error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do +warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:49:14 | LL | fn cloned(x: &Vec) -> Vec { @@ -59,7 +63,7 @@ LL | let i = (e).clone(); LL ~ x.to_owned() | -error: writing `&String` instead of `&str` involves a new object where a slice will do +warning: writing `&String` instead of `&str` involves a new object where a slice will do --> $DIR/ptr_arg.rs:58:18 | LL | fn str_cloned(x: &String) -> String { @@ -75,7 +79,7 @@ LL | let d = a.clone().clone().clone(); LL ~ x.to_owned() | -error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do +warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do --> $DIR/ptr_arg.rs:66:19 | LL | fn path_cloned(x: &PathBuf) -> PathBuf { @@ -91,7 +95,7 @@ LL | let d = a.clone().clone().clone(); LL ~ x.to_path_buf() | -error: writing `&String` instead of `&str` involves a new object where a slice will do +warning: writing `&String` instead of `&str` involves a new object where a slice will do --> $DIR/ptr_arg.rs:74:44 | LL | fn false_positive_capacity(x: &Vec, y: &String) { @@ -105,19 +109,19 @@ LL ~ let b = y.to_owned(); LL ~ let c = y; | -error: using a reference to `Cow` is not recommended +warning: using a reference to `Cow` is not recommended --> $DIR/ptr_arg.rs:88:25 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` -error: writing `&String` instead of `&str` involves a new object where a slice will do +warning: writing `&String` instead of `&str` involves a new object where a slice will do --> $DIR/ptr_arg.rs:117:66 | LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec, _s: &String) {} | ^^^^^^^ help: change this to: `&str` -error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do +warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:146:21 | LL | fn foo_vec(vec: &Vec) { @@ -130,7 +134,7 @@ LL ~ let _ = vec.to_owned().pop(); LL ~ let _ = vec.to_owned().clone(); | -error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do +warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do --> $DIR/ptr_arg.rs:151:23 | LL | fn foo_path(path: &PathBuf) { @@ -143,7 +147,7 @@ LL ~ let _ = path.to_path_buf().pop(); LL ~ let _ = path.to_path_buf().clone(); | -error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do +warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do --> $DIR/ptr_arg.rs:156:21 | LL | fn foo_str(str: &PathBuf) { @@ -156,29 +160,29 @@ LL ~ let _ = str.to_path_buf().pop(); LL ~ let _ = str.to_path_buf().clone(); | -error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do +warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:162:29 | LL | fn mut_vec_slice_methods(v: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` -error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do +warning: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do --> $DIR/ptr_arg.rs:224:17 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` -error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do +warning: writing `&mut String` instead of `&mut str` involves a new object where a slice will do --> $DIR/ptr_arg.rs:224:35 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^ help: change this to: `&mut str` -error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do +warning: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do --> $DIR/ptr_arg.rs:224:51 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/ptr_as_ptr.fixed b/tests/ui/ptr_as_ptr.fixed index df36a9b842bf..d7e4c397aa0d 100644 --- a/tests/ui/ptr_as_ptr.fixed +++ b/tests/ui/ptr_as_ptr.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::ptr_as_ptr)] @@ -7,7 +7,7 @@ extern crate macro_rules; macro_rules! cast_it { ($ptr: ident) => { - $ptr.cast::() + $ptr as *const i32 }; } diff --git a/tests/ui/ptr_as_ptr.rs b/tests/ui/ptr_as_ptr.rs index 302c66462d9b..bd44e20efbda 100644 --- a/tests/ui/ptr_as_ptr.rs +++ b/tests/ui/ptr_as_ptr.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::ptr_as_ptr)] diff --git a/tests/ui/ptr_as_ptr.stderr b/tests/ui/ptr_as_ptr.stderr index a68e1cab6d35..11b9bab96792 100644 --- a/tests/ui/ptr_as_ptr.stderr +++ b/tests/ui/ptr_as_ptr.stderr @@ -1,36 +1,40 @@ -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:18:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` | - = note: `-D clippy::ptr-as-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ptr_as_ptr.rs:4:9 + | +LL | #![warn(clippy::ptr_as_ptr)] + | ^^^^^^^^^^^^^^^^^^ -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:19:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:24:17 | LL | let _ = *ptr_ptr as *const i32; | ^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `(*ptr_ptr).cast::()` -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:37:25 | LL | let _: *const i32 = ptr as *const _; | ^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast()` -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:38:23 | LL | let _: *mut i32 = mut_ptr as _; | ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()` -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:10:9 | LL | $ptr as *const i32 @@ -39,19 +43,19 @@ LL | $ptr as *const i32 LL | let _ = cast_it!(ptr); | ------------- in this macro invocation | - = note: this error originates in the macro `cast_it` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `cast_it` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:62:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` -error: `as` casting between raw pointers without changing its mutability +warning: `as` casting between raw pointers without changing its mutability --> $DIR/ptr_as_ptr.rs:63:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/ptr_eq.fixed b/tests/ui/ptr_eq.fixed index 209081e6e801..d5fa273d41f0 100644 --- a/tests/ui/ptr_eq.fixed +++ b/tests/ui/ptr_eq.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::ptr_eq)] macro_rules! mac { diff --git a/tests/ui/ptr_eq.rs b/tests/ui/ptr_eq.rs index 69162870807a..e033366a4aab 100644 --- a/tests/ui/ptr_eq.rs +++ b/tests/ui/ptr_eq.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::ptr_eq)] macro_rules! mac { diff --git a/tests/ui/ptr_eq.stderr b/tests/ui/ptr_eq.stderr index 45d8c60382b5..c47ce1907847 100644 --- a/tests/ui/ptr_eq.stderr +++ b/tests/ui/ptr_eq.stderr @@ -1,16 +1,20 @@ -error: use `std::ptr::eq` when comparing raw pointers +warning: use `std::ptr::eq` when comparing raw pointers --> $DIR/ptr_eq.rs:20:13 | LL | let _ = a as *const _ as usize == b as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` | - = note: `-D clippy::ptr-eq` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ptr_eq.rs:2:9 + | +LL | #![warn(clippy::ptr_eq)] + | ^^^^^^^^^^^^^^ -error: use `std::ptr::eq` when comparing raw pointers +warning: use `std::ptr::eq` when comparing raw pointers --> $DIR/ptr_eq.rs:21:13 | LL | let _ = a as *const _ == b as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/ptr_offset_with_cast.fixed b/tests/ui/ptr_offset_with_cast.fixed index c57e2990fb95..f69bc131898f 100644 --- a/tests/ui/ptr_offset_with_cast.fixed +++ b/tests/ui/ptr_offset_with_cast.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::unnecessary_cast)] fn main() { diff --git a/tests/ui/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs index 3de7997acddd..eae36c27729e 100644 --- a/tests/ui/ptr_offset_with_cast.rs +++ b/tests/ui/ptr_offset_with_cast.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::unnecessary_cast)] fn main() { diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index 3ba40593d644..aa2776421c88 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -1,16 +1,16 @@ -error: use of `offset` with a `usize` casted to an `isize` +warning: use of `offset` with a `usize` casted to an `isize` --> $DIR/ptr_offset_with_cast.rs:13:17 | LL | let _ = ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` | - = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` + = note: `#[warn(clippy::ptr_offset_with_cast)]` on by default -error: use of `wrapping_offset` with a `usize` casted to an `isize` +warning: use of `wrapping_offset` with a `usize` casted to an `isize` --> $DIR/ptr_offset_with_cast.rs:17:17 | LL | let _ = ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/pub_use.stderr b/tests/ui/pub_use.stderr index ba4ee732c05c..980cae3c883f 100644 --- a/tests/ui/pub_use.stderr +++ b/tests/ui/pub_use.stderr @@ -1,11 +1,15 @@ -error: using `pub use` +warning: using `pub use` --> $DIR/pub_use.rs:10:5 | LL | pub use inner::Test; | ^^^^^^^^^^^^^^^^^^^^ | = help: move the exported item to a public module instead - = note: `-D clippy::pub-use` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/pub_use.rs:1:9 + | +LL | #![warn(clippy::pub_use)] + | ^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/question_mark.fixed b/tests/ui/question_mark.fixed index 5c49d46da726..7f1660f31fa5 100644 --- a/tests/ui/question_mark.fixed +++ b/tests/ui/question_mark.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unreachable_code)] #![allow(dead_code)] #![allow(clippy::unnecessary_wraps)] diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs index d057df6a9b35..a90eae50ed45 100644 --- a/tests/ui/question_mark.rs +++ b/tests/ui/question_mark.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unreachable_code)] #![allow(dead_code)] #![allow(clippy::unnecessary_wraps)] diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index 23172d7e535d..7f39b8222d34 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -1,4 +1,4 @@ -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:7:5 | LL | / if a.is_none() { @@ -6,9 +6,9 @@ LL | | return None; LL | | } | |_____^ help: replace it with: `a?;` | - = note: `-D clippy::question-mark` implied by `-D warnings` + = note: `#[warn(clippy::question_mark)]` on by default -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:52:9 | LL | / if (self.opt).is_none() { @@ -16,7 +16,7 @@ LL | | return None; LL | | } | |_________^ help: replace it with: `(self.opt)?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:56:9 | LL | / if self.opt.is_none() { @@ -24,7 +24,7 @@ LL | | return None LL | | } | |_________^ help: replace it with: `self.opt?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:60:17 | LL | let _ = if self.opt.is_none() { @@ -35,7 +35,7 @@ LL | | self.opt LL | | }; | |_________^ help: replace it with: `Some(self.opt?)` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:66:17 | LL | let _ = if let Some(x) = self.opt { @@ -46,7 +46,7 @@ LL | | return None; LL | | }; | |_________^ help: replace it with: `self.opt?` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:83:9 | LL | / if self.opt.is_none() { @@ -54,7 +54,7 @@ LL | | return None; LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:91:9 | LL | / if self.opt.is_none() { @@ -62,7 +62,7 @@ LL | | return None; LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:99:9 | LL | / if self.opt.is_none() { @@ -70,7 +70,7 @@ LL | | return None; LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:106:26 | LL | let v: &Vec<_> = if let Some(ref v) = self.opt { @@ -81,7 +81,7 @@ LL | | return None; LL | | }; | |_________^ help: replace it with: `self.opt.as_ref()?` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:116:17 | LL | let v = if let Some(v) = self.opt { @@ -92,7 +92,7 @@ LL | | return None; LL | | }; | |_________^ help: replace it with: `self.opt?` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:131:5 | LL | / if f().is_none() { @@ -100,13 +100,13 @@ LL | | return None; LL | | } | |_____^ help: replace it with: `f()?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:143:13 | LL | let _ = if let Ok(x) = x { x } else { return x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x?` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:145:5 | LL | / if x.is_err() { @@ -114,7 +114,7 @@ LL | | return x; LL | | } | |_____^ help: replace it with: `x?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:196:5 | LL | / if let Err(err) = func_returning_result() { @@ -122,7 +122,7 @@ LL | | return Err(err); LL | | } | |_____^ help: replace it with: `func_returning_result()?;` -error: this block may be rewritten with the `?` operator +warning: this block may be rewritten with the `?` operator --> $DIR/question_mark.rs:203:5 | LL | / if let Err(err) = func_returning_result() { @@ -130,5 +130,5 @@ LL | | return Err(err); LL | | } | |_____^ help: replace it with: `func_returning_result()?;` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/question_mark_used.stderr b/tests/ui/question_mark_used.stderr index 8b5fcbcdbfd6..f3e1e63e5656 100644 --- a/tests/ui/question_mark_used.stderr +++ b/tests/ui/question_mark_used.stderr @@ -1,11 +1,15 @@ -error: question mark operator was used +warning: question mark operator was used --> $DIR/question_mark_used.rs:11:5 | LL | other_function()?; | ^^^^^^^^^^^^^^^^^ | = help: consider using a custom macro or match expression - = note: `-D clippy::question-mark-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/question_mark_used.rs:4:9 + | +LL | #![warn(clippy::question_mark_used)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index dcb5061371f8..68c5e63012f4 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,10 +1,14 @@ -error: it is more idiomatic to use `v1.iter().enumerate()` +warning: it is more idiomatic to use `v1.iter().enumerate()` --> $DIR/range.rs:5:14 | LL | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::range-zip-with-len` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/range.rs:1:8 + | +LL | #[warn(clippy::range_zip_with_len)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/range_contains.fixed b/tests/ui/range_contains.fixed index 4923731fe45e..0a92ee7c8dd3 100644 --- a/tests/ui/range_contains.fixed +++ b/tests/ui/range_contains.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_range_contains)] #![allow(unused)] diff --git a/tests/ui/range_contains.rs b/tests/ui/range_contains.rs index d623ccb5da63..7a83be609571 100644 --- a/tests/ui/range_contains.rs +++ b/tests/ui/range_contains.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::manual_range_contains)] #![allow(unused)] diff --git a/tests/ui/range_contains.stderr b/tests/ui/range_contains.stderr index ea34023a4664..fce90a4607fc 100644 --- a/tests/ui/range_contains.stderr +++ b/tests/ui/range_contains.stderr @@ -1,130 +1,134 @@ -error: manual `Range::contains` implementation +warning: manual `Range::contains` implementation --> $DIR/range_contains.rs:13:5 | LL | x >= 8 && x < 12; | ^^^^^^^^^^^^^^^^ help: use: `(8..12).contains(&x)` | - = note: `-D clippy::manual-range-contains` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/range_contains.rs:3:9 + | +LL | #![warn(clippy::manual_range_contains)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual `Range::contains` implementation +warning: manual `Range::contains` implementation --> $DIR/range_contains.rs:14:5 | LL | x < 42 && x >= 21; | ^^^^^^^^^^^^^^^^^ help: use: `(21..42).contains(&x)` -error: manual `Range::contains` implementation +warning: manual `Range::contains` implementation --> $DIR/range_contains.rs:15:5 | LL | 100 > x && 1 <= x; | ^^^^^^^^^^^^^^^^^ help: use: `(1..100).contains(&x)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:18:5 | LL | x >= 9 && x <= 99; | ^^^^^^^^^^^^^^^^^ help: use: `(9..=99).contains(&x)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:19:5 | LL | x <= 33 && x >= 1; | ^^^^^^^^^^^^^^^^^ help: use: `(1..=33).contains(&x)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:20:5 | LL | 999 >= x && 1 <= x; | ^^^^^^^^^^^^^^^^^^ help: use: `(1..=999).contains(&x)` -error: manual `!Range::contains` implementation +warning: manual `!Range::contains` implementation --> $DIR/range_contains.rs:23:5 | LL | x < 8 || x >= 12; | ^^^^^^^^^^^^^^^^ help: use: `!(8..12).contains(&x)` -error: manual `!Range::contains` implementation +warning: manual `!Range::contains` implementation --> $DIR/range_contains.rs:24:5 | LL | x >= 42 || x < 21; | ^^^^^^^^^^^^^^^^^ help: use: `!(21..42).contains(&x)` -error: manual `!Range::contains` implementation +warning: manual `!Range::contains` implementation --> $DIR/range_contains.rs:25:5 | LL | 100 <= x || 1 > x; | ^^^^^^^^^^^^^^^^^ help: use: `!(1..100).contains(&x)` -error: manual `!RangeInclusive::contains` implementation +warning: manual `!RangeInclusive::contains` implementation --> $DIR/range_contains.rs:28:5 | LL | x < 9 || x > 99; | ^^^^^^^^^^^^^^^ help: use: `!(9..=99).contains(&x)` -error: manual `!RangeInclusive::contains` implementation +warning: manual `!RangeInclusive::contains` implementation --> $DIR/range_contains.rs:29:5 | LL | x > 33 || x < 1; | ^^^^^^^^^^^^^^^ help: use: `!(1..=33).contains(&x)` -error: manual `!RangeInclusive::contains` implementation +warning: manual `!RangeInclusive::contains` implementation --> $DIR/range_contains.rs:30:5 | LL | 999 < x || 1 > x; | ^^^^^^^^^^^^^^^^ help: use: `!(1..=999).contains(&x)` -error: manual `Range::contains` implementation +warning: manual `Range::contains` implementation --> $DIR/range_contains.rs:45:5 | LL | y >= 0. && y < 1.; | ^^^^^^^^^^^^^^^^^ help: use: `(0. ..1.).contains(&y)` -error: manual `!RangeInclusive::contains` implementation +warning: manual `!RangeInclusive::contains` implementation --> $DIR/range_contains.rs:46:5 | LL | y < 0. || y > 1.; | ^^^^^^^^^^^^^^^^ help: use: `!(0. ..=1.).contains(&y)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:49:5 | LL | x >= -10 && x <= 10; | ^^^^^^^^^^^^^^^^^^^ help: use: `(-10..=10).contains(&x)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:51:5 | LL | y >= -3. && y <= 3.; | ^^^^^^^^^^^^^^^^^^^ help: use: `(-3. ..=3.).contains(&y)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:56:30 | LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&z)` -error: manual `RangeInclusive::contains` implementation +warning: manual `RangeInclusive::contains` implementation --> $DIR/range_contains.rs:56:5 | LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&x)` -error: manual `!Range::contains` implementation +warning: manual `!Range::contains` implementation --> $DIR/range_contains.rs:57:29 | LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10); | ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&z)` -error: manual `!Range::contains` implementation +warning: manual `!Range::contains` implementation --> $DIR/range_contains.rs:57:5 | LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10); | ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&x)` -error: manual `Range::contains` implementation +warning: manual `Range::contains` implementation --> $DIR/range_contains.rs:76:5 | LL | x >= 8 && x < 35; | ^^^^^^^^^^^^^^^^ help: use: `(8..35).contains(&x)` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/range_plus_minus_one.fixed b/tests/ui/range_plus_minus_one.fixed index a16a3e54d45e..a18fd7de8886 100644 --- a/tests/ui/range_plus_minus_one.fixed +++ b/tests/ui/range_plus_minus_one.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_parens)] #![allow(clippy::iter_with_drain)] @@ -46,8 +46,8 @@ fn main() { let _ = ..11 - 1; let _ = ..11; let _ = ..11; - let _ = (1..=11); - let _ = ((f() + 1)..=f()); + let _ = (1..11 + 1); + let _ = (f() + 1)..(f() + 1); const ONE: usize = 1; // integer consts are linted, too diff --git a/tests/ui/range_plus_minus_one.rs b/tests/ui/range_plus_minus_one.rs index bd6cb4d21be5..689a6b7a17ce 100644 --- a/tests/ui/range_plus_minus_one.rs +++ b/tests/ui/range_plus_minus_one.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_parens)] #![allow(clippy::iter_with_drain)] diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index 0223696243b2..d4cfdc0830cb 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,60 +1,68 @@ -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:31:14 | LL | for _ in 0..3 + 1 {} | ^^^^^^^^ help: use: `0..=3` | - = note: `-D clippy::range-plus-one` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/range_plus_minus_one.rs:25:8 + | +LL | #[warn(clippy::range_plus_one)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:34:14 | LL | for _ in 0..1 + 5 {} | ^^^^^^^^ help: use: `0..=5` -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:37:14 | LL | for _ in 1..1 + 1 {} | ^^^^^^^^ help: use: `1..=1` -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:43:14 | LL | for _ in 0..(1 + f()) {} | ^^^^^^^^^^^^ help: use: `0..=f()` -error: an exclusive range would be more readable +warning: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:47:13 | LL | let _ = ..=11 - 1; | ^^^^^^^^^ help: use: `..11` | - = note: `-D clippy::range-minus-one` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/range_plus_minus_one.rs:26:8 + | +LL | #[warn(clippy::range_minus_one)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: an exclusive range would be more readable +warning: an exclusive range would be more readable --> $DIR/range_plus_minus_one.rs:48:13 | LL | let _ = ..=(11 - 1); | ^^^^^^^^^^^ help: use: `..11` -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:49:13 | LL | let _ = (1..11 + 1); | ^^^^^^^^^^^ help: use: `(1..=11)` -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:50:13 | LL | let _ = (f() + 1)..(f() + 1); | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` -error: an inclusive range would be more readable +warning: an inclusive range would be more readable --> $DIR/range_plus_minus_one.rs:54:14 | LL | for _ in 1..ONE + ONE {} | ^^^^^^^^^^^^ help: use: `1..=ONE` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/rc_buffer.fixed b/tests/ui/rc_buffer.fixed index 8910c01b1fcf..d8a9aa2786d4 100644 --- a/tests/ui/rc_buffer.fixed +++ b/tests/ui/rc_buffer.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::rc_buffer)] #![allow(dead_code, unused_imports)] @@ -9,19 +9,19 @@ use std::rc::Rc; struct S { // triggers lint - bad1: Rc, - bad2: Rc, - bad3: Rc<[u8]>, - bad4: Rc, + bad1: Rc, + bad2: Rc, + bad3: Rc>, + bad4: Rc, // does not trigger lint good1: Rc>, } // triggers lint -fn func_bad1(_: Rc) {} -fn func_bad2(_: Rc) {} -fn func_bad3(_: Rc<[u8]>) {} -fn func_bad4(_: Rc) {} +fn func_bad1(_: Rc) {} +fn func_bad2(_: Rc) {} +fn func_bad3(_: Rc>) {} +fn func_bad4(_: Rc) {} // does not trigger lint fn func_good1(_: Rc>) {} diff --git a/tests/ui/rc_buffer.rs b/tests/ui/rc_buffer.rs index 1e63a43262ec..d8a9aa2786d4 100644 --- a/tests/ui/rc_buffer.rs +++ b/tests/ui/rc_buffer.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::rc_buffer)] #![allow(dead_code, unused_imports)] diff --git a/tests/ui/rc_buffer.stderr b/tests/ui/rc_buffer.stderr index 9ed028e3df41..270019c0d5c0 100644 --- a/tests/ui/rc_buffer.stderr +++ b/tests/ui/rc_buffer.stderr @@ -1,52 +1,56 @@ -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:12:11 | LL | bad1: Rc, | ^^^^^^^^^^ help: try: `Rc` | - = note: `-D clippy::rc-buffer` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/rc_buffer.rs:2:9 + | +LL | #![warn(clippy::rc_buffer)] + | ^^^^^^^^^^^^^^^^^ -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:13:11 | LL | bad2: Rc, | ^^^^^^^^^^^ help: try: `Rc` -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:14:11 | LL | bad3: Rc>, | ^^^^^^^^^^^ help: try: `Rc<[u8]>` -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:15:11 | LL | bad4: Rc, | ^^^^^^^^^^^^ help: try: `Rc` -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:21:17 | LL | fn func_bad1(_: Rc) {} | ^^^^^^^^^^ help: try: `Rc` -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:22:17 | LL | fn func_bad2(_: Rc) {} | ^^^^^^^^^^^ help: try: `Rc` -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:23:17 | LL | fn func_bad3(_: Rc>) {} | ^^^^^^^^^^^ help: try: `Rc<[u8]>` -error: usage of `Rc` when T is a buffer type +warning: usage of `Rc` when T is a buffer type --> $DIR/rc_buffer.rs:24:17 | LL | fn func_bad4(_: Rc) {} | ^^^^^^^^^^^^ help: try: `Rc` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/rc_buffer_arc.fixed b/tests/ui/rc_buffer_arc.fixed index 13dd6f5fcd18..21dc27bc5fa5 100644 --- a/tests/ui/rc_buffer_arc.fixed +++ b/tests/ui/rc_buffer_arc.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::rc_buffer)] #![allow(dead_code, unused_imports)] @@ -8,19 +8,19 @@ use std::sync::{Arc, Mutex}; struct S { // triggers lint - bad1: Arc, - bad2: Arc, - bad3: Arc<[u8]>, - bad4: Arc, + bad1: Arc, + bad2: Arc, + bad3: Arc>, + bad4: Arc, // does not trigger lint good1: Arc>, } // triggers lint -fn func_bad1(_: Arc) {} -fn func_bad2(_: Arc) {} -fn func_bad3(_: Arc<[u8]>) {} -fn func_bad4(_: Arc) {} +fn func_bad1(_: Arc) {} +fn func_bad2(_: Arc) {} +fn func_bad3(_: Arc>) {} +fn func_bad4(_: Arc) {} // does not trigger lint fn func_good1(_: Arc>) {} diff --git a/tests/ui/rc_buffer_arc.rs b/tests/ui/rc_buffer_arc.rs index 1a521bfeb7c8..21dc27bc5fa5 100644 --- a/tests/ui/rc_buffer_arc.rs +++ b/tests/ui/rc_buffer_arc.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::rc_buffer)] #![allow(dead_code, unused_imports)] diff --git a/tests/ui/rc_buffer_arc.stderr b/tests/ui/rc_buffer_arc.stderr index 911feea73529..1edc74db304a 100644 --- a/tests/ui/rc_buffer_arc.stderr +++ b/tests/ui/rc_buffer_arc.stderr @@ -1,52 +1,56 @@ -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:11:11 | LL | bad1: Arc, | ^^^^^^^^^^^ help: try: `Arc` | - = note: `-D clippy::rc-buffer` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/rc_buffer_arc.rs:2:9 + | +LL | #![warn(clippy::rc_buffer)] + | ^^^^^^^^^^^^^^^^^ -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:12:11 | LL | bad2: Arc, | ^^^^^^^^^^^^ help: try: `Arc` -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:13:11 | LL | bad3: Arc>, | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:14:11 | LL | bad4: Arc, | ^^^^^^^^^^^^^ help: try: `Arc` -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:20:17 | LL | fn func_bad1(_: Arc) {} | ^^^^^^^^^^^ help: try: `Arc` -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:21:17 | LL | fn func_bad2(_: Arc) {} | ^^^^^^^^^^^^ help: try: `Arc` -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:22:17 | LL | fn func_bad3(_: Arc>) {} | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` -error: usage of `Arc` when T is a buffer type +warning: usage of `Arc` when T is a buffer type --> $DIR/rc_buffer_arc.rs:23:17 | LL | fn func_bad4(_: Arc) {} | ^^^^^^^^^^^^^ help: try: `Arc` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/rc_clone_in_vec_init/arc.stderr b/tests/ui/rc_clone_in_vec_init/arc.stderr index 7814f5b54036..0bb9f7ce663f 100644 --- a/tests/ui/rc_clone_in_vec_init/arc.stderr +++ b/tests/ui/rc_clone_in_vec_init/arc.stderr @@ -1,11 +1,15 @@ -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/arc.rs:7:13 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: each element will point to the same `Arc` instance - = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/arc.rs:1:9 + | +LL | #![warn(clippy::rc_clone_in_vec_init)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider initializing each `Arc` element individually | LL ~ let v = { @@ -22,7 +26,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/arc.rs:15:21 | LL | let v = vec![Arc::new("x".to_string()); 2]; @@ -45,7 +49,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/arc.rs:21:13 | LL | let v = vec![ @@ -75,7 +79,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/arc.rs:30:14 | LL | let v1 = vec![ @@ -105,5 +109,5 @@ LL + vec![data; 2] LL ~ }; | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/rc_clone_in_vec_init/rc.stderr b/tests/ui/rc_clone_in_vec_init/rc.stderr index 80deb7cb9f24..d442bf2e1762 100644 --- a/tests/ui/rc_clone_in_vec_init/rc.stderr +++ b/tests/ui/rc_clone_in_vec_init/rc.stderr @@ -1,11 +1,15 @@ -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/rc.rs:8:13 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: each element will point to the same `Rc` instance - = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/rc.rs:1:9 + | +LL | #![warn(clippy::rc_clone_in_vec_init)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider initializing each `Rc` element individually | LL ~ let v = { @@ -22,7 +26,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/rc.rs:16:21 | LL | let v = vec![Rc::new("x".to_string()); 2]; @@ -45,7 +49,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/rc.rs:22:13 | LL | let v = vec![ @@ -75,7 +79,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/rc.rs:31:14 | LL | let v1 = vec![ @@ -105,5 +109,5 @@ LL + vec![data; 2] LL ~ }; | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/rc_clone_in_vec_init/weak.stderr b/tests/ui/rc_clone_in_vec_init/weak.stderr index 789e14a302f6..7fb175744020 100644 --- a/tests/ui/rc_clone_in_vec_init/weak.stderr +++ b/tests/ui/rc_clone_in_vec_init/weak.stderr @@ -1,11 +1,15 @@ -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:8:13 | LL | let v = vec![SyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: each element will point to the same `Weak` instance - = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/weak.rs:1:9 + | +LL | #![warn(clippy::rc_clone_in_vec_init)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider initializing each `Weak` element individually | LL ~ let v = { @@ -22,7 +26,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:9:14 | LL | let v2 = vec![UnSyncWeak::::new(); 2]; @@ -45,7 +49,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:11:13 | LL | let v = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; @@ -68,7 +72,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:12:13 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; @@ -91,7 +95,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:20:21 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; @@ -114,7 +118,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:21:22 | LL | let v2 = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; @@ -137,7 +141,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:27:13 | LL | let v = vec![ @@ -167,7 +171,7 @@ LL + vec![data; 2] LL ~ }; | -error: initializing a reference-counted pointer in `vec![elem; len]` +warning: initializing a reference-counted pointer in `vec![elem; len]` --> $DIR/weak.rs:36:14 | LL | let v1 = vec![ @@ -197,5 +201,5 @@ LL + vec![data; 2] LL ~ }; | -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/rc_mutex.stderr b/tests/ui/rc_mutex.stderr index cee3bd8b224d..c805d4dd746f 100644 --- a/tests/ui/rc_mutex.stderr +++ b/tests/ui/rc_mutex.stderr @@ -1,13 +1,17 @@ -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/rc_mutex.rs:8:10 | LL | foo: Rc>, | ^^^^^^^^^^^^^^ | = help: consider using `Rc>` or `Arc>` instead - = note: `-D clippy::rc-mutex` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/rc_mutex.rs:1:9 + | +LL | #![warn(clippy::rc_mutex)] + | ^^^^^^^^^^^^^^^^ -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/rc_mutex.rs:26:18 | LL | fn test1(foo: Rc>) {} @@ -15,7 +19,7 @@ LL | fn test1(foo: Rc>) {} | = help: consider using `Rc>` or `Arc>` instead -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/rc_mutex.rs:27:15 | LL | fn test2(foo: Rc>) {} @@ -23,7 +27,7 @@ LL | fn test2(foo: Rc>) {} | = help: consider using `Rc>` or `Arc>` instead -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/rc_mutex.rs:28:15 | LL | fn test3(foo: Rc>>) {} @@ -31,5 +35,5 @@ LL | fn test3(foo: Rc>>) {} | = help: consider using `Rc>` or `Arc>` instead -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/read_zero_byte_vec.stderr b/tests/ui/read_zero_byte_vec.stderr index 08ba9753d7c4..1cb590833ba9 100644 --- a/tests/ui/read_zero_byte_vec.stderr +++ b/tests/ui/read_zero_byte_vec.stderr @@ -1,64 +1,68 @@ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:17:5 | LL | f.read_exact(&mut data).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data.resize(20, 0); f.read_exact(&mut data).unwrap();` | - = note: `-D clippy::read-zero-byte-vec` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/read_zero_byte_vec.rs:1:9 + | +LL | #![warn(clippy::read_zero_byte_vec)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:21:5 | LL | f.read_exact(&mut data2)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data2.resize(cap, 0); f.read_exact(&mut data2)?;` -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:25:5 | LL | f.read_exact(&mut data3)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:29:5 | LL | let _ = f.read(&mut data4)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:34:9 | LL | f.read(&mut data5) | ^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:40:9 | LL | f.read(&mut data6) | ^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:70:5 | LL | r.read(&mut data).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:74:5 | LL | r.read_exact(&mut data2).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:80:5 | LL | r.read(&mut data).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: reading zero byte data to `Vec` +warning: reading zero byte data to `Vec` --> $DIR/read_zero_byte_vec.rs:84:5 | LL | r.read_exact(&mut data2).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/recursive_format_impl.stderr b/tests/ui/recursive_format_impl.stderr index 8a58b9a3b178..67d000c02a4d 100644 --- a/tests/ui/recursive_format_impl.stderr +++ b/tests/ui/recursive_format_impl.stderr @@ -1,82 +1,86 @@ -error: using `self.to_string` in `fmt::Display` implementation will cause infinite recursion +warning: using `self.to_string` in `fmt::Display` implementation will cause infinite recursion --> $DIR/recursive_format_impl.rs:31:25 | LL | write!(f, "{}", self.to_string()) | ^^^^^^^^^^^^^^^^ | - = note: `-D clippy::recursive-format-impl` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/recursive_format_impl.rs:1:9 + | +LL | #![warn(clippy::recursive_format_impl)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:75:9 | LL | write!(f, "{}", self) | ^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:84:9 | LL | write!(f, "{}", &self) | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Debug` in `impl Debug` will cause infinite recursion +warning: using `self` as `Debug` in `impl Debug` will cause infinite recursion --> $DIR/recursive_format_impl.rs:90:9 | LL | write!(f, "{:?}", &self) | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:99:9 | LL | write!(f, "{}", &&&self) | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:173:9 | LL | write!(f, "{}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Debug` in `impl Debug` will cause infinite recursion +warning: using `self` as `Debug` in `impl Debug` will cause infinite recursion --> $DIR/recursive_format_impl.rs:179:9 | LL | write!(f, "{:?}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:195:9 | LL | write!(f, "{}", *self) | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:211:9 | LL | write!(f, "{}", **&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: using `self` as `Display` in `impl Display` will cause infinite recursion +warning: using `self` as `Display` in `impl Display` will cause infinite recursion --> $DIR/recursive_format_impl.rs:227:9 | LL | write!(f, "{}", &&**&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/redundant_allocation.stderr b/tests/ui/redundant_allocation.stderr index e0826fefa6cf..5cfb9c4b87f3 100644 --- a/tests/ui/redundant_allocation.stderr +++ b/tests/ui/redundant_allocation.stderr @@ -1,4 +1,4 @@ -error: usage of `Box>` +warning: usage of `Box>` --> $DIR/redundant_allocation.rs:17:30 | LL | pub fn box_test6(foo: Box>) {} @@ -6,9 +6,14 @@ LL | pub fn box_test6(foo: Box>) {} | = note: `Rc` is already on the heap, `Box>` makes an extra allocation = help: consider using just `Box` or `Rc` - = note: `-D clippy::redundant-allocation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_allocation.rs:1:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::redundant_allocation)]` implied by `#[warn(clippy::all)]` -error: usage of `Box>` +warning: usage of `Box>` --> $DIR/redundant_allocation.rs:19:30 | LL | pub fn box_test7(foo: Box>) {} @@ -17,7 +22,7 @@ LL | pub fn box_test7(foo: Box>) {} = note: `Arc` is already on the heap, `Box>` makes an extra allocation = help: consider using just `Box` or `Arc` -error: usage of `Box>>` +warning: usage of `Box>>` --> $DIR/redundant_allocation.rs:21:27 | LL | pub fn box_test8() -> Box>> { @@ -26,7 +31,7 @@ LL | pub fn box_test8() -> Box>> { = note: `Rc>` is already on the heap, `Box>>` makes an extra allocation = help: consider using just `Box>` or `Rc>` -error: usage of `Box>` +warning: usage of `Box>` --> $DIR/redundant_allocation.rs:25:30 | LL | pub fn box_test9(foo: Box>) -> Box>> { @@ -35,7 +40,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = note: `Arc` is already on the heap, `Box>` makes an extra allocation = help: consider using just `Box` or `Arc` -error: usage of `Box>>` +warning: usage of `Box>>` --> $DIR/redundant_allocation.rs:25:46 | LL | pub fn box_test9(foo: Box>) -> Box>> { @@ -44,7 +49,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = note: `Arc>` is already on the heap, `Box>>` makes an extra allocation = help: consider using just `Box>` or `Arc>` -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/redundant_allocation.rs:37:24 | LL | pub fn rc_test5(a: Rc>) {} @@ -53,7 +58,7 @@ LL | pub fn rc_test5(a: Rc>) {} = note: `Box` is already on the heap, `Rc>` makes an extra allocation = help: consider using just `Rc` or `Box` -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/redundant_allocation.rs:39:24 | LL | pub fn rc_test7(a: Rc>) {} @@ -62,7 +67,7 @@ LL | pub fn rc_test7(a: Rc>) {} = note: `Arc` is already on the heap, `Rc>` makes an extra allocation = help: consider using just `Rc` or `Arc` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:41:26 | LL | pub fn rc_test8() -> Rc>> { @@ -71,7 +76,7 @@ LL | pub fn rc_test8() -> Rc>> { = note: `Box>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Box>` -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/redundant_allocation.rs:45:29 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { @@ -80,7 +85,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = note: `Arc` is already on the heap, `Rc>` makes an extra allocation = help: consider using just `Rc` or `Arc` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:45:44 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { @@ -89,7 +94,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = note: `Arc>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Arc>` -error: usage of `Arc>` +warning: usage of `Arc>` --> $DIR/redundant_allocation.rs:57:25 | LL | pub fn arc_test5(a: Arc>) {} @@ -98,7 +103,7 @@ LL | pub fn arc_test5(a: Arc>) {} = note: `Box` is already on the heap, `Arc>` makes an extra allocation = help: consider using just `Arc` or `Box` -error: usage of `Arc>` +warning: usage of `Arc>` --> $DIR/redundant_allocation.rs:59:25 | LL | pub fn arc_test6(a: Arc>) {} @@ -107,7 +112,7 @@ LL | pub fn arc_test6(a: Arc>) {} = note: `Rc` is already on the heap, `Arc>` makes an extra allocation = help: consider using just `Arc` or `Rc` -error: usage of `Arc>>` +warning: usage of `Arc>>` --> $DIR/redundant_allocation.rs:61:27 | LL | pub fn arc_test8() -> Arc>> { @@ -116,7 +121,7 @@ LL | pub fn arc_test8() -> Arc>> { = note: `Box>` is already on the heap, `Arc>>` makes an extra allocation = help: consider using just `Arc>` or `Box>` -error: usage of `Arc>` +warning: usage of `Arc>` --> $DIR/redundant_allocation.rs:65:30 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { @@ -125,7 +130,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = note: `Rc` is already on the heap, `Arc>` makes an extra allocation = help: consider using just `Arc` or `Rc` -error: usage of `Arc>>` +warning: usage of `Arc>>` --> $DIR/redundant_allocation.rs:65:45 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { @@ -134,7 +139,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = note: `Rc>` is already on the heap, `Arc>>` makes an extra allocation = help: consider using just `Arc>` or `Rc>` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:87:27 | LL | pub fn test_rc_box(_: Rc>>) {} @@ -143,7 +148,7 @@ LL | pub fn test_rc_box(_: Rc>>) {} = note: `Box>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Box>` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:119:31 | LL | pub fn test_rc_box_str(_: Rc>>) {} @@ -152,7 +157,7 @@ LL | pub fn test_rc_box_str(_: Rc>>) {} = note: `Box>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Box>` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:120:33 | LL | pub fn test_rc_box_slice(_: Rc>>) {} @@ -161,7 +166,7 @@ LL | pub fn test_rc_box_slice(_: Rc>>) {} = note: `Box>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Box>` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:121:32 | LL | pub fn test_rc_box_path(_: Rc>>) {} @@ -170,7 +175,7 @@ LL | pub fn test_rc_box_path(_: Rc>>) {} = note: `Box>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Box>` -error: usage of `Rc>>` +warning: usage of `Rc>>` --> $DIR/redundant_allocation.rs:122:34 | LL | pub fn test_rc_box_custom(_: Rc>>) {} @@ -179,5 +184,5 @@ LL | pub fn test_rc_box_custom(_: Rc>>) {} = note: `Box>` is already on the heap, `Rc>>` makes an extra allocation = help: consider using just `Rc>` or `Box>` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/redundant_allocation_fixable.fixed b/tests/ui/redundant_allocation_fixable.fixed index 6db02718c70b..c59422dd9660 100644 --- a/tests/ui/redundant_allocation_fixable.fixed +++ b/tests/ui/redundant_allocation_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::disallowed_names, unused_variables, dead_code)] @@ -23,15 +23,15 @@ mod outer_box { use std::rc::Rc; use std::sync::Arc; - pub fn box_test1(foo: &T) {} + pub fn box_test1(foo: Box<&T>) {} - pub fn box_test2(foo: &MyStruct) {} + pub fn box_test2(foo: Box<&MyStruct>) {} - pub fn box_test3(foo: &MyEnum) {} + pub fn box_test3(foo: Box<&MyEnum>) {} pub fn box_test4_neg(foo: Box>) {} - pub fn box_test5(foo: Box) {} + pub fn box_test5(foo: Box>) {} } mod outer_rc { @@ -42,15 +42,15 @@ mod outer_rc { use std::rc::Rc; use std::sync::Arc; - pub fn rc_test1(foo: &T) {} + pub fn rc_test1(foo: Rc<&T>) {} - pub fn rc_test2(foo: &MyStruct) {} + pub fn rc_test2(foo: Rc<&MyStruct>) {} - pub fn rc_test3(foo: &MyEnum) {} + pub fn rc_test3(foo: Rc<&MyEnum>) {} pub fn rc_test4_neg(foo: Rc>) {} - pub fn rc_test6(a: Rc) {} + pub fn rc_test6(a: Rc>) {} } mod outer_arc { @@ -61,15 +61,15 @@ mod outer_arc { use std::rc::Rc; use std::sync::Arc; - pub fn arc_test1(foo: &T) {} + pub fn arc_test1(foo: Arc<&T>) {} - pub fn arc_test2(foo: &MyStruct) {} + pub fn arc_test2(foo: Arc<&MyStruct>) {} - pub fn arc_test3(foo: &MyEnum) {} + pub fn arc_test3(foo: Arc<&MyEnum>) {} pub fn arc_test4_neg(foo: Arc>) {} - pub fn arc_test7(a: Arc) {} + pub fn arc_test7(a: Arc>) {} } fn main() {} diff --git a/tests/ui/redundant_allocation_fixable.rs b/tests/ui/redundant_allocation_fixable.rs index c15806f30c04..c59422dd9660 100644 --- a/tests/ui/redundant_allocation_fixable.rs +++ b/tests/ui/redundant_allocation_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::disallowed_names, unused_variables, dead_code)] diff --git a/tests/ui/redundant_allocation_fixable.stderr b/tests/ui/redundant_allocation_fixable.stderr index 8dd4a6a26874..72cd810a9305 100644 --- a/tests/ui/redundant_allocation_fixable.stderr +++ b/tests/ui/redundant_allocation_fixable.stderr @@ -1,13 +1,18 @@ -error: usage of `Box<&T>` +warning: usage of `Box<&T>` --> $DIR/redundant_allocation_fixable.rs:26:30 | LL | pub fn box_test1(foo: Box<&T>) {} | ^^^^^^^ help: try: `&T` | = note: `&T` is already a pointer, `Box<&T>` allocates a pointer on the heap - = note: `-D clippy::redundant-allocation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_allocation_fixable.rs:2:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::redundant_allocation)]` implied by `#[warn(clippy::all)]` -error: usage of `Box<&MyStruct>` +warning: usage of `Box<&MyStruct>` --> $DIR/redundant_allocation_fixable.rs:28:27 | LL | pub fn box_test2(foo: Box<&MyStruct>) {} @@ -15,7 +20,7 @@ LL | pub fn box_test2(foo: Box<&MyStruct>) {} | = note: `&MyStruct` is already a pointer, `Box<&MyStruct>` allocates a pointer on the heap -error: usage of `Box<&MyEnum>` +warning: usage of `Box<&MyEnum>` --> $DIR/redundant_allocation_fixable.rs:30:27 | LL | pub fn box_test3(foo: Box<&MyEnum>) {} @@ -23,7 +28,7 @@ LL | pub fn box_test3(foo: Box<&MyEnum>) {} | = note: `&MyEnum` is already a pointer, `Box<&MyEnum>` allocates a pointer on the heap -error: usage of `Box>` +warning: usage of `Box>` --> $DIR/redundant_allocation_fixable.rs:34:30 | LL | pub fn box_test5(foo: Box>) {} @@ -31,7 +36,7 @@ LL | pub fn box_test5(foo: Box>) {} | = note: `Box` is already on the heap, `Box>` makes an extra allocation -error: usage of `Rc<&T>` +warning: usage of `Rc<&T>` --> $DIR/redundant_allocation_fixable.rs:45:29 | LL | pub fn rc_test1(foo: Rc<&T>) {} @@ -39,7 +44,7 @@ LL | pub fn rc_test1(foo: Rc<&T>) {} | = note: `&T` is already a pointer, `Rc<&T>` allocates a pointer on the heap -error: usage of `Rc<&MyStruct>` +warning: usage of `Rc<&MyStruct>` --> $DIR/redundant_allocation_fixable.rs:47:26 | LL | pub fn rc_test2(foo: Rc<&MyStruct>) {} @@ -47,7 +52,7 @@ LL | pub fn rc_test2(foo: Rc<&MyStruct>) {} | = note: `&MyStruct` is already a pointer, `Rc<&MyStruct>` allocates a pointer on the heap -error: usage of `Rc<&MyEnum>` +warning: usage of `Rc<&MyEnum>` --> $DIR/redundant_allocation_fixable.rs:49:26 | LL | pub fn rc_test3(foo: Rc<&MyEnum>) {} @@ -55,7 +60,7 @@ LL | pub fn rc_test3(foo: Rc<&MyEnum>) {} | = note: `&MyEnum` is already a pointer, `Rc<&MyEnum>` allocates a pointer on the heap -error: usage of `Rc>` +warning: usage of `Rc>` --> $DIR/redundant_allocation_fixable.rs:53:24 | LL | pub fn rc_test6(a: Rc>) {} @@ -63,7 +68,7 @@ LL | pub fn rc_test6(a: Rc>) {} | = note: `Rc` is already on the heap, `Rc>` makes an extra allocation -error: usage of `Arc<&T>` +warning: usage of `Arc<&T>` --> $DIR/redundant_allocation_fixable.rs:64:30 | LL | pub fn arc_test1(foo: Arc<&T>) {} @@ -71,7 +76,7 @@ LL | pub fn arc_test1(foo: Arc<&T>) {} | = note: `&T` is already a pointer, `Arc<&T>` allocates a pointer on the heap -error: usage of `Arc<&MyStruct>` +warning: usage of `Arc<&MyStruct>` --> $DIR/redundant_allocation_fixable.rs:66:27 | LL | pub fn arc_test2(foo: Arc<&MyStruct>) {} @@ -79,7 +84,7 @@ LL | pub fn arc_test2(foo: Arc<&MyStruct>) {} | = note: `&MyStruct` is already a pointer, `Arc<&MyStruct>` allocates a pointer on the heap -error: usage of `Arc<&MyEnum>` +warning: usage of `Arc<&MyEnum>` --> $DIR/redundant_allocation_fixable.rs:68:27 | LL | pub fn arc_test3(foo: Arc<&MyEnum>) {} @@ -87,7 +92,7 @@ LL | pub fn arc_test3(foo: Arc<&MyEnum>) {} | = note: `&MyEnum` is already a pointer, `Arc<&MyEnum>` allocates a pointer on the heap -error: usage of `Arc>` +warning: usage of `Arc>` --> $DIR/redundant_allocation_fixable.rs:72:25 | LL | pub fn arc_test7(a: Arc>) {} @@ -95,5 +100,5 @@ LL | pub fn arc_test7(a: Arc>) {} | = note: `Arc` is already on the heap, `Arc>` makes an extra allocation -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/redundant_clone.fixed b/tests/ui/redundant_clone.fixed index 00b427450935..8bebb5183bc1 100644 --- a/tests/ui/redundant_clone.fixed +++ b/tests/ui/redundant_clone.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // rustfix-only-machine-applicable #![feature(lint_reasons)] #![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)] diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs index f899127db8d0..b4bd5d16b1a6 100644 --- a/tests/ui/redundant_clone.rs +++ b/tests/ui/redundant_clone.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // rustfix-only-machine-applicable #![feature(lint_reasons)] #![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)] diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index 782590034d05..9c8505d03b2a 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -1,4 +1,4 @@ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:10:42 | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); @@ -9,9 +9,9 @@ note: this value is dropped without further use | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::redundant-clone` implied by `-D warnings` + = note: `#[warn(clippy::redundant_clone)]` on by default -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:13:15 | LL | let _s = s.clone(); @@ -23,7 +23,7 @@ note: this value is dropped without further use LL | let _s = s.clone(); | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:16:15 | LL | let _s = s.to_string(); @@ -35,7 +35,7 @@ note: this value is dropped without further use LL | let _s = s.to_string(); | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:19:15 | LL | let _s = s.to_owned(); @@ -47,7 +47,7 @@ note: this value is dropped without further use LL | let _s = s.to_owned(); | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:21:42 | LL | let _s = Path::new("/a/b/").join("c").to_owned(); @@ -59,7 +59,7 @@ note: this value is dropped without further use LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:23:42 | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); @@ -71,7 +71,7 @@ note: this value is dropped without further use LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:25:29 | LL | let _s = OsString::new().to_owned(); @@ -83,7 +83,7 @@ note: this value is dropped without further use LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:27:29 | LL | let _s = OsString::new().to_os_string(); @@ -95,7 +95,7 @@ note: this value is dropped without further use LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:38:19 | LL | let _t = tup.0.clone(); @@ -107,7 +107,7 @@ note: this value is dropped without further use LL | let _t = tup.0.clone(); | ^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:70:25 | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } @@ -119,7 +119,7 @@ note: this value is dropped without further use LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:127:15 | LL | let _s = s.clone(); @@ -131,7 +131,7 @@ note: this value is dropped without further use LL | let _s = s.clone(); | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:128:15 | LL | let _t = t.clone(); @@ -143,7 +143,7 @@ note: this value is dropped without further use LL | let _t = t.clone(); | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:138:19 | LL | let _f = f.clone(); @@ -155,7 +155,7 @@ note: this value is dropped without further use LL | let _f = f.clone(); | ^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:150:14 | LL | let y = x.clone().join("matthias"); @@ -167,7 +167,7 @@ note: cloned value is neither consumed nor mutated LL | let y = x.clone().join("matthias"); | ^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/redundant_clone.rs:204:11 | LL | foo(&x.clone(), move || { @@ -179,5 +179,5 @@ note: this value is dropped without further use LL | foo(&x.clone(), move || { | ^ -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/redundant_closure_call_early.stderr b/tests/ui/redundant_closure_call_early.stderr index 2735e41738f0..0f3f402ae16b 100644 --- a/tests/ui/redundant_closure_call_early.stderr +++ b/tests/ui/redundant_closure_call_early.stderr @@ -1,16 +1,20 @@ -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_early.rs:9:17 | LL | let mut k = (|m| m + 1)(i); | ^^^^^^^^^^^^^^ | - = note: `-D clippy::redundant-closure-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_closure_call_early.rs:3:9 + | +LL | #![warn(clippy::redundant_closure_call)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_early.rs:12:9 | LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/redundant_closure_call_fixable.fixed b/tests/ui/redundant_closure_call_fixable.fixed index c0e49ff4caa7..703088b045fc 100644 --- a/tests/ui/redundant_closure_call_fixable.fixed +++ b/tests/ui/redundant_closure_call_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(async_closure)] #![warn(clippy::redundant_closure_call)] @@ -28,12 +28,12 @@ fn main() { macro_rules! m { () => { - 0 + (|| 0)() }; } macro_rules! m2 { () => { - m!() + (|| m!())() }; } m2!(); diff --git a/tests/ui/redundant_closure_call_fixable.rs b/tests/ui/redundant_closure_call_fixable.rs index 9e6e54348a8c..aafa4f9f2fcc 100644 --- a/tests/ui/redundant_closure_call_fixable.rs +++ b/tests/ui/redundant_closure_call_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(async_closure)] #![warn(clippy::redundant_closure_call)] diff --git a/tests/ui/redundant_closure_call_fixable.stderr b/tests/ui/redundant_closure_call_fixable.stderr index d71bcba2a820..7b850f404d2a 100644 --- a/tests/ui/redundant_closure_call_fixable.stderr +++ b/tests/ui/redundant_closure_call_fixable.stderr @@ -1,12 +1,16 @@ -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:16:13 | LL | let a = (|| 42)(); | ^^^^^^^^^ help: try doing something like: `42` | - = note: `-D clippy::redundant-closure-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_closure_call_fixable.rs:4:9 + | +LL | #![warn(clippy::redundant_closure_call)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:17:13 | LL | let b = (async || { @@ -26,7 +30,7 @@ LL + x * y LL ~ }; | -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:22:13 | LL | let c = (|| { @@ -46,13 +50,13 @@ LL + x * y LL ~ }; | -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:27:13 | LL | let d = (async || something().await)(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async { something().await }` -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:36:13 | LL | (|| m!())() @@ -61,9 +65,9 @@ LL | (|| m!())() LL | m2!(); | ----- in this macro invocation | - = note: this error originates in the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) -error: try not to call a closure in the expression where it is declared +warning: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:31:13 | LL | (|| 0)() @@ -72,7 +76,7 @@ LL | (|| 0)() LL | m2!(); | ----- in this macro invocation | - = note: this error originates in the macro `m` which comes from the expansion of the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `m` which comes from the expansion of the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/redundant_closure_call_late.stderr b/tests/ui/redundant_closure_call_late.stderr index 4eca43a2b599..b3285bf9d9bd 100644 --- a/tests/ui/redundant_closure_call_late.stderr +++ b/tests/ui/redundant_closure_call_late.stderr @@ -1,22 +1,26 @@ -error: closure called just once immediately after it was declared +warning: closure called just once immediately after it was declared --> $DIR/redundant_closure_call_late.rs:16:5 | LL | i = redun_closure(); | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::redundant-closure-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_closure_call_late.rs:3:9 + | +LL | #![warn(clippy::redundant_closure_call)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: closure called just once immediately after it was declared +warning: closure called just once immediately after it was declared --> $DIR/redundant_closure_call_late.rs:20:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ -error: closure called just once immediately after it was declared +warning: closure called just once immediately after it was declared --> $DIR/redundant_closure_call_late.rs:22:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/redundant_else.stderr b/tests/ui/redundant_else.stderr index de9d00a60246..80ef20c837e7 100644 --- a/tests/ui/redundant_else.stderr +++ b/tests/ui/redundant_else.stderr @@ -1,4 +1,4 @@ -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:10:16 | LL | } else { @@ -8,9 +8,13 @@ LL | | } | |_________^ | = help: remove the `else` block and move the contents out - = note: `-D clippy::redundant-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_else.rs:1:9 + | +LL | #![warn(clippy::redundant_else)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:17:16 | LL | } else { @@ -21,7 +25,7 @@ LL | | } | = help: remove the `else` block and move the contents out -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:26:16 | LL | } else { @@ -32,7 +36,7 @@ LL | | } | = help: remove the `else` block and move the contents out -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:35:12 | LL | } else { @@ -43,7 +47,7 @@ LL | | } | = help: remove the `else` block and move the contents out -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:42:16 | LL | } else { @@ -54,7 +58,7 @@ LL | | } | = help: remove the `else` block and move the contents out -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:52:16 | LL | } else { @@ -65,7 +69,7 @@ LL | | } | = help: remove the `else` block and move the contents out -error: redundant else block +warning: redundant else block --> $DIR/redundant_else.rs:61:16 | LL | } else { @@ -76,5 +80,5 @@ LL | | } | = help: remove the `else` block and move the contents out -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/redundant_field_names.fixed b/tests/ui/redundant_field_names.fixed index 276266a2dd80..d2a65399da65 100644 --- a/tests/ui/redundant_field_names.fixed +++ b/tests/ui/redundant_field_names.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::redundant_field_names)] #![allow(clippy::extra_unused_type_parameters, clippy::no_effect, dead_code, unused_variables)] diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index f674141c138e..605ffd21e2f7 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::redundant_field_names)] #![allow(clippy::extra_unused_type_parameters, clippy::no_effect, dead_code, unused_variables)] diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 00a72c50cf7d..26982e1d0729 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,52 +1,56 @@ -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:35:9 | LL | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` | - = note: `-D clippy::redundant-field-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_field_names.rs:3:9 + | +LL | #![warn(clippy::redundant_field_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:36:9 | LL | age: age, | ^^^^^^^^ help: replace it with: `age` -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:57:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:58:23 | LL | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:59:21 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:59:35 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:61:32 | LL | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` -error: redundant field names in struct initialization +warning: redundant field names in struct initialization --> $DIR/redundant_field_names.rs:83:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/redundant_pattern_matching_drop_order.fixed b/tests/ui/redundant_pattern_matching_drop_order.fixed index ce3229f17591..de7a5d06deb0 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.fixed +++ b/tests/ui/redundant_pattern_matching_drop_order.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // Issue #5746 #![warn(clippy::redundant_pattern_matching)] @@ -9,13 +9,13 @@ fn main() { let m = std::sync::Mutex::new((0, 0)); // Result - if m.lock().is_ok() {} - if Err::<(), _>(m.lock().unwrap().0).is_err() {} + if let Ok(_) = m.lock() {} + if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} { - if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {} + if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} } - if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() { + if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { } else { } if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {} @@ -25,13 +25,13 @@ fn main() { if Err::<(), _>((String::new(), ())).is_err() {} // Option - if Some(m.lock()).is_some() {} - if Some(m.lock().unwrap().0).is_some() {} + if let Some(_) = Some(m.lock()) {} + if let Some(_) = Some(m.lock().unwrap().0) {} { - if None::>.is_none() {} + if let None = None::> {} } - if None::>.is_none() { + if let None = None::> { } else { } @@ -41,13 +41,13 @@ fn main() { if Some((String::new(), ())).is_some() {} // Poll - if Ready(m.lock()).is_ready() {} - if Ready(m.lock().unwrap().0).is_ready() {} + if let Ready(_) = Ready(m.lock()) {} + if let Ready(_) = Ready(m.lock().unwrap().0) {} { - if Pending::>.is_pending() {} + if let Pending = Pending::> {} } - if Pending::>.is_pending() { + if let Pending = Pending::> { } else { } diff --git a/tests/ui/redundant_pattern_matching_drop_order.rs b/tests/ui/redundant_pattern_matching_drop_order.rs index 29b8543cf473..8fb6ed5f7eca 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.rs +++ b/tests/ui/redundant_pattern_matching_drop_order.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // Issue #5746 #![warn(clippy::redundant_pattern_matching)] diff --git a/tests/ui/redundant_pattern_matching_drop_order.stderr b/tests/ui/redundant_pattern_matching_drop_order.stderr index 23f08103f358..05230239d25a 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.stderr +++ b/tests/ui/redundant_pattern_matching_drop_order.stderr @@ -1,4 +1,4 @@ -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_drop_order.rs:12:12 | LL | if let Ok(_) = m.lock() {} @@ -6,9 +6,13 @@ LL | if let Ok(_) = m.lock() {} | = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_pattern_matching_drop_order.rs:4:9 + | +LL | #![warn(clippy::redundant_pattern_matching)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_drop_order.rs:13:12 | LL | if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} @@ -17,7 +21,7 @@ LL | if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_drop_order.rs:16:16 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} @@ -26,7 +30,7 @@ LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_drop_order.rs:18:12 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { @@ -35,31 +39,31 @@ LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_drop_order.rs:21:12 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} | -------^^^^^----------------------------------------- help: try this: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_drop_order.rs:22:12 | LL | if let Err(_) = Err::, _>(()) {} | -------^^^^^^------------------------------------------ help: try this: `if Err::, _>(()).is_err()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_drop_order.rs:24:12 | LL | if let Ok(_) = Ok::<_, ()>(String::new()) {} | -------^^^^^----------------------------- help: try this: `if Ok::<_, ()>(String::new()).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_drop_order.rs:25:12 | LL | if let Err(_) = Err::<(), _>((String::new(), ())) {} | -------^^^^^^------------------------------------ help: try this: `if Err::<(), _>((String::new(), ())).is_err()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_drop_order.rs:28:12 | LL | if let Some(_) = Some(m.lock()) {} @@ -68,7 +72,7 @@ LL | if let Some(_) = Some(m.lock()) {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_drop_order.rs:29:12 | LL | if let Some(_) = Some(m.lock().unwrap().0) {} @@ -77,7 +81,7 @@ LL | if let Some(_) = Some(m.lock().unwrap().0) {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_drop_order.rs:32:16 | LL | if let None = None::> {} @@ -86,7 +90,7 @@ LL | if let None = None::> {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_drop_order.rs:34:12 | LL | if let None = None::> { @@ -95,25 +99,25 @@ LL | if let None = None::> { = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_drop_order.rs:38:12 | LL | if let None = None::> {} | -------^^^^------------------------------------ help: try this: `if None::>.is_none()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_drop_order.rs:40:12 | LL | if let Some(_) = Some(String::new()) {} | -------^^^^^^^---------------------- help: try this: `if Some(String::new()).is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_drop_order.rs:41:12 | LL | if let Some(_) = Some((String::new(), ())) {} | -------^^^^^^^---------------------------- help: try this: `if Some((String::new(), ())).is_some()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_drop_order.rs:44:12 | LL | if let Ready(_) = Ready(m.lock()) {} @@ -122,7 +126,7 @@ LL | if let Ready(_) = Ready(m.lock()) {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_drop_order.rs:45:12 | LL | if let Ready(_) = Ready(m.lock().unwrap().0) {} @@ -131,7 +135,7 @@ LL | if let Ready(_) = Ready(m.lock().unwrap().0) {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_drop_order.rs:48:16 | LL | if let Pending = Pending::> {} @@ -140,7 +144,7 @@ LL | if let Pending = Pending::> {} = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_drop_order.rs:50:12 | LL | if let Pending = Pending::> { @@ -149,23 +153,23 @@ LL | if let Pending = Pending::> { = note: this will change drop order of the result, as well as all temporaries = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_drop_order.rs:54:12 | LL | if let Pending = Pending::> {} | -------^^^^^^^--------------------------------------- help: try this: `if Pending::>.is_pending()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_drop_order.rs:56:12 | LL | if let Ready(_) = Ready(String::new()) {} | -------^^^^^^^^----------------------- help: try this: `if Ready(String::new()).is_ready()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_drop_order.rs:57:12 | LL | if let Ready(_) = Ready((String::new(), ())) {} | -------^^^^^^^^----------------------------- help: try this: `if Ready((String::new(), ())).is_ready()` -error: aborting due to 22 previous errors +warning: 22 warnings emitted diff --git a/tests/ui/redundant_pattern_matching_ipaddr.fixed b/tests/ui/redundant_pattern_matching_ipaddr.fixed index 21bae909555c..fc2ff5c9ef54 100644 --- a/tests/ui/redundant_pattern_matching_ipaddr.fixed +++ b/tests/ui/redundant_pattern_matching_ipaddr.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all, clippy::redundant_pattern_matching)] #![allow(unused_must_use)] #![allow( @@ -32,13 +32,25 @@ fn main() { println!("{}", ipaddr); } - V4(Ipv4Addr::LOCALHOST).is_ipv4(); + match V4(Ipv4Addr::LOCALHOST) { + V4(_) => true, + V6(_) => false, + }; - V4(Ipv4Addr::LOCALHOST).is_ipv6(); + match V4(Ipv4Addr::LOCALHOST) { + V4(_) => false, + V6(_) => true, + }; - V6(Ipv6Addr::LOCALHOST).is_ipv6(); + match V6(Ipv6Addr::LOCALHOST) { + V4(_) => false, + V6(_) => true, + }; - V6(Ipv6Addr::LOCALHOST).is_ipv4(); + match V6(Ipv6Addr::LOCALHOST) { + V4(_) => true, + V6(_) => false, + }; let _ = if V4(Ipv4Addr::LOCALHOST).is_ipv4() { true @@ -70,7 +82,13 @@ const fn ipaddr_const() { while V6(Ipv6Addr::LOCALHOST).is_ipv6() {} - V4(Ipv4Addr::LOCALHOST).is_ipv4(); + match V4(Ipv4Addr::LOCALHOST) { + V4(_) => true, + V6(_) => false, + }; - V6(Ipv6Addr::LOCALHOST).is_ipv6(); + match V6(Ipv6Addr::LOCALHOST) { + V4(_) => false, + V6(_) => true, + }; } diff --git a/tests/ui/redundant_pattern_matching_ipaddr.rs b/tests/ui/redundant_pattern_matching_ipaddr.rs index 4dd9171677ec..574671d03d1c 100644 --- a/tests/ui/redundant_pattern_matching_ipaddr.rs +++ b/tests/ui/redundant_pattern_matching_ipaddr.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all, clippy::redundant_pattern_matching)] #![allow(unused_must_use)] #![allow( diff --git a/tests/ui/redundant_pattern_matching_ipaddr.stderr b/tests/ui/redundant_pattern_matching_ipaddr.stderr index 536b589de54c..34ab71231603 100644 --- a/tests/ui/redundant_pattern_matching_ipaddr.stderr +++ b/tests/ui/redundant_pattern_matching_ipaddr.stderr @@ -1,36 +1,40 @@ -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:17:12 | LL | if let V4(_) = &ipaddr {} | -------^^^^^---------- help: try this: `if ipaddr.is_ipv4()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_pattern_matching_ipaddr.rs:2:22 + | +LL | #![warn(clippy::all, clippy::redundant_pattern_matching)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:19:12 | LL | if let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try this: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:21:12 | LL | if let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try this: `if V6(Ipv6Addr::LOCALHOST).is_ipv6()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:23:15 | LL | while let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try this: `while V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:25:15 | LL | while let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try this: `while V6(Ipv6Addr::LOCALHOST).is_ipv6()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:35:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { @@ -39,7 +43,7 @@ LL | | V6(_) => false, LL | | }; | |_____^ help: try this: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:40:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { @@ -48,7 +52,7 @@ LL | | V6(_) => true, LL | | }; | |_____^ help: try this: `V4(Ipv4Addr::LOCALHOST).is_ipv6()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:45:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { @@ -57,7 +61,7 @@ LL | | V6(_) => true, LL | | }; | |_____^ help: try this: `V6(Ipv6Addr::LOCALHOST).is_ipv6()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:50:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { @@ -66,49 +70,49 @@ LL | | V6(_) => false, LL | | }; | |_____^ help: try this: `V6(Ipv6Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:55:20 | LL | let _ = if let V4(_) = V4(Ipv4Addr::LOCALHOST) { | -------^^^^^-------------------------- help: try this: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:63:20 | LL | let _ = if let V4(_) = gen_ipaddr() { | -------^^^^^--------------- help: try this: `if gen_ipaddr().is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:65:19 | LL | } else if let V6(_) = gen_ipaddr() { | -------^^^^^--------------- help: try this: `if gen_ipaddr().is_ipv6()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:77:12 | LL | if let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try this: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:79:12 | LL | if let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try this: `if V6(Ipv6Addr::LOCALHOST).is_ipv6()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:81:15 | LL | while let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try this: `while V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:83:15 | LL | while let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try this: `while V6(Ipv6Addr::LOCALHOST).is_ipv6()` -error: redundant pattern matching, consider using `is_ipv4()` +warning: redundant pattern matching, consider using `is_ipv4()` --> $DIR/redundant_pattern_matching_ipaddr.rs:85:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { @@ -117,7 +121,7 @@ LL | | V6(_) => false, LL | | }; | |_____^ help: try this: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` -error: redundant pattern matching, consider using `is_ipv6()` +warning: redundant pattern matching, consider using `is_ipv6()` --> $DIR/redundant_pattern_matching_ipaddr.rs:90:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { @@ -126,5 +130,5 @@ LL | | V6(_) => true, LL | | }; | |_____^ help: try this: `V6(Ipv6Addr::LOCALHOST).is_ipv6()` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/redundant_pattern_matching_option.fixed b/tests/ui/redundant_pattern_matching_option.fixed index a89845c1dd32..1dc245847404 100644 --- a/tests/ui/redundant_pattern_matching_option.fixed +++ b/tests/ui/redundant_pattern_matching_option.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] @@ -36,11 +36,20 @@ fn main() { if Some(42).is_some() {} - Some(42).is_some(); + match Some(42) { + Some(_) => true, + None => false, + }; - None::<()>.is_none(); + match None::<()> { + Some(_) => false, + None => true, + }; - let _ = None::<()>.is_none(); + let _ = match None::<()> { + Some(_) => false, + None => true, + }; let opt = Some(false); let _ = if opt.is_some() { true } else { false }; @@ -76,9 +85,15 @@ const fn issue6067() { while None::<()>.is_none() {} - Some(42).is_some(); + match Some(42) { + Some(_) => true, + None => false, + }; - None::<()>.is_none(); + match None::<()> { + Some(_) => false, + None => true, + }; } #[allow(clippy::deref_addrof, dead_code, clippy::needless_borrow)] diff --git a/tests/ui/redundant_pattern_matching_option.rs b/tests/ui/redundant_pattern_matching_option.rs index d6f44403487e..0b69e13f6559 100644 --- a/tests/ui/redundant_pattern_matching_option.rs +++ b/tests/ui/redundant_pattern_matching_option.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] diff --git a/tests/ui/redundant_pattern_matching_option.stderr b/tests/ui/redundant_pattern_matching_option.stderr index 27ff812ba45e..95fe8f849350 100644 --- a/tests/ui/redundant_pattern_matching_option.stderr +++ b/tests/ui/redundant_pattern_matching_option.stderr @@ -1,48 +1,52 @@ -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:14:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try this: `if None::<()>.is_none()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_pattern_matching_option.rs:4:9 + | +LL | #![warn(clippy::redundant_pattern_matching)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:16:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try this: `if Some(42).is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:18:12 | LL | if let Some(_) = Some(42) { | -------^^^^^^^----------- help: try this: `if Some(42).is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:24:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try this: `while Some(42).is_some()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:26:15 | LL | while let None = Some(42) {} | ----------^^^^----------- help: try this: `while Some(42).is_none()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:28:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try this: `while None::<()>.is_none()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:31:15 | LL | while let Some(_) = v.pop() { | ----------^^^^^^^---------- help: try this: `while v.pop().is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:39:5 | LL | / match Some(42) { @@ -51,7 +55,7 @@ LL | | None => false, LL | | }; | |_____^ help: try this: `Some(42).is_some()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:44:5 | LL | / match None::<()> { @@ -60,7 +64,7 @@ LL | | None => true, LL | | }; | |_____^ help: try this: `None::<()>.is_none()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:49:13 | LL | let _ = match None::<()> { @@ -70,49 +74,49 @@ LL | | None => true, LL | | }; | |_____^ help: try this: `None::<()>.is_none()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:55:20 | LL | let _ = if let Some(_) = opt { true } else { false }; | -------^^^^^^^------ help: try this: `if opt.is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:59:20 | LL | let _ = if let Some(_) = gen_opt() { | -------^^^^^^^------------ help: try this: `if gen_opt().is_some()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:61:19 | LL | } else if let None = gen_opt() { | -------^^^^------------ help: try this: `if gen_opt().is_none()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:80:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try this: `if Some(42).is_some()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:82:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try this: `if None::<()>.is_none()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:84:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try this: `while Some(42).is_some()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:86:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try this: `while None::<()>.is_none()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_option.rs:88:5 | LL | / match Some(42) { @@ -121,7 +125,7 @@ LL | | None => false, LL | | }; | |_____^ help: try this: `Some(42).is_some()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:93:5 | LL | / match None::<()> { @@ -130,17 +134,17 @@ LL | | None => true, LL | | }; | |_____^ help: try this: `None::<()>.is_none()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:101:12 | LL | if let None = *(&None::<()>) {} | -------^^^^----------------- help: try this: `if (&None::<()>).is_none()` -error: redundant pattern matching, consider using `is_none()` +warning: redundant pattern matching, consider using `is_none()` --> $DIR/redundant_pattern_matching_option.rs:102:12 | LL | if let None = *&None::<()> {} | -------^^^^--------------- help: try this: `if (&None::<()>).is_none()` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/redundant_pattern_matching_poll.fixed b/tests/ui/redundant_pattern_matching_poll.fixed index 3645f2c4bfdd..5216c5f8675c 100644 --- a/tests/ui/redundant_pattern_matching_poll.fixed +++ b/tests/ui/redundant_pattern_matching_poll.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] @@ -33,11 +33,20 @@ fn main() { if Ready(42).is_ready() {} - Ready(42).is_ready(); + match Ready(42) { + Ready(_) => true, + Pending => false, + }; - Pending::<()>.is_pending(); + match Pending::<()> { + Ready(_) => false, + Pending => true, + }; - let _ = Pending::<()>.is_pending(); + let _ = match Pending::<()> { + Ready(_) => false, + Pending => true, + }; let poll = Ready(false); let _ = if poll.is_ready() { true } else { false }; @@ -70,7 +79,13 @@ const fn poll_const() { while Pending::<()>.is_pending() {} - Ready(42).is_ready(); + match Ready(42) { + Ready(_) => true, + Pending => false, + }; - Pending::<()>.is_pending(); + match Pending::<()> { + Ready(_) => false, + Pending => true, + }; } diff --git a/tests/ui/redundant_pattern_matching_poll.rs b/tests/ui/redundant_pattern_matching_poll.rs index 866c71b7cfa8..892a21d9d298 100644 --- a/tests/ui/redundant_pattern_matching_poll.rs +++ b/tests/ui/redundant_pattern_matching_poll.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] diff --git a/tests/ui/redundant_pattern_matching_poll.stderr b/tests/ui/redundant_pattern_matching_poll.stderr index 1b480f3157f7..c1e793d9e820 100644 --- a/tests/ui/redundant_pattern_matching_poll.stderr +++ b/tests/ui/redundant_pattern_matching_poll.stderr @@ -1,42 +1,46 @@ -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:16:12 | LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try this: `if Pending::<()>.is_pending()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_pattern_matching_poll.rs:4:9 + | +LL | #![warn(clippy::redundant_pattern_matching)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:18:12 | LL | if let Ready(_) = Ready(42) {} | -------^^^^^^^^------------ help: try this: `if Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:20:12 | LL | if let Ready(_) = Ready(42) { | -------^^^^^^^^------------ help: try this: `if Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:26:15 | LL | while let Ready(_) = Ready(42) {} | ----------^^^^^^^^------------ help: try this: `while Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:28:15 | LL | while let Pending = Ready(42) {} | ----------^^^^^^^------------ help: try this: `while Ready(42).is_pending()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:30:15 | LL | while let Pending = Pending::<()> {} | ----------^^^^^^^---------------- help: try this: `while Pending::<()>.is_pending()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:36:5 | LL | / match Ready(42) { @@ -45,7 +49,7 @@ LL | | Pending => false, LL | | }; | |_____^ help: try this: `Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:41:5 | LL | / match Pending::<()> { @@ -54,7 +58,7 @@ LL | | Pending => true, LL | | }; | |_____^ help: try this: `Pending::<()>.is_pending()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:46:13 | LL | let _ = match Pending::<()> { @@ -64,49 +68,49 @@ LL | | Pending => true, LL | | }; | |_____^ help: try this: `Pending::<()>.is_pending()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:52:20 | LL | let _ = if let Ready(_) = poll { true } else { false }; | -------^^^^^^^^------- help: try this: `if poll.is_ready()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:56:20 | LL | let _ = if let Ready(_) = gen_poll() { | -------^^^^^^^^------------- help: try this: `if gen_poll().is_ready()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:58:19 | LL | } else if let Pending = gen_poll() { | -------^^^^^^^------------- help: try this: `if gen_poll().is_pending()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:74:12 | LL | if let Ready(_) = Ready(42) {} | -------^^^^^^^^------------ help: try this: `if Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:76:12 | LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try this: `if Pending::<()>.is_pending()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:78:15 | LL | while let Ready(_) = Ready(42) {} | ----------^^^^^^^^------------ help: try this: `while Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:80:15 | LL | while let Pending = Pending::<()> {} | ----------^^^^^^^---------------- help: try this: `while Pending::<()>.is_pending()` -error: redundant pattern matching, consider using `is_ready()` +warning: redundant pattern matching, consider using `is_ready()` --> $DIR/redundant_pattern_matching_poll.rs:82:5 | LL | / match Ready(42) { @@ -115,7 +119,7 @@ LL | | Pending => false, LL | | }; | |_____^ help: try this: `Ready(42).is_ready()` -error: redundant pattern matching, consider using `is_pending()` +warning: redundant pattern matching, consider using `is_pending()` --> $DIR/redundant_pattern_matching_poll.rs:87:5 | LL | / match Pending::<()> { @@ -124,5 +128,5 @@ LL | | Pending => true, LL | | }; | |_____^ help: try this: `Pending::<()>.is_pending()` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/redundant_pattern_matching_result.fixed b/tests/ui/redundant_pattern_matching_result.fixed index b88c5d0bec82..a0325a65004c 100644 --- a/tests/ui/redundant_pattern_matching_result.fixed +++ b/tests/ui/redundant_pattern_matching_result.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] #![allow(deprecated, unused_must_use)] @@ -30,13 +30,25 @@ fn main() { println!("{}", x); } - Ok::(42).is_ok(); + match Ok::(42) { + Ok(_) => true, + Err(_) => false, + }; - Ok::(42).is_err(); + match Ok::(42) { + Ok(_) => false, + Err(_) => true, + }; - Err::(42).is_err(); + match Err::(42) { + Ok(_) => false, + Err(_) => true, + }; - Err::(42).is_ok(); + match Err::(42) { + Ok(_) => true, + Err(_) => false, + }; let _ = if Ok::(4).is_ok() { true } else { false }; @@ -103,7 +115,13 @@ const fn issue6067() { while Ok::(10).is_err() {} - Ok::(42).is_ok(); + match Ok::(42) { + Ok(_) => true, + Err(_) => false, + }; - Err::(42).is_err(); + match Err::(42) { + Ok(_) => false, + Err(_) => true, + }; } diff --git a/tests/ui/redundant_pattern_matching_result.rs b/tests/ui/redundant_pattern_matching_result.rs index 5949cb2271c6..26f37d169fac 100644 --- a/tests/ui/redundant_pattern_matching_result.rs +++ b/tests/ui/redundant_pattern_matching_result.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] #![allow(deprecated, unused_must_use)] diff --git a/tests/ui/redundant_pattern_matching_result.stderr b/tests/ui/redundant_pattern_matching_result.stderr index e6afe9eb78ea..8d899cf38c25 100644 --- a/tests/ui/redundant_pattern_matching_result.stderr +++ b/tests/ui/redundant_pattern_matching_result.stderr @@ -1,36 +1,40 @@ -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:15:12 | LL | if let Ok(_) = &result {} | -------^^^^^---------- help: try this: `if result.is_ok()` | - = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_pattern_matching_result.rs:3:9 + | +LL | #![warn(clippy::redundant_pattern_matching)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:17:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try this: `if Ok::(42).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:19:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try this: `if Err::(42).is_err()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:21:15 | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try this: `while Ok::(10).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:23:15 | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try this: `while Ok::(10).is_err()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:33:5 | LL | / match Ok::(42) { @@ -39,7 +43,7 @@ LL | | Err(_) => false, LL | | }; | |_____^ help: try this: `Ok::(42).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:38:5 | LL | / match Ok::(42) { @@ -48,7 +52,7 @@ LL | | Err(_) => true, LL | | }; | |_____^ help: try this: `Ok::(42).is_err()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:43:5 | LL | / match Err::(42) { @@ -57,7 +61,7 @@ LL | | Err(_) => true, LL | | }; | |_____^ help: try this: `Err::(42).is_err()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:48:5 | LL | / match Err::(42) { @@ -66,73 +70,73 @@ LL | | Err(_) => false, LL | | }; | |_____^ help: try this: `Err::(42).is_ok()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:53:20 | LL | let _ = if let Ok(_) = Ok::(4) { true } else { false }; | -------^^^^^--------------------- help: try this: `if Ok::(4).is_ok()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:59:20 | LL | let _ = if let Ok(_) = gen_res() { | -------^^^^^------------ help: try this: `if gen_res().is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:61:19 | LL | } else if let Err(_) = gen_res() { | -------^^^^^^------------ help: try this: `if gen_res().is_err()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_result.rs:84:19 | LL | while let Some(_) = r#try!(result_opt()) {} | ----------^^^^^^^----------------------- help: try this: `while (r#try!(result_opt())).is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_result.rs:85:16 | LL | if let Some(_) = r#try!(result_opt()) {} | -------^^^^^^^----------------------- help: try this: `if (r#try!(result_opt())).is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_result.rs:91:12 | LL | if let Some(_) = m!() {} | -------^^^^^^^------- help: try this: `if m!().is_some()` -error: redundant pattern matching, consider using `is_some()` +warning: redundant pattern matching, consider using `is_some()` --> $DIR/redundant_pattern_matching_result.rs:92:15 | LL | while let Some(_) = m!() {} | ----------^^^^^^^------- help: try this: `while m!().is_some()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:110:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try this: `if Ok::(42).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:112:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try this: `if Err::(42).is_err()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:114:15 | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try this: `while Ok::(10).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:116:15 | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try this: `while Ok::(10).is_err()` -error: redundant pattern matching, consider using `is_ok()` +warning: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:118:5 | LL | / match Ok::(42) { @@ -141,7 +145,7 @@ LL | | Err(_) => false, LL | | }; | |_____^ help: try this: `Ok::(42).is_ok()` -error: redundant pattern matching, consider using `is_err()` +warning: redundant pattern matching, consider using `is_err()` --> $DIR/redundant_pattern_matching_result.rs:123:5 | LL | / match Err::(42) { @@ -150,5 +154,5 @@ LL | | Err(_) => true, LL | | }; | |_____^ help: try this: `Err::(42).is_err()` -error: aborting due to 22 previous errors +warning: 22 warnings emitted diff --git a/tests/ui/redundant_pub_crate.fixed b/tests/ui/redundant_pub_crate.fixed index 106947de68c1..f65c0fdd35da 100644 --- a/tests/ui/redundant_pub_crate.fixed +++ b/tests/ui/redundant_pub_crate.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::redundant_pub_crate)] diff --git a/tests/ui/redundant_pub_crate.rs b/tests/ui/redundant_pub_crate.rs index f96cfd318438..fb07fed98bef 100644 --- a/tests/ui/redundant_pub_crate.rs +++ b/tests/ui/redundant_pub_crate.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] #![warn(clippy::redundant_pub_crate)] diff --git a/tests/ui/redundant_pub_crate.stderr b/tests/ui/redundant_pub_crate.stderr index 6fccdaa4e203..499ba2cc7f64 100644 --- a/tests/ui/redundant_pub_crate.stderr +++ b/tests/ui/redundant_pub_crate.stderr @@ -1,4 +1,4 @@ -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:7:5 | LL | pub(crate) fn g() {} // private due to m1 @@ -6,9 +6,13 @@ LL | pub(crate) fn g() {} // private due to m1 | | | help: consider using: `pub` | - = note: `-D clippy::redundant-pub-crate` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_pub_crate.rs:3:9 + | +LL | #![warn(clippy::redundant_pub_crate)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:12:9 | LL | pub(crate) fn g() {} // private due to m1_1 and m1 @@ -16,7 +20,7 @@ LL | pub(crate) fn g() {} // private due to m1_1 and m1 | | | help: consider using: `pub` -error: pub(crate) module inside private module +warning: pub(crate) module inside private module --> $DIR/redundant_pub_crate.rs:16:5 | LL | pub(crate) mod m1_2 { @@ -24,7 +28,7 @@ LL | pub(crate) mod m1_2 { | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:19:9 | LL | pub(crate) fn g() {} // private due to m1_2 and m1 @@ -32,7 +36,7 @@ LL | pub(crate) fn g() {} // private due to m1_2 and m1 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:25:9 | LL | pub(crate) fn g() {} // private due to m1 @@ -40,7 +44,7 @@ LL | pub(crate) fn g() {} // private due to m1 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:32:5 | LL | pub(crate) fn g() {} // already crate visible due to m2 @@ -48,7 +52,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:37:9 | LL | pub(crate) fn g() {} // private due to m2_1 @@ -56,7 +60,7 @@ LL | pub(crate) fn g() {} // private due to m2_1 | | | help: consider using: `pub` -error: pub(crate) module inside private module +warning: pub(crate) module inside private module --> $DIR/redundant_pub_crate.rs:41:5 | LL | pub(crate) mod m2_2 { @@ -64,7 +68,7 @@ LL | pub(crate) mod m2_2 { | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:44:9 | LL | pub(crate) fn g() {} // already crate visible due to m2_2 and m2 @@ -72,7 +76,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2_2 and m2 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:50:9 | LL | pub(crate) fn g() {} // already crate visible due to m2 @@ -80,7 +84,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:62:9 | LL | pub(crate) fn g() {} // private due to m3_1 @@ -88,7 +92,7 @@ LL | pub(crate) fn g() {} // private due to m3_1 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:69:9 | LL | pub(crate) fn g() {} // already crate visible due to m3_2 @@ -96,7 +100,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m3_2 | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:82:5 | LL | pub(crate) fn g() {} // private: not re-exported by `pub use m4::*` @@ -104,7 +108,7 @@ LL | pub(crate) fn g() {} // private: not re-exported by `pub use m4::*` | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:87:9 | LL | pub(crate) fn g() {} // private due to m4_1 @@ -112,7 +116,7 @@ LL | pub(crate) fn g() {} // private due to m4_1 | | | help: consider using: `pub` -error: pub(crate) module inside private module +warning: pub(crate) module inside private module --> $DIR/redundant_pub_crate.rs:91:5 | LL | pub(crate) mod m4_2 { @@ -120,7 +124,7 @@ LL | pub(crate) mod m4_2 { | | | help: consider using: `pub` -error: pub(crate) function inside private module +warning: pub(crate) function inside private module --> $DIR/redundant_pub_crate.rs:94:9 | LL | pub(crate) fn g() {} // private due to m4_2 @@ -128,5 +132,5 @@ LL | pub(crate) fn g() {} // private due to m4_2 | | | help: consider using: `pub` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/redundant_slicing.fixed b/tests/ui/redundant_slicing.fixed index 8dd8d3092378..56ddca71903e 100644 --- a/tests/ui/redundant_slicing.fixed +++ b/tests/ui/redundant_slicing.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::deref_by_slicing)] #![warn(clippy::redundant_slicing)] diff --git a/tests/ui/redundant_slicing.rs b/tests/ui/redundant_slicing.rs index 51c16dd8d65a..d67b6665e260 100644 --- a/tests/ui/redundant_slicing.rs +++ b/tests/ui/redundant_slicing.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused, clippy::deref_by_slicing)] #![warn(clippy::redundant_slicing)] diff --git a/tests/ui/redundant_slicing.stderr b/tests/ui/redundant_slicing.stderr index 82367143c07f..4592a16cdf7d 100644 --- a/tests/ui/redundant_slicing.stderr +++ b/tests/ui/redundant_slicing.stderr @@ -1,22 +1,26 @@ -error: redundant slicing of the whole range +warning: redundant slicing of the whole range --> $DIR/redundant_slicing.rs:10:13 | LL | let _ = &slice[..]; // Redundant slice | ^^^^^^^^^^ help: use the original value instead: `slice` | - = note: `-D clippy::redundant-slicing` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/redundant_slicing.rs:4:9 + | +LL | #![warn(clippy::redundant_slicing)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant slicing of the whole range +warning: redundant slicing of the whole range --> $DIR/redundant_slicing.rs:14:13 | LL | let _ = &(&*v)[..]; // Outer borrow is redundant | ^^^^^^^^^^ help: use the original value instead: `(&*v)` -error: redundant slicing of the whole range +warning: redundant slicing of the whole range --> $DIR/redundant_slicing.rs:31:13 | LL | let _ = &m!(slice)[..]; | ^^^^^^^^^^^^^^ help: use the original value instead: `slice` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/redundant_static_lifetimes.fixed b/tests/ui/redundant_static_lifetimes.fixed index bca777a890c3..a83699ec68da 100644 --- a/tests/ui/redundant_static_lifetimes.fixed +++ b/tests/ui/redundant_static_lifetimes.fixed @@ -1,43 +1,43 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #[derive(Debug)] struct Foo; -const VAR_ONE: &str = "Test constant #1"; // ERROR Consider removing 'static. +const VAR_ONE: &str = "Test constant #1"; // ERROR: Consider removing 'static. const VAR_TWO: &str = "Test constant #2"; // This line should not raise a warning. -const VAR_THREE: &[&str] = &["one", "two"]; // ERROR Consider removing 'static +const VAR_THREE: &[&str] = &["one", "two"]; // ERROR: Consider removing 'static -const VAR_FOUR: (&str, (&str, &str), &str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +const VAR_FOUR: (&str, (&str, &str), &str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static const VAR_SIX: &u8 = &5; const VAR_HEIGHT: &Foo = &Foo {}; -const VAR_SLICE: &[u8] = b"Test constant #1"; // ERROR Consider removing 'static. +const VAR_SLICE: &[u8] = b"Test constant #1"; // ERROR: Consider removing 'static. -const VAR_TUPLE: &(u8, u8) = &(1, 2); // ERROR Consider removing 'static. +const VAR_TUPLE: &(u8, u8) = &(1, 2); // ERROR: Consider removing 'static. -const VAR_ARRAY: &[u8; 1] = b"T"; // ERROR Consider removing 'static. +const VAR_ARRAY: &[u8; 1] = b"T"; // ERROR: Consider removing 'static. -static STATIC_VAR_ONE: &str = "Test static #1"; // ERROR Consider removing 'static. +static STATIC_VAR_ONE: &str = "Test static #1"; // ERROR: Consider removing 'static. static STATIC_VAR_TWO: &str = "Test static #2"; // This line should not raise a warning. -static STATIC_VAR_THREE: &[&str] = &["one", "two"]; // ERROR Consider removing 'static +static STATIC_VAR_THREE: &[&str] = &["one", "two"]; // ERROR: Consider removing 'static static STATIC_VAR_SIX: &u8 = &5; static STATIC_VAR_HEIGHT: &Foo = &Foo {}; -static STATIC_VAR_SLICE: &[u8] = b"Test static #3"; // ERROR Consider removing 'static. +static STATIC_VAR_SLICE: &[u8] = b"Test static #3"; // ERROR: Consider removing 'static. -static STATIC_VAR_TUPLE: &(u8, u8) = &(1, 2); // ERROR Consider removing 'static. +static STATIC_VAR_TUPLE: &(u8, u8) = &(1, 2); // ERROR: Consider removing 'static. -static STATIC_VAR_ARRAY: &[u8; 1] = b"T"; // ERROR Consider removing 'static. +static STATIC_VAR_ARRAY: &[u8; 1] = b"T"; // ERROR: Consider removing 'static. static mut STATIC_MUT_SLICE: &mut [u32] = &mut [0]; diff --git a/tests/ui/redundant_static_lifetimes.rs b/tests/ui/redundant_static_lifetimes.rs index afe7644816d2..b165cbaa3aa1 100644 --- a/tests/ui/redundant_static_lifetimes.rs +++ b/tests/ui/redundant_static_lifetimes.rs @@ -1,43 +1,43 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #[derive(Debug)] struct Foo; -const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. +const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removing 'static. const VAR_TWO: &str = "Test constant #2"; // This line should not raise a warning. -const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static -const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static const VAR_SIX: &'static u8 = &5; const VAR_HEIGHT: &'static Foo = &Foo {}; -const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. +const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR: Consider removing 'static. -const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. -const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. -static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static. +static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR: Consider removing 'static. static STATIC_VAR_TWO: &str = "Test static #2"; // This line should not raise a warning. -static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static static STATIC_VAR_SIX: &'static u8 = &5; static STATIC_VAR_HEIGHT: &'static Foo = &Foo {}; -static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static. +static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR: Consider removing 'static. -static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. -static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0]; diff --git a/tests/ui/redundant_static_lifetimes.stderr b/tests/ui/redundant_static_lifetimes.stderr index b2cbd2d9d01b..a5def2b20d41 100644 --- a/tests/ui/redundant_static_lifetimes.stderr +++ b/tests/ui/redundant_static_lifetimes.stderr @@ -1,112 +1,112 @@ -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:8:17 | -LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. +LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` | - = note: `-D clippy::redundant-static-lifetimes` implied by `-D warnings` + = note: `#[warn(clippy::redundant_static_lifetimes)]` on by default -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:12:21 | -LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:14:32 | -LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:14:47 | -LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:16:17 | LL | const VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:18:20 | LL | const VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:20:19 | -LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. +LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR: Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:22:19 | -LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:24:19 | -LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:26:25 | -LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static. +LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR: Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:30:29 | -LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:32:25 | LL | static STATIC_VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:34:28 | LL | static STATIC_VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:36:27 | -LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static. +LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR: Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:38:27 | -LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:40:27 | -LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:42:31 | LL | static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0]; | -^^^^^^^---------- help: consider removing `'static`: `&mut [u32]` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes.rs:71:16 | LL | static V: &'static u8 = &17; | -^^^^^^^--- help: consider removing `'static`: `&u8` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/redundant_static_lifetimes_multiple.rs b/tests/ui/redundant_static_lifetimes_multiple.rs index f57dd58e230a..b3f263a7d66d 100644 --- a/tests/ui/redundant_static_lifetimes_multiple.rs +++ b/tests/ui/redundant_static_lifetimes_multiple.rs @@ -1,12 +1,12 @@ // these are rustfixable, but run-rustfix tests cannot handle them -const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; -static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static -static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; diff --git a/tests/ui/redundant_static_lifetimes_multiple.stderr b/tests/ui/redundant_static_lifetimes_multiple.stderr index cc7e55a757a3..e64a2abeb75f 100644 --- a/tests/ui/redundant_static_lifetimes_multiple.stderr +++ b/tests/ui/redundant_static_lifetimes_multiple.stderr @@ -1,64 +1,64 @@ -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:3:18 | -LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` | - = note: `-D clippy::redundant-static-lifetimes` implied by `-D warnings` + = note: `#[warn(clippy::redundant_static_lifetimes)]` on by default -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:3:30 | -LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:5:29 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` -error: constants have by default a `'static` lifetime +warning: constants have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:5:39 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:7:40 | -LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:7:55 | -LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:9:26 | -LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:9:38 | -LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:11:37 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` -error: statics have by default a `'static` lifetime +warning: statics have by default a `'static` lifetime --> $DIR/redundant_static_lifetimes_multiple.rs:11:47 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/ref_binding_to_reference.stderr b/tests/ui/ref_binding_to_reference.stderr index eb36cd516a24..e4a5198d1398 100644 --- a/tests/ui/ref_binding_to_reference.stderr +++ b/tests/ui/ref_binding_to_reference.stderr @@ -1,16 +1,20 @@ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:31:14 | LL | Some(ref x) => x, | ^^^^^ | - = note: `-D clippy::ref-binding-to-reference` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ref_binding_to_reference.rs:4:9 + | +LL | #![warn(clippy::ref_binding_to_reference)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this | LL | Some(x) => &x, | ~ ~~ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:37:14 | LL | Some(ref x) => { @@ -24,7 +28,7 @@ LL ~ f1(x); LL ~ &x | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:47:14 | LL | Some(ref x) => m2!(x), @@ -35,7 +39,7 @@ help: try this LL | Some(x) => m2!(&x), | ~ ~~ -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:52:15 | LL | let _ = |&ref x: &&String| { @@ -47,7 +51,7 @@ LL ~ let _ = |&x: &&String| { LL ~ let _: &&String = &x; | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:58:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { @@ -60,7 +64,7 @@ LL ~ let _: &&String = &x; LL ~ x | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:65:11 | LL | fn f(&ref x: &&String) { @@ -72,7 +76,7 @@ LL ~ fn f(&x: &&String) { LL ~ let _: &&String = &x; | -error: this pattern creates a reference to a reference +warning: this pattern creates a reference to a reference --> $DIR/ref_binding_to_reference.rs:73:11 | LL | fn f(&ref x: &&String) { @@ -84,5 +88,5 @@ LL ~ fn f(&x: &&String) { LL ~ let _: &&String = &x; | -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/ref_option_ref.stderr b/tests/ui/ref_option_ref.stderr index b61334758e85..fa6c192089b7 100644 --- a/tests/ui/ref_option_ref.stderr +++ b/tests/ui/ref_option_ref.stderr @@ -1,70 +1,74 @@ -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:10:23 | LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` | - = note: `-D clippy::ref-option-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/ref_option_ref.rs:2:9 + | +LL | #![warn(clippy::ref_option_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:12:18 | LL | const REF_CONST: &Option<&i32> = &Some(CONST_THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:14:25 | LL | type RefOptRefU32<'a> = &'a Option<&'a u32>; | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:15:25 | LL | type RefOptRef<'a, T> = &'a Option<&'a T>; | ^^^^^^^^^^^^^^^^^ help: try: `Option<&'a T>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:17:14 | LL | fn foo(data: &Option<&u32>) {} | ^^^^^^^^^^^^^ help: try: `Option<&u32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:19:23 | LL | fn bar(data: &u32) -> &Option<&u32> { | ^^^^^^^^^^^^^ help: try: `Option<&u32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:24:11 | LL | data: &'a Option<&'a u32>, | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:27:32 | LL | struct StructTupleRef<'a>(u32, &'a Option<&'a u32>); | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:31:14 | LL | Variant2(&'a Option<&'a u32>), | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:40:14 | LL | type A = &'static Option<&'static Self>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'static Self>` -error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` +warning: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` --> $DIR/ref_option_ref.rs:46:12 | LL | let x: &Option<&u32> = &None; | ^^^^^^^^^^^^^ help: try: `Option<&u32>` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index c2440f39e0a0..bbb17a8791e5 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -1,13 +1,17 @@ -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:13:45 | LL | let pipe_in_wrong_position = Regex::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is - = note: `-D clippy::trivial-regex` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/regex.rs:2:32 + | +LL | #![warn(clippy::invalid_regex, clippy::trivial_regex)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:14:60 | LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); @@ -15,30 +19,34 @@ LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | = help: the regex is unlikely to be useful as it is -error: regex syntax error: invalid character class range, the start must be <= the end +warning: regex syntax error: invalid character class range, the start must be <= the end --> $DIR/regex.rs:15:42 | LL | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ | - = note: `-D clippy::invalid-regex` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/regex.rs:2:9 + | +LL | #![warn(clippy::invalid_regex, clippy::trivial_regex)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: regex syntax error: invalid character class range, the start must be <= the end +warning: regex syntax error: invalid character class range, the start must be <= the end --> $DIR/regex.rs:16:37 | LL | let some_unicode = Regex::new("[é-è]"); | ^^^ -error: regex parse error: - ( - ^ - error: unclosed group +warning: regex parse error: + ( + ^ + error: unclosed group --> $DIR/regex.rs:18:33 | LL | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:20:53 | LL | let binary_pipe_in_wrong_position = BRegex::new("|"); @@ -46,72 +54,72 @@ LL | let binary_pipe_in_wrong_position = BRegex::new("|"); | = help: the regex is unlikely to be useful as it is -error: regex parse error: - ( - ^ - error: unclosed group +warning: regex parse error: + ( + ^ + error: unclosed group --> $DIR/regex.rs:21:41 | LL | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ -error: regex parse error: - ( - ^ - error: unclosed group +warning: regex parse error: + ( + ^ + error: unclosed group --> $DIR/regex.rs:22:56 | LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ -error: regex parse error: - ( - ^ - error: unclosed group +warning: regex parse error: + ( + ^ + error: unclosed group --> $DIR/regex.rs:34:37 | -LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); +LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); | ^^^^^^^^^^^^^ -error: regex parse error: - ( - ^ - error: unclosed group +warning: regex parse error: + ( + ^ + error: unclosed group --> $DIR/regex.rs:35:39 | -LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); +LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); | ^^^^^^^^^^^^^ -error: regex syntax error: unrecognized escape sequence +warning: regex syntax error: unrecognized escape sequence --> $DIR/regex.rs:37:45 | -LL | let raw_string_error = Regex::new(r"[...//...]"); +LL | let raw_string_error = Regex::new(r"[...\/...]"); | ^^ -error: regex syntax error: unrecognized escape sequence +warning: regex syntax error: unrecognized escape sequence --> $DIR/regex.rs:38:46 | -LL | let raw_string_error = Regex::new(r#"[...//...]"#); +LL | let raw_string_error = Regex::new(r#"[...\/...]"#); | ^^ -error: regex parse error: - /b/c - ^^ - error: unrecognized escape sequence +warning: regex parse error: + \b\c + ^^ + error: unrecognized escape sequence --> $DIR/regex.rs:40:42 | -LL | let escaped_string_span = Regex::new("/b/c"); +LL | let escaped_string_span = Regex::new("\\b\\c"); | ^^^^^^^^ | = help: consider using a raw string literal: `r".."` -error: regex syntax error: duplicate flag +warning: regex syntax error: duplicate flag --> $DIR/regex.rs:42:34 | LL | let aux_span = Regex::new("(?ixi)"); | ^ ^ -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:46:33 | LL | let trivial_eq = Regex::new("^foobar$"); @@ -119,7 +127,7 @@ LL | let trivial_eq = Regex::new("^foobar$"); | = help: consider using `==` on `str`s -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:48:48 | LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); @@ -127,7 +135,7 @@ LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | = help: consider using `==` on `str`s -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:50:42 | LL | let trivial_starts_with = Regex::new("^foobar"); @@ -135,7 +143,7 @@ LL | let trivial_starts_with = Regex::new("^foobar"); | = help: consider using `str::starts_with` -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:52:40 | LL | let trivial_ends_with = Regex::new("foobar$"); @@ -143,7 +151,7 @@ LL | let trivial_ends_with = Regex::new("foobar$"); | = help: consider using `str::ends_with` -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:54:39 | LL | let trivial_contains = Regex::new("foobar"); @@ -151,7 +159,7 @@ LL | let trivial_contains = Regex::new("foobar"); | = help: consider using `str::contains` -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:56:39 | LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); @@ -159,15 +167,15 @@ LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | = help: consider using `str::contains` -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:58:40 | -LL | let trivial_backslash = Regex::new("a/.b"); +LL | let trivial_backslash = Regex::new("a\\.b"); | ^^^^^^^ | = help: consider using `str::contains` -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:61:36 | LL | let trivial_empty = Regex::new(""); @@ -175,7 +183,7 @@ LL | let trivial_empty = Regex::new(""); | = help: the regex is unlikely to be useful as it is -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:63:36 | LL | let trivial_empty = Regex::new("^"); @@ -183,7 +191,7 @@ LL | let trivial_empty = Regex::new("^"); | = help: the regex is unlikely to be useful as it is -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:65:36 | LL | let trivial_empty = Regex::new("^$"); @@ -191,7 +199,7 @@ LL | let trivial_empty = Regex::new("^$"); | = help: consider using `str::is_empty` -error: trivial regex +warning: trivial regex --> $DIR/regex.rs:67:44 | LL | let binary_trivial_empty = BRegex::new("^$"); @@ -199,5 +207,5 @@ LL | let binary_trivial_empty = BRegex::new("^$"); | = help: consider using `str::is_empty` -error: aborting due to 25 previous errors +warning: 25 warnings emitted diff --git a/tests/ui/rename.fixed b/tests/ui/rename.fixed index 5076f61334d6..e8a00a9e7f71 100644 --- a/tests/ui/rename.fixed +++ b/tests/ui/rename.fixed @@ -2,7 +2,7 @@ // Use that command to update this file and do not edit by hand. // Manual edits will be overwritten. -// run-rustfix +//@run-rustfix #![allow(clippy::almost_complete_range)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/rename.rs b/tests/ui/rename.rs index 64bc1ca7116c..c8ea70c2bcb1 100644 --- a/tests/ui/rename.rs +++ b/tests/ui/rename.rs @@ -2,7 +2,7 @@ // Use that command to update this file and do not edit by hand. // Manual edits will be overwritten. -// run-rustfix +//@run-rustfix #![allow(clippy::almost_complete_range)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index 27a0263292ef..ce0ee3dad846 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -1,256 +1,256 @@ -error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range` +warning: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range` --> $DIR/rename.rs:42:9 | LL | #![warn(clippy::almost_complete_letter_range)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range` | - = note: `-D renamed-and-removed-lints` implied by `-D warnings` + = note: `#[warn(renamed_and_removed_lints)]` on by default -error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` +warning: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` --> $DIR/rename.rs:43:9 | LL | #![warn(clippy::blacklisted_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names` -error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions` +warning: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions` --> $DIR/rename.rs:44:9 | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` -error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions` +warning: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions` --> $DIR/rename.rs:45:9 | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` -error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` +warning: lint `clippy::box_vec` has been renamed to `clippy::box_collection` --> $DIR/rename.rs:46:9 | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` -error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` +warning: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` --> $DIR/rename.rs:47:9 | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` -error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` +warning: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` --> $DIR/rename.rs:48:9 | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` -error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` +warning: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` --> $DIR/rename.rs:49:9 | LL | #![warn(clippy::derive_hash_xor_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` -error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` +warning: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` --> $DIR/rename.rs:50:9 | LL | #![warn(clippy::disallowed_method)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods` -error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` +warning: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` --> $DIR/rename.rs:51:9 | LL | #![warn(clippy::disallowed_type)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` -error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` +warning: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` --> $DIR/rename.rs:52:9 | LL | #![warn(clippy::eval_order_dependence)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression` -error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` +warning: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` --> $DIR/rename.rs:53:9 | LL | #![warn(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion` -error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` +warning: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` --> $DIR/rename.rs:54:9 | LL | #![warn(clippy::if_let_some_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok` -error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr` +warning: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr` --> $DIR/rename.rs:55:9 | LL | #![warn(clippy::logic_bug)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr` -error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` +warning: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` --> $DIR/rename.rs:56:9 | LL | #![warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` -error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` +warning: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` --> $DIR/rename.rs:57:9 | LL | #![warn(clippy::option_and_then_some)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map` -error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` +warning: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` --> $DIR/rename.rs:58:9 | LL | #![warn(clippy::option_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` -error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` +warning: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` --> $DIR/rename.rs:59:9 | LL | #![warn(clippy::option_map_unwrap_or)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` -error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` +warning: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` --> $DIR/rename.rs:60:9 | LL | #![warn(clippy::option_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` -error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` +warning: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` --> $DIR/rename.rs:61:9 | LL | #![warn(clippy::option_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` -error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow` +warning: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow` --> $DIR/rename.rs:62:9 | LL | #![warn(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow` -error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` +warning: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` --> $DIR/rename.rs:63:9 | LL | #![warn(clippy::result_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` -error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` +warning: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` --> $DIR/rename.rs:64:9 | LL | #![warn(clippy::result_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` -error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` +warning: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` --> $DIR/rename.rs:65:9 | LL | #![warn(clippy::result_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` -error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` +warning: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` --> $DIR/rename.rs:66:9 | LL | #![warn(clippy::single_char_push_str)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str` -error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` +warning: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` --> $DIR/rename.rs:67:9 | LL | #![warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` -error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl` +warning: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl` --> $DIR/rename.rs:68:9 | LL | #![warn(clippy::to_string_in_display)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl` -error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` +warning: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` --> $DIR/rename.rs:69:9 | LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` -error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` +warning: lint `clippy::drop_bounds` has been renamed to `drop_bounds` --> $DIR/rename.rs:70:9 | LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` -error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` +warning: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:71:9 | LL | #![warn(clippy::for_loop_over_option)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` -error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` +warning: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:72:9 | LL | #![warn(clippy::for_loop_over_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` -error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` +warning: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:73:9 | LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` -error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` +warning: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` --> $DIR/rename.rs:74:9 | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` -error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` +warning: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` --> $DIR/rename.rs:75:9 | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` -error: lint `clippy::invalid_ref` has been renamed to `invalid_value` +warning: lint `clippy::invalid_ref` has been renamed to `invalid_value` --> $DIR/rename.rs:76:9 | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` -error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` +warning: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` --> $DIR/rename.rs:77:9 | LL | #![warn(clippy::let_underscore_drop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop` -error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` +warning: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` --> $DIR/rename.rs:78:9 | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` -error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` +warning: lint `clippy::panic_params` has been renamed to `non_fmt_panics` --> $DIR/rename.rs:79:9 | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` -error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` +warning: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` --> $DIR/rename.rs:80:9 | LL | #![warn(clippy::positional_named_format_parameters)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally` -error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` +warning: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` --> $DIR/rename.rs:81:9 | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` -error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` +warning: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` --> $DIR/rename.rs:82:9 | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` -error: lint `clippy::unused_label` has been renamed to `unused_labels` +warning: lint `clippy::unused_label` has been renamed to `unused_labels` --> $DIR/rename.rs:83:9 | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` -error: aborting due to 42 previous errors +warning: 42 warnings emitted diff --git a/tests/ui/renamed_builtin_attr.fixed b/tests/ui/renamed_builtin_attr.fixed index cb91b841d2cb..50da8be3ede7 100644 --- a/tests/ui/renamed_builtin_attr.fixed +++ b/tests/ui/renamed_builtin_attr.fixed @@ -1,4 +1,5 @@ -// run-rustfix +//@run-rustfix #[clippy::cognitive_complexity = "1"] +//~^ ERROR: usage of deprecated attribute fn main() {} diff --git a/tests/ui/renamed_builtin_attr.rs b/tests/ui/renamed_builtin_attr.rs index b3ce2758067c..81d8f47f946f 100644 --- a/tests/ui/renamed_builtin_attr.rs +++ b/tests/ui/renamed_builtin_attr.rs @@ -1,4 +1,5 @@ -// run-rustfix +//@run-rustfix #[clippy::cyclomatic_complexity = "1"] +//~^ ERROR: usage of deprecated attribute fn main() {} diff --git a/tests/ui/repeat_once.fixed b/tests/ui/repeat_once.fixed index dc197e50300d..c517bfcc6aa9 100644 --- a/tests/ui/repeat_once.fixed +++ b/tests/ui/repeat_once.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::repeat_once)] #[allow(unused, clippy::redundant_clone)] fn main() { diff --git a/tests/ui/repeat_once.rs b/tests/ui/repeat_once.rs index 0ec5127117c6..9a30b47418ff 100644 --- a/tests/ui/repeat_once.rs +++ b/tests/ui/repeat_once.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::repeat_once)] #[allow(unused, clippy::redundant_clone)] fn main() { diff --git a/tests/ui/repeat_once.stderr b/tests/ui/repeat_once.stderr index 915eea3bfc6b..cacd7c135bd1 100644 --- a/tests/ui/repeat_once.stderr +++ b/tests/ui/repeat_once.stderr @@ -1,40 +1,44 @@ -error: calling `repeat(1)` on slice +warning: calling `repeat(1)` on slice --> $DIR/repeat_once.rs:10:13 | LL | let a = [1; 5].repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `[1; 5].to_vec()` | - = note: `-D clippy::repeat-once` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/repeat_once.rs:2:9 + | +LL | #![warn(clippy::repeat_once)] + | ^^^^^^^^^^^^^^^^^^^ -error: calling `repeat(1)` on slice +warning: calling `repeat(1)` on slice --> $DIR/repeat_once.rs:11:13 | LL | let b = slice.repeat(1); | ^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `slice.to_vec()` -error: calling `repeat(1)` on str +warning: calling `repeat(1)` on str --> $DIR/repeat_once.rs:12:13 | LL | let c = "hello".repeat(N); | ^^^^^^^^^^^^^^^^^ help: consider using `.to_string()` instead: `"hello".to_string()` -error: calling `repeat(1)` on str +warning: calling `repeat(1)` on str --> $DIR/repeat_once.rs:13:13 | LL | let d = "hi".repeat(1); | ^^^^^^^^^^^^^^ help: consider using `.to_string()` instead: `"hi".to_string()` -error: calling `repeat(1)` on str +warning: calling `repeat(1)` on str --> $DIR/repeat_once.rs:14:13 | LL | let e = s.repeat(1); | ^^^^^^^^^^^ help: consider using `.to_string()` instead: `s.to_string()` -error: calling `repeat(1)` on a string literal +warning: calling `repeat(1)` on a string literal --> $DIR/repeat_once.rs:15:13 | LL | let f = string.repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.clone()` instead: `string.clone()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/repl_uninit.stderr b/tests/ui/repl_uninit.stderr index 09468eeaea4b..32a0949e3e27 100644 --- a/tests/ui/repl_uninit.stderr +++ b/tests/ui/repl_uninit.stderr @@ -1,18 +1,22 @@ -error: replacing with `mem::uninitialized()` +warning: replacing with `mem::uninitialized()` --> $DIR/repl_uninit.rs:15:23 | LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` | - = note: `-D clippy::mem-replace-with-uninit` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/repl_uninit.rs:2:9 + | +LL | #![warn(clippy::mem_replace_with_uninit)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: replacing with `mem::MaybeUninit::uninit().assume_init()` +warning: replacing with `mem::MaybeUninit::uninit().assume_init()` --> $DIR/repl_uninit.rs:21:23 | LL | let taken_v = mem::replace(&mut v, mem::MaybeUninit::uninit().assume_init()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` -error: replacing with `mem::zeroed()` +warning: replacing with `mem::zeroed()` --> $DIR/repl_uninit.rs:27:23 | LL | let taken_v = mem::replace(&mut v, mem::zeroed()); @@ -20,11 +24,11 @@ LL | let taken_v = mem::replace(&mut v, mem::zeroed()); | = help: consider using a default value or the `take_mut` crate instead -error: replacing with `mem::uninitialized()` +warning: replacing with `mem::uninitialized()` --> $DIR/repl_uninit.rs:39:28 | LL | let taken_u = unsafe { mem::replace(uref, mem::uninitialized()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(uref)` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/rest_pat_in_fully_bound_structs.stderr b/tests/ui/rest_pat_in_fully_bound_structs.stderr index e15633fb1a13..3aa7b20e766d 100644 --- a/tests/ui/rest_pat_in_fully_bound_structs.stderr +++ b/tests/ui/rest_pat_in_fully_bound_structs.stderr @@ -1,13 +1,17 @@ -error: unnecessary use of `..` pattern in struct binding. All fields were already bound +warning: unnecessary use of `..` pattern in struct binding. All fields were already bound --> $DIR/rest_pat_in_fully_bound_structs.rs:22:9 | LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider removing `..` from this binding - = note: `-D clippy::rest-pat-in-fully-bound-structs` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/rest_pat_in_fully_bound_structs.rs:1:9 + | +LL | #![warn(clippy::rest_pat_in_fully_bound_structs)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary use of `..` pattern in struct binding. All fields were already bound +warning: unnecessary use of `..` pattern in struct binding. All fields were already bound --> $DIR/rest_pat_in_fully_bound_structs.rs:23:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint @@ -15,7 +19,7 @@ LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | = help: consider removing `..` from this binding -error: unnecessary use of `..` pattern in struct binding. All fields were already bound +warning: unnecessary use of `..` pattern in struct binding. All fields were already bound --> $DIR/rest_pat_in_fully_bound_structs.rs:29:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint @@ -23,5 +27,5 @@ LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | = help: consider removing `..` from this binding -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/result_large_err.stderr b/tests/ui/result_large_err.stderr index c386edfd2157..0a17073aaab0 100644 --- a/tests/ui/result_large_err.stderr +++ b/tests/ui/result_large_err.stderr @@ -1,13 +1,17 @@ -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:8:23 | LL | pub fn large_err() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes | = help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>` - = note: `-D clippy::result-large-err` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/result_large_err.rs:1:9 + | +LL | #![warn(clippy::result_large_err)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:19:21 | LL | pub fn ret() -> Result<(), Self> { @@ -15,7 +19,7 @@ LL | pub fn ret() -> Result<(), Self> { | = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:24:26 | LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> { @@ -23,7 +27,7 @@ LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> { | = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:29:45 | LL | pub fn large_err_via_type_alias(x: T) -> Fdlr { @@ -31,7 +35,7 @@ LL | pub fn large_err_via_type_alias(x: T) -> Fdlr { | = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:37:34 | LL | pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeError)> { @@ -39,7 +43,7 @@ LL | pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeErro | = help: try reducing the size of `(u128, R, FullyDefinedLargeError)`, for example by boxing large elements or replacing it with `Box<(u128, R, FullyDefinedLargeError)>` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:48:34 | LL | _Omg([u8; 512]), @@ -50,7 +54,7 @@ LL | pub fn large_enum_error() -> Result<(), Self> { | = help: try reducing the size of `LargeErrorVariants<()>`, for example by boxing large elements or replacing it with `Box>` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:60:30 | LL | _Biggest([u8; 1024]), @@ -63,7 +67,7 @@ LL | fn large_enum_error() -> Result<(), Self> { | = help: try reducing the size of `MultipleLargeVariants`, for example by boxing large elements or replacing it with `Box` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:66:25 | LL | fn large_error() -> Result<(), [u8; 512]> { @@ -71,7 +75,7 @@ LL | fn large_error() -> Result<(), [u8; 512]> { | = help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:85:29 | LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { @@ -79,7 +83,7 @@ LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { | = help: try reducing the size of `FullyDefinedUnionError`, for example by boxing large elements or replacing it with `Box` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:94:40 | LL | pub fn param_large_union() -> Result<(), UnionError> { @@ -87,7 +91,7 @@ LL | pub fn param_large_union() -> Result<(), UnionError> { | = help: try reducing the size of `UnionError`, for example by boxing large elements or replacing it with `Box>` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:103:34 | LL | pub fn array_error_subst() -> Result<(), ArrayError> { @@ -95,7 +99,7 @@ LL | pub fn array_error_subst() -> Result<(), ArrayError> { | = help: try reducing the size of `ArrayError`, for example by boxing large elements or replacing it with `Box>` -error: the `Err`-variant returned from this function is very large +warning: the `Err`-variant returned from this function is very large --> $DIR/result_large_err.rs:107:31 | LL | pub fn array_error() -> Result<(), ArrayError<(i32, T), U>> { @@ -103,5 +107,5 @@ LL | pub fn array_error() -> Result<(), ArrayError<(i32, T), U>> { | = help: try reducing the size of `ArrayError<(i32, T), U>`, for example by boxing large elements or replacing it with `Box>` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/result_map_or_into_option.fixed b/tests/ui/result_map_or_into_option.fixed index 331531b5165f..119ff25918a7 100644 --- a/tests/ui/result_map_or_into_option.fixed +++ b/tests/ui/result_map_or_into_option.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::result_map_or_into_option)] diff --git a/tests/ui/result_map_or_into_option.rs b/tests/ui/result_map_or_into_option.rs index 3058480e2ad3..eeeef830af0a 100644 --- a/tests/ui/result_map_or_into_option.rs +++ b/tests/ui/result_map_or_into_option.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::result_map_or_into_option)] diff --git a/tests/ui/result_map_or_into_option.stderr b/tests/ui/result_map_or_into_option.stderr index febf32147d13..d4b94a33c323 100644 --- a/tests/ui/result_map_or_into_option.stderr +++ b/tests/ui/result_map_or_into_option.stderr @@ -1,10 +1,14 @@ -error: called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling `ok()` instead +warning: called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling `ok()` instead --> $DIR/result_map_or_into_option.rs:7:13 | LL | let _ = opt.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^^^ help: try using `ok` instead: `opt.ok()` | - = note: `-D clippy::result-map-or-into-option` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/result_map_or_into_option.rs:3:9 + | +LL | #![warn(clippy::result_map_or_into_option)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/result_map_unit_fn_fixable.fixed b/tests/ui/result_map_unit_fn_fixable.fixed index d8b56237e983..0583d29277b3 100644 --- a/tests/ui/result_map_unit_fn_fixable.fixed +++ b/tests/ui/result_map_unit_fn_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::result_map_unit_fn)] #![allow(unused)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/result_map_unit_fn_fixable.rs b/tests/ui/result_map_unit_fn_fixable.rs index 44f50d21109c..7ad3bdd04bd6 100644 --- a/tests/ui/result_map_unit_fn_fixable.rs +++ b/tests/ui/result_map_unit_fn_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::result_map_unit_fn)] #![allow(unused)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/result_map_unit_fn_fixable.stderr b/tests/ui/result_map_unit_fn_fixable.stderr index 782febd52644..5f6855a4dc07 100644 --- a/tests/ui/result_map_unit_fn_fixable.stderr +++ b/tests/ui/result_map_unit_fn_fixable.stderr @@ -1,4 +1,4 @@ -error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:35:5 | LL | x.field.map(do_nothing); @@ -6,9 +6,13 @@ LL | x.field.map(do_nothing); | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(x_field) }` | - = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/result_map_unit_fn_fixable.rs:2:9 + | +LL | #![warn(clippy::result_map_unit_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:37:5 | LL | x.field.map(do_nothing); @@ -16,7 +20,7 @@ LL | x.field.map(do_nothing); | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(x_field) }` -error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:39:5 | LL | x.field.map(diverge); @@ -24,7 +28,7 @@ LL | x.field.map(diverge); | | | help: try this: `if let Ok(x_field) = x.field { diverge(x_field) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:45:5 | LL | x.field.map(|value| x.do_result_nothing(value + captured)); @@ -32,7 +36,7 @@ LL | x.field.map(|value| x.do_result_nothing(value + captured)); | | | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:47:5 | LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); @@ -40,7 +44,7 @@ LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | | | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:50:5 | LL | x.field.map(|value| do_nothing(value + captured)); @@ -48,7 +52,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:52:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); @@ -56,7 +60,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:54:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); @@ -64,7 +68,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:56:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); @@ -72,7 +76,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:59:5 | LL | x.field.map(|value| diverge(value + captured)); @@ -80,7 +84,7 @@ LL | x.field.map(|value| diverge(value + captured)); | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:61:5 | LL | x.field.map(|value| { diverge(value + captured) }); @@ -88,7 +92,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:63:5 | LL | x.field.map(|value| { diverge(value + captured); }); @@ -96,7 +100,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:65:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); @@ -104,7 +108,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:70:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); @@ -112,7 +116,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | | | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:72:5 | LL | x.field.map(|value| { plus_one(value + captured); }); @@ -120,7 +124,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:74:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); @@ -128,7 +132,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:77:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); @@ -136,7 +140,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | | | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_fixable.rs:79:5 | LL | x.field.map(|value| println!("{:?}", value)); @@ -144,5 +148,5 @@ LL | x.field.map(|value| println!("{:?}", value)); | | | help: try this: `if let Ok(value) = x.field { println!("{:?}", value) }` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/result_map_unit_fn_unfixable.stderr b/tests/ui/result_map_unit_fn_unfixable.stderr index d0e534f63568..c57f6132324b 100644 --- a/tests/ui/result_map_unit_fn_unfixable.stderr +++ b/tests/ui/result_map_unit_fn_unfixable.stderr @@ -1,4 +1,4 @@ -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:23:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); @@ -6,9 +6,13 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | | | help: try this: `if let Ok(value) = x.field { ... }` | - = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/result_map_unit_fn_unfixable.rs:1:9 + | +LL | #![warn(clippy::result_map_unit_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:25:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); @@ -16,7 +20,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) | | | help: try this: `if let Ok(value) = x.field { ... }` -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:29:5 | LL | // x.field.map(|value| { @@ -27,7 +31,7 @@ LL | || }); | |______| | -error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:33:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); @@ -35,7 +39,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | | | help: try this: `if let Ok(value) = x.field { ... }` -error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:37:5 | LL | "12".parse::().map(diverge); @@ -43,7 +47,7 @@ LL | "12".parse::().map(diverge); | | | help: try this: `if let Ok(a) = "12".parse::() { diverge(a) }` -error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` +warning: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` --> $DIR/result_map_unit_fn_unfixable.rs:43:5 | LL | y.map(do_nothing); @@ -51,5 +55,5 @@ LL | y.map(do_nothing); | | | help: try this: `if let Ok(_y) = y { do_nothing(_y) }` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/result_unit_error.stderr b/tests/ui/result_unit_error.stderr index 8393a4bf03bc..58444e9968ec 100644 --- a/tests/ui/result_unit_error.stderr +++ b/tests/ui/result_unit_error.stderr @@ -1,13 +1,17 @@ -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/result_unit_error.rs:3:1 | LL | pub fn returns_unit_error() -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use a custom `Error` type instead - = note: `-D clippy::result-unit-err` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/result_unit_error.rs:1:9 + | +LL | #![warn(clippy::result_unit_err)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/result_unit_error.rs:12:5 | LL | fn get_that_error(&self) -> Result; @@ -15,7 +19,7 @@ LL | fn get_that_error(&self) -> Result; | = help: use a custom `Error` type instead -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/result_unit_error.rs:14:5 | LL | fn get_this_one_too(&self) -> Result { @@ -23,7 +27,7 @@ LL | fn get_this_one_too(&self) -> Result { | = help: use a custom `Error` type instead -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/result_unit_error.rs:32:5 | LL | pub fn unit_error(&self) -> Result { @@ -31,7 +35,7 @@ LL | pub fn unit_error(&self) -> Result { | = help: use a custom `Error` type instead -error: this returns a `Result<_, ()>` +warning: this returns a `Result<_, ()>` --> $DIR/result_unit_error.rs:41:5 | LL | pub fn should_lint() -> ResInv<(), usize> { @@ -39,5 +43,5 @@ LL | pub fn should_lint() -> ResInv<(), usize> { | = help: use a custom `Error` type instead -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/return_self_not_must_use.stderr b/tests/ui/return_self_not_must_use.stderr index 34932fe1c2c5..d03212752a04 100644 --- a/tests/ui/return_self_not_must_use.stderr +++ b/tests/ui/return_self_not_must_use.stderr @@ -1,13 +1,17 @@ -error: missing `#[must_use]` attribute on a method returning `Self` +warning: missing `#[must_use]` attribute on a method returning `Self` --> $DIR/return_self_not_must_use.rs:8:5 | LL | fn what(&self) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type - = note: `-D clippy::return-self-not-must-use` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/return_self_not_must_use.rs:2:9 + | +LL | #![warn(clippy::return_self_not_must_use)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: missing `#[must_use]` attribute on a method returning `Self` +warning: missing `#[must_use]` attribute on a method returning `Self` --> $DIR/return_self_not_must_use.rs:18:5 | LL | / pub fn foo(&self) -> Self { @@ -17,7 +21,7 @@ LL | | } | = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type -error: missing `#[must_use]` attribute on a method returning `Self` +warning: missing `#[must_use]` attribute on a method returning `Self` --> $DIR/return_self_not_must_use.rs:21:5 | LL | / pub fn bar(self) -> Self { @@ -27,5 +31,5 @@ LL | | } | = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/reversed_empty_ranges_fixable.fixed b/tests/ui/reversed_empty_ranges_fixable.fixed index c67edb36c67a..1837249eae1e 100644 --- a/tests/ui/reversed_empty_ranges_fixable.fixed +++ b/tests/ui/reversed_empty_ranges_fixable.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::reversed_empty_ranges)] #![allow(clippy::uninlined_format_args)] @@ -7,11 +7,11 @@ const ANSWER: i32 = 42; fn main() { // These should be linted: - (21..=42).rev().for_each(|x| println!("{}", x)); - let _ = (21..ANSWER).rev().filter(|x| x % 2 == 0).take(10).collect::>(); + (42..=21).for_each(|x| println!("{}", x)); + let _ = (ANSWER..21).filter(|x| x % 2 == 0).take(10).collect::>(); - for _ in (-42..=-21).rev() {} - for _ in (21u32..42u32).rev() {} + for _ in -21..=-42 {} + for _ in 42u32..21u32 {} // These should be ignored as they are not empty ranges: diff --git a/tests/ui/reversed_empty_ranges_fixable.rs b/tests/ui/reversed_empty_ranges_fixable.rs index 0a4fef5bfe87..1837249eae1e 100644 --- a/tests/ui/reversed_empty_ranges_fixable.rs +++ b/tests/ui/reversed_empty_ranges_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::reversed_empty_ranges)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/reversed_empty_ranges_fixable.stderr b/tests/ui/reversed_empty_ranges_fixable.stderr index c2495ea95f97..5060695dae7c 100644 --- a/tests/ui/reversed_empty_ranges_fixable.stderr +++ b/tests/ui/reversed_empty_ranges_fixable.stderr @@ -1,16 +1,20 @@ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_fixable.rs:10:5 | LL | (42..=21).for_each(|x| println!("{}", x)); | ^^^^^^^^^ | - = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/reversed_empty_ranges_fixable.rs:2:9 + | +LL | #![warn(clippy::reversed_empty_ranges)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | LL | (21..=42).rev().for_each(|x| println!("{}", x)); | ~~~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_fixable.rs:11:13 | LL | let _ = (ANSWER..21).filter(|x| x % 2 == 0).take(10).collect::>(); @@ -21,7 +25,7 @@ help: consider using the following if you are attempting to iterate over this ra LL | let _ = (21..ANSWER).rev().filter(|x| x % 2 == 0).take(10).collect::>(); | ~~~~~~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_fixable.rs:13:14 | LL | for _ in -21..=-42 {} @@ -32,7 +36,7 @@ help: consider using the following if you are attempting to iterate over this ra LL | for _ in (-42..=-21).rev() {} | ~~~~~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_fixable.rs:14:14 | LL | for _ in 42u32..21u32 {} @@ -43,5 +47,5 @@ help: consider using the following if you are attempting to iterate over this ra LL | for _ in (21u32..42u32).rev() {} | ~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/reversed_empty_ranges_loops_fixable.fixed b/tests/ui/reversed_empty_ranges_loops_fixable.fixed index 78401e463d50..42f9957dfbd0 100644 --- a/tests/ui/reversed_empty_ranges_loops_fixable.fixed +++ b/tests/ui/reversed_empty_ranges_loops_fixable.fixed @@ -1,19 +1,19 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::reversed_empty_ranges)] #![allow(clippy::uninlined_format_args)] fn main() { const MAX_LEN: usize = 42; - for i in (0..10).rev() { + for i in 10..0 { println!("{}", i); } - for i in (0..=10).rev() { + for i in 10..=0 { println!("{}", i); } - for i in (0..MAX_LEN).rev() { + for i in MAX_LEN..0 { println!("{}", i); } @@ -32,16 +32,16 @@ fn main() { println!("{}", i); } - for i in (0..10).rev().map(|x| x * 2) { + for i in (10..0).map(|x| x * 2) { println!("{}", i); } // testing that the empty range lint folds constants - for i in (5 + 4..10).rev() { + for i in 10..5 + 4 { println!("{}", i); } - for i in ((3 - 1)..(5 + 2)).rev() { + for i in (5 + 2)..(3 - 1) { println!("{}", i); } diff --git a/tests/ui/reversed_empty_ranges_loops_fixable.rs b/tests/ui/reversed_empty_ranges_loops_fixable.rs index f9e0f7fcd6db..42f9957dfbd0 100644 --- a/tests/ui/reversed_empty_ranges_loops_fixable.rs +++ b/tests/ui/reversed_empty_ranges_loops_fixable.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::reversed_empty_ranges)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/reversed_empty_ranges_loops_fixable.stderr b/tests/ui/reversed_empty_ranges_loops_fixable.stderr index dfc52e64c751..c73532b3ed08 100644 --- a/tests/ui/reversed_empty_ranges_loops_fixable.stderr +++ b/tests/ui/reversed_empty_ranges_loops_fixable.stderr @@ -1,16 +1,20 @@ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_fixable.rs:8:14 | LL | for i in 10..0 { | ^^^^^ | - = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/reversed_empty_ranges_loops_fixable.rs:2:9 + | +LL | #![warn(clippy::reversed_empty_ranges)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | LL | for i in (0..10).rev() { | ~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_fixable.rs:12:14 | LL | for i in 10..=0 { @@ -21,7 +25,7 @@ help: consider using the following if you are attempting to iterate over this ra LL | for i in (0..=10).rev() { | ~~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_fixable.rs:16:14 | LL | for i in MAX_LEN..0 { @@ -32,7 +36,7 @@ help: consider using the following if you are attempting to iterate over this ra LL | for i in (0..MAX_LEN).rev() { | ~~~~~~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_fixable.rs:35:14 | LL | for i in (10..0).map(|x| x * 2) { @@ -43,7 +47,7 @@ help: consider using the following if you are attempting to iterate over this ra LL | for i in (0..10).rev().map(|x| x * 2) { | ~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_fixable.rs:40:14 | LL | for i in 10..5 + 4 { @@ -54,7 +58,7 @@ help: consider using the following if you are attempting to iterate over this ra LL | for i in (5 + 4..10).rev() { | ~~~~~~~~~~~~~~~~~ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_fixable.rs:44:14 | LL | for i in (5 + 2)..(3 - 1) { @@ -65,5 +69,5 @@ help: consider using the following if you are attempting to iterate over this ra LL | for i in ((3 - 1)..(5 + 2)).rev() { | ~~~~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/reversed_empty_ranges_loops_unfixable.stderr b/tests/ui/reversed_empty_ranges_loops_unfixable.stderr index 4490ff35f5a6..10dfd7fd1c50 100644 --- a/tests/ui/reversed_empty_ranges_loops_unfixable.stderr +++ b/tests/ui/reversed_empty_ranges_loops_unfixable.stderr @@ -1,16 +1,20 @@ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_unfixable.rs:5:14 | LL | for i in 5..5 { | ^^^^ | - = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/reversed_empty_ranges_loops_unfixable.rs:1:9 + | +LL | #![warn(clippy::reversed_empty_ranges)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_loops_unfixable.rs:9:14 | LL | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/reversed_empty_ranges_unfixable.stderr b/tests/ui/reversed_empty_ranges_unfixable.stderr index f23d4eb0f9ca..bac1ca66a176 100644 --- a/tests/ui/reversed_empty_ranges_unfixable.stderr +++ b/tests/ui/reversed_empty_ranges_unfixable.stderr @@ -1,22 +1,26 @@ -error: this range is reversed and using it to index a slice will panic at run-time +warning: this range is reversed and using it to index a slice will panic at run-time --> $DIR/reversed_empty_ranges_unfixable.rs:8:18 | LL | let _ = &arr[3usize..=1usize]; | ^^^^^^^^^^^^^^^ | - = note: `-D clippy::reversed-empty-ranges` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/reversed_empty_ranges_unfixable.rs:1:9 + | +LL | #![warn(clippy::reversed_empty_ranges)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this range is reversed and using it to index a slice will panic at run-time +warning: this range is reversed and using it to index a slice will panic at run-time --> $DIR/reversed_empty_ranges_unfixable.rs:9:18 | LL | let _ = &arr[SOME_NUM..1]; | ^^^^^^^^^^^ -error: this range is empty so it will yield no values +warning: this range is empty so it will yield no values --> $DIR/reversed_empty_ranges_unfixable.rs:11:14 | LL | for _ in ANSWER..ANSWER {} | ^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/same_functions_in_if_condition.rs b/tests/ui/same_functions_in_if_condition.rs index e6198a1bc9a0..02e347ed9f6c 100644 --- a/tests/ui/same_functions_in_if_condition.rs +++ b/tests/ui/same_functions_in_if_condition.rs @@ -1,5 +1,5 @@ #![feature(adt_const_params)] -#![warn(clippy::same_functions_in_if_condition)] +#![deny(clippy::same_functions_in_if_condition)] // ifs_same_cond warning is different from `ifs_same_cond`. // clippy::if_same_then_else, clippy::comparison_chain -- all empty blocks #![allow(incomplete_features)] @@ -35,33 +35,33 @@ fn ifs_same_cond_fn() { if function() { } else if function() { - //~ ERROR ifs same condition + //~^ ERROR: `if` has the same function call as a previous `if` } if fn_arg(a) { } else if fn_arg(a) { - //~ ERROR ifs same condition + //~^ ERROR: `if` has the same function call as a previous `if` } if obj.method() { } else if obj.method() { - //~ ERROR ifs same condition + //~^ ERROR: `if` has the same function call as a previous `if` } if obj.method_arg(a) { } else if obj.method_arg(a) { - //~ ERROR ifs same condition + //~^ ERROR: `if` has the same function call as a previous `if` } let mut v = vec![1]; if v.pop().is_none() { - //~ ERROR ifs same condition } else if v.pop().is_none() { + //~^ ERROR: `if` has the same function call as a previous `if` } if v.len() == 42 { - //~ ERROR ifs same condition } else if v.len() == 42 { + //~^ ERROR: `if` has the same function call as a previous `if` } if v.len() == 1 { diff --git a/tests/ui/same_functions_in_if_condition.stderr b/tests/ui/same_functions_in_if_condition.stderr index f352ade150ee..d7b2d762db72 100644 --- a/tests/ui/same_functions_in_if_condition.stderr +++ b/tests/ui/same_functions_in_if_condition.stderr @@ -9,7 +9,11 @@ note: same as this | LL | if function() { | ^^^^^^^^^^ - = note: `-D clippy::same-functions-in-if-condition` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/same_functions_in_if_condition.rs:2:9 + | +LL | #![deny(clippy::same_functions_in_if_condition)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` --> $DIR/same_functions_in_if_condition.rs:42:15 @@ -48,7 +52,7 @@ LL | if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:59:15 + --> $DIR/same_functions_in_if_condition.rs:58:15 | LL | } else if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ @@ -60,7 +64,7 @@ LL | if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:64:15 + --> $DIR/same_functions_in_if_condition.rs:63:15 | LL | } else if v.len() == 42 { | ^^^^^^^^^^^^^ diff --git a/tests/ui/same_item_push.stderr b/tests/ui/same_item_push.stderr index 1d1254d9fcc6..bddefa2a37a4 100644 --- a/tests/ui/same_item_push.stderr +++ b/tests/ui/same_item_push.stderr @@ -1,13 +1,17 @@ -error: it looks like the same item is being pushed into this Vec +warning: it looks like the same item is being pushed into this Vec --> $DIR/same_item_push.rs:23:9 | LL | vec.push(item); | ^^^ | = help: try using vec![item;SIZE] or vec.resize(NEW_SIZE, item) - = note: `-D clippy::same-item-push` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/same_item_push.rs:1:9 + | +LL | #![warn(clippy::same_item_push)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: it looks like the same item is being pushed into this Vec +warning: it looks like the same item is being pushed into this Vec --> $DIR/same_item_push.rs:29:9 | LL | vec.push(item); @@ -15,7 +19,7 @@ LL | vec.push(item); | = help: try using vec![item;SIZE] or vec.resize(NEW_SIZE, item) -error: it looks like the same item is being pushed into this Vec +warning: it looks like the same item is being pushed into this Vec --> $DIR/same_item_push.rs:34:9 | LL | vec.push(13); @@ -23,7 +27,7 @@ LL | vec.push(13); | = help: try using vec![13;SIZE] or vec.resize(NEW_SIZE, 13) -error: it looks like the same item is being pushed into this Vec +warning: it looks like the same item is being pushed into this Vec --> $DIR/same_item_push.rs:39:9 | LL | vec.push(VALUE); @@ -31,7 +35,7 @@ LL | vec.push(VALUE); | = help: try using vec![VALUE;SIZE] or vec.resize(NEW_SIZE, VALUE) -error: it looks like the same item is being pushed into this Vec +warning: it looks like the same item is being pushed into this Vec --> $DIR/same_item_push.rs:45:9 | LL | vec.push(item); @@ -39,5 +43,5 @@ LL | vec.push(item); | = help: try using vec![item;SIZE] or vec.resize(NEW_SIZE, item) -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/same_name_method.stderr b/tests/ui/same_name_method.stderr index 0c6908c09593..708226a8c714 100644 --- a/tests/ui/same_name_method.stderr +++ b/tests/ui/same_name_method.stderr @@ -1,4 +1,4 @@ -error: method's name is the same as an existing method in a trait +warning: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:21:13 | LL | fn foo() {} @@ -9,9 +9,13 @@ note: existing `foo` defined here | LL | fn foo() {} | ^^^^^^^^^^^ - = note: `-D clippy::same-name-method` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/same_name_method.rs:2:9 + | +LL | #![warn(clippy::same_name_method)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: method's name is the same as an existing method in a trait +warning: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:35:13 | LL | fn clone() {} @@ -22,9 +26,9 @@ note: existing `clone` defined here | LL | #[derive(Clone)] | ^^^^^ - = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) -error: method's name is the same as an existing method in a trait +warning: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:45:13 | LL | fn foo() {} @@ -36,7 +40,7 @@ note: existing `foo` defined here LL | fn foo() {} | ^^^^^^^^^^^ -error: method's name is the same as an existing method in a trait +warning: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:59:13 | LL | fn foo() {} @@ -48,7 +52,7 @@ note: existing `foo` defined here LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ -error: method's name is the same as an existing method in a trait +warning: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:71:13 | LL | fn foo() {} @@ -60,5 +64,5 @@ note: existing `foo` defined here LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/search_is_some.rs b/tests/ui/search_is_some.rs index 72f335153c1b..670599b0dcf5 100644 --- a/tests/ui/search_is_some.rs +++ b/tests/ui/search_is_some.rs @@ -1,4 +1,4 @@ -// aux-build:option_helpers.rs +//@aux-build:option_helpers.rs #![warn(clippy::search_is_some)] #![allow(dead_code)] extern crate option_helpers; diff --git a/tests/ui/search_is_some.stderr b/tests/ui/search_is_some.stderr index 6bea8c674779..5e45b4d279e2 100644 --- a/tests/ui/search_is_some.stderr +++ b/tests/ui/search_is_some.stderr @@ -1,4 +1,4 @@ -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some.rs:14:13 | LL | let _ = v.iter().find(|&x| { @@ -9,9 +9,13 @@ LL | | ).is_some(); | |______________________________^ | = help: this is more succinctly expressed by calling `any()` - = note: `-D clippy::search-is-some` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/search_is_some.rs:2:9 + | +LL | #![warn(clippy::search_is_some)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: called `is_some()` after searching an `Iterator` with `position` +warning: called `is_some()` after searching an `Iterator` with `position` --> $DIR/search_is_some.rs:20:13 | LL | let _ = v.iter().position(|&x| { @@ -23,7 +27,7 @@ LL | | ).is_some(); | = help: this is more succinctly expressed by calling `any()` -error: called `is_some()` after searching an `Iterator` with `rposition` +warning: called `is_some()` after searching an `Iterator` with `rposition` --> $DIR/search_is_some.rs:26:13 | LL | let _ = v.iter().rposition(|&x| { @@ -35,13 +39,13 @@ LL | | ).is_some(); | = help: this is more succinctly expressed by calling `any()` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some.rs:41:20 | LL | let _ = (0..1).find(some_closure).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(some_closure)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some.rs:51:13 | LL | let _ = v.iter().find(|&x| { @@ -53,7 +57,7 @@ LL | | ).is_none(); | = help: this is more succinctly expressed by calling `any()` with negation -error: called `is_none()` after searching an `Iterator` with `position` +warning: called `is_none()` after searching an `Iterator` with `position` --> $DIR/search_is_some.rs:57:13 | LL | let _ = v.iter().position(|&x| { @@ -65,7 +69,7 @@ LL | | ).is_none(); | = help: this is more succinctly expressed by calling `any()` with negation -error: called `is_none()` after searching an `Iterator` with `rposition` +warning: called `is_none()` after searching an `Iterator` with `rposition` --> $DIR/search_is_some.rs:63:13 | LL | let _ = v.iter().rposition(|&x| { @@ -77,11 +81,11 @@ LL | | ).is_none(); | = help: this is more succinctly expressed by calling `any()` with negation -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some.rs:78:13 | LL | let _ = (0..1).find(some_closure).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(some_closure)` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/search_is_some_fixable_none.fixed b/tests/ui/search_is_some_fixable_none.fixed index 5190c5304c75..6b717dc9b689 100644 --- a/tests/ui/search_is_some_fixable_none.fixed +++ b/tests/ui/search_is_some_fixable_none.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::explicit_auto_deref)] #![warn(clippy::search_is_some)] @@ -117,8 +117,8 @@ mod issue7392 { let _ = ![String::from("Hey hey")].iter().any(|s| s.len() == 2); let v = vec![3, 2, 1, 0]; - let _ = !v.iter().any(|x| deref_enough(*x)); - let _ = !v.iter().any(|x: &u32| deref_enough(*x)); + let _ = v.iter().find(|x| deref_enough(**x)).is_none(); + let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_none(); #[allow(clippy::redundant_closure)] let _ = !v.iter().any(|x| arg_no_deref(&x)); @@ -211,6 +211,6 @@ mod issue7392 { let v = vec![instance]; let _ = !v.iter().any(|fp| fp.field.is_power_of_two()); let _ = !v.iter().any(|fp| test_u32_1(fp.field)); - let _ = !v.iter().any(|fp| test_u32_2(*fp.field)); + let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none(); } } diff --git a/tests/ui/search_is_some_fixable_none.rs b/tests/ui/search_is_some_fixable_none.rs index 310d87333a93..6b2537a96c2a 100644 --- a/tests/ui/search_is_some_fixable_none.rs +++ b/tests/ui/search_is_some_fixable_none.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::explicit_auto_deref)] #![warn(clippy::search_is_some)] diff --git a/tests/ui/search_is_some_fixable_none.stderr b/tests/ui/search_is_some_fixable_none.stderr index 933ce5cf42d2..fa516481f4f1 100644 --- a/tests/ui/search_is_some_fixable_none.stderr +++ b/tests/ui/search_is_some_fixable_none.stderr @@ -1,54 +1,58 @@ -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:10:13 | LL | let _ = v.iter().find(|&x| *x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| *x < 0)` | - = note: `-D clippy::search-is-some` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/search_is_some_fixable_none.rs:3:9 + | +LL | #![warn(clippy::search_is_some)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:11:13 | LL | let _ = (0..1).find(|x| **y == *x).is_none(); // one dereference less | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(|x| **y == x)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:12:13 | LL | let _ = (0..1).find(|x| *x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(0..1).any(|x| x == 0)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:13:13 | LL | let _ = v.iter().find(|x| **x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| *x == 0)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:14:13 | LL | let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(4..5).any(|x| x == 1 || x == 3 || x == 5)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:15:13 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(1..3).any(|x| [1, 2, 3].contains(&x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:16:13 | LL | let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(1..3).any(|x| x == 0 || [1, 2, 3].contains(&x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:17:13 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:18:13 | LL | let _ = (1..3) @@ -57,91 +61,91 @@ LL | | .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains( LL | | .is_none(); | |__________________^ help: use `!_.any()` instead: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)` -error: called `is_none()` after searching an `Iterator` with `position` +warning: called `is_none()` after searching an `Iterator` with `position` --> $DIR/search_is_some_fixable_none.rs:23:13 | LL | let _ = v.iter().position(|&x| x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|&x| x < 0)` -error: called `is_none()` after searching an `Iterator` with `rposition` +warning: called `is_none()` after searching an `Iterator` with `rposition` --> $DIR/search_is_some_fixable_none.rs:26:13 | LL | let _ = v.iter().rposition(|&x| x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|&x| x < 0)` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:32:13 | LL | let _ = "hello world".find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!"hello world".contains("world")` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:33:13 | LL | let _ = "hello world".find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!"hello world".contains(&s2)` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:34:13 | LL | let _ = "hello world".find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!"hello world".contains(&s2[2..])` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:36:13 | LL | let _ = s1.find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1.contains("world")` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:37:13 | LL | let _ = s1.find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1.contains(&s2)` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:38:13 | LL | let _ = s1.find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1.contains(&s2[2..])` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:40:13 | LL | let _ = s1[2..].find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1[2..].contains("world")` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:41:13 | LL | let _ = s1[2..].find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1[2..].contains(&s2)` -error: called `is_none()` after calling `find()` on a string +warning: called `is_none()` after calling `find()` on a string --> $DIR/search_is_some_fixable_none.rs:42:13 | LL | let _ = s1[2..].find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.contains()` instead: `!s1[2..].contains(&s2[2..])` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:58:25 | LL | .filter(|c| filter_hand.iter().find(|cc| c == cc).is_none()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!filter_hand.iter().any(|cc| c == &cc)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:74:30 | LL | .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_none()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!filter_hand.iter().any(|cc| c == cc)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:85:17 | LL | let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.foo == 1 && v.bar == 2)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:88:17 | LL | let _ = vfoo @@ -157,55 +161,55 @@ LL ~ let _ = !vfoo LL ~ .iter().any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2); | -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:96:17 | LL | let _ = vfoo.iter().find(|a| a[0] == 42).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|a| a[0] == 42)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:102:17 | LL | let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|sub| sub[1..4].len() == 3)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:120:17 | LL | let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![ppx].iter().any(|ppp_x: &&u32| please(ppp_x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:121:17 | LL | let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![String::from("Hey hey")].iter().any(|s| s.len() == 2)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:124:17 | LL | let _ = v.iter().find(|x| deref_enough(**x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| deref_enough(*x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:125:17 | LL | let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x: &u32| deref_enough(*x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:128:17 | LL | let _ = v.iter().find(|x| arg_no_deref(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x| arg_no_deref(&x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:130:17 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|x: &u32| arg_no_deref(&x))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:150:17 | LL | let _ = vfoo @@ -221,65 +225,65 @@ LL ~ let _ = !vfoo LL ~ .iter().any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2); | -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:166:17 | LL | let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.inner[0].bar == 2)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:171:17 | LL | let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|x| (**x)[0] == 9)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:184:17 | LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!vfoo.iter().any(|v| v.by_ref(&v.bar))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:188:17 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:189:17 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:208:17 | LL | let _ = v.iter().find(|s| s[0].is_empty()).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|s| s[0].is_empty())` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:209:17 | LL | let _ = v.iter().find(|s| test_string_1(&s[0])).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|s| test_string_1(&s[0]))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:218:17 | LL | let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|fp| fp.field.is_power_of_two())` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:219:17 | LL | let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|fp| test_u32_1(fp.field))` -error: called `is_none()` after searching an `Iterator` with `find` +warning: called `is_none()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_none.rs:220:17 | LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `!_.any()` instead: `!v.iter().any(|fp| test_u32_2(*fp.field))` -error: aborting due to 43 previous errors +warning: 43 warnings emitted diff --git a/tests/ui/search_is_some_fixable_some.fixed b/tests/ui/search_is_some_fixable_some.fixed index 385a9986aba0..64224153c1ac 100644 --- a/tests/ui/search_is_some_fixable_some.fixed +++ b/tests/ui/search_is_some_fixable_some.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::explicit_auto_deref)] #![warn(clippy::search_is_some)] @@ -118,8 +118,8 @@ mod issue7392 { let _ = [String::from("Hey hey")].iter().any(|s| s.len() == 2); let v = vec![3, 2, 1, 0]; - let _ = v.iter().any(|x| deref_enough(*x)); - let _ = v.iter().any(|x: &u32| deref_enough(*x)); + let _ = v.iter().find(|x| deref_enough(**x)).is_some(); + let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_some(); #[allow(clippy::redundant_closure)] let _ = v.iter().any(|x| arg_no_deref(&x)); @@ -213,7 +213,7 @@ mod issue7392 { let v = vec![instance]; let _ = v.iter().any(|fp| fp.field.is_power_of_two()); let _ = v.iter().any(|fp| test_u32_1(fp.field)); - let _ = v.iter().any(|fp| test_u32_2(*fp.field)); + let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_some(); } } diff --git a/tests/ui/search_is_some_fixable_some.rs b/tests/ui/search_is_some_fixable_some.rs index 67e190ee3783..b15283994576 100644 --- a/tests/ui/search_is_some_fixable_some.rs +++ b/tests/ui/search_is_some_fixable_some.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, clippy::explicit_auto_deref)] #![warn(clippy::search_is_some)] diff --git a/tests/ui/search_is_some_fixable_some.stderr b/tests/ui/search_is_some_fixable_some.stderr index c5c3c92c9182..750ab82d43f1 100644 --- a/tests/ui/search_is_some_fixable_some.stderr +++ b/tests/ui/search_is_some_fixable_some.stderr @@ -1,54 +1,58 @@ -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:10:22 | LL | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| *x < 0)` | - = note: `-D clippy::search-is-some` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/search_is_some_fixable_some.rs:3:9 + | +LL | #![warn(clippy::search_is_some)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:11:20 | LL | let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| **y == x)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:12:20 | LL | let _ = (0..1).find(|x| *x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| x == 0)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:13:22 | LL | let _ = v.iter().find(|x| **x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| *x == 0)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:14:20 | LL | let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| x == 1 || x == 3 || x == 5)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:15:20 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| [1, 2, 3].contains(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:16:20 | LL | let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| x == 0 || [1, 2, 3].contains(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:17:20 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| [1, 2, 3].contains(&x) || x == 0)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:19:10 | LL | .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1) @@ -56,91 +60,91 @@ LL | .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains( LL | | .is_some(); | |__________________^ help: use `any()` instead: `any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)` -error: called `is_some()` after searching an `Iterator` with `position` +warning: called `is_some()` after searching an `Iterator` with `position` --> $DIR/search_is_some_fixable_some.rs:23:22 | LL | let _ = v.iter().position(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|&x| x < 0)` -error: called `is_some()` after searching an `Iterator` with `rposition` +warning: called `is_some()` after searching an `Iterator` with `rposition` --> $DIR/search_is_some_fixable_some.rs:26:22 | LL | let _ = v.iter().rposition(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|&x| x < 0)` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:31:27 | LL | let _ = "hello world".find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains("world")` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:32:27 | LL | let _ = "hello world".find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2)` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:33:27 | LL | let _ = "hello world".find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2[2..])` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:35:16 | LL | let _ = s1.find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains("world")` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:36:16 | LL | let _ = s1.find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2)` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:37:16 | LL | let _ = s1.find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2[2..])` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:39:21 | LL | let _ = s1[2..].find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains("world")` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:40:21 | LL | let _ = s1[2..].find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2)` -error: called `is_some()` after calling `find()` on a string +warning: called `is_some()` after calling `find()` on a string --> $DIR/search_is_some_fixable_some.rs:41:21 | LL | let _ = s1[2..].find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use `contains()` instead: `contains(&s2[2..])` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:57:44 | LL | .filter(|c| filter_hand.iter().find(|cc| c == cc).is_some()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|cc| c == &cc)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:73:49 | LL | .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_some()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|cc| c == cc)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:84:29 | LL | let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.foo == 1 && v.bar == 2)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:89:14 | LL | .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2) @@ -148,55 +152,55 @@ LL | .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2) LL | | .is_some(); | |______________________^ help: use `any()` instead: `any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:95:29 | LL | let _ = vfoo.iter().find(|a| a[0] == 42).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|a| a[0] == 42)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:101:29 | LL | let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|sub| sub[1..4].len() == 3)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:119:30 | LL | let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|ppp_x: &&u32| please(ppp_x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:120:50 | LL | let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|s| s.len() == 2)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:123:26 | LL | let _ = v.iter().find(|x| deref_enough(**x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| deref_enough(*x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:124:26 | LL | let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| deref_enough(*x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:127:26 | LL | let _ = v.iter().find(|x| arg_no_deref(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| arg_no_deref(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:129:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| arg_no_deref(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:151:14 | LL | .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2) @@ -204,89 +208,89 @@ LL | .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == LL | | .is_some(); | |______________________^ help: use `any()` instead: `any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:165:29 | LL | let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.inner[0].bar == 2)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:170:29 | LL | let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x| (**x)[0] == 9)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:183:29 | LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|v| v.by_ref(&v.bar))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:187:55 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|(&x, y)| x == *y)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:188:55 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|(&x, y)| x == *y)` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:207:26 | LL | let _ = v.iter().find(|s| s[0].is_empty()).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|s| s[0].is_empty())` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:208:26 | LL | let _ = v.iter().find(|s| test_string_1(&s[0])).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|s| test_string_1(&s[0]))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:217:26 | LL | let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|fp| fp.field.is_power_of_two())` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:218:26 | LL | let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|fp| test_u32_1(fp.field))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:219:26 | LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|fp| test_u32_2(*fp.field))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:234:18 | LL | v.iter().find(|x: &&u32| func(x)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| func(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:243:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_impl(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| arg_no_deref_impl(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:246:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_dyn(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| arg_no_deref_dyn(&x))` -error: called `is_some()` after searching an `Iterator` with `find` +warning: called `is_some()` after searching an `Iterator` with `find` --> $DIR/search_is_some_fixable_some.rs:249:26 | LL | let _ = v.iter().find(|x: &&u32| (*arg_no_deref_dyn)(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `any()` instead: `any(|x: &u32| (*arg_no_deref_dyn)(&x))` -error: aborting due to 47 previous errors +warning: 47 warnings emitted diff --git a/tests/ui/seek_from_current.fixed b/tests/ui/seek_from_current.fixed index 1309c91b81c9..34c33baf686d 100644 --- a/tests/ui/seek_from_current.fixed +++ b/tests/ui/seek_from_current.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::seek_from_current)] use std::fs::File; diff --git a/tests/ui/seek_from_current.rs b/tests/ui/seek_from_current.rs index 5d9b1424cf68..22bcff1bc405 100644 --- a/tests/ui/seek_from_current.rs +++ b/tests/ui/seek_from_current.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::seek_from_current)] use std::fs::File; diff --git a/tests/ui/seek_from_current.stderr b/tests/ui/seek_from_current.stderr index c079f3611929..d6a4e9b14b5d 100644 --- a/tests/ui/seek_from_current.stderr +++ b/tests/ui/seek_from_current.stderr @@ -1,10 +1,14 @@ -error: using `SeekFrom::Current` to start from current position +warning: using `SeekFrom::Current` to start from current position --> $DIR/seek_from_current.rs:20:5 | LL | f.seek(SeekFrom::Current(0))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `f.stream_position()` | - = note: `-D clippy::seek-from-current` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/seek_from_current.rs:2:9 + | +LL | #![warn(clippy::seek_from_current)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/seek_to_start_instead_of_rewind.fixed b/tests/ui/seek_to_start_instead_of_rewind.fixed index dc24d447c607..d8a6e6985d4a 100644 --- a/tests/ui/seek_to_start_instead_of_rewind.fixed +++ b/tests/ui/seek_to_start_instead_of_rewind.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::seek_to_start_instead_of_rewind)] diff --git a/tests/ui/seek_to_start_instead_of_rewind.rs b/tests/ui/seek_to_start_instead_of_rewind.rs index 4adde2c40182..fc6a6433c2b0 100644 --- a/tests/ui/seek_to_start_instead_of_rewind.rs +++ b/tests/ui/seek_to_start_instead_of_rewind.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused)] #![warn(clippy::seek_to_start_instead_of_rewind)] diff --git a/tests/ui/seek_to_start_instead_of_rewind.stderr b/tests/ui/seek_to_start_instead_of_rewind.stderr index 342ec00fe729..e1e0050c5061 100644 --- a/tests/ui/seek_to_start_instead_of_rewind.stderr +++ b/tests/ui/seek_to_start_instead_of_rewind.stderr @@ -1,22 +1,26 @@ -error: used `seek` to go to the start of the stream +warning: used `seek` to go to the start of the stream --> $DIR/seek_to_start_instead_of_rewind.rs:53:7 | LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` | - = note: `-D clippy::seek-to-start-instead-of-rewind` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/seek_to_start_instead_of_rewind.rs:3:9 + | +LL | #![warn(clippy::seek_to_start_instead_of_rewind)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used `seek` to go to the start of the stream +warning: used `seek` to go to the start of the stream --> $DIR/seek_to_start_instead_of_rewind.rs:58:7 | LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` -error: used `seek` to go to the start of the stream +warning: used `seek` to go to the start of the stream --> $DIR/seek_to_start_instead_of_rewind.rs:134:7 | LL | f.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/self_assignment.stderr b/tests/ui/self_assignment.stderr index 826e0d0ba888..34cc490f13c1 100644 --- a/tests/ui/self_assignment.stderr +++ b/tests/ui/self_assignment.stderr @@ -1,70 +1,74 @@ -error: self-assignment of `a` to `a` +warning: self-assignment of `a` to `a` --> $DIR/self_assignment.rs:12:5 | LL | a = a; | ^^^^^ | - = note: `-D clippy::self-assignment` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/self_assignment.rs:1:9 + | +LL | #![warn(clippy::self_assignment)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: self-assignment of `*b` to `*b` +warning: self-assignment of `*b` to `*b` --> $DIR/self_assignment.rs:13:5 | LL | *b = *b; | ^^^^^^^ -error: self-assignment of `s` to `s` +warning: self-assignment of `s` to `s` --> $DIR/self_assignment.rs:14:5 | LL | s = s; | ^^^^^ -error: self-assignment of `s.a` to `s.a` +warning: self-assignment of `s.a` to `s.a` --> $DIR/self_assignment.rs:15:5 | LL | s.a = s.a; | ^^^^^^^^^ -error: self-assignment of `s.b[5 + 5]` to `s.b[10]` +warning: self-assignment of `s.b[5 + 5]` to `s.b[10]` --> $DIR/self_assignment.rs:16:5 | LL | s.b[10] = s.b[5 + 5]; | ^^^^^^^^^^^^^^^^^^^^ -error: self-assignment of `s.c[0][1]` to `s.c[0][1]` +warning: self-assignment of `s.c[0][1]` to `s.c[0][1]` --> $DIR/self_assignment.rs:17:5 | LL | s.c[0][1] = s.c[0][1]; | ^^^^^^^^^^^^^^^^^^^^^ -error: self-assignment of `s.b[a]` to `s.b[a]` +warning: self-assignment of `s.b[a]` to `s.b[a]` --> $DIR/self_assignment.rs:18:5 | LL | s.b[a] = s.b[a]; | ^^^^^^^^^^^^^^^ -error: self-assignment of `*s.e` to `*s.e` +warning: self-assignment of `*s.e` to `*s.e` --> $DIR/self_assignment.rs:19:5 | LL | *s.e = *s.e; | ^^^^^^^^^^^ -error: self-assignment of `s.b[10 + a]` to `s.b[a + 10]` +warning: self-assignment of `s.b[10 + a]` to `s.b[a + 10]` --> $DIR/self_assignment.rs:20:5 | LL | s.b[a + 10] = s.b[10 + a]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: self-assignment of `t.1` to `t.1` +warning: self-assignment of `t.1` to `t.1` --> $DIR/self_assignment.rs:23:5 | LL | t.1 = t.1; | ^^^^^^^^^ -error: self-assignment of `(t.0)` to `t.0` +warning: self-assignment of `(t.0)` to `t.0` --> $DIR/self_assignment.rs:24:5 | LL | t.0 = (t.0); | ^^^^^^^^^^^ -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/self_named_constructors.stderr b/tests/ui/self_named_constructors.stderr index ba989f06dc80..d1811155fe66 100644 --- a/tests/ui/self_named_constructors.stderr +++ b/tests/ui/self_named_constructors.stderr @@ -1,4 +1,4 @@ -error: constructor `should_spawn` has the same name as the type +warning: constructor `should_spawn` has the same name as the type --> $DIR/self_named_constructors.rs:7:5 | LL | / pub fn should_spawn() -> ShouldSpawn { @@ -6,7 +6,11 @@ LL | | ShouldSpawn LL | | } | |_____^ | - = note: `-D clippy::self-named-constructors` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/self_named_constructors.rs:1:9 + | +LL | #![warn(clippy::self_named_constructors)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/semicolon_if_nothing_returned.stderr b/tests/ui/semicolon_if_nothing_returned.stderr index 8d9a67585cf1..ce96194f3ad6 100644 --- a/tests/ui/semicolon_if_nothing_returned.stderr +++ b/tests/ui/semicolon_if_nothing_returned.stderr @@ -1,34 +1,38 @@ -error: consider adding a `;` to the last statement for consistent formatting +warning: consider adding a `;` to the last statement for consistent formatting --> $DIR/semicolon_if_nothing_returned.rs:8:5 | LL | println!("Hello") | ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");` | - = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/semicolon_if_nothing_returned.rs:1:9 + | +LL | #![warn(clippy::semicolon_if_nothing_returned)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: consider adding a `;` to the last statement for consistent formatting +warning: consider adding a `;` to the last statement for consistent formatting --> $DIR/semicolon_if_nothing_returned.rs:12:5 | LL | get_unit() | ^^^^^^^^^^ help: add a `;` here: `get_unit();` -error: consider adding a `;` to the last statement for consistent formatting +warning: consider adding a `;` to the last statement for consistent formatting --> $DIR/semicolon_if_nothing_returned.rs:17:5 | LL | y = x + 1 | ^^^^^^^^^ help: add a `;` here: `y = x + 1;` -error: consider adding a `;` to the last statement for consistent formatting +warning: consider adding a `;` to the last statement for consistent formatting --> $DIR/semicolon_if_nothing_returned.rs:23:9 | LL | hello() | ^^^^^^^ help: add a `;` here: `hello();` -error: consider adding a `;` to the last statement for consistent formatting +warning: consider adding a `;` to the last statement for consistent formatting --> $DIR/semicolon_if_nothing_returned.rs:34:9 | LL | ptr::drop_in_place(s.as_mut_ptr()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/semicolon_inside_block.fixed b/tests/ui/semicolon_inside_block.fixed index 42e97e1ca358..ee359f60cbd7 100644 --- a/tests/ui/semicolon_inside_block.fixed +++ b/tests/ui/semicolon_inside_block.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( unused, clippy::unused_unit, diff --git a/tests/ui/semicolon_inside_block.rs b/tests/ui/semicolon_inside_block.rs index f40848f702e1..e8516f79b20c 100644 --- a/tests/ui/semicolon_inside_block.rs +++ b/tests/ui/semicolon_inside_block.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( unused, clippy::unused_unit, diff --git a/tests/ui/semicolon_inside_block.stderr b/tests/ui/semicolon_inside_block.stderr index 48d3690e2bde..3c71ee589c9c 100644 --- a/tests/ui/semicolon_inside_block.stderr +++ b/tests/ui/semicolon_inside_block.stderr @@ -1,17 +1,21 @@ -error: consider moving the `;` inside the block for consistent formatting +warning: consider moving the `;` inside the block for consistent formatting --> $DIR/semicolon_inside_block.rs:39:5 | LL | { unit_fn_block() }; | ^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::semicolon-inside-block` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/semicolon_inside_block.rs:9:9 + | +LL | #![warn(clippy::semicolon_inside_block)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: put the `;` here | LL - { unit_fn_block() }; LL + { unit_fn_block(); } | -error: consider moving the `;` inside the block for consistent formatting +warning: consider moving the `;` inside the block for consistent formatting --> $DIR/semicolon_inside_block.rs:40:5 | LL | unsafe { unit_fn_block() }; @@ -23,7 +27,7 @@ LL - unsafe { unit_fn_block() }; LL + unsafe { unit_fn_block(); } | -error: consider moving the `;` inside the block for consistent formatting +warning: consider moving the `;` inside the block for consistent formatting --> $DIR/semicolon_inside_block.rs:48:5 | LL | / { @@ -38,7 +42,7 @@ LL ~ unit_fn_block(); LL ~ } | -error: consider moving the `;` inside the block for consistent formatting +warning: consider moving the `;` inside the block for consistent formatting --> $DIR/semicolon_inside_block.rs:61:5 | LL | { m!(()) }; @@ -50,5 +54,5 @@ LL - { m!(()) }; LL + { m!(()); } | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/semicolon_outside_block.fixed b/tests/ui/semicolon_outside_block.fixed index 091eaa7518e9..034c7f8c7c18 100644 --- a/tests/ui/semicolon_outside_block.fixed +++ b/tests/ui/semicolon_outside_block.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( unused, clippy::unused_unit, diff --git a/tests/ui/semicolon_outside_block.rs b/tests/ui/semicolon_outside_block.rs index 7ce46431fac9..4dc956d8a4b5 100644 --- a/tests/ui/semicolon_outside_block.rs +++ b/tests/ui/semicolon_outside_block.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow( unused, clippy::unused_unit, diff --git a/tests/ui/semicolon_outside_block.stderr b/tests/ui/semicolon_outside_block.stderr index dcc102e60994..3444c8816082 100644 --- a/tests/ui/semicolon_outside_block.stderr +++ b/tests/ui/semicolon_outside_block.stderr @@ -1,17 +1,21 @@ -error: consider moving the `;` outside the block for consistent formatting +warning: consider moving the `;` outside the block for consistent formatting --> $DIR/semicolon_outside_block.rs:42:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::semicolon-outside-block` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/semicolon_outside_block.rs:9:9 + | +LL | #![warn(clippy::semicolon_outside_block)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: put the `;` here | LL - { unit_fn_block(); } LL + { unit_fn_block() }; | -error: consider moving the `;` outside the block for consistent formatting +warning: consider moving the `;` outside the block for consistent formatting --> $DIR/semicolon_outside_block.rs:43:5 | LL | unsafe { unit_fn_block(); } @@ -23,7 +27,7 @@ LL - unsafe { unit_fn_block(); } LL + unsafe { unit_fn_block() }; | -error: consider moving the `;` outside the block for consistent formatting +warning: consider moving the `;` outside the block for consistent formatting --> $DIR/semicolon_outside_block.rs:52:5 | LL | / { @@ -38,7 +42,7 @@ LL ~ unit_fn_block() LL ~ }; | -error: consider moving the `;` outside the block for consistent formatting +warning: consider moving the `;` outside the block for consistent formatting --> $DIR/semicolon_outside_block.rs:62:5 | LL | { m!(()); } @@ -50,5 +54,5 @@ LL - { m!(()); } LL + { m!(()) }; | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index 760c9c9908a6..987204c166ec 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -1,4 +1,4 @@ -error: you should not implement `visit_string` without also implementing `visit_str` +warning: you should not implement `visit_string` without also implementing `visit_str` --> $DIR/serde.rs:39:5 | LL | / fn visit_string(self, _v: String) -> Result @@ -9,7 +9,11 @@ LL | | unimplemented!() LL | | } | |_____^ | - = note: `-D clippy::serde-api-misuse` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/serde.rs:1:9 + | +LL | #![warn(clippy::serde_api_misuse)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index c3d7bc2a5360..c1a9b3103fa2 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,4 +1,4 @@ -error: `x` is shadowed by itself in `x` +warning: `x` is shadowed by itself in `x` --> $DIR/shadow.rs:6:9 | LL | let x = x; @@ -9,9 +9,13 @@ note: previous binding is here | LL | let x = 1; | ^ - = note: `-D clippy::shadow-same` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/shadow.rs:1:9 + | +LL | #![warn(clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)] + | ^^^^^^^^^^^^^^^^^^^ -error: `mut x` is shadowed by itself in `&x` +warning: `mut x` is shadowed by itself in `&x` --> $DIR/shadow.rs:7:13 | LL | let mut x = &x; @@ -23,7 +27,7 @@ note: previous binding is here LL | let x = x; | ^ -error: `x` is shadowed by itself in `&mut x` +warning: `x` is shadowed by itself in `&mut x` --> $DIR/shadow.rs:8:9 | LL | let x = &mut x; @@ -35,7 +39,7 @@ note: previous binding is here LL | let mut x = &x; | ^^^^^ -error: `x` is shadowed by itself in `*x` +warning: `x` is shadowed by itself in `*x` --> $DIR/shadow.rs:9:9 | LL | let x = *x; @@ -47,7 +51,7 @@ note: previous binding is here LL | let x = &mut x; | ^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:14:9 | LL | let x = x.0; @@ -58,9 +62,13 @@ note: previous binding is here | LL | let x = ([[0]], ()); | ^ - = note: `-D clippy::shadow-reuse` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/shadow.rs:1:30 + | +LL | #![warn(clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)] + | ^^^^^^^^^^^^^^^^^^^^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:15:9 | LL | let x = x[0]; @@ -72,7 +80,7 @@ note: previous binding is here LL | let x = x.0; | ^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:16:10 | LL | let [x] = x; @@ -84,7 +92,7 @@ note: previous binding is here LL | let x = x[0]; | ^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:17:9 | LL | let x = Some(x); @@ -96,7 +104,7 @@ note: previous binding is here LL | let [x] = x; | ^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:18:9 | LL | let x = foo(x); @@ -108,7 +116,7 @@ note: previous binding is here LL | let x = Some(x); | ^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:19:9 | LL | let x = || x; @@ -120,7 +128,7 @@ note: previous binding is here LL | let x = foo(x); | ^ -error: `x` is shadowed +warning: `x` is shadowed --> $DIR/shadow.rs:20:9 | LL | let x = Some(1).map(|_| x)?; @@ -132,7 +140,7 @@ note: previous binding is here LL | let x = || x; | ^ -error: `y` is shadowed +warning: `y` is shadowed --> $DIR/shadow.rs:22:9 | LL | let y = match y { @@ -144,7 +152,7 @@ note: previous binding is here LL | let y = 1; | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:31:9 | LL | let x = 2; @@ -155,9 +163,13 @@ note: previous binding is here | LL | let x = 1; | ^ - = note: `-D clippy::shadow-unrelated` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/shadow.rs:1:52 + | +LL | #![warn(clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:36:13 | LL | let x = 1; @@ -169,7 +181,7 @@ note: previous binding is here LL | fn f(x: u32) { | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:41:14 | LL | Some(x) => { @@ -181,7 +193,7 @@ note: previous binding is here LL | let x = 1; | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:42:17 | LL | let x = 1; @@ -193,7 +205,7 @@ note: previous binding is here LL | Some(x) => { | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:46:17 | LL | if let Some(x) = Some(1) {} @@ -205,7 +217,7 @@ note: previous binding is here LL | let x = 1; | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:47:20 | LL | while let Some(x) = Some(1) {} @@ -217,7 +229,7 @@ note: previous binding is here LL | let x = 1; | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:48:15 | LL | let _ = |[x]: [u32; 1]| { @@ -229,7 +241,7 @@ note: previous binding is here LL | let x = 1; | ^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:49:13 | LL | let x = 1; @@ -241,7 +253,7 @@ note: previous binding is here LL | let _ = |[x]: [u32; 1]| { | ^ -error: `y` is shadowed +warning: `y` is shadowed --> $DIR/shadow.rs:52:17 | LL | if let Some(y) = y {} @@ -253,7 +265,7 @@ note: previous binding is here LL | let y = Some(1); | ^ -error: `_b` shadows a previous, unrelated binding +warning: `_b` shadows a previous, unrelated binding --> $DIR/shadow.rs:88:9 | LL | let _b = _a; @@ -265,7 +277,7 @@ note: previous binding is here LL | pub async fn foo2(_a: i32, _b: i64) { | ^^ -error: `x` shadows a previous, unrelated binding +warning: `x` shadows a previous, unrelated binding --> $DIR/shadow.rs:94:21 | LL | if let Some(x) = Some(1) { x } else { 1 } @@ -277,5 +289,5 @@ note: previous binding is here LL | let x = 1; | ^ -error: aborting due to 23 previous errors +warning: 23 warnings emitted diff --git a/tests/ui/short_circuit_statement.fixed b/tests/ui/short_circuit_statement.fixed index dd22ecab0b55..1737d5014419 100644 --- a/tests/ui/short_circuit_statement.fixed +++ b/tests/ui/short_circuit_statement.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::short_circuit_statement)] #![allow(clippy::nonminimal_bool)] diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index 73a55bf1f5e2..ab93aa1ca5ca 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::short_circuit_statement)] #![allow(clippy::nonminimal_bool)] diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index aa84ac3a7925..9a734d86155e 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -1,22 +1,26 @@ -error: boolean short circuit operator in statement may be clearer using an explicit test +warning: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:7:5 | LL | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` | - = note: `-D clippy::short-circuit-statement` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/short_circuit_statement.rs:3:9 + | +LL | #![warn(clippy::short_circuit_statement)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: boolean short circuit operator in statement may be clearer using an explicit test +warning: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:8:5 | LL | f() || g(); | ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }` -error: boolean short circuit operator in statement may be clearer using an explicit test +warning: boolean short circuit operator in statement may be clearer using an explicit test --> $DIR/short_circuit_statement.rs:9:5 | LL | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if 1 != 2 { g(); }` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/should_impl_trait/method_list_1.stderr b/tests/ui/should_impl_trait/method_list_1.stderr index 161dd66b086e..91b344d1dc37 100644 --- a/tests/ui/should_impl_trait/method_list_1.stderr +++ b/tests/ui/should_impl_trait/method_list_1.stderr @@ -1,4 +1,4 @@ -error: method `add` can be confused for the standard trait method `std::ops::Add::add` +warning: method `add` can be confused for the standard trait method `std::ops::Add::add` --> $DIR/method_list_1.rs:25:5 | LL | / pub fn add(self, other: T) -> T { @@ -7,9 +7,14 @@ LL | | } | |_____^ | = help: consider implementing the trait `std::ops::Add` or choosing a less ambiguous method name - = note: `-D clippy::should-implement-trait` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/method_list_1.rs:1:9 + | +LL | #![warn(clippy::all, clippy::pedantic)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::should_implement_trait)]` implied by `#[warn(clippy::all)]` -error: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` +warning: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` --> $DIR/method_list_1.rs:29:5 | LL | / pub fn as_mut(&mut self) -> &mut T { @@ -19,7 +24,7 @@ LL | | } | = help: consider implementing the trait `std::convert::AsMut` or choosing a less ambiguous method name -error: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` +warning: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` --> $DIR/method_list_1.rs:33:5 | LL | / pub fn as_ref(&self) -> &T { @@ -29,7 +34,7 @@ LL | | } | = help: consider implementing the trait `std::convert::AsRef` or choosing a less ambiguous method name -error: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` +warning: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` --> $DIR/method_list_1.rs:37:5 | LL | / pub fn bitand(self, rhs: T) -> T { @@ -39,7 +44,7 @@ LL | | } | = help: consider implementing the trait `std::ops::BitAnd` or choosing a less ambiguous method name -error: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` +warning: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` --> $DIR/method_list_1.rs:41:5 | LL | / pub fn bitor(self, rhs: Self) -> Self { @@ -49,7 +54,7 @@ LL | | } | = help: consider implementing the trait `std::ops::BitOr` or choosing a less ambiguous method name -error: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` +warning: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` --> $DIR/method_list_1.rs:45:5 | LL | / pub fn bitxor(self, rhs: Self) -> Self { @@ -59,7 +64,7 @@ LL | | } | = help: consider implementing the trait `std::ops::BitXor` or choosing a less ambiguous method name -error: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` +warning: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` --> $DIR/method_list_1.rs:49:5 | LL | / pub fn borrow(&self) -> &str { @@ -69,7 +74,7 @@ LL | | } | = help: consider implementing the trait `std::borrow::Borrow` or choosing a less ambiguous method name -error: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` +warning: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` --> $DIR/method_list_1.rs:53:5 | LL | / pub fn borrow_mut(&mut self) -> &mut str { @@ -79,7 +84,7 @@ LL | | } | = help: consider implementing the trait `std::borrow::BorrowMut` or choosing a less ambiguous method name -error: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` +warning: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` --> $DIR/method_list_1.rs:57:5 | LL | / pub fn clone(&self) -> Self { @@ -89,7 +94,7 @@ LL | | } | = help: consider implementing the trait `std::clone::Clone` or choosing a less ambiguous method name -error: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` +warning: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` --> $DIR/method_list_1.rs:61:5 | LL | / pub fn cmp(&self, other: &Self) -> Self { @@ -99,7 +104,7 @@ LL | | } | = help: consider implementing the trait `std::cmp::Ord` or choosing a less ambiguous method name -error: method `default` can be confused for the standard trait method `std::default::Default::default` +warning: method `default` can be confused for the standard trait method `std::default::Default::default` --> $DIR/method_list_1.rs:65:5 | LL | / pub fn default() -> Self { @@ -109,7 +114,7 @@ LL | | } | = help: consider implementing the trait `std::default::Default` or choosing a less ambiguous method name -error: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` +warning: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` --> $DIR/method_list_1.rs:69:5 | LL | / pub fn deref(&self) -> &Self { @@ -119,7 +124,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Deref` or choosing a less ambiguous method name -error: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` +warning: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` --> $DIR/method_list_1.rs:73:5 | LL | / pub fn deref_mut(&mut self) -> &mut Self { @@ -129,7 +134,7 @@ LL | | } | = help: consider implementing the trait `std::ops::DerefMut` or choosing a less ambiguous method name -error: method `div` can be confused for the standard trait method `std::ops::Div::div` +warning: method `div` can be confused for the standard trait method `std::ops::Div::div` --> $DIR/method_list_1.rs:77:5 | LL | / pub fn div(self, rhs: Self) -> Self { @@ -139,7 +144,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Div` or choosing a less ambiguous method name -error: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` +warning: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` --> $DIR/method_list_1.rs:81:5 | LL | / pub fn drop(&mut self) { @@ -149,5 +154,5 @@ LL | | } | = help: consider implementing the trait `std::ops::Drop` or choosing a less ambiguous method name -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/should_impl_trait/method_list_2.stderr b/tests/ui/should_impl_trait/method_list_2.stderr index 10bfea68ff57..716c20445250 100644 --- a/tests/ui/should_impl_trait/method_list_2.stderr +++ b/tests/ui/should_impl_trait/method_list_2.stderr @@ -1,4 +1,4 @@ -error: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` +warning: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` --> $DIR/method_list_2.rs:26:5 | LL | / pub fn eq(&self, other: &Self) -> bool { @@ -7,9 +7,14 @@ LL | | } | |_____^ | = help: consider implementing the trait `std::cmp::PartialEq` or choosing a less ambiguous method name - = note: `-D clippy::should-implement-trait` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/method_list_2.rs:1:9 + | +LL | #![warn(clippy::all, clippy::pedantic)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::should_implement_trait)]` implied by `#[warn(clippy::all)]` -error: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` +warning: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` --> $DIR/method_list_2.rs:30:5 | LL | / pub fn from_iter(iter: T) -> Self { @@ -19,7 +24,7 @@ LL | | } | = help: consider implementing the trait `std::iter::FromIterator` or choosing a less ambiguous method name -error: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` +warning: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` --> $DIR/method_list_2.rs:34:5 | LL | / pub fn from_str(s: &str) -> Result { @@ -29,7 +34,7 @@ LL | | } | = help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name -error: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` +warning: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` --> $DIR/method_list_2.rs:38:5 | LL | / pub fn hash(&self, state: &mut T) { @@ -39,7 +44,7 @@ LL | | } | = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name -error: method `index` can be confused for the standard trait method `std::ops::Index::index` +warning: method `index` can be confused for the standard trait method `std::ops::Index::index` --> $DIR/method_list_2.rs:42:5 | LL | / pub fn index(&self, index: usize) -> &Self { @@ -49,7 +54,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name -error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` +warning: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` --> $DIR/method_list_2.rs:46:5 | LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { @@ -59,7 +64,7 @@ LL | | } | = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name -error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` +warning: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` --> $DIR/method_list_2.rs:50:5 | LL | / pub fn into_iter(self) -> Self { @@ -69,7 +74,7 @@ LL | | } | = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name -error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` +warning: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` --> $DIR/method_list_2.rs:54:5 | LL | / pub fn mul(self, rhs: Self) -> Self { @@ -79,7 +84,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name -error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` +warning: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` --> $DIR/method_list_2.rs:58:5 | LL | / pub fn neg(self) -> Self { @@ -89,7 +94,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name -error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` +warning: method `next` can be confused for the standard trait method `std::iter::Iterator::next` --> $DIR/method_list_2.rs:62:5 | LL | / pub fn next(&mut self) -> Option { @@ -99,7 +104,7 @@ LL | | } | = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name -error: method `not` can be confused for the standard trait method `std::ops::Not::not` +warning: method `not` can be confused for the standard trait method `std::ops::Not::not` --> $DIR/method_list_2.rs:66:5 | LL | / pub fn not(self) -> Self { @@ -109,7 +114,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name -error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` +warning: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` --> $DIR/method_list_2.rs:70:5 | LL | / pub fn rem(self, rhs: Self) -> Self { @@ -119,7 +124,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name -error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` +warning: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` --> $DIR/method_list_2.rs:74:5 | LL | / pub fn shl(self, rhs: Self) -> Self { @@ -129,7 +134,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name -error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` +warning: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` --> $DIR/method_list_2.rs:78:5 | LL | / pub fn shr(self, rhs: Self) -> Self { @@ -139,7 +144,7 @@ LL | | } | = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name -error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` +warning: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` --> $DIR/method_list_2.rs:82:5 | LL | / pub fn sub(self, rhs: Self) -> Self { @@ -149,5 +154,5 @@ LL | | } | = help: consider implementing the trait `std::ops::Sub` or choosing a less ambiguous method name -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/significant_drop_in_scrutinee.fixed b/tests/ui/significant_drop_in_scrutinee.fixed new file mode 100644 index 000000000000..acc78d6bb043 --- /dev/null +++ b/tests/ui/significant_drop_in_scrutinee.fixed @@ -0,0 +1,627 @@ +// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 +// //@run-rustfix +#![warn(clippy::significant_drop_in_scrutinee)] +#![allow(dead_code, unused_assignments)] +#![allow(clippy::match_single_binding, clippy::single_match, clippy::uninlined_format_args)] + +use std::num::ParseIntError; +use std::ops::Deref; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::RwLock; +use std::sync::{Mutex, MutexGuard}; + +struct State {} + +impl State { + fn foo(&self) -> bool { + true + } + + fn bar(&self) {} +} + +fn should_not_trigger_lint_with_mutex_guard_outside_match() { + let mutex = Mutex::new(State {}); + + // Should not trigger lint because the temporary should drop at the `;` on line before the match + let is_foo = mutex.lock().unwrap().foo(); + match is_foo { + true => { + mutex.lock().unwrap().bar(); + }, + false => {}, + }; +} + +fn should_not_trigger_lint_with_mutex_guard_when_taking_ownership_in_match() { + let mutex = Mutex::new(State {}); + + // Should not trigger lint because the scrutinee is explicitly returning the MutexGuard, + // so its lifetime should not be surprising. + match mutex.lock() { + Ok(guard) => { + guard.foo(); + mutex.lock().unwrap().bar(); + }, + _ => {}, + }; +} + +fn should_trigger_lint_with_mutex_guard_in_match_scrutinee() { + let mutex = Mutex::new(State {}); + + // Should trigger lint because the lifetime of the temporary MutexGuard is surprising because it + // is preserved until the end of the match, but there is no clear indication that this is the + // case. + match mutex.lock().unwrap().foo() { + true => { + mutex.lock().unwrap().bar(); + }, + false => {}, + }; +} + +fn should_not_trigger_lint_with_mutex_guard_in_match_scrutinee_when_lint_allowed() { + let mutex = Mutex::new(State {}); + + // Lint should not be triggered because it is "allowed" below. + #[allow(clippy::significant_drop_in_scrutinee)] + match mutex.lock().unwrap().foo() { + true => { + mutex.lock().unwrap().bar(); + }, + false => {}, + }; +} + +fn should_not_trigger_lint_for_insignificant_drop() { + // Should not trigger lint because there are no temporaries whose drops have a significant + // side effect. + match 1u64.to_string().is_empty() { + true => { + println!("It was empty") + }, + false => { + println!("It was not empty") + }, + } +} + +struct StateWithMutex { + m: Mutex, +} + +struct MutexGuardWrapper<'a> { + mg: MutexGuard<'a, u64>, +} + +impl<'a> MutexGuardWrapper<'a> { + fn get_the_value(&self) -> u64 { + *self.mg.deref() + } +} + +struct MutexGuardWrapperWrapper<'a> { + mg: MutexGuardWrapper<'a>, +} + +impl<'a> MutexGuardWrapperWrapper<'a> { + fn get_the_value(&self) -> u64 { + *self.mg.mg.deref() + } +} + +impl StateWithMutex { + fn lock_m(&self) -> MutexGuardWrapper<'_> { + MutexGuardWrapper { + mg: self.m.lock().unwrap(), + } + } + + fn lock_m_m(&self) -> MutexGuardWrapperWrapper<'_> { + MutexGuardWrapperWrapper { + mg: MutexGuardWrapper { + mg: self.m.lock().unwrap(), + }, + } + } + + fn foo(&self) -> bool { + true + } + + fn bar(&self) {} +} + +fn should_trigger_lint_with_wrapped_mutex() { + let s = StateWithMutex { m: Mutex::new(1) }; + + // Should trigger lint because a temporary contains a type with a significant drop and its + // lifetime is not obvious. Additionally, it is not obvious from looking at the scrutinee that + // the temporary contains such a type, making it potentially even more surprising. + match s.lock_m().get_the_value() { + 1 => { + println!("Got 1. Is it still 1?"); + println!("{}", s.lock_m().get_the_value()); + }, + 2 => { + println!("Got 2. Is it still 2?"); + println!("{}", s.lock_m().get_the_value()); + }, + _ => {}, + } + println!("All done!"); +} + +fn should_trigger_lint_with_double_wrapped_mutex() { + let s = StateWithMutex { m: Mutex::new(1) }; + + // Should trigger lint because a temporary contains a type which further contains a type with a + // significant drop and its lifetime is not obvious. Additionally, it is not obvious from + // looking at the scrutinee that the temporary contains such a type, making it potentially even + // more surprising. + match s.lock_m_m().get_the_value() { + 1 => { + println!("Got 1. Is it still 1?"); + println!("{}", s.lock_m().get_the_value()); + }, + 2 => { + println!("Got 2. Is it still 2?"); + println!("{}", s.lock_m().get_the_value()); + }, + _ => {}, + } + println!("All done!"); +} + +struct Counter { + i: AtomicU64, +} + +#[clippy::has_significant_drop] +struct CounterWrapper<'a> { + counter: &'a Counter, +} + +impl<'a> CounterWrapper<'a> { + fn new(counter: &Counter) -> CounterWrapper { + counter.i.fetch_add(1, Ordering::Relaxed); + CounterWrapper { counter } + } +} + +impl<'a> Drop for CounterWrapper<'a> { + fn drop(&mut self) { + self.counter.i.fetch_sub(1, Ordering::Relaxed); + } +} + +impl Counter { + fn temp_increment(&self) -> Vec { + vec![CounterWrapper::new(self), CounterWrapper::new(self)] + } +} + +fn should_trigger_lint_for_vec() { + let counter = Counter { i: AtomicU64::new(0) }; + + // Should trigger lint because the temporary in the scrutinee returns a collection of types + // which have significant drops. The types with significant drops are also non-obvious when + // reading the expression in the scrutinee. + match counter.temp_increment().len() { + 2 => { + let current_count = counter.i.load(Ordering::Relaxed); + println!("Current count {}", current_count); + assert_eq!(current_count, 0); + }, + 1 => {}, + 3 => {}, + _ => {}, + }; +} + +struct StateWithField { + s: String, +} + +// Should trigger lint only on the type in the tuple which is created using a temporary +// with a significant drop. Additionally, this test ensures that the format of the tuple +// is preserved correctly in the suggestion. +fn should_trigger_lint_for_tuple_in_scrutinee() { + let mutex1 = Mutex::new(StateWithField { s: "one".to_owned() }); + + { + match (mutex1.lock().unwrap().s.len(), true) { + (3, _) => { + println!("started"); + mutex1.lock().unwrap().s.len(); + println!("done"); + }, + (_, _) => {}, + }; + + match (true, mutex1.lock().unwrap().s.len(), true) { + (_, 3, _) => { + println!("started"); + mutex1.lock().unwrap().s.len(); + println!("done"); + }, + (_, _, _) => {}, + }; + + let mutex2 = Mutex::new(StateWithField { s: "two".to_owned() }); + match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { + (3, _, 3) => { + println!("started"); + mutex1.lock().unwrap().s.len(); + mutex2.lock().unwrap().s.len(); + println!("done"); + }, + (_, _, _) => {}, + }; + + let mutex3 = Mutex::new(StateWithField { s: "three".to_owned() }); + match mutex3.lock().unwrap().s.as_str() { + "three" => { + println!("started"); + mutex1.lock().unwrap().s.len(); + mutex2.lock().unwrap().s.len(); + println!("done"); + }, + _ => {}, + }; + + match (true, mutex3.lock().unwrap().s.as_str()) { + (_, "three") => { + println!("started"); + mutex1.lock().unwrap().s.len(); + mutex2.lock().unwrap().s.len(); + println!("done"); + }, + (_, _) => {}, + }; + } +} + +// Should trigger lint when either side of a binary operation creates a temporary with a +// significant drop. +// To avoid potential unnecessary copies or creating references that would trigger the significant +// drop problem, the lint recommends moving the entire binary operation. +fn should_trigger_lint_for_accessing_field_in_mutex_in_one_side_of_binary_op() { + let mutex = Mutex::new(StateWithField { s: "state".to_owned() }); + + match mutex.lock().unwrap().s.len() > 1 { + true => { + mutex.lock().unwrap().s.len(); + }, + false => {}, + }; + + match 1 < mutex.lock().unwrap().s.len() { + true => { + mutex.lock().unwrap().s.len(); + }, + false => {}, + }; +} + +// Should trigger lint when both sides of a binary operation creates a temporary with a +// significant drop. +// To avoid potential unnecessary copies or creating references that would trigger the significant +// drop problem, the lint recommends moving the entire binary operation. +fn should_trigger_lint_for_accessing_fields_in_mutex_in_both_sides_of_binary_op() { + let mutex1 = Mutex::new(StateWithField { s: "state".to_owned() }); + let mutex2 = Mutex::new(StateWithField { + s: "statewithfield".to_owned(), + }); + + match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() { + true => { + println!( + "{} < {}", + mutex1.lock().unwrap().s.len(), + mutex2.lock().unwrap().s.len() + ); + }, + false => {}, + }; + + match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() { + true => { + println!( + "{} >= {}", + mutex1.lock().unwrap().s.len(), + mutex2.lock().unwrap().s.len() + ); + }, + false => {}, + }; +} + +fn should_not_trigger_lint_for_closure_in_scrutinee() { + let mutex1 = Mutex::new(StateWithField { s: "one".to_owned() }); + + let get_mutex_guard = || mutex1.lock().unwrap().s.len(); + + // Should not trigger lint because the temporary with a significant drop will be dropped + // at the end of the closure, so the MutexGuard will be unlocked and not have a potentially + // surprising lifetime. + match get_mutex_guard() > 1 { + true => { + mutex1.lock().unwrap().s.len(); + }, + false => {}, + }; +} + +fn should_trigger_lint_for_return_from_closure_in_scrutinee() { + let mutex1 = Mutex::new(StateWithField { s: "one".to_owned() }); + + let get_mutex_guard = || mutex1.lock().unwrap(); + + // Should trigger lint because the temporary with a significant drop is returned from the + // closure but not used directly in any match arms, so it has a potentially surprising lifetime. + match get_mutex_guard().s.len() > 1 { + true => { + mutex1.lock().unwrap().s.len(); + }, + false => {}, + }; +} + +fn should_trigger_lint_for_return_from_match_in_scrutinee() { + let mutex1 = Mutex::new(StateWithField { s: "one".to_owned() }); + let mutex2 = Mutex::new(StateWithField { s: "two".to_owned() }); + + let i = 100; + + // Should trigger lint because the nested match within the scrutinee returns a temporary with a + // significant drop is but not used directly in any match arms, so it has a potentially + // surprising lifetime. + match match i { + 100 => mutex1.lock().unwrap(), + _ => mutex2.lock().unwrap(), + } + .s + .len() + > 1 + { + true => { + mutex1.lock().unwrap().s.len(); + }, + false => { + println!("nothing to do here"); + }, + }; +} + +fn should_trigger_lint_for_return_from_if_in_scrutinee() { + let mutex1 = Mutex::new(StateWithField { s: "one".to_owned() }); + let mutex2 = Mutex::new(StateWithField { s: "two".to_owned() }); + + let i = 100; + + // Should trigger lint because the nested if-expression within the scrutinee returns a temporary + // with a significant drop is but not used directly in any match arms, so it has a potentially + // surprising lifetime. + match if i > 1 { + mutex1.lock().unwrap() + } else { + mutex2.lock().unwrap() + } + .s + .len() + > 1 + { + true => { + mutex1.lock().unwrap().s.len(); + }, + false => {}, + }; +} + +fn should_not_trigger_lint_for_if_in_scrutinee() { + let mutex = Mutex::new(StateWithField { s: "state".to_owned() }); + + let i = 100; + + // Should not trigger the lint because the temporary with a significant drop *is* dropped within + // the body of the if-expression nested within the match scrutinee, and therefore does not have + // a potentially surprising lifetime. + match if i > 1 { + mutex.lock().unwrap().s.len() > 1 + } else { + false + } { + true => { + mutex.lock().unwrap().s.len(); + }, + false => {}, + }; +} + +struct StateWithBoxedMutexGuard { + u: Mutex, +} + +impl StateWithBoxedMutexGuard { + fn new() -> StateWithBoxedMutexGuard { + StateWithBoxedMutexGuard { u: Mutex::new(42) } + } + fn lock(&self) -> Box> { + Box::new(self.u.lock().unwrap()) + } +} + +fn should_trigger_lint_for_boxed_mutex_guard() { + let s = StateWithBoxedMutexGuard::new(); + + // Should trigger lint because a temporary Box holding a type with a significant drop in a match + // scrutinee may have a potentially surprising lifetime. + match s.lock().deref().deref() { + 0 | 1 => println!("Value was less than 2"), + _ => println!("Value is {}", s.lock().deref()), + }; +} + +struct StateStringWithBoxedMutexGuard { + s: Mutex, +} + +impl StateStringWithBoxedMutexGuard { + fn new() -> StateStringWithBoxedMutexGuard { + StateStringWithBoxedMutexGuard { + s: Mutex::new("A String".to_owned()), + } + } + fn lock(&self) -> Box> { + Box::new(self.s.lock().unwrap()) + } +} + +fn should_trigger_lint_for_boxed_mutex_guard_holding_string() { + let s = StateStringWithBoxedMutexGuard::new(); + + let matcher = String::from("A String"); + + // Should trigger lint because a temporary Box holding a type with a significant drop in a match + // scrutinee may have a potentially surprising lifetime. + match s.lock().deref().deref() { + matcher => println!("Value is {}", s.lock().deref()), + _ => println!("Value was not a match"), + }; +} + +struct StateWithIntField { + i: u64, +} + +// Should trigger lint when either side of an assign expression contains a temporary with a +// significant drop, because the temporary's lifetime will be extended to the end of the match. +// To avoid potential unnecessary copies or creating references that would trigger the significant +// drop problem, the lint recommends moving the entire binary operation. +fn should_trigger_lint_in_assign_expr() { + let mutex = Mutex::new(StateWithIntField { i: 10 }); + + let mut i = 100; + + match mutex.lock().unwrap().i = i { + _ => { + println!("{}", mutex.lock().unwrap().i); + }, + }; + + match i = mutex.lock().unwrap().i { + _ => { + println!("{}", mutex.lock().unwrap().i); + }, + }; + + match mutex.lock().unwrap().i += 1 { + _ => { + println!("{}", mutex.lock().unwrap().i); + }, + }; + + match i += mutex.lock().unwrap().i { + _ => { + println!("{}", mutex.lock().unwrap().i); + }, + }; +} + +#[derive(Debug)] +enum RecursiveEnum { + Foo(Option>), +} + +#[derive(Debug)] +enum GenericRecursiveEnum { + Foo(T, Option>>), +} + +fn should_not_cause_stack_overflow() { + // Test that when a type recursively contains itself, a stack overflow does not occur when + // checking sub-types for significant drops. + let f = RecursiveEnum::Foo(Some(Box::new(RecursiveEnum::Foo(None)))); + match f { + RecursiveEnum::Foo(Some(f)) => { + println!("{:?}", f) + }, + RecursiveEnum::Foo(f) => { + println!("{:?}", f) + }, + } + + let f = GenericRecursiveEnum::Foo(1u64, Some(Box::new(GenericRecursiveEnum::Foo(2u64, None)))); + match f { + GenericRecursiveEnum::Foo(i, Some(f)) => { + println!("{} {:?}", i, f) + }, + GenericRecursiveEnum::Foo(i, f) => { + println!("{} {:?}", i, f) + }, + } +} + +fn should_not_produce_lint_for_try_desugar() -> Result { + // TryDesugar (i.e. using `?` for a Result type) will turn into a match but is out of scope + // for this lint + let rwlock = RwLock::new("1".to_string()); + let result = rwlock.read().unwrap().parse::()?; + println!("{}", result); + rwlock.write().unwrap().push('2'); + Ok(result) +} + +struct ResultReturner { + s: String, +} + +impl ResultReturner { + fn to_number(&self) -> Result { + self.s.parse::() + } +} + +fn should_trigger_lint_for_non_ref_move_and_clone_suggestion() { + let rwlock = RwLock::::new(ResultReturner { s: "1".to_string() }); + match rwlock.read().unwrap().to_number() { + Ok(n) => println!("Converted to number: {}", n), + Err(e) => println!("Could not convert {} to number", e), + }; +} + +fn should_trigger_lint_for_read_write_lock_for_loop() { + // For-in loops desugar to match expressions and are prone to the type of deadlock this lint is + // designed to look for. + let rwlock = RwLock::>::new(vec!["1".to_string()]); + for s in rwlock.read().unwrap().iter() { + println!("{}", s); + } +} + +fn do_bar(mutex: &Mutex) { + mutex.lock().unwrap().bar(); +} + +fn should_trigger_lint_without_significant_drop_in_arm() { + let mutex = Mutex::new(State {}); + + // Should trigger lint because the lifetime of the temporary MutexGuard is surprising because it + // is preserved until the end of the match, but there is no clear indication that this is the + // case. + match mutex.lock().unwrap().foo() { + true => do_bar(&mutex), + false => {}, + }; +} + +fn should_not_trigger_on_significant_iterator_drop() { + let lines = std::io::stdin().lines(); + for line in lines { + println!("foo: {}", line.unwrap()); + } +} + +fn main() {} diff --git a/tests/ui/significant_drop_in_scrutinee.rs b/tests/ui/significant_drop_in_scrutinee.rs index c65df9ece38c..acc78d6bb043 100644 --- a/tests/ui/significant_drop_in_scrutinee.rs +++ b/tests/ui/significant_drop_in_scrutinee.rs @@ -1,5 +1,5 @@ // FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 -// // run-rustfix +// //@run-rustfix #![warn(clippy::significant_drop_in_scrutinee)] #![allow(dead_code, unused_assignments)] #![allow(clippy::match_single_binding, clippy::single_match, clippy::uninlined_format_args)] diff --git a/tests/ui/significant_drop_in_scrutinee.stderr b/tests/ui/significant_drop_in_scrutinee.stderr index 75063a8c987e..7e93fabba98b 100644 --- a/tests/ui/significant_drop_in_scrutinee.stderr +++ b/tests/ui/significant_drop_in_scrutinee.stderr @@ -1,4 +1,4 @@ -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:56:11 | LL | match mutex.lock().unwrap().foo() { @@ -11,14 +11,18 @@ LL | }; | - temporary lives until here | = note: this might lead to deadlocks or other unexpected behavior - = note: `-D clippy::significant-drop-in-scrutinee` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/significant_drop_in_scrutinee.rs:3:9 + | +LL | #![warn(clippy::significant_drop_in_scrutinee)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try moving the temporary above the match | LL ~ let value = mutex.lock().unwrap().foo(); LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:142:11 | LL | match s.lock_m().get_the_value() { @@ -37,7 +41,7 @@ LL ~ let value = s.lock_m().get_the_value(); LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:163:11 | LL | match s.lock_m_m().get_the_value() { @@ -56,7 +60,7 @@ LL ~ let value = s.lock_m_m().get_the_value(); LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:211:11 | LL | match counter.temp_increment().len() { @@ -72,7 +76,7 @@ LL ~ let value = counter.temp_increment().len(); LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:234:16 | LL | match (mutex1.lock().unwrap().s.len(), true) { @@ -91,7 +95,7 @@ LL ~ let value = mutex1.lock().unwrap().s.len(); LL ~ match (value, true) { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:243:22 | LL | match (true, mutex1.lock().unwrap().s.len(), true) { @@ -110,7 +114,7 @@ LL ~ let value = mutex1.lock().unwrap().s.len(); LL ~ match (true, value, true) { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:253:16 | LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { @@ -131,7 +135,7 @@ LL ~ let value = mutex1.lock().unwrap().s.len(); LL ~ match (value, true, mutex2.lock().unwrap().s.len()) { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:253:54 | LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { @@ -152,7 +156,7 @@ LL ~ let value = mutex2.lock().unwrap().s.len(); LL ~ match (mutex1.lock().unwrap().s.len(), true, value) { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:264:15 | LL | match mutex3.lock().unwrap().s.as_str() { @@ -168,7 +172,7 @@ LL | }; | = note: this might lead to deadlocks or other unexpected behavior -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:274:22 | LL | match (true, mutex3.lock().unwrap().s.as_str()) { @@ -184,7 +188,7 @@ LL | }; | = note: this might lead to deadlocks or other unexpected behavior -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:293:11 | LL | match mutex.lock().unwrap().s.len() > 1 { @@ -203,7 +207,7 @@ LL ~ let value = mutex.lock().unwrap().s.len() > 1; LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:300:11 | LL | match 1 < mutex.lock().unwrap().s.len() { @@ -222,7 +226,7 @@ LL ~ let value = 1 < mutex.lock().unwrap().s.len(); LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:318:11 | LL | match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() { @@ -243,7 +247,7 @@ LL ~ let value = mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.l LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:329:11 | LL | match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() { @@ -264,7 +268,7 @@ LL ~ let value = mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s. LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:364:11 | LL | match get_mutex_guard().s.len() > 1 { @@ -283,7 +287,7 @@ LL ~ let value = get_mutex_guard().s.len() > 1; LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:381:11 | LL | match match i { @@ -315,7 +319,7 @@ LL + > 1; LL ~ match value | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:407:11 | LL | match if i > 1 { @@ -348,7 +352,7 @@ LL + > 1; LL ~ match value | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:461:11 | LL | match s.lock().deref().deref() { @@ -366,7 +370,7 @@ LL ~ let value = *s.lock().deref().deref(); LL ~ match value { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:489:11 | LL | match s.lock().deref().deref() { @@ -379,7 +383,7 @@ LL | }; | = note: this might lead to deadlocks or other unexpected behavior -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:508:11 | LL | match mutex.lock().unwrap().i = i { @@ -398,7 +402,7 @@ LL ~ mutex.lock().unwrap().i = i; LL ~ match () { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:514:11 | LL | match i = mutex.lock().unwrap().i { @@ -417,7 +421,7 @@ LL ~ i = mutex.lock().unwrap().i; LL ~ match () { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:520:11 | LL | match mutex.lock().unwrap().i += 1 { @@ -436,7 +440,7 @@ LL ~ mutex.lock().unwrap().i += 1; LL ~ match () { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:526:11 | LL | match i += mutex.lock().unwrap().i { @@ -455,7 +459,7 @@ LL ~ i += mutex.lock().unwrap().i; LL ~ match () { | -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:589:11 | LL | match rwlock.read().unwrap().to_number() { @@ -466,7 +470,7 @@ LL | }; | = note: this might lead to deadlocks or other unexpected behavior -error: temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression +warning: temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression --> $DIR/significant_drop_in_scrutinee.rs:599:14 | LL | for s in rwlock.read().unwrap().iter() { @@ -477,7 +481,7 @@ LL | } | = note: this might lead to deadlocks or other unexpected behavior -error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression +warning: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression --> $DIR/significant_drop_in_scrutinee.rs:614:11 | LL | match mutex.lock().unwrap().foo() { @@ -493,5 +497,5 @@ LL ~ let value = mutex.lock().unwrap().foo(); LL ~ match value { | -error: aborting due to 26 previous errors +warning: 26 warnings emitted diff --git a/tests/ui/significant_drop_tightening.fixed b/tests/ui/significant_drop_tightening.fixed index da998c610bd2..9c139deb95f2 100644 --- a/tests/ui/significant_drop_tightening.fixed +++ b/tests/ui/significant_drop_tightening.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::significant_drop_tightening)] @@ -12,7 +12,6 @@ pub fn complex_return_triggers_the_lint() -> i32 { let lock = mutex.lock().unwrap(); let _ = *lock; let _ = *lock; - drop(lock); foo() } @@ -45,7 +44,6 @@ pub fn unnecessary_contention_with_multiple_owned_results() { let lock = mutex.lock().unwrap(); let rslt0 = lock.abs(); let rslt1 = lock.is_positive(); - drop(lock); do_heavy_computation_that_takes_time((rslt0, rslt1)); } } @@ -64,16 +62,14 @@ pub fn unnecessary_contention_with_single_owned_results() { { let mutex = Mutex::new(1i32); - - let rslt0 = mutex.lock().unwrap().abs(); - + let lock = mutex.lock().unwrap(); + let rslt0 = lock.abs(); do_heavy_computation_that_takes_time(rslt0); } { let mutex = Mutex::new(vec![1i32]); - - mutex.lock().unwrap().clear(); - + let mut lock = mutex.lock().unwrap(); + lock.clear(); do_heavy_computation_that_takes_time(()); } } diff --git a/tests/ui/significant_drop_tightening.rs b/tests/ui/significant_drop_tightening.rs index 83823f95f68a..9c139deb95f2 100644 --- a/tests/ui/significant_drop_tightening.rs +++ b/tests/ui/significant_drop_tightening.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::significant_drop_tightening)] diff --git a/tests/ui/significant_drop_tightening.stderr b/tests/ui/significant_drop_tightening.stderr index ab8ce356ec7b..ea30ee0b1465 100644 --- a/tests/ui/significant_drop_tightening.stderr +++ b/tests/ui/significant_drop_tightening.stderr @@ -1,4 +1,4 @@ -error: temporary with significant `Drop` can be early dropped +warning: temporary with significant `Drop` can be early dropped --> $DIR/significant_drop_tightening.rs:12:9 | LL | pub fn complex_return_triggers_the_lint() -> i32 { @@ -15,14 +15,18 @@ LL | | } | |_- temporary `lock` is currently being dropped at the end of its contained scope | = note: this might lead to unnecessary resource contention - = note: `-D clippy::significant-drop-tightening` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/significant_drop_tightening.rs:3:9 + | +LL | #![warn(clippy::significant_drop_tightening)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: drop the temporary after the end of its last usage | LL ~ let _ = *lock; LL + drop(lock); | -error: temporary with significant `Drop` can be early dropped +warning: temporary with significant `Drop` can be early dropped --> $DIR/significant_drop_tightening.rs:44:13 | LL | / { @@ -42,7 +46,7 @@ LL ~ let rslt1 = lock.is_positive(); LL + drop(lock); | -error: temporary with significant `Drop` can be early dropped +warning: temporary with significant `Drop` can be early dropped --> $DIR/significant_drop_tightening.rs:65:13 | LL | / { @@ -66,7 +70,7 @@ LL - let rslt0 = lock.abs(); LL + | -error: temporary with significant `Drop` can be early dropped +warning: temporary with significant `Drop` can be early dropped --> $DIR/significant_drop_tightening.rs:71:17 | LL | / { @@ -90,5 +94,5 @@ LL - lock.clear(); LL + | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/similar_names.stderr b/tests/ui/similar_names.stderr index 43c5cee4b457..2fc302645c88 100644 --- a/tests/ui/similar_names.stderr +++ b/tests/ui/similar_names.stderr @@ -1,4 +1,4 @@ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:21:9 | LL | let bpple: i32; @@ -9,9 +9,13 @@ note: existing binding defined here | LL | let apple: i32; | ^^^^^ - = note: `-D clippy::similar-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/similar_names.rs:1:9 + | +LL | #![warn(clippy::similar_names)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:23:9 | LL | let cpple: i32; @@ -23,7 +27,7 @@ note: existing binding defined here LL | let apple: i32; | ^^^^^ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:47:9 | LL | let bluby: i32; @@ -35,7 +39,7 @@ note: existing binding defined here LL | let blubx: i32; | ^^^^^ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:51:9 | LL | let coke: i32; @@ -47,7 +51,7 @@ note: existing binding defined here LL | let cake: i32; | ^^^^ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:69:9 | LL | let xyzeabc: i32; @@ -59,7 +63,7 @@ note: existing binding defined here LL | let xyz1abc: i32; | ^^^^^^^ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:73:9 | LL | let parsee: i32; @@ -71,7 +75,7 @@ note: existing binding defined here LL | let parser: i32; | ^^^^^^ -error: binding's name is too similar to existing binding +warning: binding's name is too similar to existing binding --> $DIR/similar_names.rs:94:16 | LL | bpple: sprang, @@ -83,5 +87,5 @@ note: existing binding defined here LL | apple: spring, | ^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/single_char_add_str.fixed b/tests/ui/single_char_add_str.fixed index 63a6d37a9cce..cbcf1ab21c9b 100644 --- a/tests/ui/single_char_add_str.fixed +++ b/tests/ui/single_char_add_str.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::single_char_add_str)] macro_rules! get_string { diff --git a/tests/ui/single_char_add_str.rs b/tests/ui/single_char_add_str.rs index a799ea7d8856..a1f005cc833b 100644 --- a/tests/ui/single_char_add_str.rs +++ b/tests/ui/single_char_add_str.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::single_char_add_str)] macro_rules! get_string { diff --git a/tests/ui/single_char_add_str.stderr b/tests/ui/single_char_add_str.stderr index 55d91583ad04..38dcbed06624 100644 --- a/tests/ui/single_char_add_str.stderr +++ b/tests/ui/single_char_add_str.stderr @@ -1,94 +1,98 @@ -error: calling `push_str()` using a single-character string literal +warning: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:14:5 | LL | string.push_str("R"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('R')` | - = note: `-D clippy::single-char-add-str` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_char_add_str.rs:2:9 + | +LL | #![warn(clippy::single_char_add_str)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `push_str()` using a single-character string literal +warning: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:15:5 | LL | string.push_str("'"); - | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('/'')` + | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\'')` -error: calling `push_str()` using a single-character string literal +warning: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:20:5 | -LL | string.push_str("/x52"); - | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('/x52')` +LL | string.push_str("\x52"); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\x52')` -error: calling `push_str()` using a single-character string literal +warning: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:21:5 | -LL | string.push_str("/u{0052}"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('/u{0052}')` +LL | string.push_str("\u{0052}"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\u{0052}')` -error: calling `push_str()` using a single-character string literal +warning: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:22:5 | LL | string.push_str(r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('a')` -error: calling `push_str()` using a single-character string literal +warning: calling `push_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:24:5 | LL | get_string!().push_str("ö"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `get_string!().push('ö')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:29:5 | LL | string.insert_str(0, "R"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, 'R')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:30:5 | LL | string.insert_str(1, "'"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(1, '/'')` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(1, '\'')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:35:5 | -LL | string.insert_str(0, "/x52"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '/x52')` +LL | string.insert_str(0, "\x52"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '\x52')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:36:5 | -LL | string.insert_str(0, "/u{0052}"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '/u{0052}')` +LL | string.insert_str(0, "\u{0052}"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '\u{0052}')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:38:5 | LL | string.insert_str(x, r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(x, 'a')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:40:5 | LL | string.insert_str(Y, r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, 'a')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:41:5 | LL | string.insert_str(Y, r##"""##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '"')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:42:5 | LL | string.insert_str(Y, r##"'"##); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '/'')` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '\'')` -error: calling `insert_str()` using a single-character string literal +warning: calling `insert_str()` using a single-character string literal --> $DIR/single_char_add_str.rs:44:5 | LL | get_string!().insert_str(1, "?"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `get_string!().insert(1, '?')` -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/single_char_lifetime_names.stderr b/tests/ui/single_char_lifetime_names.stderr index bfe6d44b5898..45e303be9c58 100644 --- a/tests/ui/single_char_lifetime_names.stderr +++ b/tests/ui/single_char_lifetime_names.stderr @@ -1,13 +1,17 @@ -error: single-character lifetime names are likely uninformative +warning: single-character lifetime names are likely uninformative --> $DIR/single_char_lifetime_names.rs:5:22 | LL | struct DiagnosticCtx<'a, 'b> | ^^ | = help: use a more informative name - = note: `-D clippy::single-char-lifetime-names` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_char_lifetime_names.rs:1:9 + | +LL | #![warn(clippy::single_char_lifetime_names)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: single-character lifetime names are likely uninformative +warning: single-character lifetime names are likely uninformative --> $DIR/single_char_lifetime_names.rs:5:26 | LL | struct DiagnosticCtx<'a, 'b> @@ -15,7 +19,7 @@ LL | struct DiagnosticCtx<'a, 'b> | = help: use a more informative name -error: single-character lifetime names are likely uninformative +warning: single-character lifetime names are likely uninformative --> $DIR/single_char_lifetime_names.rs:14:6 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { @@ -23,7 +27,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | = help: use a more informative name -error: single-character lifetime names are likely uninformative +warning: single-character lifetime names are likely uninformative --> $DIR/single_char_lifetime_names.rs:14:10 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { @@ -31,7 +35,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | = help: use a more informative name -error: single-character lifetime names are likely uninformative +warning: single-character lifetime names are likely uninformative --> $DIR/single_char_lifetime_names.rs:34:15 | LL | fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a str>) { @@ -39,5 +43,5 @@ LL | fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a st | = help: use a more informative name -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/single_char_pattern.fixed b/tests/ui/single_char_pattern.fixed index 68e26726724b..dba89872070e 100644 --- a/tests/ui/single_char_pattern.fixed +++ b/tests/ui/single_char_pattern.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_must_use)] diff --git a/tests/ui/single_char_pattern.rs b/tests/ui/single_char_pattern.rs index 186202d78ec5..6a145a14bfdc 100644 --- a/tests/ui/single_char_pattern.rs +++ b/tests/ui/single_char_pattern.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_must_use)] diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index 5564aac674d9..aa8c87a0aee4 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,238 +1,238 @@ -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:9:13 | LL | x.split("x"); | ^^^ help: try using a `char` instead: `'x'` | - = note: `-D clippy::single-char-pattern` implied by `-D warnings` + = note: `#[warn(clippy::single_char_pattern)]` on by default -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:15:13 | LL | x.split("ß"); | ^^^ help: try using a `char` instead: `'ß'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:16:13 | LL | x.split("ℝ"); | ^^^ help: try using a `char` instead: `'ℝ'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:17:13 | LL | x.split("💣"); | ^^^^ help: try using a `char` instead: `'💣'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:20:23 | LL | x.split_inclusive("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:21:16 | LL | x.contains("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:22:19 | LL | x.starts_with("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:23:17 | LL | x.ends_with("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:24:12 | LL | x.find("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:25:13 | LL | x.rfind("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:26:14 | LL | x.rsplit("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:27:24 | LL | x.split_terminator("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:28:25 | LL | x.rsplit_terminator("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:29:17 | LL | x.splitn(2, "x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:30:18 | LL | x.rsplitn(2, "x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:31:18 | LL | x.split_once("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:32:19 | LL | x.rsplit_once("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:33:15 | LL | x.matches("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:34:16 | LL | x.rmatches("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:35:21 | LL | x.match_indices("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:36:22 | LL | x.rmatch_indices("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:37:26 | LL | x.trim_start_matches("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:38:24 | LL | x.trim_end_matches("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:39:20 | LL | x.strip_prefix("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:40:20 | LL | x.strip_suffix("x"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:41:15 | LL | x.replace("x", "y"); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:42:16 | LL | x.replacen("x", "y", 3); | ^^^ help: try using a `char` instead: `'x'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:44:13 | -LL | x.split("/n"); - | ^^^^ help: try using a `char` instead: `'/n'` +LL | x.split("\n"); + | ^^^^ help: try using a `char` instead: `'\n'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:45:13 | LL | x.split("'"); - | ^^^ help: try using a `char` instead: `'/''` + | ^^^ help: try using a `char` instead: `'\''` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:46:13 | -LL | x.split("/'"); - | ^^^^ help: try using a `char` instead: `'/''` +LL | x.split("\'"); + | ^^^^ help: try using a `char` instead: `'\''` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:51:31 | LL | x.replace(';', ",").split(","); // issue #2978 | ^^^ help: try using a `char` instead: `','` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:52:19 | -LL | x.starts_with("/x03"); // issue #2996 - | ^^^^^^ help: try using a `char` instead: `'/x03'` +LL | x.starts_with("\x03"); // issue #2996 + | ^^^^^^ help: try using a `char` instead: `'\x03'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:59:13 | LL | x.split(r"a"); | ^^^^ help: try using a `char` instead: `'a'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:60:13 | LL | x.split(r#"a"#); | ^^^^^^ help: try using a `char` instead: `'a'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:61:13 | LL | x.split(r###"a"###); | ^^^^^^^^^^ help: try using a `char` instead: `'a'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:62:13 | LL | x.split(r###"'"###); - | ^^^^^^^^^^ help: try using a `char` instead: `'/''` + | ^^^^^^^^^^ help: try using a `char` instead: `'\''` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:63:13 | LL | x.split(r###"#"###); | ^^^^^^^^^^ help: try using a `char` instead: `'#'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:65:13 | -LL | x.split(r#"/"#); - | ^^^^^^ help: try using a `char` instead: `'/'` +LL | x.split(r#"\"#); + | ^^^^^^ help: try using a `char` instead: `'\\'` -error: single-character string constant used as pattern +warning: single-character string constant used as pattern --> $DIR/single_char_pattern.rs:66:13 | -LL | x.split(r"/"); - | ^^^^ help: try using a `char` instead: `'/'` +LL | x.split(r"\"); + | ^^^^ help: try using a `char` instead: `'\\'` -error: aborting due to 39 previous errors +warning: 39 warnings emitted diff --git a/tests/ui/single_component_path_imports.fixed b/tests/ui/single_component_path_imports.fixed index 4c40739d6f55..81ede36a4e43 100644 --- a/tests/ui/single_component_path_imports.fixed +++ b/tests/ui/single_component_path_imports.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::single_component_path_imports)] #![allow(unused_imports)] diff --git a/tests/ui/single_component_path_imports.rs b/tests/ui/single_component_path_imports.rs index 9280bab3c71b..f03ec1a90be6 100644 --- a/tests/ui/single_component_path_imports.rs +++ b/tests/ui/single_component_path_imports.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::single_component_path_imports)] #![allow(unused_imports)] diff --git a/tests/ui/single_component_path_imports.stderr b/tests/ui/single_component_path_imports.stderr index 71dcc25d6e5b..6b235b65693c 100644 --- a/tests/ui/single_component_path_imports.stderr +++ b/tests/ui/single_component_path_imports.stderr @@ -1,16 +1,20 @@ -error: this import is redundant +warning: this import is redundant --> $DIR/single_component_path_imports.rs:5:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely | - = note: `-D clippy::single-component-path-imports` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_component_path_imports.rs:2:9 + | +LL | #![warn(clippy::single_component_path_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this import is redundant +warning: this import is redundant --> $DIR/single_component_path_imports.rs:23:5 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/single_component_path_imports_nested_first.stderr b/tests/ui/single_component_path_imports_nested_first.stderr index 330f285202d0..e3cabd4a0391 100644 --- a/tests/ui/single_component_path_imports_nested_first.stderr +++ b/tests/ui/single_component_path_imports_nested_first.stderr @@ -1,12 +1,16 @@ -error: this import is redundant +warning: this import is redundant --> $DIR/single_component_path_imports_nested_first.rs:4:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely | - = note: `-D clippy::single-component-path-imports` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_component_path_imports_nested_first.rs:1:9 + | +LL | #![warn(clippy::single_component_path_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this import is redundant +warning: this import is redundant --> $DIR/single_component_path_imports_nested_first.rs:13:10 | LL | use {regex, serde}; @@ -14,7 +18,7 @@ LL | use {regex, serde}; | = help: remove this import -error: this import is redundant +warning: this import is redundant --> $DIR/single_component_path_imports_nested_first.rs:13:17 | LL | use {regex, serde}; @@ -22,5 +26,5 @@ LL | use {regex, serde}; | = help: remove this import -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/single_element_loop.fixed b/tests/ui/single_element_loop.fixed index a0dcc0172e8b..1697a0cf29b8 100644 --- a/tests/ui/single_element_loop.fixed +++ b/tests/ui/single_element_loop.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // Tests from for_loop.rs that don't have suggestions #[warn(clippy::single_element_loop)] diff --git a/tests/ui/single_element_loop.rs b/tests/ui/single_element_loop.rs index bc014035c98a..860424f42ddf 100644 --- a/tests/ui/single_element_loop.rs +++ b/tests/ui/single_element_loop.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // Tests from for_loop.rs that don't have suggestions #[warn(clippy::single_element_loop)] diff --git a/tests/ui/single_element_loop.stderr b/tests/ui/single_element_loop.stderr index 14437a59745e..2364417e07d0 100644 --- a/tests/ui/single_element_loop.stderr +++ b/tests/ui/single_element_loop.stderr @@ -1,4 +1,4 @@ -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:7:5 | LL | / for item in &[item1] { @@ -6,7 +6,11 @@ LL | | dbg!(item); LL | | } | |_____^ | - = note: `-D clippy::single-element-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_element_loop.rs:4:8 + | +LL | #[warn(clippy::single_element_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | LL ~ { @@ -15,7 +19,7 @@ LL + dbg!(item); LL + } | -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:11:5 | LL | / for item in [item1].iter() { @@ -31,7 +35,7 @@ LL + dbg!(item); LL + } | -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:15:5 | LL | / for item in &[0..5] { @@ -47,7 +51,7 @@ LL + dbg!(item); LL + } | -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:19:5 | LL | / for item in [0..5].iter_mut() { @@ -63,7 +67,7 @@ LL + dbg!(item); LL + } | -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:23:5 | LL | / for item in [0..5] { @@ -79,7 +83,7 @@ LL + dbg!(item); LL + } | -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:27:5 | LL | / for item in [0..5].into_iter() { @@ -95,7 +99,7 @@ LL + dbg!(item); LL + } | -error: for loop over a single element +warning: for loop over a single element --> $DIR/single_element_loop.rs:46:5 | LL | / for _ in [42] { @@ -122,5 +126,5 @@ LL + }; LL + } | -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index 7cecc1b73950..4a45f0012f96 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,4 +1,4 @@ -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:9:5 | LL | / match x { @@ -9,7 +9,11 @@ LL | | _ => (), LL | | }; | |_____^ | - = note: `-D clippy::single-match` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_match.rs:1:9 + | +LL | #![warn(clippy::single_match)] + | ^^^^^^^^^^^^^^^^^^^^ help: try this | LL ~ if let Some(y) = x { @@ -17,7 +21,7 @@ LL + println!("{:?}", y); LL ~ }; | -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:17:5 | LL | / match x { @@ -29,7 +33,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y) }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:26:5 | LL | / match z { @@ -38,7 +42,7 @@ LL | | _ => {}, LL | | }; | |_____^ help: try this: `if let (2..=3, 7..=9) = z { dummy() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:55:5 | LL | / match x { @@ -47,7 +51,7 @@ LL | | None => (), LL | | }; | |_____^ help: try this: `if let Some(y) = x { dummy() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:60:5 | LL | / match y { @@ -56,7 +60,7 @@ LL | | Err(..) => (), LL | | }; | |_____^ help: try this: `if let Ok(y) = y { dummy() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:67:5 | LL | / match c { @@ -65,7 +69,7 @@ LL | | Cow::Owned(..) => (), LL | | }; | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }` -error: you seem to be trying to use `match` for an equality check. Consider using `if` +warning: you seem to be trying to use `match` for an equality check. Consider using `if` --> $DIR/single_match.rs:88:5 | LL | / match x { @@ -74,7 +78,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if x == "test" { println!() }` -error: you seem to be trying to use `match` for an equality check. Consider using `if` +warning: you seem to be trying to use `match` for an equality check. Consider using `if` --> $DIR/single_match.rs:101:5 | LL | / match x { @@ -83,7 +87,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if x == Foo::A { println!() }` -error: you seem to be trying to use `match` for an equality check. Consider using `if` +warning: you seem to be trying to use `match` for an equality check. Consider using `if` --> $DIR/single_match.rs:107:5 | LL | / match x { @@ -92,7 +96,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if x == FOO_C { println!() }` -error: you seem to be trying to use `match` for an equality check. Consider using `if` +warning: you seem to be trying to use `match` for an equality check. Consider using `if` --> $DIR/single_match.rs:112:5 | LL | / match &&x { @@ -101,7 +105,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if x == Foo::A { println!() }` -error: you seem to be trying to use `match` for an equality check. Consider using `if` +warning: you seem to be trying to use `match` for an equality check. Consider using `if` --> $DIR/single_match.rs:118:5 | LL | / match &x { @@ -110,7 +114,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if x == &Foo::A { println!() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:135:5 | LL | / match x { @@ -119,7 +123,7 @@ LL | | _ => (), LL | | } | |_____^ help: try this: `if let Bar::A = x { println!() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:143:5 | LL | / match x { @@ -128,7 +132,7 @@ LL | | _ => (), LL | | }; | |_____^ help: try this: `if let None = x { println!() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:165:5 | LL | / match x { @@ -137,7 +141,7 @@ LL | | (None, _) => {}, LL | | } | |_____^ help: try this: `if let (Some(_), _) = x {}` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:171:5 | LL | / match x { @@ -146,7 +150,7 @@ LL | | (_, _) => {}, LL | | } | |_____^ help: try this: `if let (Some(E::V), _) = x { todo!() }` -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match.rs:177:5 | LL | / match (Some(42), Some(E::V), Some(42)) { @@ -155,5 +159,5 @@ LL | | (..) => {}, LL | | } | |_____^ help: try this: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/single_match_else.rs b/tests/ui/single_match_else.rs index 5d03f77e9326..63260ec1f018 100644 --- a/tests/ui/single_match_else.rs +++ b/tests/ui/single_match_else.rs @@ -1,4 +1,4 @@ -// aux-build: proc_macro_with_span.rs +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::single_match_else)] #![allow(clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)] diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 62876a55dc61..2de6b77af7f8 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -1,4 +1,4 @@ -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match_else.rs:17:13 | LL | let _ = match ExprNode::Butterflies { @@ -11,7 +11,11 @@ LL | | }, LL | | }; | |_____^ | - = note: `-D clippy::single-match-else` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/single_match_else.rs:2:9 + | +LL | #![warn(clippy::single_match_else)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this | LL ~ let _ = if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { @@ -20,7 +24,7 @@ LL + None LL ~ }; | -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match_else.rs:82:5 | LL | / match Some(1) { @@ -40,7 +44,7 @@ LL + return LL + } | -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match_else.rs:91:5 | LL | / match Some(1) { @@ -60,7 +64,7 @@ LL + return; LL + } | -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match_else.rs:101:5 | LL | / match Result::::Ok(1) { @@ -80,7 +84,7 @@ LL + return; LL + } | -error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` --> $DIR/single_match_else.rs:110:5 | LL | / match Cow::from("moo") { @@ -100,5 +104,5 @@ LL + return; LL + } | -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/size_of_in_element_count/expressions.stderr b/tests/ui/size_of_in_element_count/expressions.stderr index 037f695f3ee9..e3ff15bfb74a 100644 --- a/tests/ui/size_of_in_element_count/expressions.stderr +++ b/tests/ui/size_of_in_element_count/expressions.stderr @@ -1,13 +1,17 @@ -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/expressions.rs:15:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type - = note: `-D clippy::size-of-in-element-count` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/expressions.rs:1:9 + | +LL | #![warn(clippy::size_of_in_element_count)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/expressions.rs:18:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) }; @@ -15,7 +19,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * si | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/expressions.rs:21:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() / 2) }; @@ -23,7 +27,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/expressions.rs:30:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::())) }; @@ -31,5 +35,5 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::< | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/size_of_in_element_count/functions.stderr b/tests/ui/size_of_in_element_count/functions.stderr index 4351e6a14fe5..f1804a4cdf05 100644 --- a/tests/ui/size_of_in_element_count/functions.stderr +++ b/tests/ui/size_of_in_element_count/functions.stderr @@ -1,13 +1,17 @@ -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:18:68 | LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type - = note: `-D clippy::size-of-in-element-count` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/functions.rs:1:9 + | +LL | #![warn(clippy::size_of_in_element_count)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:19:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; @@ -15,7 +19,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:21:49 | LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; @@ -23,7 +27,7 @@ LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:22:64 | LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::()) }; @@ -31,7 +35,7 @@ LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of:: $DIR/functions.rs:23:51 | LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; @@ -39,7 +43,7 @@ LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:24:66 | LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::()) }; @@ -47,7 +51,7 @@ LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::< | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:26:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; @@ -55,7 +59,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:27:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; @@ -63,7 +67,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:29:46 | LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; @@ -71,7 +75,7 @@ LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:30:47 | LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; @@ -79,7 +83,7 @@ LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:32:66 | LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::() * SIZE) }; @@ -87,7 +91,7 @@ LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::< | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:34:46 | LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); @@ -95,7 +99,7 @@ LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:35:38 | LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); @@ -103,7 +107,7 @@ LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:37:49 | LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; @@ -111,7 +115,7 @@ LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:38:41 | LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; @@ -119,7 +123,7 @@ LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:40:33 | LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; @@ -127,7 +131,7 @@ LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:41:29 | LL | y.as_ptr().wrapping_sub(size_of::()); @@ -135,7 +139,7 @@ LL | y.as_ptr().wrapping_sub(size_of::()); | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:42:29 | LL | unsafe { y.as_ptr().add(size_of::()) }; @@ -143,7 +147,7 @@ LL | unsafe { y.as_ptr().add(size_of::()) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:43:33 | LL | y.as_mut_ptr().wrapping_add(size_of::()); @@ -151,7 +155,7 @@ LL | y.as_mut_ptr().wrapping_add(size_of::()); | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:44:32 | LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; @@ -159,7 +163,7 @@ LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: found a count of bytes instead of a count of elements of `T` +warning: found a count of bytes instead of a count of elements of `T` --> $DIR/functions.rs:45:36 | LL | y.as_mut_ptr().wrapping_offset(size_of::() as isize); @@ -167,5 +171,5 @@ LL | y.as_mut_ptr().wrapping_offset(size_of::() as isize); | = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/size_of_ref.stderr b/tests/ui/size_of_ref.stderr index d4c13ac3290b..9a76b3737006 100644 --- a/tests/ui/size_of_ref.stderr +++ b/tests/ui/size_of_ref.stderr @@ -1,13 +1,17 @@ -error: argument to `std::mem::size_of_val()` is a reference to a reference +warning: argument to `std::mem::size_of_val()` is a reference to a reference --> $DIR/size_of_ref.rs:13:5 | LL | size_of_val(&&x); | ^^^^^^^^^^^^^^^^ | = help: dereference the argument to `std::mem::size_of_val()` to get the size of the value instead of the size of the reference-type - = note: `-D clippy::size-of-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/size_of_ref.rs:2:9 + | +LL | #![warn(clippy::size_of_ref)] + | ^^^^^^^^^^^^^^^^^^^ -error: argument to `std::mem::size_of_val()` is a reference to a reference +warning: argument to `std::mem::size_of_val()` is a reference to a reference --> $DIR/size_of_ref.rs:14:5 | LL | size_of_val(&y); @@ -15,7 +19,7 @@ LL | size_of_val(&y); | = help: dereference the argument to `std::mem::size_of_val()` to get the size of the value instead of the size of the reference-type -error: argument to `std::mem::size_of_val()` is a reference to a reference +warning: argument to `std::mem::size_of_val()` is a reference to a reference --> $DIR/size_of_ref.rs:25:9 | LL | std::mem::size_of_val(&self) + (std::mem::size_of::() * self.data.capacity()) @@ -23,5 +27,5 @@ LL | std::mem::size_of_val(&self) + (std::mem::size_of::() * self.da | = help: dereference the argument to `std::mem::size_of_val()` to get the size of the value instead of the size of the reference-type -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/skip_while_next.rs b/tests/ui/skip_while_next.rs index a551c19d98bc..62574e2c8cea 100644 --- a/tests/ui/skip_while_next.rs +++ b/tests/ui/skip_while_next.rs @@ -1,4 +1,4 @@ -// aux-build:option_helpers.rs +//@aux-build:option_helpers.rs #![warn(clippy::skip_while_next)] #![allow(clippy::disallowed_names)] diff --git a/tests/ui/skip_while_next.stderr b/tests/ui/skip_while_next.stderr index 7308ab4e55c9..c1a416eeab58 100644 --- a/tests/ui/skip_while_next.stderr +++ b/tests/ui/skip_while_next.stderr @@ -1,13 +1,17 @@ -error: called `skip_while(

).next()` on an `Iterator` +warning: called `skip_while(

).next()` on an `Iterator` --> $DIR/skip_while_next.rs:14:13 | LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: this is more succinctly expressed by calling `.find(!

)` instead - = note: `-D clippy::skip-while-next` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/skip_while_next.rs:3:9 + | +LL | #![warn(clippy::skip_while_next)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: called `skip_while(

).next()` on an `Iterator` +warning: called `skip_while(

).next()` on an `Iterator` --> $DIR/skip_while_next.rs:17:13 | LL | let _ = v.iter().skip_while(|&x| { @@ -19,5 +23,5 @@ LL | | ).next(); | = help: this is more succinctly expressed by calling `.find(!

)` instead -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/slow_vector_initialization.stderr b/tests/ui/slow_vector_initialization.stderr index cb3ce3e95a7a..1ca4b0d7365f 100644 --- a/tests/ui/slow_vector_initialization.stderr +++ b/tests/ui/slow_vector_initialization.stderr @@ -1,4 +1,4 @@ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:13:5 | LL | let mut vec1 = Vec::with_capacity(len); @@ -6,9 +6,9 @@ LL | let mut vec1 = Vec::with_capacity(len); LL | vec1.extend(repeat(0).take(len)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::slow-vector-initialization` implied by `-D warnings` + = note: `#[warn(clippy::slow_vector_initialization)]` on by default -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:17:5 | LL | let mut vec2 = Vec::with_capacity(len - 10); @@ -16,7 +16,7 @@ LL | let mut vec2 = Vec::with_capacity(len - 10); LL | vec2.extend(repeat(0).take(len - 10)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:24:5 | LL | let mut vec4 = Vec::with_capacity(len); @@ -24,7 +24,7 @@ LL | let mut vec4 = Vec::with_capacity(len); LL | vec4.extend(repeat(0).take(vec4.capacity())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:34:5 | LL | let mut resized_vec = Vec::with_capacity(30); @@ -32,7 +32,7 @@ LL | let mut resized_vec = Vec::with_capacity(30); LL | resized_vec.resize(30, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:37:5 | LL | let mut extend_vec = Vec::with_capacity(30); @@ -40,7 +40,7 @@ LL | let mut extend_vec = Vec::with_capacity(30); LL | extend_vec.extend(repeat(0).take(30)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:44:5 | LL | let mut vec1 = Vec::with_capacity(len); @@ -48,7 +48,7 @@ LL | let mut vec1 = Vec::with_capacity(len); LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:52:5 | LL | let mut vec3 = Vec::with_capacity(len - 10); @@ -56,7 +56,7 @@ LL | let mut vec3 = Vec::with_capacity(len - 10); LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:55:5 | LL | let mut vec4 = Vec::with_capacity(len); @@ -64,7 +64,7 @@ LL | let mut vec4 = Vec::with_capacity(len); LL | vec4.resize(vec4.capacity(), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: slow zero-filling initialization +warning: slow zero-filling initialization --> $DIR/slow_vector_initialization.rs:59:5 | LL | vec1 = Vec::with_capacity(10); @@ -72,5 +72,5 @@ LL | vec1 = Vec::with_capacity(10); LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/stable_sort_primitive.fixed b/tests/ui/stable_sort_primitive.fixed index f5f18169df29..1370dd2df4da 100644 --- a/tests/ui/stable_sort_primitive.fixed +++ b/tests/ui/stable_sort_primitive.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::stable_sort_primitive)] fn main() { diff --git a/tests/ui/stable_sort_primitive.rs b/tests/ui/stable_sort_primitive.rs index 8149c5638e0f..cd344dd12389 100644 --- a/tests/ui/stable_sort_primitive.rs +++ b/tests/ui/stable_sort_primitive.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::stable_sort_primitive)] fn main() { diff --git a/tests/ui/stable_sort_primitive.stderr b/tests/ui/stable_sort_primitive.stderr index 1432fdcff77a..54e3935cba12 100644 --- a/tests/ui/stable_sort_primitive.stderr +++ b/tests/ui/stable_sort_primitive.stderr @@ -1,13 +1,17 @@ -error: used `sort` on primitive type `i32` +warning: used `sort` on primitive type `i32` --> $DIR/stable_sort_primitive.rs:7:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` | = note: an unstable sort typically performs faster without any observable difference for this data type - = note: `-D clippy::stable-sort-primitive` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/stable_sort_primitive.rs:2:9 + | +LL | #![warn(clippy::stable_sort_primitive)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used `sort` on primitive type `bool` +warning: used `sort` on primitive type `bool` --> $DIR/stable_sort_primitive.rs:9:5 | LL | vec.sort(); @@ -15,7 +19,7 @@ LL | vec.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type -error: used `sort` on primitive type `char` +warning: used `sort` on primitive type `char` --> $DIR/stable_sort_primitive.rs:11:5 | LL | vec.sort(); @@ -23,7 +27,7 @@ LL | vec.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type -error: used `sort` on primitive type `str` +warning: used `sort` on primitive type `str` --> $DIR/stable_sort_primitive.rs:13:5 | LL | vec.sort(); @@ -31,7 +35,7 @@ LL | vec.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type -error: used `sort` on primitive type `tuple` +warning: used `sort` on primitive type `tuple` --> $DIR/stable_sort_primitive.rs:15:5 | LL | vec.sort(); @@ -39,7 +43,7 @@ LL | vec.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type -error: used `sort` on primitive type `array` +warning: used `sort` on primitive type `array` --> $DIR/stable_sort_primitive.rs:17:5 | LL | vec.sort(); @@ -47,7 +51,7 @@ LL | vec.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type -error: used `sort` on primitive type `i32` +warning: used `sort` on primitive type `i32` --> $DIR/stable_sort_primitive.rs:19:5 | LL | arr.sort(); @@ -55,5 +59,5 @@ LL | arr.sort(); | = note: an unstable sort typically performs faster without any observable difference for this data type -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/starts_ends_with.fixed b/tests/ui/starts_ends_with.fixed index 983fac7afe69..29d56f852edd 100644 --- a/tests/ui/starts_ends_with.fixed +++ b/tests/ui/starts_ends_with.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_must_use)] fn main() {} diff --git a/tests/ui/starts_ends_with.rs b/tests/ui/starts_ends_with.rs index e3335dd2e2ef..56bbe2574d42 100644 --- a/tests/ui/starts_ends_with.rs +++ b/tests/ui/starts_ends_with.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_must_use)] fn main() {} diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index 2dd9f53b8026..440bb6524172 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,102 +1,102 @@ -error: you should use the `starts_with` method +warning: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:8:5 | LL | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` | - = note: `-D clippy::chars-next-cmp` implied by `-D warnings` + = note: `#[warn(clippy::chars_next_cmp)]` on by default -error: you should use the `starts_with` method +warning: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:9:5 | LL | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` -error: you should use the `starts_with` method +warning: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:12:5 | -LL | "".chars().next() == Some('/n'); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with('/n')` +LL | "".chars().next() == Some('\n'); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with('\n')` -error: you should use the `starts_with` method +warning: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:13:5 | -LL | Some('/n') != "".chars().next(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with('/n')` +LL | Some('\n') != "".chars().next(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with('\n')` -error: you should use the `starts_with` method +warning: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:18:8 | LL | if s.chars().next().unwrap() == 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:22:8 | LL | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` | - = note: `-D clippy::chars-last-cmp` implied by `-D warnings` + = note: `#[warn(clippy::chars_last_cmp)]` on by default -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:26:8 | LL | if s.chars().last().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` -error: you should use the `starts_with` method +warning: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:30:8 | LL | if s.chars().next().unwrap() != 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:34:8 | LL | if s.chars().next_back().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:38:8 | -LL | if s.chars().last().unwrap() != '/n' { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('/n')` +LL | if s.chars().last().unwrap() != '\n' { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('\n')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:46:5 | LL | "".chars().last() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:47:5 | LL | Some(' ') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:48:5 | LL | "".chars().next_back() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:49:5 | LL | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:52:5 | -LL | "".chars().last() == Some('/n'); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with('/n')` +LL | "".chars().last() == Some('\n'); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with('\n')` -error: you should use the `ends_with` method +warning: you should use the `ends_with` method --> $DIR/starts_ends_with.rs:53:5 | -LL | Some('/n') != "".chars().last(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with('/n')` +LL | Some('\n') != "".chars().last(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with('\n')` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/std_instead_of_core.stderr b/tests/ui/std_instead_of_core.stderr index d2102497350b..2ca887e8f4ee 100644 --- a/tests/ui/std_instead_of_core.stderr +++ b/tests/ui/std_instead_of_core.stderr @@ -1,13 +1,17 @@ -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:9:9 | LL | use std::hash::Hasher; | ^^^^^^^^^^^^^^^^^ | = help: consider importing the item from `core` - = note: `-D clippy::std-instead-of-core` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/std_instead_of_core.rs:6:8 + | +LL | #[warn(clippy::std_instead_of_core)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:11:9 | LL | use ::std::hash::Hash; @@ -15,7 +19,7 @@ LL | use ::std::hash::Hash; | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:16:20 | LL | use std::fmt::{Debug, Result}; @@ -23,7 +27,7 @@ LL | use std::fmt::{Debug, Result}; | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:16:27 | LL | use std::fmt::{Debug, Result}; @@ -31,7 +35,7 @@ LL | use std::fmt::{Debug, Result}; | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:19:15 | LL | let ptr = std::ptr::null::(); @@ -39,7 +43,7 @@ LL | let ptr = std::ptr::null::(); | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:20:19 | LL | let ptr_mut = ::std::ptr::null_mut::(); @@ -47,7 +51,7 @@ LL | let ptr_mut = ::std::ptr::null_mut::(); | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:23:16 | LL | let cell = std::cell::Cell::new(8u32); @@ -55,7 +59,7 @@ LL | let cell = std::cell::Cell::new(8u32); | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:24:25 | LL | let cell_absolute = ::std::cell::Cell::new(8u32); @@ -63,7 +67,7 @@ LL | let cell_absolute = ::std::cell::Cell::new(8u32); | = help: consider importing the item from `core` -error: used import from `std` instead of `core` +warning: used import from `std` instead of `core` --> $DIR/std_instead_of_core.rs:32:9 | LL | use std::iter::Iterator; @@ -71,16 +75,20 @@ LL | use std::iter::Iterator; | = help: consider importing the item from `core` -error: used import from `std` instead of `alloc` +warning: used import from `std` instead of `alloc` --> $DIR/std_instead_of_core.rs:38:9 | LL | use std::vec; | ^^^^^^^^ | = help: consider importing the item from `alloc` - = note: `-D clippy::std-instead-of-alloc` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/std_instead_of_core.rs:35:8 + | +LL | #[warn(clippy::std_instead_of_alloc)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used import from `std` instead of `alloc` +warning: used import from `std` instead of `alloc` --> $DIR/std_instead_of_core.rs:39:9 | LL | use std::vec::Vec; @@ -88,14 +96,18 @@ LL | use std::vec::Vec; | = help: consider importing the item from `alloc` -error: used import from `alloc` instead of `core` +warning: used import from `alloc` instead of `core` --> $DIR/std_instead_of_core.rs:44:9 | LL | use alloc::slice::from_ref; | ^^^^^^^^^^^^^^^^^^^^^^ | = help: consider importing the item from `core` - = note: `-D clippy::alloc-instead-of-core` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/std_instead_of_core.rs:42:8 + | +LL | #[warn(clippy::alloc_instead_of_core)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/str_to_string.stderr b/tests/ui/str_to_string.stderr index 1d47da571fa1..052bcf2552c6 100644 --- a/tests/ui/str_to_string.stderr +++ b/tests/ui/str_to_string.stderr @@ -1,13 +1,17 @@ -error: `to_string()` called on a `&str` +warning: `to_string()` called on a `&str` --> $DIR/str_to_string.rs:4:17 | LL | let hello = "hello world".to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using `.to_owned()` - = note: `-D clippy::str-to-string` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/str_to_string.rs:1:9 + | +LL | #![warn(clippy::str_to_string)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: `to_string()` called on a `&str` +warning: `to_string()` called on a `&str` --> $DIR/str_to_string.rs:6:5 | LL | msg.to_string(); @@ -15,5 +19,5 @@ LL | msg.to_string(); | = help: consider using `.to_owned()` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/string_add.rs b/tests/ui/string_add.rs index 16673c01e630..2fe821364e10 100644 --- a/tests/ui/string_add.rs +++ b/tests/ui/string_add.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #[macro_use] extern crate macro_rules; diff --git a/tests/ui/string_add.stderr b/tests/ui/string_add.stderr index 3987641c75a3..b28e455f99be 100644 --- a/tests/ui/string_add.stderr +++ b/tests/ui/string_add.stderr @@ -1,30 +1,34 @@ -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/string_add.rs:13:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | - = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = note: `#[warn(clippy::assign_op_pattern)]` on by default -error: you added something to a string. Consider using `String::push_str()` instead +warning: you added something to a string. Consider using `String::push_str()` instead --> $DIR/string_add.rs:13:13 | LL | x = x + "."; | ^^^^^^^ | - = note: `-D clippy::string-add` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/string_add.rs:6:8 + | +LL | #[warn(clippy::string_add)] + | ^^^^^^^^^^^^^^^^^^ -error: you added something to a string. Consider using `String::push_str()` instead +warning: you added something to a string. Consider using `String::push_str()` instead --> $DIR/string_add.rs:17:13 | LL | let z = y + "..."; | ^^^^^^^^^ -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/string_add.rs:22:5 | LL | x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/string_add_assign.fixed b/tests/ui/string_add_assign.fixed index b687f43b2541..616c6daaf660 100644 --- a/tests/ui/string_add_assign.fixed +++ b/tests/ui/string_add_assign.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[allow(clippy::string_add, unused)] #[warn(clippy::string_add_assign)] diff --git a/tests/ui/string_add_assign.rs b/tests/ui/string_add_assign.rs index e5dbde108fbd..e1f8859757c6 100644 --- a/tests/ui/string_add_assign.rs +++ b/tests/ui/string_add_assign.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[allow(clippy::string_add, unused)] #[warn(clippy::string_add_assign)] diff --git a/tests/ui/string_add_assign.stderr b/tests/ui/string_add_assign.stderr index 7676175c1b82..19591c06d439 100644 --- a/tests/ui/string_add_assign.stderr +++ b/tests/ui/string_add_assign.stderr @@ -1,24 +1,28 @@ -error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead +warning: you assigned the result of adding something to this string. Consider using `String::push_str()` instead --> $DIR/string_add_assign.rs:10:9 | LL | x = x + "."; | ^^^^^^^^^^^ | - = note: `-D clippy::string-add-assign` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/string_add_assign.rs:4:8 + | +LL | #[warn(clippy::string_add_assign)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/string_add_assign.rs:10:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | - = note: `-D clippy::assign-op-pattern` implied by `-D warnings` + = note: `#[warn(clippy::assign_op_pattern)]` on by default -error: manual implementation of an assign operation +warning: manual implementation of an assign operation --> $DIR/string_add_assign.rs:19:5 | LL | x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/string_extend.fixed b/tests/ui/string_extend.fixed index d200d7310fca..65c9abff3d41 100644 --- a/tests/ui/string_extend.fixed +++ b/tests/ui/string_extend.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[derive(Copy, Clone)] struct HasChars; diff --git a/tests/ui/string_extend.rs b/tests/ui/string_extend.rs index 0dd96a3b2103..5f72ffe2fda7 100644 --- a/tests/ui/string_extend.rs +++ b/tests/ui/string_extend.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #[derive(Copy, Clone)] struct HasChars; diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index b35c77fd9611..9a8728eaa580 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -1,28 +1,28 @@ -error: calling `.extend(_.chars())` +warning: calling `.extend(_.chars())` --> $DIR/string_extend.rs:18:5 | LL | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)` | - = note: `-D clippy::string-extend-chars` implied by `-D warnings` + = note: `#[warn(clippy::string_extend_chars)]` on by default -error: calling `.extend(_.chars())` +warning: calling `.extend(_.chars())` --> $DIR/string_extend.rs:21:5 | LL | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str("abc")` -error: calling `.extend(_.chars())` +warning: calling `.extend(_.chars())` --> $DIR/string_extend.rs:24:5 | LL | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)` -error: calling `.extend(_.chars())` +warning: calling `.extend(_.chars())` --> $DIR/string_extend.rs:34:5 | LL | s.extend(abc[0..2].chars()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&abc[0..2])` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/string_from_utf8_as_bytes.fixed b/tests/ui/string_from_utf8_as_bytes.fixed index 6e665cdd5630..9b315ae2b558 100644 --- a/tests/ui/string_from_utf8_as_bytes.fixed +++ b/tests/ui/string_from_utf8_as_bytes.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::string_from_utf8_as_bytes)] fn main() { diff --git a/tests/ui/string_from_utf8_as_bytes.rs b/tests/ui/string_from_utf8_as_bytes.rs index 670d206d3679..043dd2350829 100644 --- a/tests/ui/string_from_utf8_as_bytes.rs +++ b/tests/ui/string_from_utf8_as_bytes.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::string_from_utf8_as_bytes)] fn main() { diff --git a/tests/ui/string_from_utf8_as_bytes.stderr b/tests/ui/string_from_utf8_as_bytes.stderr index bf5e5d33e8f9..9902aab3dc45 100644 --- a/tests/ui/string_from_utf8_as_bytes.stderr +++ b/tests/ui/string_from_utf8_as_bytes.stderr @@ -1,10 +1,14 @@ -error: calling a slice of `as_bytes()` with `from_utf8` should be not necessary +warning: calling a slice of `as_bytes()` with `from_utf8` should be not necessary --> $DIR/string_from_utf8_as_bytes.rs:5:13 | LL | let _ = std::str::from_utf8(&"Hello World!".as_bytes()[6..11]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(&"Hello World!"[6..11])` | - = note: `-D clippy::string-from-utf8-as-bytes` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/string_from_utf8_as_bytes.rs:2:9 + | +LL | #![warn(clippy::string_from_utf8_as_bytes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/string_lit_as_bytes.fixed b/tests/ui/string_lit_as_bytes.fixed index 506187fc1257..238e8c53d9d9 100644 --- a/tests/ui/string_lit_as_bytes.fixed +++ b/tests/ui/string_lit_as_bytes.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_variables)] #![warn(clippy::string_lit_as_bytes)] @@ -22,7 +22,7 @@ fn str_lit_as_bytes() { let current_version = env!("CARGO_PKG_VERSION").as_bytes(); - let includestr = include_bytes!("string_lit_as_bytes.rs"); + let includestr = include_str!("string_lit_as_bytes.rs").as_bytes(); let _ = b"string with newline\t\n"; diff --git a/tests/ui/string_lit_as_bytes.rs b/tests/ui/string_lit_as_bytes.rs index 2c339f1ddb81..b550bea001f4 100644 --- a/tests/ui/string_lit_as_bytes.rs +++ b/tests/ui/string_lit_as_bytes.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_variables)] #![warn(clippy::string_lit_as_bytes)] diff --git a/tests/ui/string_lit_as_bytes.stderr b/tests/ui/string_lit_as_bytes.stderr index f47d6161c6cf..34eb72bb5dc1 100644 --- a/tests/ui/string_lit_as_bytes.stderr +++ b/tests/ui/string_lit_as_bytes.stderr @@ -1,40 +1,44 @@ -error: calling `as_bytes()` on a string literal +warning: calling `as_bytes()` on a string literal --> $DIR/string_lit_as_bytes.rs:7:14 | LL | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` | - = note: `-D clippy::string-lit-as-bytes` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/string_lit_as_bytes.rs:4:9 + | +LL | #![warn(clippy::string_lit_as_bytes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `as_bytes()` on a string literal +warning: calling `as_bytes()` on a string literal --> $DIR/string_lit_as_bytes.rs:9:14 | LL | let bs = r###"raw string with 3# plus " ""###.as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `br###"raw string with 3# plus " ""###` -error: calling `into_bytes()` on a string literal +warning: calling `into_bytes()` on a string literal --> $DIR/string_lit_as_bytes.rs:11:14 | LL | let bs = "lit to string".to_string().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to string".to_vec()` -error: calling `into_bytes()` on a string literal +warning: calling `into_bytes()` on a string literal --> $DIR/string_lit_as_bytes.rs:12:14 | LL | let bs = "lit to owned".to_owned().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to owned".to_vec()` -error: calling `as_bytes()` on `include_str!(..)` +warning: calling `as_bytes()` on `include_str!(..)` --> $DIR/string_lit_as_bytes.rs:25:22 | LL | let includestr = include_str!("string_lit_as_bytes.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("string_lit_as_bytes.rs")` -error: calling `as_bytes()` on a string literal +warning: calling `as_bytes()` on a string literal --> $DIR/string_lit_as_bytes.rs:27:13 | -LL | let _ = "string with newline/t/n".as_bytes(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"string with newline/t/n"` +LL | let _ = "string with newline\t\n".as_bytes(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"string with newline\t\n"` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/string_slice.stderr b/tests/ui/string_slice.stderr index 55040bf5df2d..a5363532091e 100644 --- a/tests/ui/string_slice.stderr +++ b/tests/ui/string_slice.stderr @@ -1,22 +1,26 @@ -error: indexing into a string may panic if the index is within a UTF-8 character +warning: indexing into a string may panic if the index is within a UTF-8 character --> $DIR/string_slice.rs:5:6 | LL | &"Ölkanne"[1..]; | ^^^^^^^^^^^^^^ | - = note: `-D clippy::string-slice` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/string_slice.rs:1:8 + | +LL | #[warn(clippy::string_slice)] + | ^^^^^^^^^^^^^^^^^^^^ -error: indexing into a string may panic if the index is within a UTF-8 character +warning: indexing into a string may panic if the index is within a UTF-8 character --> $DIR/string_slice.rs:7:6 | LL | &m[2..5]; | ^^^^^^^ -error: indexing into a string may panic if the index is within a UTF-8 character +warning: indexing into a string may panic if the index is within a UTF-8 character --> $DIR/string_slice.rs:9:6 | LL | &s[0..2]; | ^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/string_to_string.stderr b/tests/ui/string_to_string.stderr index e304c3e346db..bcbe0c54ab33 100644 --- a/tests/ui/string_to_string.stderr +++ b/tests/ui/string_to_string.stderr @@ -1,11 +1,15 @@ -error: `to_string()` called on a `String` +warning: `to_string()` called on a `String` --> $DIR/string_to_string.rs:6:17 | LL | let mut v = message.to_string(); | ^^^^^^^^^^^^^^^^^^^ | = help: consider using `.clone()` - = note: `-D clippy::string-to-string` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/string_to_string.rs:1:9 + | +LL | #![warn(clippy::string_to_string)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/strlen_on_c_strings.fixed b/tests/ui/strlen_on_c_strings.fixed index 947a59bcc027..ef207e28cca3 100644 --- a/tests/ui/strlen_on_c_strings.fixed +++ b/tests/ui/strlen_on_c_strings.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::strlen_on_c_strings)] #![allow(dead_code)] diff --git a/tests/ui/strlen_on_c_strings.rs b/tests/ui/strlen_on_c_strings.rs index 1237f1ab03ac..03ec5f79d092 100644 --- a/tests/ui/strlen_on_c_strings.rs +++ b/tests/ui/strlen_on_c_strings.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::strlen_on_c_strings)] #![allow(dead_code)] diff --git a/tests/ui/strlen_on_c_strings.stderr b/tests/ui/strlen_on_c_strings.stderr index 296268a5f1df..463ffb91911b 100644 --- a/tests/ui/strlen_on_c_strings.stderr +++ b/tests/ui/strlen_on_c_strings.stderr @@ -1,46 +1,50 @@ -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:15:13 | LL | let _ = unsafe { libc::strlen(cstring.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `cstring.as_bytes().len()` | - = note: `-D clippy::strlen-on-c-strings` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/strlen_on_c_strings.rs:3:9 + | +LL | #![warn(clippy::strlen_on_c_strings)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:19:13 | LL | let _ = unsafe { libc::strlen(cstr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `cstr.to_bytes().len()` -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:21:13 | LL | let _ = unsafe { strlen(cstr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `cstr.to_bytes().len()` -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:24:22 | LL | let _ = unsafe { strlen((*pcstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(*pcstr).to_bytes().len()` -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:29:22 | LL | let _ = unsafe { strlen(unsafe_identity(cstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unsafe_identity(cstr).to_bytes().len()` -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:30:13 | LL | let _ = unsafe { strlen(unsafe { unsafe_identity(cstr) }.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unsafe { unsafe_identity(cstr) }.to_bytes().len()` -error: using `libc::strlen` on a `CString` or `CStr` value +warning: using `libc::strlen` on a `CString` or `CStr` value --> $DIR/strlen_on_c_strings.rs:33:22 | LL | let _ = unsafe { strlen(f(cstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `f(cstr).to_bytes().len()` -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/struct_excessive_bools.stderr b/tests/ui/struct_excessive_bools.stderr index e4d50043acb0..e12add0657bd 100644 --- a/tests/ui/struct_excessive_bools.stderr +++ b/tests/ui/struct_excessive_bools.stderr @@ -1,4 +1,4 @@ -error: more than 3 bools in a struct +warning: more than 3 bools in a struct --> $DIR/struct_excessive_bools.rs:22:1 | LL | / struct BadFoo { @@ -10,9 +10,13 @@ LL | | } | |_^ | = help: consider using a state machine or refactoring bools into two-variant enums - = note: `-D clippy::struct-excessive-bools` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/struct_excessive_bools.rs:1:9 + | +LL | #![warn(clippy::struct_excessive_bools)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: more than 3 bools in a struct +warning: more than 3 bools in a struct --> $DIR/struct_excessive_bools.rs:38:5 | LL | / struct FooFoo { @@ -25,5 +29,5 @@ LL | | } | = help: consider using a state machine or refactoring bools into two-variant enums -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index ced1305874e5..c168ba25d7db 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,60 +1,64 @@ -error: suspicious use of `-` in `Add` impl +warning: suspicious use of `-` in `Add` impl --> $DIR/suspicious_arithmetic_impl.rs:13:20 | LL | Foo(self.0 - other.0) | ^ | - = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_arithmetic_impl.rs:1:9 + | +LL | #![warn(clippy::suspicious_arithmetic_impl)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: suspicious use of `-` in `AddAssign` impl +warning: suspicious use of `-` in `AddAssign` impl --> $DIR/suspicious_arithmetic_impl.rs:19:23 | LL | *self = *self - other; | ^ | - = note: `-D clippy::suspicious-op-assign-impl` implied by `-D warnings` + = note: `#[warn(clippy::suspicious_op_assign_impl)]` on by default -error: suspicious use of `/` in `MulAssign` impl +warning: suspicious use of `/` in `MulAssign` impl --> $DIR/suspicious_arithmetic_impl.rs:32:16 | LL | self.0 /= other.0; | ^^ -error: suspicious use of `/` in `Rem` impl +warning: suspicious use of `/` in `Rem` impl --> $DIR/suspicious_arithmetic_impl.rs:70:20 | LL | Foo(self.0 / other.0) | ^ -error: suspicious use of `|` in `BitAnd` impl +warning: suspicious use of `|` in `BitAnd` impl --> $DIR/suspicious_arithmetic_impl.rs:78:20 | LL | Foo(self.0 | other.0) | ^ -error: suspicious use of `^` in `BitOr` impl +warning: suspicious use of `^` in `BitOr` impl --> $DIR/suspicious_arithmetic_impl.rs:86:20 | LL | Foo(self.0 ^ other.0) | ^ -error: suspicious use of `&` in `BitXor` impl +warning: suspicious use of `&` in `BitXor` impl --> $DIR/suspicious_arithmetic_impl.rs:94:20 | LL | Foo(self.0 & other.0) | ^ -error: suspicious use of `>>` in `Shl` impl +warning: suspicious use of `>>` in `Shl` impl --> $DIR/suspicious_arithmetic_impl.rs:102:20 | LL | Foo(self.0 >> other.0) | ^^ -error: suspicious use of `<<` in `Shr` impl +warning: suspicious use of `<<` in `Shr` impl --> $DIR/suspicious_arithmetic_impl.rs:110:20 | LL | Foo(self.0 << other.0) | ^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/suspicious_command_arg_space.stderr b/tests/ui/suspicious_command_arg_space.stderr index 9bc0ca93aec9..38f0a5cc48e0 100644 --- a/tests/ui/suspicious_command_arg_space.stderr +++ b/tests/ui/suspicious_command_arg_space.stderr @@ -1,16 +1,16 @@ -error: single argument that looks like it should be multiple arguments +warning: single argument that looks like it should be multiple arguments --> $DIR/suspicious_command_arg_space.rs:3:44 | LL | std::process::Command::new("echo").arg("-n hello").spawn().unwrap(); | ^^^^^^^^^^ | - = note: `-D clippy::suspicious-command-arg-space` implied by `-D warnings` + = note: `#[warn(clippy::suspicious_command_arg_space)]` on by default help: consider splitting the argument | LL | std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap(); | ~~~~ ~~~~~~~~~~~~~~~ -error: single argument that looks like it should be multiple arguments +warning: single argument that looks like it should be multiple arguments --> $DIR/suspicious_command_arg_space.rs:4:43 | LL | std::process::Command::new("cat").arg("--number file").spawn().unwrap(); @@ -21,5 +21,5 @@ help: consider splitting the argument LL | std::process::Command::new("cat").args(["--number", "file"]).spawn().unwrap(); | ~~~~ ~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/suspicious_else_formatting.rs b/tests/ui/suspicious_else_formatting.rs index 21753e5dc6a4..b40142f79129 100644 --- a/tests/ui/suspicious_else_formatting.rs +++ b/tests/ui/suspicious_else_formatting.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_suspicious_else_formatting.rs +//@aux-build:proc_macro_suspicious_else_formatting.rs:proc-macro #![warn(clippy::suspicious_else_formatting)] #![allow(clippy::if_same_then_else, clippy::let_unit_value)] diff --git a/tests/ui/suspicious_else_formatting.stderr b/tests/ui/suspicious_else_formatting.stderr index 2e512b47f123..1b31d7490054 100644 --- a/tests/ui/suspicious_else_formatting.stderr +++ b/tests/ui/suspicious_else_formatting.stderr @@ -1,13 +1,17 @@ -error: this looks like an `else {..}` but the `else` is missing +warning: this looks like an `else {..}` but the `else` is missing --> $DIR/suspicious_else_formatting.rs:17:6 | LL | } { | ^ | = note: to remove this lint, add the missing `else` or add a new line before the next block - = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_else_formatting.rs:3:9 + | +LL | #![warn(clippy::suspicious_else_formatting)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this looks like an `else if` but the `else` is missing +warning: this looks like an `else if` but the `else` is missing --> $DIR/suspicious_else_formatting.rs:21:6 | LL | } if foo() { @@ -15,7 +19,7 @@ LL | } if foo() { | = 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 +warning: this looks like an `else if` but the `else` is missing --> $DIR/suspicious_else_formatting.rs:28:10 | LL | } if foo() { @@ -23,7 +27,7 @@ LL | } if foo() { | = 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 +warning: this looks like an `else if` but the `else` is missing --> $DIR/suspicious_else_formatting.rs:36:10 | LL | } if foo() { @@ -31,7 +35,7 @@ LL | } if foo() { | = note: to remove this lint, add the missing `else` or add a new line before the second `if` -error: this is an `else {..}` but the formatting might hide it +warning: this is an `else {..}` but the formatting might hide it --> $DIR/suspicious_else_formatting.rs:45:6 | LL | } else @@ -41,7 +45,7 @@ LL | | { | = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` -error: this is an `else if` but the formatting might hide it +warning: this is an `else if` but the formatting might hide it --> $DIR/suspicious_else_formatting.rs:57:6 | LL | } else @@ -51,7 +55,7 @@ LL | | if foo() { // the span of the above error should continue here | = 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 +warning: this is an `else if` but the formatting might hide it --> $DIR/suspicious_else_formatting.rs:62:6 | LL | } @@ -62,7 +66,7 @@ LL | | if foo() { // the span of the above error should continue here | = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` -error: this is an `else {..}` but the formatting might hide it +warning: this is an `else {..}` but the formatting might hide it --> $DIR/suspicious_else_formatting.rs:89:6 | LL | } @@ -74,7 +78,7 @@ LL | | { | = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` -error: this is an `else {..}` but the formatting might hide it +warning: this is an `else {..}` but the formatting might hide it --> $DIR/suspicious_else_formatting.rs:97:6 | LL | } @@ -86,5 +90,5 @@ LL | | { | = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/suspicious_map.stderr b/tests/ui/suspicious_map.stderr index e251674819e4..3eb61ce11151 100644 --- a/tests/ui/suspicious_map.stderr +++ b/tests/ui/suspicious_map.stderr @@ -1,13 +1,17 @@ -error: this call to `map()` won't have an effect on the call to `count()` +warning: this call to `map()` won't have an effect on the call to `count()` --> $DIR/suspicious_map.rs:4:13 | LL | let _ = (0..3).map(|x| x + 2).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: make sure you did not confuse `map` with `filter`, `for_each` or `inspect` - = note: `-D clippy::suspicious-map` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_map.rs:1:9 + | +LL | #![warn(clippy::suspicious_map)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: this call to `map()` won't have an effect on the call to `count()` +warning: this call to `map()` won't have an effect on the call to `count()` --> $DIR/suspicious_map.rs:7:13 | LL | let _ = (0..3).map(f).count(); @@ -15,5 +19,5 @@ LL | let _ = (0..3).map(f).count(); | = help: make sure you did not confuse `map` with `filter`, `for_each` or `inspect` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/suspicious_operation_groupings.fixed b/tests/ui/suspicious_operation_groupings.fixed index ede8a39fed71..014977c4aea4 100644 --- a/tests/ui/suspicious_operation_groupings.fixed +++ b/tests/ui/suspicious_operation_groupings.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suspicious_operation_groupings)] #![allow(dead_code, unused_parens, clippy::eq_op)] @@ -84,22 +84,22 @@ fn odd_number_of_pairs(s1: &S, s2: &S) -> i32 { fn not_caught_by_eq_op_middle_change_left(s1: &S, s2: &S) -> i32 { // There's no `s1.b` - s1.a * s2.a + s1.b * s2.b + s1.c * s2.c + s1.a * s2.a + s2.b * s2.b + s1.c * s2.c } fn not_caught_by_eq_op_middle_change_right(s1: &S, s2: &S) -> i32 { // There's no `s2.b` - s1.a * s2.a + s1.b * s2.b + s1.c * s2.c + s1.a * s2.a + s1.b * s1.b + s1.c * s2.c } fn not_caught_by_eq_op_start(s1: &S, s2: &S) -> i32 { // There's no `s2.a` - s1.a * s2.a + s1.b * s2.b + s1.c * s2.c + s1.a * s1.a + s1.b * s2.b + s1.c * s2.c } fn not_caught_by_eq_op_end(s1: &S, s2: &S) -> i32 { // There's no `s2.c` - s1.a * s2.a + s1.b * s2.b + s1.c * s2.c + s1.a * s2.a + s1.b * s2.b + s1.c * s1.c } fn the_cross_product_should_not_lint(s1: &S, s2: &S) -> (i32, i32, i32) { @@ -112,7 +112,7 @@ fn the_cross_product_should_not_lint(s1: &S, s2: &S) -> (i32, i32, i32) { fn outer_parens_simple(s1: &S, s2: &S) -> i32 { // There's no `s2.b` - (s1.a * s2.a + s1.b * s2.b) + (s1.a * s2.a + s1.b * s1.b) } fn outer_parens(s1: &S, s2: &S) -> i32 { @@ -147,12 +147,12 @@ fn all_parens_right_tree(s1: &S, s2: &S) -> i32 { fn inside_other_binop_expression(s1: &S, s2: &S) -> i32 { // There's no `s1.b` - (s1.a * s2.a + s1.b * s2.b) / 2 + (s1.a * s2.a + s2.b * s2.b) / 2 } fn inside_function_call(s1: &S, s2: &S) -> i32 { // There's no `s1.b` - i32::swap_bytes(s1.a * s2.a + s1.b * s2.b) + i32::swap_bytes(s1.a * s2.a + s2.b * s2.b) } fn inside_larger_boolean_expression(s1: &S, s2: &S) -> bool { diff --git a/tests/ui/suspicious_operation_groupings.rs b/tests/ui/suspicious_operation_groupings.rs index 26ce97bb37f8..dd4f3b71c378 100644 --- a/tests/ui/suspicious_operation_groupings.rs +++ b/tests/ui/suspicious_operation_groupings.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::suspicious_operation_groupings)] #![allow(dead_code, unused_parens, clippy::eq_op)] diff --git a/tests/ui/suspicious_operation_groupings.stderr b/tests/ui/suspicious_operation_groupings.stderr index 29f229245fed..1ac6be4d41bb 100644 --- a/tests/ui/suspicious_operation_groupings.stderr +++ b/tests/ui/suspicious_operation_groupings.stderr @@ -1,160 +1,164 @@ -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:16:9 | LL | self.x == other.y && self.y == other.y && self.z == other.z | ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x` | - = note: `-D clippy::suspicious-operation-groupings` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_operation_groupings.rs:2:9 + | +LL | #![warn(clippy::suspicious_operation_groupings)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:29:20 | LL | s1.a < s2.a && s1.a < s2.b | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:77:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:82:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:82:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:87:19 | LL | s1.a * s2.a + s2.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:92:19 | LL | s1.a * s2.a + s1.b * s1.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:97:5 | LL | s1.a * s1.a + s1.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.a * s2.a` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:102:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s1.c | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:115:20 | LL | (s1.a * s2.a + s1.b * s1.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:120:34 | LL | (s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:125:38 | LL | (s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:130:39 | LL | ((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:135:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:135:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:140:40 | LL | (((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b)) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:145:40 | LL | ((s1.a * s2.a) + ((s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:150:20 | LL | (s1.a * s2.a + s2.b * s2.b) / 2 | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:155:35 | LL | i32::swap_bytes(s1.a * s2.a + s2.b * s2.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:160:29 | LL | s1.a > 0 && s1.b > 0 && s1.d == s2.c && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:165:17 | LL | s1.a > 0 && s1.d == s2.c && s1.b > 0 && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:174:77 | LL | (n1.inner.0).0 == (n2.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.1).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `(n1.inner.2).0 == (n2.inner.2).0` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:188:25 | LL | s1.a <= s2.a && s1.a <= s2.b | ^^^^^^^^^^^^ help: did you mean: `s1.b <= s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:194:23 | LL | if s1.a < s2.a && s1.a < s2.b { | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:201:48 | LL | -(-(-s1.a * -s2.a) + (-(-s1.b * -s2.b) + -(-s1.c * -s2.b) + -(-s1.d * -s2.d))) | ^^^^^^^^^^^^^ help: did you mean: `-s1.c * -s2.c` -error: this sequence of operators looks suspiciously like a bug +warning: this sequence of operators looks suspiciously like a bug --> $DIR/suspicious_operation_groupings.rs:206:27 | LL | -(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a }) | ^^^^^^^^^^^^^ help: did you mean: `-s1.b < -s2.b` -error: aborting due to 26 previous errors +warning: 26 warnings emitted diff --git a/tests/ui/suspicious_splitn.stderr b/tests/ui/suspicious_splitn.stderr index 55ce63d4faa8..b175dbdc472f 100644 --- a/tests/ui/suspicious_splitn.stderr +++ b/tests/ui/suspicious_splitn.stderr @@ -1,13 +1,17 @@ -error: `splitn` called with `0` splits +warning: `splitn` called with `0` splits --> $DIR/suspicious_splitn.rs:10:13 | LL | let _ = "a,b".splitn(0, ','); | ^^^^^^^^^^^^^^^^^^^^ | = note: the resulting iterator will always return `None` - = note: `-D clippy::suspicious-splitn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_splitn.rs:1:9 + | +LL | #![warn(clippy::suspicious_splitn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `rsplitn` called with `0` splits +warning: `rsplitn` called with `0` splits --> $DIR/suspicious_splitn.rs:11:13 | LL | let _ = "a,b".rsplitn(0, ','); @@ -15,7 +19,7 @@ LL | let _ = "a,b".rsplitn(0, ','); | = note: the resulting iterator will always return `None` -error: `splitn` called with `1` split +warning: `splitn` called with `1` split --> $DIR/suspicious_splitn.rs:12:13 | LL | let _ = "a,b".splitn(1, ','); @@ -23,7 +27,7 @@ LL | let _ = "a,b".splitn(1, ','); | = note: the resulting iterator will always return the entire string followed by `None` -error: `splitn` called with `0` splits +warning: `splitn` called with `0` splits --> $DIR/suspicious_splitn.rs:13:13 | LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); @@ -31,7 +35,7 @@ LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); | = note: the resulting iterator will always return `None` -error: `splitn_mut` called with `0` splits +warning: `splitn_mut` called with `0` splits --> $DIR/suspicious_splitn.rs:14:13 | LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); @@ -39,7 +43,7 @@ LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); | = note: the resulting iterator will always return `None` -error: `splitn` called with `1` split +warning: `splitn` called with `1` split --> $DIR/suspicious_splitn.rs:15:13 | LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); @@ -47,7 +51,7 @@ LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); | = note: the resulting iterator will always return the entire slice followed by `None` -error: `rsplitn_mut` called with `1` split +warning: `rsplitn_mut` called with `1` split --> $DIR/suspicious_splitn.rs:16:13 | LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); @@ -55,7 +59,7 @@ LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); | = note: the resulting iterator will always return the entire slice followed by `None` -error: `splitn` called with `1` split +warning: `splitn` called with `1` split --> $DIR/suspicious_splitn.rs:19:13 | LL | let _ = "a,b".splitn(X + 1, ','); @@ -63,7 +67,7 @@ LL | let _ = "a,b".splitn(X + 1, ','); | = note: the resulting iterator will always return the entire string followed by `None` -error: `splitn` called with `0` splits +warning: `splitn` called with `0` splits --> $DIR/suspicious_splitn.rs:20:13 | LL | let _ = "a,b".splitn(X, ','); @@ -71,5 +75,5 @@ LL | let _ = "a,b".splitn(X, ','); | = note: the resulting iterator will always return `None` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/suspicious_to_owned.stderr b/tests/ui/suspicious_to_owned.stderr index c4ec7aa88a2a..34db3b806a46 100644 --- a/tests/ui/suspicious_to_owned.stderr +++ b/tests/ui/suspicious_to_owned.stderr @@ -1,10 +1,14 @@ -error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned +warning: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned --> $DIR/suspicious_to_owned.rs:16:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ | - = note: `-D clippy::suspicious-to-owned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_to_owned.rs:1:9 + | +LL | #![warn(clippy::suspicious_to_owned)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: depending on intent, either make the Cow an Owned variant | LL | let _ = cow.into_owned(); @@ -14,7 +18,7 @@ help: or clone the Cow itself LL | let _ = cow.clone(); | ~~~~~~~~~~~ -error: this `to_owned` call clones the Cow<'_, [char; 3]> itself and does not cause the Cow<'_, [char; 3]> contents to become owned +warning: this `to_owned` call clones the Cow<'_, [char; 3]> itself and does not cause the Cow<'_, [char; 3]> contents to become owned --> $DIR/suspicious_to_owned.rs:26:13 | LL | let _ = cow.to_owned(); @@ -29,7 +33,7 @@ help: or clone the Cow itself LL | let _ = cow.clone(); | ~~~~~~~~~~~ -error: this `to_owned` call clones the Cow<'_, Vec> itself and does not cause the Cow<'_, Vec> contents to become owned +warning: this `to_owned` call clones the Cow<'_, Vec> itself and does not cause the Cow<'_, Vec> contents to become owned --> $DIR/suspicious_to_owned.rs:36:13 | LL | let _ = cow.to_owned(); @@ -44,7 +48,7 @@ help: or clone the Cow itself LL | let _ = cow.clone(); | ~~~~~~~~~~~ -error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned +warning: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned --> $DIR/suspicious_to_owned.rs:46:13 | LL | let _ = cow.to_owned(); @@ -59,19 +63,23 @@ help: or clone the Cow itself LL | let _ = cow.clone(); | ~~~~~~~~~~~ -error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `String` by calling `to_owned` on its dereferenced type --> $DIR/suspicious_to_owned.rs:60:13 | LL | let _ = String::from(moo).to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::from(moo).clone()` | - = note: `-D clippy::implicit-clone` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_to_owned.rs:2:9 + | +LL | #![warn(clippy::implicit_clone)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type +warning: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type --> $DIR/suspicious_to_owned.rs:61:13 | LL | let _ = moos_vec.to_owned(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `moos_vec.clone()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/suspicious_unary_op_formatting.stderr b/tests/ui/suspicious_unary_op_formatting.stderr index 9f1289ccba0c..eda801aa02c1 100644 --- a/tests/ui/suspicious_unary_op_formatting.stderr +++ b/tests/ui/suspicious_unary_op_formatting.stderr @@ -1,13 +1,17 @@ -error: by not having a space between `>` and `-` it looks like `>-` is a single operator +warning: by not having a space between `>` and `-` it looks like `>-` is a single operator --> $DIR/suspicious_unary_op_formatting.rs:8:9 | LL | if a >- 30 {} | ^^^^ | = help: put a space between `>` and `-` and remove the space after `-` - = note: `-D clippy::suspicious-unary-op-formatting` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_unary_op_formatting.rs:1:9 + | +LL | #![warn(clippy::suspicious_unary_op_formatting)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: by not having a space between `>=` and `-` it looks like `>=-` is a single operator +warning: by not having a space between `>=` and `-` it looks like `>=-` is a single operator --> $DIR/suspicious_unary_op_formatting.rs:9:9 | LL | if a >=- 30 {} @@ -15,7 +19,7 @@ LL | if a >=- 30 {} | = help: put a space between `>=` and `-` and remove the space after `-` -error: by not having a space between `&&` and `!` it looks like `&&!` is a single operator +warning: by not having a space between `&&` and `!` it looks like `&&!` is a single operator --> $DIR/suspicious_unary_op_formatting.rs:14:9 | LL | if b &&! c {} @@ -23,7 +27,7 @@ LL | if b &&! c {} | = help: put a space between `&&` and `!` and remove the space after `!` -error: by not having a space between `>` and `-` it looks like `>-` is a single operator +warning: by not having a space between `>` and `-` it looks like `>-` is a single operator --> $DIR/suspicious_unary_op_formatting.rs:16:9 | LL | if a >- 30 {} @@ -31,5 +35,5 @@ LL | if a >- 30 {} | = help: put a space between `>` and `-` and remove the space after `-` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/suspicious_xor_used_as_pow.stderr b/tests/ui/suspicious_xor_used_as_pow.stderr index 8bb3c8fbeebd..1e9716daf5e5 100644 --- a/tests/ui/suspicious_xor_used_as_pow.stderr +++ b/tests/ui/suspicious_xor_used_as_pow.stderr @@ -1,42 +1,46 @@ -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:19:13 | LL | let _ = 2 ^ 5; | ^^^^^ help: did you mean to write: `2.pow(5)` | - = note: `-D clippy::suspicious-xor-used-as-pow` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/suspicious_xor_used_as_pow.rs:2:9 + | +LL | #![warn(clippy::suspicious_xor_used_as_pow)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:20:13 | LL | let _ = 2i32 ^ 9i32; | ^^^^^^^^^^^ help: did you mean to write: `2_i32.pow(9_i32)` -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:21:13 | LL | let _ = 2i32 ^ 2i32; | ^^^^^^^^^^^ help: did you mean to write: `2_i32.pow(2_i32)` -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:22:13 | LL | let _ = 50i32 ^ 3i32; | ^^^^^^^^^^^^ help: did you mean to write: `50_i32.pow(3_i32)` -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:23:13 | LL | let _ = 5i32 ^ 8i32; | ^^^^^^^^^^^ help: did you mean to write: `5_i32.pow(8_i32)` -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:24:13 | LL | let _ = 2i32 ^ 32i32; | ^^^^^^^^^^^^ help: did you mean to write: `2_i32.pow(32_i32)` -error: `^` is not the exponentiation operator +warning: `^` is not the exponentiation operator --> $DIR/suspicious_xor_used_as_pow.rs:13:9 | LL | 1 ^ 2 // should warn even if inside macro @@ -45,7 +49,7 @@ LL | 1 ^ 2 // should warn even if inside macro LL | macro_test_inside!(); | -------------------- in this macro invocation | - = note: this error originates in the macro `macro_test_inside` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `macro_test_inside` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/swap.fixed b/tests/ui/swap.fixed index fa89706a815a..9c4b2cd282eb 100644 --- a/tests/ui/swap.fixed +++ b/tests/ui/swap.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![allow( @@ -113,24 +113,29 @@ fn main() { let mut a = 42; let mut b = 1337; - std::mem::swap(&mut a, &mut b); + a = b; + b = a; ; std::mem::swap(&mut a, &mut b); let mut c = Foo(42); - std::mem::swap(&mut c.0, &mut a); + c.0 = a; + a = c.0; ; std::mem::swap(&mut c.0, &mut a); - std::mem::swap(&mut a, &mut b); + let a = b; + let b = a; let mut c = 1; let mut d = 2; - std::mem::swap(&mut d, &mut c); + d = c; + c = d; let mut b = 1; - std::mem::swap(&mut a, &mut b); + let a = b; + b = a; let b = 1; let a = 2; diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index ef8a81c8341b..9442a4c8a300 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::all)] #![allow( diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index f0acbfe253f4..33bae8fcdb5a 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,4 +1,4 @@ -error: this looks like you are swapping `bar.a` and `bar.b` manually +warning: this looks like you are swapping `bar.a` and `bar.b` manually --> $DIR/swap.rs:25:5 | LL | / let temp = bar.a; @@ -7,9 +7,14 @@ LL | | bar.b = temp; | |________________^ help: try: `std::mem::swap(&mut bar.a, &mut bar.b)` | = note: or maybe you should use `std::mem::replace`? - = note: `-D clippy::manual-swap` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/swap.rs:3:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::manual_swap)]` implied by `#[warn(clippy::all)]` -error: this looks like you are swapping elements of `foo` manually +warning: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:37:5 | LL | / let temp = foo[0]; @@ -17,7 +22,7 @@ LL | | foo[0] = foo[1]; LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` -error: this looks like you are swapping elements of `foo` manually +warning: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:46:5 | LL | / let temp = foo[0]; @@ -25,7 +30,7 @@ LL | | foo[0] = foo[1]; LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` -error: this looks like you are swapping elements of `foo` manually +warning: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:65:5 | LL | / let temp = foo[0]; @@ -33,7 +38,7 @@ LL | | foo[0] = foo[1]; LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` -error: this looks like you are swapping `a` and `b` manually +warning: this looks like you are swapping `a` and `b` manually --> $DIR/swap.rs:76:5 | LL | / a ^= b; @@ -41,7 +46,7 @@ LL | | b ^= a; LL | | a ^= b; | |___________^ help: try: `std::mem::swap(&mut a, &mut b)` -error: this looks like you are swapping `bar.a` and `bar.b` manually +warning: this looks like you are swapping `bar.a` and `bar.b` manually --> $DIR/swap.rs:84:5 | LL | / bar.a ^= bar.b; @@ -49,7 +54,7 @@ LL | | bar.b ^= bar.a; LL | | bar.a ^= bar.b; | |___________________^ help: try: `std::mem::swap(&mut bar.a, &mut bar.b)` -error: this looks like you are swapping elements of `foo` manually +warning: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:92:5 | LL | / foo[0] ^= foo[1]; @@ -57,7 +62,7 @@ LL | | foo[1] ^= foo[0]; LL | | foo[0] ^= foo[1]; | |_____________________^ help: try: `foo.swap(0, 1)` -error: this looks like you are swapping `foo[0][1]` and `bar[1][0]` manually +warning: this looks like you are swapping `foo[0][1]` and `bar[1][0]` manually --> $DIR/swap.rs:121:5 | LL | / let temp = foo[0][1]; @@ -67,7 +72,7 @@ LL | | bar[1][0] = temp; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are swapping `a` and `b` manually +warning: this looks like you are swapping `a` and `b` manually --> $DIR/swap.rs:135:7 | LL | ; let t = a; @@ -78,7 +83,7 @@ LL | | b = t; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are swapping `c.0` and `a` manually +warning: this looks like you are swapping `c.0` and `a` manually --> $DIR/swap.rs:144:7 | LL | ; let t = c.0; @@ -89,7 +94,7 @@ LL | | a = t; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are swapping `b` and `a` manually +warning: this looks like you are swapping `b` and `a` manually --> $DIR/swap.rs:170:5 | LL | / let t = b; @@ -99,7 +104,7 @@ LL | | a = t; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are trying to swap `a` and `b` +warning: this looks like you are trying to swap `a` and `b` --> $DIR/swap.rs:132:5 | LL | / a = b; @@ -107,9 +112,9 @@ LL | | b = a; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: or maybe you should use `std::mem::replace`? - = note: `-D clippy::almost-swapped` implied by `-D warnings` + = note: `#[warn(clippy::almost_swapped)]` implied by `#[warn(clippy::all)]` -error: this looks like you are trying to swap `c.0` and `a` +warning: this looks like you are trying to swap `c.0` and `a` --> $DIR/swap.rs:141:5 | LL | / c.0 = a; @@ -118,7 +123,7 @@ LL | | a = c.0; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are trying to swap `a` and `b` +warning: this looks like you are trying to swap `a` and `b` --> $DIR/swap.rs:148:5 | LL | / let a = b; @@ -127,7 +132,7 @@ LL | | let b = a; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are trying to swap `d` and `c` +warning: this looks like you are trying to swap `d` and `c` --> $DIR/swap.rs:153:5 | LL | / d = c; @@ -136,7 +141,7 @@ LL | | c = d; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are trying to swap `a` and `b` +warning: this looks like you are trying to swap `a` and `b` --> $DIR/swap.rs:157:5 | LL | / let a = b; @@ -145,7 +150,7 @@ LL | | b = a; | = note: or maybe you should use `std::mem::replace`? -error: this looks like you are swapping `s.0.x` and `s.0.y` manually +warning: this looks like you are swapping `s.0.x` and `s.0.y` manually --> $DIR/swap.rs:205:5 | LL | / let t = s.0.x; @@ -155,5 +160,5 @@ LL | | s.0.y = t; | = note: or maybe you should use `std::mem::replace`? -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/swap_ptr_to_ref.fixed b/tests/ui/swap_ptr_to_ref.fixed index 596b6ee919bb..3bede3017a13 100644 --- a/tests/ui/swap_ptr_to_ref.fixed +++ b/tests/ui/swap_ptr_to_ref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::swap_ptr_to_ref)] diff --git a/tests/ui/swap_ptr_to_ref.rs b/tests/ui/swap_ptr_to_ref.rs index 282f571211d9..726b09d37643 100644 --- a/tests/ui/swap_ptr_to_ref.rs +++ b/tests/ui/swap_ptr_to_ref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::swap_ptr_to_ref)] diff --git a/tests/ui/swap_ptr_to_ref.stderr b/tests/ui/swap_ptr_to_ref.stderr index 401ce070869a..76af125f2449 100644 --- a/tests/ui/swap_ptr_to_ref.stderr +++ b/tests/ui/swap_ptr_to_ref.stderr @@ -1,28 +1,32 @@ -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref.rs:13:9 | LL | core::mem::swap(&mut *y, &mut *z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, z)` | - = note: `-D clippy::swap-ptr-to-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/swap_ptr_to_ref.rs:3:9 + | +LL | #![warn(clippy::swap_ptr_to_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref.rs:14:9 | LL | core::mem::swap(&mut *y, &mut x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, &mut x)` -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref.rs:15:9 | LL | core::mem::swap(&mut x, &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(&mut x, y)` -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref.rs:16:9 | LL | core::mem::swap(&mut *addr_of_mut!(x), &mut *addr_of_mut!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(addr_of_mut!(x), addr_of_mut!(x))` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/swap_ptr_to_ref_unfixable.stderr b/tests/ui/swap_ptr_to_ref_unfixable.stderr index c261205d556e..d24347817abb 100644 --- a/tests/ui/swap_ptr_to_ref_unfixable.stderr +++ b/tests/ui/swap_ptr_to_ref_unfixable.stderr @@ -1,22 +1,26 @@ -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref_unfixable.rs:14:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::swap-ptr-to-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/swap_ptr_to_ref_unfixable.rs:1:9 + | +LL | #![warn(clippy::swap_ptr_to_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref_unfixable.rs:15:9 | LL | core::mem::swap(&mut *y, addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: call to `core::mem::swap` with a parameter derived from a raw pointer +warning: call to `core::mem::swap` with a parameter derived from a raw pointer --> $DIR/swap_ptr_to_ref_unfixable.rs:16:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/tabs_in_doc_comments.fixed b/tests/ui/tabs_in_doc_comments.fixed index 4bc4bc86c76c..df704267dd25 100644 --- a/tests/ui/tabs_in_doc_comments.fixed +++ b/tests/ui/tabs_in_doc_comments.fixed @@ -1,20 +1,20 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::tabs_in_doc_comments)] #[allow(dead_code)] /// /// Struct to hold two strings: -/// - first one -/// - second one +/// - first one +/// - second one pub struct DoubleString { /// - /// - First String: - /// - needs to be inside here + /// - First String: + /// - needs to be inside here first_string: String, /// - /// - Second String: - /// - needs to be inside here + /// - Second String: + /// - needs to be inside here second_string: String, } diff --git a/tests/ui/tabs_in_doc_comments.rs b/tests/ui/tabs_in_doc_comments.rs index 9db3416e6596..df704267dd25 100644 --- a/tests/ui/tabs_in_doc_comments.rs +++ b/tests/ui/tabs_in_doc_comments.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::tabs_in_doc_comments)] #[allow(dead_code)] diff --git a/tests/ui/tabs_in_doc_comments.stderr b/tests/ui/tabs_in_doc_comments.stderr index 355f2e805796..57b4084796ef 100644 --- a/tests/ui/tabs_in_doc_comments.stderr +++ b/tests/ui/tabs_in_doc_comments.stderr @@ -1,52 +1,56 @@ -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:12:9 | LL | /// - First String: | ^^^^ help: consider using four spaces per tab | - = note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/tabs_in_doc_comments.rs:3:9 + | +LL | #![warn(clippy::tabs_in_doc_comments)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:13:9 | LL | /// - needs to be inside here | ^^^^^^^^ help: consider using four spaces per tab -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:16:9 | LL | /// - Second String: | ^^^^ help: consider using four spaces per tab -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:17:9 | LL | /// - needs to be inside here | ^^^^^^^^ help: consider using four spaces per tab -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:8:5 | LL | /// - first one | ^^^^ help: consider using four spaces per tab -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:8:13 | LL | /// - first one | ^^^^^^^^ help: consider using four spaces per tab -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:9:5 | LL | /// - second one | ^^^^ help: consider using four spaces per tab -error: using tabs in doc comments is not recommended +warning: using tabs in doc comments is not recommended --> $DIR/tabs_in_doc_comments.rs:9:14 | LL | /// - second one | ^^^^ help: consider using four spaces per tab -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 7d79901a28d1..346c36cffc72 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -1,12 +1,16 @@ -error: assignment to temporary +warning: assignment to temporary --> $DIR/temporary_assignment.rs:47:5 | LL | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::temporary-assignment` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/temporary_assignment.rs:1:9 + | +LL | #![warn(clippy::temporary_assignment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: assignment to temporary +warning: assignment to temporary --> $DIR/temporary_assignment.rs:48:5 | LL | / MultiStruct { @@ -16,17 +20,17 @@ LL | | .structure LL | | .field = 1; | |______________^ -error: assignment to temporary +warning: assignment to temporary --> $DIR/temporary_assignment.rs:53:5 | LL | ArrayStruct { array: [0] }.array[0] = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: assignment to temporary +warning: assignment to temporary --> $DIR/temporary_assignment.rs:54:5 | LL | (0, 0).0 = 1; | ^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/to_digit_is_some.fixed b/tests/ui/to_digit_is_some.fixed deleted file mode 100644 index 3c5e96427146..000000000000 --- a/tests/ui/to_digit_is_some.fixed +++ /dev/null @@ -1,11 +0,0 @@ -//run-rustfix - -#![warn(clippy::to_digit_is_some)] - -fn main() { - let c = 'x'; - let d = &c; - - let _ = d.is_digit(8); - let _ = char::is_digit(c, 8); -} diff --git a/tests/ui/to_digit_is_some.stderr b/tests/ui/to_digit_is_some.stderr index 10a1b393a390..ef5d2b23fb87 100644 --- a/tests/ui/to_digit_is_some.stderr +++ b/tests/ui/to_digit_is_some.stderr @@ -1,16 +1,20 @@ -error: use of `.to_digit(..).is_some()` +warning: use of `.to_digit(..).is_some()` --> $DIR/to_digit_is_some.rs:9:13 | LL | let _ = d.to_digit(8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `d.is_digit(8)` | - = note: `-D clippy::to-digit-is-some` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/to_digit_is_some.rs:3:9 + | +LL | #![warn(clippy::to_digit_is_some)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `.to_digit(..).is_some()` +warning: use of `.to_digit(..).is_some()` --> $DIR/to_digit_is_some.rs:10:13 | LL | let _ = char::to_digit(c, 8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `char::is_digit(c, 8)` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/toplevel_ref_arg.fixed b/tests/ui/toplevel_ref_arg.fixed index 09fb66ca37e0..43f0db2dd8cd 100644 --- a/tests/ui/toplevel_ref_arg.fixed +++ b/tests/ui/toplevel_ref_arg.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::toplevel_ref_arg)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/toplevel_ref_arg.rs b/tests/ui/toplevel_ref_arg.rs index 9d1f2f810983..37c9142eccfc 100644 --- a/tests/ui/toplevel_ref_arg.rs +++ b/tests/ui/toplevel_ref_arg.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs #![warn(clippy::toplevel_ref_arg)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 9c853020ab01..dd1ee4fd256b 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,36 +1,40 @@ -error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead +warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:20:9 | LL | let ref _x = 1; | ----^^^^^^----- help: try: `let _x = &1;` | - = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/toplevel_ref_arg.rs:3:9 + | +LL | #![warn(clippy::toplevel_ref_arg)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead +warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:22:9 | LL | let ref _y: (&_, u8) = (&1, 2); | ----^^^^^^--------------------- help: try: `let _y: &(&_, u8) = &(&1, 2);` -error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead +warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:24:9 | LL | let ref _z = 1 + 2; | ----^^^^^^--------- help: try: `let _z = &(1 + 2);` -error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead +warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:26:9 | LL | let ref mut _z = 1 + 2; | ----^^^^^^^^^^--------- help: try: `let _z = &mut (1 + 2);` -error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead +warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:31:9 | LL | let ref _x = vec![1, 2, 3]; | ----^^^^^^----------------- help: try: `let _x = &vec![1, 2, 3];` -error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead +warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead --> $DIR/toplevel_ref_arg.rs:11:13 | LL | let ref _y = 42; @@ -39,7 +43,7 @@ LL | let ref _y = 42; LL | gen_binding!(); | -------------- in this macro invocation | - = note: this error originates in the macro `gen_binding` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `gen_binding` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/toplevel_ref_arg_non_rustfix.rs b/tests/ui/toplevel_ref_arg_non_rustfix.rs index 1a493fbce0ef..5bd34cb7d52a 100644 --- a/tests/ui/toplevel_ref_arg_non_rustfix.rs +++ b/tests/ui/toplevel_ref_arg_non_rustfix.rs @@ -1,4 +1,4 @@ -// aux-build:macro_rules.rs +//@aux-build:macro_rules.rs #![warn(clippy::toplevel_ref_arg)] #![allow(unused)] diff --git a/tests/ui/toplevel_ref_arg_non_rustfix.stderr b/tests/ui/toplevel_ref_arg_non_rustfix.stderr index e97011c7fd51..ddd48a1b42c9 100644 --- a/tests/ui/toplevel_ref_arg_non_rustfix.stderr +++ b/tests/ui/toplevel_ref_arg_non_rustfix.stderr @@ -1,12 +1,16 @@ -error: `ref` directly on a function argument is ignored. Consider using a reference type instead +warning: `ref` directly on a function argument is ignored. Consider using a reference type instead --> $DIR/toplevel_ref_arg_non_rustfix.rs:9:15 | LL | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | - = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/toplevel_ref_arg_non_rustfix.rs:3:9 + | +LL | #![warn(clippy::toplevel_ref_arg)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `ref` directly on a function argument is ignored. Consider using a reference type instead +warning: `ref` directly on a function argument is ignored. Consider using a reference type instead --> $DIR/toplevel_ref_arg_non_rustfix.rs:15:24 | LL | fn fun_example(ref _x: usize) {} @@ -15,7 +19,7 @@ LL | fn fun_example(ref _x: usize) {} LL | gen_function!(); | --------------- in this macro invocation | - = note: this error originates in the macro `gen_function` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `gen_function` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/track-diagnostics.rs b/tests/ui/track-diagnostics.rs index fa9221ed02d7..723ea23e9a63 100644 --- a/tests/ui/track-diagnostics.rs +++ b/tests/ui/track-diagnostics.rs @@ -1,12 +1,12 @@ -// compile-flags: -Z track-diagnostics -// error-pattern: created at +//@compile-flags: -Z track-diagnostics // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" +//@normalize-stderr-test: ".rs:\d+:\d+" -> ".rs:LL:CC" struct A; struct B; const S: A = B; +//~^ ERROR: mismatched types fn main() {} diff --git a/tests/ui/trailing_empty_array.stderr b/tests/ui/trailing_empty_array.stderr index 2e1484400352..1a35f17204c4 100644 --- a/tests/ui/trailing_empty_array.stderr +++ b/tests/ui/trailing_empty_array.stderr @@ -1,4 +1,4 @@ -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:5:1 | LL | / struct RarelyUseful { @@ -8,9 +8,13 @@ LL | | } | |_^ | = help: consider annotating `RarelyUseful` with `#[repr(C)]` or another `repr` attribute - = note: `-D clippy::trailing-empty-array` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/trailing_empty_array.rs:1:9 + | +LL | #![warn(clippy::trailing_empty_array)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:10:1 | LL | / struct OnlyField { @@ -20,7 +24,7 @@ LL | | } | = help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:14:1 | LL | / struct GenericArrayType { @@ -31,7 +35,7 @@ LL | | } | = help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:20:1 | LL | / struct OnlyAnotherAttribute { @@ -42,7 +46,7 @@ LL | | } | = help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:26:1 | LL | / struct OnlyADeriveAttribute { @@ -53,7 +57,7 @@ LL | | } | = help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:32:1 | LL | / struct ZeroSizedWithConst { @@ -64,7 +68,7 @@ LL | | } | = help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:41:1 | LL | / struct ZeroSizedWithConstFunction { @@ -75,7 +79,7 @@ LL | | } | = help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:49:1 | LL | / struct ZeroSizedWithConstFunction2 { @@ -86,7 +90,7 @@ LL | | } | = help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:54:1 | LL | struct ZeroSizedArrayWrapper([usize; 0]); @@ -94,7 +98,7 @@ LL | struct ZeroSizedArrayWrapper([usize; 0]); | = help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:56:1 | LL | struct TupleStruct(i32, [usize; 0]); @@ -102,7 +106,7 @@ LL | struct TupleStruct(i32, [usize; 0]); | = help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute -error: trailing zero-sized array in a struct which is not marked with a `repr` attribute +warning: trailing zero-sized array in a struct which is not marked with a `repr` attribute --> $DIR/trailing_empty_array.rs:58:1 | LL | / struct LotsOfFields { @@ -116,5 +120,5 @@ LL | | } | = help: consider annotating `LotsOfFields` with `#[repr(C)]` or another `repr` attribute -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 798551118309..95d31dcbee30 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,16 +1,20 @@ -error: bit mask could be simplified with a call to `trailing_zeros` +warning: bit mask could be simplified with a call to `trailing_zeros` --> $DIR/trailing_zeros.rs:6:13 | LL | let _ = (x & 0b1111 == 0); // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | - = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/trailing_zeros.rs:2:9 + | +LL | #![warn(clippy::verbose_bit_mask)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: bit mask could be simplified with a call to `trailing_zeros` +warning: bit mask could be simplified with a call to `trailing_zeros` --> $DIR/trailing_zeros.rs:7:13 | LL | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/trait_duplication_in_bounds.fixed b/tests/ui/trait_duplication_in_bounds.fixed index 4ce5d4217822..6db12caa68b4 100644 --- a/tests/ui/trait_duplication_in_bounds.fixed +++ b/tests/ui/trait_duplication_in_bounds.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::trait_duplication_in_bounds)] +//@run-rustfix +#![warn(clippy::trait_duplication_in_bounds)] #![allow(unused)] fn bad_foo(arg0: T, argo1: U) { diff --git a/tests/ui/trait_duplication_in_bounds.rs b/tests/ui/trait_duplication_in_bounds.rs index 7f2e96a22e66..77e91d8ec42e 100644 --- a/tests/ui/trait_duplication_in_bounds.rs +++ b/tests/ui/trait_duplication_in_bounds.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::trait_duplication_in_bounds)] +//@run-rustfix +#![warn(clippy::trait_duplication_in_bounds)] #![allow(unused)] fn bad_foo(arg0: T, argo1: U) { diff --git a/tests/ui/trait_duplication_in_bounds.stderr b/tests/ui/trait_duplication_in_bounds.stderr index af800ba78880..57acb0fa348c 100644 --- a/tests/ui/trait_duplication_in_bounds.stderr +++ b/tests/ui/trait_duplication_in_bounds.stderr @@ -1,4 +1,4 @@ -error: these bounds contain repeated elements +warning: these bounds contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:5:15 | LL | fn bad_foo(arg0: T, argo1: U) { @@ -7,50 +7,50 @@ LL | fn bad_foo(arg0: T, argo1 note: the lint level is defined here --> $DIR/trait_duplication_in_bounds.rs:2:9 | -LL | #![deny(clippy::trait_duplication_in_bounds)] +LL | #![warn(clippy::trait_duplication_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: these where clauses contain repeated elements +warning: these where clauses contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:11:8 | LL | T: Clone + Clone + Clone + Copy, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` -error: these bounds contain repeated elements +warning: these bounds contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:39:26 | LL | trait BadSelfTraitBound: Clone + Clone + Clone { | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone` -error: these where clauses contain repeated elements +warning: these where clauses contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:46:15 | LL | Self: Clone + Clone + Clone; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone` -error: these bounds contain repeated elements +warning: these bounds contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:60:24 | LL | trait BadTraitBound { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` -error: these where clauses contain repeated elements +warning: these where clauses contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:67:12 | LL | T: Clone + Clone + Clone + Copy, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` -error: these bounds contain repeated elements +warning: these bounds contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:100:19 | LL | fn bad_generic + GenericTrait + GenericTrait>(arg0: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait + GenericTrait` -error: these bounds contain repeated elements +warning: these bounds contain repeated elements --> $DIR/trait_duplication_in_bounds.rs:108:22 | LL | fn qualified_path(arg0: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::clone::Clone + foo::Clone` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/trait_duplication_in_bounds_unfixable.rs b/tests/ui/trait_duplication_in_bounds_unfixable.rs index 5630a0345adb..993c287431f7 100644 --- a/tests/ui/trait_duplication_in_bounds_unfixable.rs +++ b/tests/ui/trait_duplication_in_bounds_unfixable.rs @@ -1,4 +1,4 @@ -#![deny(clippy::trait_duplication_in_bounds)] +#![warn(clippy::trait_duplication_in_bounds)] use std::collections::BTreeMap; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; diff --git a/tests/ui/trait_duplication_in_bounds_unfixable.stderr b/tests/ui/trait_duplication_in_bounds_unfixable.stderr index 4d56a94646cb..73e7b4576d1b 100644 --- a/tests/ui/trait_duplication_in_bounds_unfixable.stderr +++ b/tests/ui/trait_duplication_in_bounds_unfixable.stderr @@ -1,4 +1,4 @@ -error: this trait bound is already specified in the where clause +warning: this trait bound is already specified in the where clause --> $DIR/trait_duplication_in_bounds_unfixable.rs:6:15 | LL | fn bad_foo(arg0: T, arg1: Z) @@ -8,10 +8,10 @@ LL | fn bad_foo(arg0: T, arg1: Z) note: the lint level is defined here --> $DIR/trait_duplication_in_bounds_unfixable.rs:1:9 | -LL | #![deny(clippy::trait_duplication_in_bounds)] +LL | #![warn(clippy::trait_duplication_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this trait bound is already specified in the where clause +warning: this trait bound is already specified in the where clause --> $DIR/trait_duplication_in_bounds_unfixable.rs:6:23 | LL | fn bad_foo(arg0: T, arg1: Z) @@ -19,7 +19,7 @@ LL | fn bad_foo(arg0: T, arg1: Z) | = help: consider removing this trait bound -error: this trait bound is already specified in trait declaration +warning: this trait bound is already specified in trait declaration --> $DIR/trait_duplication_in_bounds_unfixable.rs:35:15 | LL | Self: Default; @@ -27,7 +27,7 @@ LL | Self: Default; | = help: consider removing this trait bound -error: this trait bound is already specified in trait declaration +warning: this trait bound is already specified in trait declaration --> $DIR/trait_duplication_in_bounds_unfixable.rs:49:15 | LL | Self: Default + Clone; @@ -35,7 +35,7 @@ LL | Self: Default + Clone; | = help: consider removing this trait bound -error: this trait bound is already specified in trait declaration +warning: this trait bound is already specified in trait declaration --> $DIR/trait_duplication_in_bounds_unfixable.rs:55:15 | LL | Self: Default + Clone; @@ -43,7 +43,7 @@ LL | Self: Default + Clone; | = help: consider removing this trait bound -error: this trait bound is already specified in trait declaration +warning: this trait bound is already specified in trait declaration --> $DIR/trait_duplication_in_bounds_unfixable.rs:55:25 | LL | Self: Default + Clone; @@ -51,7 +51,7 @@ LL | Self: Default + Clone; | = help: consider removing this trait bound -error: this trait bound is already specified in trait declaration +warning: this trait bound is already specified in trait declaration --> $DIR/trait_duplication_in_bounds_unfixable.rs:58:15 | LL | Self: Default; @@ -59,7 +59,7 @@ LL | Self: Default; | = help: consider removing this trait bound -error: this trait bound is already specified in trait declaration +warning: this trait bound is already specified in trait declaration --> $DIR/trait_duplication_in_bounds_unfixable.rs:93:15 | LL | Self: Iterator, @@ -67,5 +67,5 @@ LL | Self: Iterator, | = help: consider removing this trait bound -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index 008b4a981d7e..23b2d0455068 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,244 +1,270 @@ -error: transmute from a reference to a pointer +warning: transmute from a reference to a pointer --> $DIR/transmute.rs:24:23 | LL | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` | - = note: `-D clippy::useless-transmute` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute.rs:17:8 + | +LL | #[warn(clippy::useless_transmute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a reference to a pointer +warning: transmute from a reference to a pointer --> $DIR/transmute.rs:26:21 | LL | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` -error: transmute from a reference to a pointer +warning: transmute from a reference to a pointer --> $DIR/transmute.rs:28:23 | LL | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` -error: transmute from a type (`std::vec::Vec`) to itself +warning: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:34:27 | LL | let _: Vec = core::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/transmute.rs:31:8 + | +LL | #[warn(clippy::useless_transmute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`std::vec::Vec`) to itself +warning: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:36:27 | LL | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`std::vec::Vec`) to itself +warning: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:38:27 | LL | let _: Vec = std::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`std::vec::Vec`) to itself +warning: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:40:27 | LL | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`std::vec::Vec`) to itself +warning: transmute from a type (`std::vec::Vec`) to itself --> $DIR/transmute.rs:42:27 | LL | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from an integer to a pointer +warning: transmute from an integer to a pointer --> $DIR/transmute.rs:44:31 | LL | let _: *const usize = std::mem::transmute(5_isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` -error: transmute from an integer to a pointer +warning: transmute from an integer to a pointer --> $DIR/transmute.rs:48:31 | LL | 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`) +warning: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) --> $DIR/transmute.rs:79:24 | LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute.rs:72:8 + | +LL | #[warn(clippy::crosspointer_transmute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) +warning: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) --> $DIR/transmute.rs:81:24 | LL | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) +warning: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) --> $DIR/transmute.rs:83:31 | LL | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) +warning: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) --> $DIR/transmute.rs:85:29 | LL | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `u32` to a `char` +warning: transmute from a `u32` to a `char` --> $DIR/transmute.rs:91:28 | LL | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` | - = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute.rs:89:8 + | +LL | #[warn(clippy::transmute_int_to_char)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `i32` to a `char` +warning: transmute from a `i32` to a `char` --> $DIR/transmute.rs:92:28 | LL | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` -error: transmute from a `u8` to a `bool` +warning: transmute from a `u8` to a `bool` --> $DIR/transmute.rs:101:28 | LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` | - = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute.rs:99:8 + | +LL | #[warn(clippy::transmute_int_to_bool)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `u32` to a `f32` +warning: transmute from a `u32` to a `f32` --> $DIR/transmute.rs:107:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` | - = note: `-D clippy::transmute-int-to-float` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute.rs:104:8 + | +LL | #[warn(clippy::transmute_int_to_float)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `i32` to a `f32` +warning: transmute from a `i32` to a `f32` --> $DIR/transmute.rs:108:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` -error: transmute from a `u64` to a `f64` +warning: transmute from a `u64` to a `f64` --> $DIR/transmute.rs:109:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)` -error: transmute from a `i64` to a `f64` +warning: transmute from a `i64` to a `f64` --> $DIR/transmute.rs:110:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)` -error: transmute from a `u8` to a `[u8; 1]` +warning: transmute from a `u8` to a `[u8; 1]` --> $DIR/transmute.rs:130:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` | - = note: `-D clippy::transmute-num-to-bytes` implied by `-D warnings` + = note: `#[warn(clippy::transmute_num_to_bytes)]` on by default -error: transmute from a `u32` to a `[u8; 4]` +warning: transmute from a `u32` to a `[u8; 4]` --> $DIR/transmute.rs:131:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` -error: transmute from a `u128` to a `[u8; 16]` +warning: transmute from a `u128` to a `[u8; 16]` --> $DIR/transmute.rs:132:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` -error: transmute from a `i8` to a `[u8; 1]` +warning: transmute from a `i8` to a `[u8; 1]` --> $DIR/transmute.rs:133:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` -error: transmute from a `i32` to a `[u8; 4]` +warning: transmute from a `i32` to a `[u8; 4]` --> $DIR/transmute.rs:134:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` -error: transmute from a `i128` to a `[u8; 16]` +warning: transmute from a `i128` to a `[u8; 16]` --> $DIR/transmute.rs:135:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` -error: transmute from a `f32` to a `[u8; 4]` +warning: transmute from a `f32` to a `[u8; 4]` --> $DIR/transmute.rs:136:30 | LL | let _: [u8; 4] = std::mem::transmute(0.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()` -error: transmute from a `f64` to a `[u8; 8]` +warning: transmute from a `f64` to a `[u8; 8]` --> $DIR/transmute.rs:137:30 | LL | let _: [u8; 8] = std::mem::transmute(0.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()` -error: transmute from a `u8` to a `[u8; 1]` +warning: transmute from a `u8` to a `[u8; 1]` --> $DIR/transmute.rs:142:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` -error: transmute from a `u32` to a `[u8; 4]` +warning: transmute from a `u32` to a `[u8; 4]` --> $DIR/transmute.rs:143:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` -error: transmute from a `u128` to a `[u8; 16]` +warning: transmute from a `u128` to a `[u8; 16]` --> $DIR/transmute.rs:144:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` -error: transmute from a `i8` to a `[u8; 1]` +warning: transmute from a `i8` to a `[u8; 1]` --> $DIR/transmute.rs:145:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` -error: transmute from a `i32` to a `[u8; 4]` +warning: transmute from a `i32` to a `[u8; 4]` --> $DIR/transmute.rs:146:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` -error: transmute from a `i128` to a `[u8; 16]` +warning: transmute from a `i128` to a `[u8; 16]` --> $DIR/transmute.rs:147:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` -error: transmute from a `&[u8]` to a `&str` +warning: transmute from a `&[u8]` to a `&str` --> $DIR/transmute.rs:157:28 | LL | let _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()` | - = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings` + = note: `#[warn(clippy::transmute_bytes_to_str)]` on by default -error: transmute from a `&mut [u8]` to a `&mut str` +warning: transmute from a `&mut [u8]` to a `&mut str` --> $DIR/transmute.rs:158:32 | LL | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` -error: transmute from a `&[u8]` to a `&str` +warning: transmute from a `&[u8]` to a `&str` --> $DIR/transmute.rs:159:30 | LL | const _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)` -error: aborting due to 38 previous errors +warning: 38 warnings emitted diff --git a/tests/ui/transmute_32bit.rs b/tests/ui/transmute_32bit.rs index ffe22b12f551..a8bb10dba399 100644 --- a/tests/ui/transmute_32bit.rs +++ b/tests/ui/transmute_32bit.rs @@ -1,14 +1,18 @@ -// ignore-64bit +//@ignore-64bit #[warn(clippy::wrong_transmute)] fn main() { unsafe { let _: *const usize = std::mem::transmute(6.0f32); + //~^ ERROR: transmute between types of different sizes let _: *mut usize = std::mem::transmute(6.0f32); + //~^ ERROR: transmute between types of different sizes let _: *const usize = std::mem::transmute('x'); + //~^ ERROR: transmute between types of different sizes let _: *mut usize = std::mem::transmute('x'); + //~^ ERROR: transmute between types of different sizes } } diff --git a/tests/ui/transmute_32bit.stderr b/tests/ui/transmute_32bit.stderr index 040519564b94..a19cd3f133e0 100644 --- a/tests/ui/transmute_32bit.stderr +++ b/tests/ui/transmute_32bit.stderr @@ -1,28 +1,39 @@ -error: transmute from a `f32` to a pointer +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types --> $DIR/transmute_32bit.rs:6:31 | LL | let _: *const usize = std::mem::transmute(6.0f32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::wrong-transmute` implied by `-D warnings` + = note: source type: `f32` (32 bits) + = note: target type: `*const usize` (64 bits) -error: transmute from a `f32` to a pointer - --> $DIR/transmute_32bit.rs:8:29 +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_32bit.rs:9:29 | LL | let _: *mut usize = std::mem::transmute(6.0f32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `f32` (32 bits) + = note: target type: `*mut usize` (64 bits) -error: transmute from a `char` to a pointer - --> $DIR/transmute_32bit.rs:10:31 +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_32bit.rs:12:31 | LL | let _: *const usize = std::mem::transmute('x'); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `char` (32 bits) + = note: target type: `*const usize` (64 bits) -error: transmute from a `char` to a pointer - --> $DIR/transmute_32bit.rs:12:29 +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_32bit.rs:15:29 | LL | let _: *mut usize = std::mem::transmute('x'); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `char` (32 bits) + = note: target type: `*mut usize` (64 bits) error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index 00dc0b2c3608..ceecf9b279f0 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -1,4 +1,4 @@ -// ignore-32bit +//@ignore-32bit #[warn(clippy::wrong_transmute)] fn main() { diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index d1854c009ef5..d14c5c7c969c 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,16 +1,20 @@ -error: transmute from a `f64` to a pointer +warning: transmute from a `f64` to a pointer --> $DIR/transmute_64bit.rs:6:31 | LL | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::wrong-transmute` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_64bit.rs:3:8 + | +LL | #[warn(clippy::wrong_transmute)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `f64` to a pointer +warning: transmute from a `f64` to a pointer --> $DIR/transmute_64bit.rs:8:29 | LL | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/transmute_collection.stderr b/tests/ui/transmute_collection.stderr index ebc05c402abf..6389f0619a82 100644 --- a/tests/ui/transmute_collection.stderr +++ b/tests/ui/transmute_collection.stderr @@ -1,112 +1,116 @@ -error: transmute from `std::vec::Vec` to `std::vec::Vec` with mismatched layout is unsound +warning: transmute from `std::vec::Vec` to `std::vec::Vec` with mismatched layout is unsound --> $DIR/transmute_collection.rs:9:17 | LL | let _ = transmute::<_, Vec>(vec![0u8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unsound-collection-transmute` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_collection.rs:1:9 + | +LL | #![warn(clippy::unsound_collection_transmute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::vec::Vec` to `std::vec::Vec<[u8; 4]>` with mismatched layout is unsound +warning: transmute from `std::vec::Vec` to `std::vec::Vec<[u8; 4]>` with mismatched layout is unsound --> $DIR/transmute_collection.rs:11:17 | LL | let _ = transmute::<_, Vec<[u8; 4]>>(vec![1234u32]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::VecDeque` to `std::collections::VecDeque` with mismatched layout is unsound +warning: transmute from `std::collections::VecDeque` to `std::collections::VecDeque` with mismatched layout is unsound --> $DIR/transmute_collection.rs:14:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::VecDeque<[u8; 4]>` to `std::collections::VecDeque` with mismatched layout is unsound +warning: transmute from `std::collections::VecDeque<[u8; 4]>` to `std::collections::VecDeque` with mismatched layout is unsound --> $DIR/transmute_collection.rs:16:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BinaryHeap` to `std::collections::BinaryHeap` with mismatched layout is unsound +warning: transmute from `std::collections::BinaryHeap` to `std::collections::BinaryHeap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:19:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BinaryHeap<[u8; 4]>` to `std::collections::BinaryHeap` with mismatched layout is unsound +warning: transmute from `std::collections::BinaryHeap<[u8; 4]>` to `std::collections::BinaryHeap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:21:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BTreeSet` to `std::collections::BTreeSet` with mismatched layout is unsound +warning: transmute from `std::collections::BTreeSet` to `std::collections::BTreeSet` with mismatched layout is unsound --> $DIR/transmute_collection.rs:24:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BTreeSet<[u8; 4]>` to `std::collections::BTreeSet` with mismatched layout is unsound +warning: transmute from `std::collections::BTreeSet<[u8; 4]>` to `std::collections::BTreeSet` with mismatched layout is unsound --> $DIR/transmute_collection.rs:26:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::HashSet` to `std::collections::HashSet` with mismatched layout is unsound +warning: transmute from `std::collections::HashSet` to `std::collections::HashSet` with mismatched layout is unsound --> $DIR/transmute_collection.rs:29:17 | LL | let _ = transmute::<_, HashSet>(HashSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::HashSet<[u8; 4]>` to `std::collections::HashSet` with mismatched layout is unsound +warning: transmute from `std::collections::HashSet<[u8; 4]>` to `std::collections::HashSet` with mismatched layout is unsound --> $DIR/transmute_collection.rs:31:17 | LL | let _ = transmute::<_, HashSet>(HashSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound +warning: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:34:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound +warning: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:35:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound +warning: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:37:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::BTreeMap<[u8; 4], u32>` to `std::collections::BTreeMap` with mismatched layout is unsound +warning: transmute from `std::collections::BTreeMap<[u8; 4], u32>` to `std::collections::BTreeMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:38:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound +warning: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:41:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound +warning: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:42:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound +warning: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:44:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `std::collections::HashMap<[u8; 4], u32>` to `std::collections::HashMap` with mismatched layout is unsound +warning: transmute from `std::collections::HashMap<[u8; 4], u32>` to `std::collections::HashMap` with mismatched layout is unsound --> $DIR/transmute_collection.rs:45:17 | LL | let _ = transmute::<_, HashMap>(HashMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/transmute_float_to_int.stderr b/tests/ui/transmute_float_to_int.stderr index eb786bb39f95..c951527497b6 100644 --- a/tests/ui/transmute_float_to_int.stderr +++ b/tests/ui/transmute_float_to_int.stderr @@ -1,40 +1,44 @@ -error: transmute from a `f32` to a `u32` +warning: transmute from a `f32` to a `u32` --> $DIR/transmute_float_to_int.rs:4:27 | LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits()` | - = note: `-D clippy::transmute-float-to-int` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_float_to_int.rs:1:9 + | +LL | #![warn(clippy::transmute_float_to_int)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `f32` to a `i32` +warning: transmute from a `f32` to a `i32` --> $DIR/transmute_float_to_int.rs:5:27 | LL | let _: i32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits() as i32` -error: transmute from a `f64` to a `u64` +warning: transmute from a `f64` to a `u64` --> $DIR/transmute_float_to_int.rs:6:27 | LL | let _: u64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits()` -error: transmute from a `f64` to a `i64` +warning: transmute from a `f64` to a `i64` --> $DIR/transmute_float_to_int.rs:7:27 | LL | let _: i64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits() as i64` -error: transmute from a `f64` to a `u64` +warning: transmute from a `f64` to a `u64` --> $DIR/transmute_float_to_int.rs:8:27 | LL | let _: u64 = unsafe { std::mem::transmute(1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.0f64.to_bits()` -error: transmute from a `f64` to a `u64` +warning: transmute from a `f64` to a `u64` --> $DIR/transmute_float_to_int.rs:9:27 | LL | let _: u64 = unsafe { std::mem::transmute(-1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-1.0f64).to_bits()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/transmute_int_to_non_zero.stderr b/tests/ui/transmute_int_to_non_zero.stderr index 33f8ce79ea78..98d130a69042 100644 --- a/tests/ui/transmute_int_to_non_zero.stderr +++ b/tests/ui/transmute_int_to_non_zero.stderr @@ -1,64 +1,68 @@ -error: transmute from a `u8` to a `NonZeroU8` +warning: transmute from a `u8` to a `NonZeroU8` --> $DIR/transmute_int_to_non_zero.rs:18:33 | LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU8::new_unchecked(int_u8)` | - = note: `-D clippy::transmute-int-to-non-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_int_to_non_zero.rs:1:9 + | +LL | #![warn(clippy::transmute_int_to_non_zero)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a `u16` to a `NonZeroU16` +warning: transmute from a `u16` to a `NonZeroU16` --> $DIR/transmute_int_to_non_zero.rs:19:34 | LL | let _: NonZeroU16 = unsafe { std::mem::transmute(int_u16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU16::new_unchecked(int_u16)` -error: transmute from a `u32` to a `NonZeroU32` +warning: transmute from a `u32` to a `NonZeroU32` --> $DIR/transmute_int_to_non_zero.rs:20:34 | LL | let _: NonZeroU32 = unsafe { std::mem::transmute(int_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU32::new_unchecked(int_u32)` -error: transmute from a `u64` to a `NonZeroU64` +warning: transmute from a `u64` to a `NonZeroU64` --> $DIR/transmute_int_to_non_zero.rs:21:34 | LL | let _: NonZeroU64 = unsafe { std::mem::transmute(int_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU64::new_unchecked(int_u64)` -error: transmute from a `u128` to a `NonZeroU128` +warning: transmute from a `u128` to a `NonZeroU128` --> $DIR/transmute_int_to_non_zero.rs:22:35 | LL | let _: NonZeroU128 = unsafe { std::mem::transmute(int_u128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU128::new_unchecked(int_u128)` -error: transmute from a `i8` to a `NonZeroI8` +warning: transmute from a `i8` to a `NonZeroI8` --> $DIR/transmute_int_to_non_zero.rs:24:33 | LL | let _: NonZeroI8 = unsafe { std::mem::transmute(int_i8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI8::new_unchecked(int_i8)` -error: transmute from a `i16` to a `NonZeroI16` +warning: transmute from a `i16` to a `NonZeroI16` --> $DIR/transmute_int_to_non_zero.rs:25:34 | LL | let _: NonZeroI16 = unsafe { std::mem::transmute(int_i16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI16::new_unchecked(int_i16)` -error: transmute from a `i32` to a `NonZeroI32` +warning: transmute from a `i32` to a `NonZeroI32` --> $DIR/transmute_int_to_non_zero.rs:26:34 | LL | let _: NonZeroI32 = unsafe { std::mem::transmute(int_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI32::new_unchecked(int_i32)` -error: transmute from a `i64` to a `NonZeroI64` +warning: transmute from a `i64` to a `NonZeroI64` --> $DIR/transmute_int_to_non_zero.rs:27:34 | LL | let _: NonZeroI64 = unsafe { std::mem::transmute(int_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI64::new_unchecked(int_i64)` -error: transmute from a `i128` to a `NonZeroI128` +warning: transmute from a `i128` to a `NonZeroI128` --> $DIR/transmute_int_to_non_zero.rs:28:35 | LL | let _: NonZeroI128 = unsafe { std::mem::transmute(int_i128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI128::new_unchecked(int_i128)` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/transmute_null_to_fn.stderr b/tests/ui/transmute_null_to_fn.stderr index f0c65497d750..daf1fb0d4283 100644 --- a/tests/ui/transmute_null_to_fn.stderr +++ b/tests/ui/transmute_null_to_fn.stderr @@ -1,13 +1,17 @@ -error: transmuting a known null pointer into a function pointer +warning: transmuting a known null pointer into a function pointer --> $DIR/transmute_null_to_fn.rs:8:23 | LL | let _: fn() = std::mem::transmute(0 as *const ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior | = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value - = note: `-D clippy::transmute-null-to-fn` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_null_to_fn.rs:2:9 + | +LL | #![warn(clippy::transmute_null_to_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmuting a known null pointer into a function pointer +warning: transmuting a known null pointer into a function pointer --> $DIR/transmute_null_to_fn.rs:9:23 | LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); @@ -15,7 +19,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); | = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value -error: transmuting a known null pointer into a function pointer +warning: transmuting a known null pointer into a function pointer --> $DIR/transmute_null_to_fn.rs:19:23 | LL | let _: fn() = std::mem::transmute(ZPTR); @@ -23,5 +27,5 @@ LL | let _: fn() = std::mem::transmute(ZPTR); | = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr index 49a8a3347e40..0189afab15ac 100644 --- a/tests/ui/transmute_ptr_to_ptr.stderr +++ b/tests/ui/transmute_ptr_to_ptr.stderr @@ -1,40 +1,44 @@ -error: transmute from a pointer to a pointer +warning: transmute from a pointer to a pointer --> $DIR/transmute_ptr_to_ptr.rs:30:29 | LL | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` | - = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_ptr_to_ptr.rs:1:9 + | +LL | #![warn(clippy::transmute_ptr_to_ptr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a pointer to a pointer +warning: transmute from a pointer to a pointer --> $DIR/transmute_ptr_to_ptr.rs:31:27 | LL | let _: *mut f32 = std::mem::transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` -error: transmute from a reference to a reference +warning: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:33:23 | LL | let _: &f32 = std::mem::transmute(&1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` -error: transmute from a reference to a reference +warning: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:34:23 | LL | let _: &f64 = std::mem::transmute(&1f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` -error: transmute from a reference to a reference +warning: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:37:27 | LL | let _: &mut f32 = std::mem::transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` -error: transmute from a reference to a reference +warning: transmute from a reference to a reference --> $DIR/transmute_ptr_to_ptr.rs:38:37 | LL | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/transmute_ptr_to_ref.fixed b/tests/ui/transmute_ptr_to_ref.fixed index 074dae5fb286..575dadde9063 100644 --- a/tests/ui/transmute_ptr_to_ref.fixed +++ b/tests/ui/transmute_ptr_to_ref.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::transmute_ptr_to_ref)] #![allow(clippy::match_single_binding)] diff --git a/tests/ui/transmute_ptr_to_ref.rs b/tests/ui/transmute_ptr_to_ref.rs index 2edc122cf471..4238ff804780 100644 --- a/tests/ui/transmute_ptr_to_ref.rs +++ b/tests/ui/transmute_ptr_to_ref.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::transmute_ptr_to_ref)] #![allow(clippy::match_single_binding)] diff --git a/tests/ui/transmute_ptr_to_ref.stderr b/tests/ui/transmute_ptr_to_ref.stderr index b3e6c09d2d7a..7faa9bbcb536 100644 --- a/tests/ui/transmute_ptr_to_ref.stderr +++ b/tests/ui/transmute_ptr_to_ref.stderr @@ -1,136 +1,140 @@ -error: transmute from a pointer type (`*const T`) to a reference type (`&T`) +warning: transmute from a pointer type (`*const T`) to a reference type (`&T`) --> $DIR/transmute_ptr_to_ref.rs:7:17 | LL | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` | - = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_ptr_to_ref.rs:3:9 + | +LL | #![warn(clippy::transmute_ptr_to_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) +warning: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute_ptr_to_ref.rs:10:21 | LL | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m` -error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) +warning: transmute from a pointer type (`*mut T`) to a reference type (`&T`) --> $DIR/transmute_ptr_to_ref.rs:13:17 | LL | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m` -error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) +warning: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) --> $DIR/transmute_ptr_to_ref.rs:16:21 | LL | 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`) +warning: transmute from a pointer type (`*const U`) to a reference type (`&T`) --> $DIR/transmute_ptr_to_ref.rs:19:17 | LL | 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`) +warning: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) --> $DIR/transmute_ptr_to_ref.rs:22:21 | LL | 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`) +warning: transmute from a pointer type (`*mut U`) to a reference type (`&T`) --> $DIR/transmute_ptr_to_ref.rs:25:17 | LL | 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>`) +warning: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, u8>`) --> $DIR/transmute_ptr_to_ref.rs:35:32 | LL | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::>()` -error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, &u8>`) +warning: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, &u8>`) --> $DIR/transmute_ptr_to_ref.rs:37:33 | LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::>()` -error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) +warning: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) --> $DIR/transmute_ptr_to_ref.rs:41:14 | LL | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:46:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:47:14 | LL | 1 => std::mem::transmute(y), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&u32>()` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:48:14 | LL | 2 => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:49:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(y), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&'b u32>()` -error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) +warning: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) --> $DIR/transmute_ptr_to_ref.rs:57:19 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` -error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) +warning: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) --> $DIR/transmute_ptr_to_ref.rs:58:19 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a.cast::()` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:60:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:61:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` -error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) +warning: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) --> $DIR/transmute_ptr_to_ref.rs:69:19 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` -error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) +warning: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) --> $DIR/transmute_ptr_to_ref.rs:70:19 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const u32)` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:72:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &u32)` -error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) +warning: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) --> $DIR/transmute_ptr_to_ref.rs:73:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &'b u32)` -error: aborting due to 22 previous errors +warning: 22 warnings emitted diff --git a/tests/ui/transmute_undefined_repr.stderr b/tests/ui/transmute_undefined_repr.stderr index e50a773290e1..b8d7ca02bd14 100644 --- a/tests/ui/transmute_undefined_repr.stderr +++ b/tests/ui/transmute_undefined_repr.stderr @@ -1,18 +1,22 @@ -error: transmute from `Ty2` which has an undefined layout +warning: transmute from `Ty2` which has an undefined layout --> $DIR/transmute_undefined_repr.rs:28:33 | LL | let _: Ty2C = transmute(value::>()); // Lint, Ty2 is unordered | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::transmute-undefined-repr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmute_undefined_repr.rs:1:9 + | +LL | #![warn(clippy::transmute_undefined_repr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute into `Ty2` which has an undefined layout +warning: transmute into `Ty2` which has an undefined layout --> $DIR/transmute_undefined_repr.rs:29:32 | LL | let _: Ty2 = transmute(value::>()); // Lint, Ty2 is unordered | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from `Ty>` to `Ty2`, both of which have an undefined layout +warning: transmute from `Ty>` to `Ty2`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:34:32 | LL | let _: Ty2 = transmute(value::>>()); // Lint, different Ty2 instances @@ -20,7 +24,7 @@ LL | let _: Ty2 = transmute(value::>>()); // | = note: two instances of the same generic type (`Ty2`) may have different layouts -error: transmute from `Ty2` to `Ty>`, both of which have an undefined layout +warning: transmute from `Ty2` to `Ty>`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:35:36 | LL | let _: Ty> = transmute(value::>()); // Lint, different Ty2 instances @@ -28,7 +32,7 @@ LL | let _: Ty> = transmute(value::>()); // | = note: two instances of the same generic type (`Ty2`) may have different layouts -error: transmute from `Ty<&Ty2>` to `&Ty2`, both of which have an undefined layout +warning: transmute from `Ty<&Ty2>` to `&Ty2`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:40:33 | LL | let _: &Ty2 = transmute(value::>>()); // Lint, different Ty2 instances @@ -36,7 +40,7 @@ LL | let _: &Ty2 = transmute(value::>>()); / | = note: two instances of the same generic type (`Ty2`) may have different layouts -error: transmute from `&Ty2` to `Ty<&Ty2>`, both of which have an undefined layout +warning: transmute from `&Ty2` to `Ty<&Ty2>`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:41:37 | LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); // Lint, different Ty2 instances @@ -44,7 +48,7 @@ LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); / | = note: two instances of the same generic type (`Ty2`) may have different layouts -error: transmute from `std::boxed::Box>` to `&mut Ty2`, both of which have an undefined layout +warning: transmute from `std::boxed::Box>` to `&mut Ty2`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:58:45 | LL | let _: &'static mut Ty2 = transmute(value::>>()); // Lint, different Ty2 instances @@ -52,7 +56,7 @@ LL | let _: &'static mut Ty2 = transmute(value::` to `std::boxed::Box>`, both of which have an undefined layout +warning: transmute from `&mut Ty2` to `std::boxed::Box>`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:59:37 | LL | let _: Box> = transmute(value::<&'static mut Ty2>()); // Lint, different Ty2 instances @@ -60,7 +64,7 @@ LL | let _: Box> = transmute(value::<&'static mut Ty2` which has an undefined layout +warning: transmute into `*const Ty2` which has an undefined layout --> $DIR/transmute_undefined_repr.rs:119:39 | LL | let _: *const Ty2 = transmute(value::<*const Ty2C>>()); // Err @@ -68,7 +72,7 @@ LL | let _: *const Ty2 = transmute(value::<*const Ty2C` has an undefined layout -error: transmute from `*const Ty2` which has an undefined layout +warning: transmute from `*const Ty2` which has an undefined layout --> $DIR/transmute_undefined_repr.rs:120:50 | LL | let _: *const Ty2C> = transmute(value::<*const Ty2>()); // Err @@ -76,7 +80,7 @@ LL | let _: *const Ty2C> = transmute(value::<*const T | = note: the contained type `Ty2` has an undefined layout -error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout +warning: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:150:35 | LL | let _: Vec> = transmute(value::>>()); // Err @@ -84,7 +88,7 @@ LL | let _: Vec> = transmute(value::>>()); / | = note: two instances of the same generic type (`Vec`) may have different layouts -error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout +warning: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout --> $DIR/transmute_undefined_repr.rs:151:35 | LL | let _: Vec> = transmute(value::>>()); // Err @@ -92,5 +96,5 @@ LL | let _: Vec> = transmute(value::>>()); / | = note: two instances of the same generic type (`Vec`) may have different layouts -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/transmutes_expressible_as_ptr_casts.fixed b/tests/ui/transmutes_expressible_as_ptr_casts.fixed index 55307506eb3c..36a884f9d2be 100644 --- a/tests/ui/transmutes_expressible_as_ptr_casts.fixed +++ b/tests/ui/transmutes_expressible_as_ptr_casts.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::transmutes_expressible_as_ptr_casts)] // These two warnings currently cover the cases transmutes_expressible_as_ptr_casts // would otherwise be responsible for @@ -15,17 +15,17 @@ fn main() { // the casts, since the casts are the recommended fixes. // e is an integer and U is *U_0, while U_0: Sized; addr-ptr-cast - let _ptr_i32_transmute = unsafe { usize::MAX as *const i32 }; + let _ptr_i32_transmute = unsafe { transmute::(usize::MAX) }; let ptr_i32 = usize::MAX as *const i32; // e has type *T, U is *U_0, and either U_0: Sized ... - let _ptr_i8_transmute = unsafe { ptr_i32 as *const i8 }; + let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr_i32) }; let _ptr_i8 = ptr_i32 as *const i8; let slice_ptr = &[0, 1, 2, 3] as *const [i32]; // ... or pointer_kind(T) = pointer_kind(U_0); ptr-ptr-cast - let _ptr_to_unsized_transmute = unsafe { slice_ptr as *const [u32] }; + let _ptr_to_unsized_transmute = unsafe { transmute::<*const [i32], *const [u32]>(slice_ptr) }; let _ptr_to_unsized = slice_ptr as *const [u32]; // TODO: We could try testing vtable casts here too, but maybe // we should wait until std::raw::TraitObject is stabilized? @@ -37,7 +37,7 @@ fn main() { let array_ref: &[i32; 4] = &[1, 2, 3, 4]; // e has type &[T; n] and U is *const T; array-ptr-cast - let _array_ptr_transmute = unsafe { array_ref as *const [i32; 4] }; + let _array_ptr_transmute = unsafe { transmute::<&[i32; 4], *const [i32; 4]>(array_ref) }; let _array_ptr = array_ref as *const [i32; 4]; fn foo(_: usize) -> u8 { @@ -63,7 +63,7 @@ fn main() { // fail if the ordering of the checks ever changes enough to cause these cases to // fall through into `do_check`. fn trigger_do_check_to_emit_error(in_param: &[i32; 1]) -> *const u8 { - unsafe { in_param as *const [i32; 1] as *const u8 } + unsafe { transmute::<&[i32; 1], *const u8>(in_param) } } #[repr(C)] diff --git a/tests/ui/transmutes_expressible_as_ptr_casts.rs b/tests/ui/transmutes_expressible_as_ptr_casts.rs index e7360f3f9dcb..d7e1d6cb871e 100644 --- a/tests/ui/transmutes_expressible_as_ptr_casts.rs +++ b/tests/ui/transmutes_expressible_as_ptr_casts.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::transmutes_expressible_as_ptr_casts)] // These two warnings currently cover the cases transmutes_expressible_as_ptr_casts // would otherwise be responsible for diff --git a/tests/ui/transmutes_expressible_as_ptr_casts.stderr b/tests/ui/transmutes_expressible_as_ptr_casts.stderr index e862fcb67a4a..e16cc023428f 100644 --- a/tests/ui/transmutes_expressible_as_ptr_casts.stderr +++ b/tests/ui/transmutes_expressible_as_ptr_casts.stderr @@ -1,62 +1,74 @@ -error: transmute from an integer to a pointer +warning: transmute from an integer to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:18:39 | LL | let _ptr_i32_transmute = unsafe { transmute::(usize::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32` | - = note: `-D clippy::useless-transmute` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmutes_expressible_as_ptr_casts.rs:5:9 + | +LL | #![warn(clippy::useless_transmute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a pointer to a pointer +warning: transmute from a pointer to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:22:38 | LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as *const i8` | - = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmutes_expressible_as_ptr_casts.rs:6:9 + | +LL | #![warn(clippy::transmute_ptr_to_ptr)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a pointer to a pointer +warning: transmute from a pointer to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:28:46 | LL | let _ptr_to_unsized_transmute = unsafe { transmute::<*const [i32], *const [u32]>(slice_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice_ptr as *const [u32]` -error: transmute from `*const i32` to `usize` which could be expressed as a pointer cast instead +warning: transmute from `*const i32` to `usize` which could be expressed as a pointer cast instead --> $DIR/transmutes_expressible_as_ptr_casts.rs:34:50 | LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, usize>(ptr_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as usize` | - = note: `-D clippy::transmutes-expressible-as-ptr-casts` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmutes_expressible_as_ptr_casts.rs:2:9 + | +LL | #![warn(clippy::transmutes_expressible_as_ptr_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmute from a reference to a pointer +warning: transmute from a reference to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:40:41 | LL | let _array_ptr_transmute = unsafe { transmute::<&[i32; 4], *const [i32; 4]>(array_ref) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array_ref as *const [i32; 4]` -error: transmute from `fn(usize) -> u8` to `*const usize` which could be expressed as a pointer cast instead +warning: transmute from `fn(usize) -> u8` to `*const usize` which could be expressed as a pointer cast instead --> $DIR/transmutes_expressible_as_ptr_casts.rs:48:41 | LL | let _usize_ptr_transmute = unsafe { transmute:: u8, *const usize>(foo) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as *const usize` -error: transmute from `fn(usize) -> u8` to `usize` which could be expressed as a pointer cast instead +warning: transmute from `fn(usize) -> u8` to `usize` which could be expressed as a pointer cast instead --> $DIR/transmutes_expressible_as_ptr_casts.rs:52:49 | LL | let _usize_from_fn_ptr_transmute = unsafe { transmute:: u8, usize>(foo) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as usize` -error: transmute from `*const u32` to `usize` which could be expressed as a pointer cast instead +warning: transmute from `*const u32` to `usize` which could be expressed as a pointer cast instead --> $DIR/transmutes_expressible_as_ptr_casts.rs:55:36 | LL | let _usize_from_ref = unsafe { transmute::<*const u32, usize>(&1u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&1u32 as *const u32 as usize` -error: transmute from a reference to a pointer +warning: transmute from a reference to a pointer --> $DIR/transmutes_expressible_as_ptr_casts.rs:66:14 | LL | unsafe { transmute::<&[i32; 1], *const u8>(in_param) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `in_param as *const [i32; 1] as *const u8` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/transmuting_null.stderr b/tests/ui/transmuting_null.stderr index 1848fc2490a0..699b810cb5a6 100644 --- a/tests/ui/transmuting_null.stderr +++ b/tests/ui/transmuting_null.stderr @@ -1,22 +1,26 @@ -error: transmuting a known null pointer into a reference +warning: transmuting a known null pointer into a reference --> $DIR/transmuting_null.rs:10:23 | LL | let _: &u64 = std::mem::transmute(0 as *const u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::transmuting-null` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/transmuting_null.rs:2:9 + | +LL | #![warn(clippy::transmuting_null)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmuting a known null pointer into a reference +warning: transmuting a known null pointer into a reference --> $DIR/transmuting_null.rs:11:23 | LL | let _: &u64 = std::mem::transmute(std::ptr::null::()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: transmuting a known null pointer into a reference +warning: transmuting a known null pointer into a reference --> $DIR/transmuting_null.rs:21:23 | LL | let _: &u64 = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/trim_split_whitespace.fixed b/tests/ui/trim_split_whitespace.fixed index e4d352f7367e..7909b319ddd5 100644 --- a/tests/ui/trim_split_whitespace.fixed +++ b/tests/ui/trim_split_whitespace.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::trim_split_whitespace)] #![allow(clippy::let_unit_value)] diff --git a/tests/ui/trim_split_whitespace.rs b/tests/ui/trim_split_whitespace.rs index f98451a98371..0cf58979fb20 100644 --- a/tests/ui/trim_split_whitespace.rs +++ b/tests/ui/trim_split_whitespace.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::trim_split_whitespace)] #![allow(clippy::let_unit_value)] diff --git a/tests/ui/trim_split_whitespace.stderr b/tests/ui/trim_split_whitespace.stderr index 5ae7849e27d2..e1f652af5fd0 100644 --- a/tests/ui/trim_split_whitespace.stderr +++ b/tests/ui/trim_split_whitespace.stderr @@ -1,52 +1,56 @@ -error: found call to `str::trim` before `str::split_whitespace` +warning: found call to `str::trim` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:62:23 | LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` | - = note: `-D clippy::trim-split-whitespace` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/trim_split_whitespace.rs:2:9 + | +LL | #![warn(clippy::trim_split_whitespace)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: found call to `str::trim_start` before `str::split_whitespace` +warning: found call to `str::trim_start` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:63:23 | LL | let _ = " A B C ".trim_start().split_whitespace(); // should trigger lint | ^^^^^^^^^^^^^ help: remove `trim_start()` -error: found call to `str::trim_end` before `str::split_whitespace` +warning: found call to `str::trim_end` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:64:23 | LL | let _ = " A B C ".trim_end().split_whitespace(); // should trigger lint | ^^^^^^^^^^^ help: remove `trim_end()` -error: found call to `str::trim` before `str::split_whitespace` +warning: found call to `str::trim` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:67:37 | LL | let _ = (" A B C ").to_string().trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` -error: found call to `str::trim_start` before `str::split_whitespace` +warning: found call to `str::trim_start` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:68:37 | LL | let _ = (" A B C ").to_string().trim_start().split_whitespace(); // should trigger lint | ^^^^^^^^^^^^^ help: remove `trim_start()` -error: found call to `str::trim_end` before `str::split_whitespace` +warning: found call to `str::trim_end` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:69:37 | LL | let _ = (" A B C ").to_string().trim_end().split_whitespace(); // should trigger lint | ^^^^^^^^^^^ help: remove `trim_end()` -error: found call to `str::trim` before `str::split_whitespace` +warning: found call to `str::trim` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:76:15 | LL | let _ = s.trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` -error: found call to `str::trim` before `str::split_whitespace` +warning: found call to `str::trim` before `str::split_whitespace` --> $DIR/trim_split_whitespace.rs:84:15 | LL | let _ = s.trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/trivially_copy_pass_by_ref.rs b/tests/ui/trivially_copy_pass_by_ref.rs index c0af011d33d0..66c9641d6a6c 100644 --- a/tests/ui/trivially_copy_pass_by_ref.rs +++ b/tests/ui/trivially_copy_pass_by_ref.rs @@ -1,6 +1,6 @@ -// normalize-stderr-test "\(\d+ byte\)" -> "(N byte)" -// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)" -#![deny(clippy::trivially_copy_pass_by_ref)] +//@normalize-stderr-test: "\(\d+ byte\)" -> "(N byte)" +//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)" +#![warn(clippy::trivially_copy_pass_by_ref)] #![allow( clippy::disallowed_names, clippy::needless_lifetimes, diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 8c5cfa8a0f17..bf8e4bd14690 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,4 +1,4 @@ -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:51:11 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} @@ -7,110 +7,110 @@ LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} note: the lint level is defined here --> $DIR/trivially_copy_pass_by_ref.rs:3:9 | -LL | #![deny(clippy::trivially_copy_pass_by_ref)] +LL | #![warn(clippy::trivially_copy_pass_by_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:51:20 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:51:29 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:58:12 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:58:22 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:58:31 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:58:40 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:60:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:60:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:60:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:62:35 | LL | fn bad_issue7518(self, other: &Self) {} | ^^^^^ help: consider passing by value instead: `Self` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:74:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:74:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:74:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:78:34 | LL | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:110:21 | LL | fn foo_never(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:115:15 | LL | fn foo(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` -error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) +warning: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte) --> $DIR/trivially_copy_pass_by_ref.rs:142:37 | LL | fn _unrelated_lifetimes<'a, 'b>(_x: &'a u32, y: &'b u32) -> &'b u32 { | ^^^^^^^ help: consider passing by value instead: `u32` -error: aborting due to 18 previous errors +warning: 18 warnings emitted diff --git a/tests/ui/try_err.fixed b/tests/ui/try_err.fixed index 264194419c73..fcb4d0b35f4c 100644 --- a/tests/ui/try_err.fixed +++ b/tests/ui/try_err.fixed @@ -1,7 +1,7 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs -#![deny(clippy::try_err)] +#![warn(clippy::try_err)] #![allow(clippy::unnecessary_wraps, clippy::needless_question_mark)] #[macro_use] @@ -84,7 +84,7 @@ macro_rules! try_validation { ($e: expr) => {{ match $e { Ok(_) => 0, - Err(_) => return Err(1), + Err(_) => Err(1)?, } }}; } @@ -99,7 +99,7 @@ macro_rules! try_validation_in_macro { ($e: expr) => {{ match $e { Ok(_) => 0, - Err(_) => return Err(ret_one!()), + Err(_) => Err(ret_one!())?, } }}; } diff --git a/tests/ui/try_err.rs b/tests/ui/try_err.rs index bc6979bf4571..2407c00b5475 100644 --- a/tests/ui/try_err.rs +++ b/tests/ui/try_err.rs @@ -1,7 +1,7 @@ -// run-rustfix -// aux-build:macro_rules.rs +//@run-rustfix +//@aux-build:macro_rules.rs -#![deny(clippy::try_err)] +#![warn(clippy::try_err)] #![allow(clippy::unnecessary_wraps, clippy::needless_question_mark)] #[macro_use] diff --git a/tests/ui/try_err.stderr b/tests/ui/try_err.stderr index 0cb1328fbfcf..dfb73e9dd0de 100644 --- a/tests/ui/try_err.stderr +++ b/tests/ui/try_err.stderr @@ -1,4 +1,4 @@ -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:19:9 | LL | Err(err)?; @@ -7,28 +7,28 @@ LL | Err(err)?; note: the lint level is defined here --> $DIR/try_err.rs:4:9 | -LL | #![deny(clippy::try_err)] +LL | #![warn(clippy::try_err)] | ^^^^^^^^^^^^^^^ -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:29:9 | LL | Err(err)?; | ^^^^^^^^^ help: try this: `return Err(err.into())` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:49:17 | LL | Err(err)?; | ^^^^^^^^^ help: try this: `return Err(err)` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:68:17 | LL | Err(err)?; | ^^^^^^^^^ help: try this: `return Err(err.into())` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:87:23 | LL | Err(_) => Err(1)?, @@ -37,9 +37,9 @@ LL | Err(_) => Err(1)?, LL | try_validation!(Ok::<_, i32>(5)); | -------------------------------- in this macro invocation | - = note: this error originates in the macro `try_validation` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `try_validation` (in Nightly builds, run with -Z macro-backtrace for more info) -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:102:23 | LL | Err(_) => Err(ret_one!())?, @@ -48,37 +48,37 @@ LL | Err(_) => Err(ret_one!())?, LL | try_validation_in_macro!(Ok::<_, i32>(5)); | ----------------------------------------- in this macro invocation | - = note: this error originates in the macro `try_validation_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `try_validation_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:141:9 | LL | Err(foo!())?; | ^^^^^^^^^^^^ help: try this: `return Err(foo!())` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:148:9 | LL | Err(io::ErrorKind::WriteZero)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Poll::Ready(Err(io::ErrorKind::WriteZero.into()))` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:150:9 | LL | Err(io::Error::new(io::ErrorKind::InvalidInput, "error"))? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Poll::Ready(Err(io::Error::new(io::ErrorKind::InvalidInput, "error")))` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:158:9 | LL | Err(io::ErrorKind::NotFound)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `return Poll::Ready(Some(Err(io::ErrorKind::NotFound.into())))` -error: returning an `Err(_)` with the `?` operator +warning: returning an `Err(_)` with the `?` operator --> $DIR/try_err.rs:167:16 | LL | return Err(42)?; | ^^^^^^^^ help: try this: `Err(42)` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/type_complexity.stderr b/tests/ui/type_complexity.stderr index 9da7edb1c3b7..40a803c5effb 100644 --- a/tests/ui/type_complexity.stderr +++ b/tests/ui/type_complexity.stderr @@ -1,94 +1,99 @@ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:7:12 | LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::type-complexity` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/type_complexity.rs:1:9 + | +LL | #![warn(clippy::all)] + | ^^^^^^^^^^^ + = note: `#[warn(clippy::type_complexity)]` implied by `#[warn(clippy::all)]` -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:8:12 | LL | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:11:8 | LL | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:14:11 | LL | struct Ts(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:17:11 | LL | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:18:17 | LL | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:22:14 | LL | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:23:30 | LL | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:27:14 | LL | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:28:14 | LL | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:29:25 | LL | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:30:29 | LL | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:42:15 | LL | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:46:14 | LL | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: very complex type used. Consider factoring parts into `type` definitions +warning: very complex type used. Consider factoring parts into `type` definitions --> $DIR/type_complexity.rs:49:13 | LL | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 15 previous errors +warning: 15 warnings emitted diff --git a/tests/ui/type_repetition_in_bounds.rs b/tests/ui/type_repetition_in_bounds.rs index 8b4613b3f6ec..e8f0196510ec 100644 --- a/tests/ui/type_repetition_in_bounds.rs +++ b/tests/ui/type_repetition_in_bounds.rs @@ -1,4 +1,4 @@ -#![deny(clippy::type_repetition_in_bounds)] +#![warn(clippy::type_repetition_in_bounds)] #![allow(clippy::extra_unused_type_parameters)] use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; diff --git a/tests/ui/type_repetition_in_bounds.stderr b/tests/ui/type_repetition_in_bounds.stderr index a90df03c04ff..82a1404cecd9 100644 --- a/tests/ui/type_repetition_in_bounds.stderr +++ b/tests/ui/type_repetition_in_bounds.stderr @@ -1,4 +1,4 @@ -error: this type has already been used as a bound predicate +warning: this type has already been used as a bound predicate --> $DIR/type_repetition_in_bounds.rs:9:5 | LL | T: Clone, @@ -8,10 +8,10 @@ LL | T: Clone, note: the lint level is defined here --> $DIR/type_repetition_in_bounds.rs:1:9 | -LL | #![deny(clippy::type_repetition_in_bounds)] +LL | #![warn(clippy::type_repetition_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this type has already been used as a bound predicate +warning: this type has already been used as a bound predicate --> $DIR/type_repetition_in_bounds.rs:26:5 | LL | Self: Copy + Default + Ord, @@ -19,7 +19,7 @@ LL | Self: Copy + Default + Ord, | = help: consider combining the bounds: `Self: Clone + Copy + Default + Ord` -error: this type has already been used as a bound predicate +warning: this type has already been used as a bound predicate --> $DIR/type_repetition_in_bounds.rs:86:5 | LL | T: Clone, @@ -27,7 +27,7 @@ LL | T: Clone, | = help: consider combining the bounds: `T: ?Sized + Clone` -error: this type has already been used as a bound predicate +warning: this type has already been used as a bound predicate --> $DIR/type_repetition_in_bounds.rs:91:5 | LL | T: ?Sized, @@ -35,5 +35,5 @@ LL | T: ?Sized, | = help: consider combining the bounds: `T: Clone + ?Sized` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/types.fixed b/tests/ui/types.fixed index 417da42edf17..4a2616a7a228 100644 --- a/tests/ui/types.fixed +++ b/tests/ui/types.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_variables)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/types.rs b/tests/ui/types.rs index b16e9e538b10..5e0917907db7 100644 --- a/tests/ui/types.rs +++ b/tests/ui/types.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code, unused_variables)] #![warn(clippy::cast_lossless)] diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index 59c3e05a1aa3..027ac6fdd544 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,10 +1,14 @@ -error: casting `i32` to `i64` may become silently lossy if you later change the type +warning: casting `i32` to `i64` may become silently lossy if you later change the type --> $DIR/types.rs:14:22 | LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` | - = note: `-D clippy::cast-lossless` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/types.rs:4:9 + | +LL | #![warn(clippy::cast_lossless)] + | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/unchecked_duration_subtraction.fixed b/tests/ui/unchecked_duration_subtraction.fixed index a0e49a8beb1e..757d15921847 100644 --- a/tests/ui/unchecked_duration_subtraction.fixed +++ b/tests/ui/unchecked_duration_subtraction.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unchecked_duration_subtraction)] use std::time::{Duration, Instant}; diff --git a/tests/ui/unchecked_duration_subtraction.rs b/tests/ui/unchecked_duration_subtraction.rs index a14a7ea57cc5..da7faab6753e 100644 --- a/tests/ui/unchecked_duration_subtraction.rs +++ b/tests/ui/unchecked_duration_subtraction.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unchecked_duration_subtraction)] use std::time::{Duration, Instant}; diff --git a/tests/ui/unchecked_duration_subtraction.stderr b/tests/ui/unchecked_duration_subtraction.stderr index a2e0aa1d7c08..42aa606e6b58 100644 --- a/tests/ui/unchecked_duration_subtraction.stderr +++ b/tests/ui/unchecked_duration_subtraction.stderr @@ -1,28 +1,32 @@ -error: unchecked subtraction of a 'Duration' from an 'Instant' +warning: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:10:13 | LL | let _ = _first - second; | ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap()` | - = note: `-D clippy::unchecked-duration-subtraction` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unchecked_duration_subtraction.rs:2:9 + | +LL | #![warn(clippy::unchecked_duration_subtraction)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unchecked subtraction of a 'Duration' from an 'Instant' +warning: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:12:13 | LL | let _ = Instant::now() - Duration::from_secs(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap()` -error: unchecked subtraction of a 'Duration' from an 'Instant' +warning: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:14:13 | LL | let _ = _first - Duration::from_secs(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap()` -error: unchecked subtraction of a 'Duration' from an 'Instant' +warning: unchecked subtraction of a 'Duration' from an 'Instant' --> $DIR/unchecked_duration_subtraction.rs:16:13 | LL | let _ = Instant::now() - second; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap()` -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/undocumented_unsafe_blocks.rs b/tests/ui/undocumented_unsafe_blocks.rs index c05eb447b2eb..88b1ce6a4444 100644 --- a/tests/ui/undocumented_unsafe_blocks.rs +++ b/tests/ui/undocumented_unsafe_blocks.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_unsafe.rs +//@aux-build:proc_macro_unsafe.rs:proc-macro #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] #![allow(clippy::let_unit_value, clippy::missing_safety_doc)] diff --git a/tests/ui/undocumented_unsafe_blocks.stderr b/tests/ui/undocumented_unsafe_blocks.stderr index d1c1bb5ffeac..f3cee85d842e 100644 --- a/tests/ui/undocumented_unsafe_blocks.stderr +++ b/tests/ui/undocumented_unsafe_blocks.stderr @@ -1,13 +1,17 @@ -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:262:19 | LL | /* Safety: */ unsafe {} | ^^^^^^^^^ | = help: consider adding a safety comment on the preceding line - = note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/undocumented_unsafe_blocks.rs:3:9 + | +LL | #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:266:5 | LL | unsafe {} @@ -15,7 +19,7 @@ LL | unsafe {} | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:270:14 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; @@ -23,7 +27,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:270:29 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; @@ -31,7 +35,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:270:48 | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; @@ -39,7 +43,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:274:18 | LL | let _ = (42, unsafe {}, "test", unsafe {}); @@ -47,7 +51,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:274:37 | LL | let _ = (42, unsafe {}, "test", unsafe {}); @@ -55,7 +59,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:278:14 | LL | let _ = *unsafe { &42 }; @@ -63,7 +67,7 @@ LL | let _ = *unsafe { &42 }; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:283:19 | LL | let _ = match unsafe {} { @@ -71,7 +75,7 @@ LL | let _ = match unsafe {} { | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:289:14 | LL | let _ = &unsafe {}; @@ -79,7 +83,7 @@ LL | let _ = &unsafe {}; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:293:14 | LL | let _ = [unsafe {}; 5]; @@ -87,7 +91,7 @@ LL | let _ = [unsafe {}; 5]; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:297:13 | LL | let _ = unsafe {}; @@ -95,7 +99,7 @@ LL | let _ = unsafe {}; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:307:8 | LL | t!(unsafe {}); @@ -103,7 +107,7 @@ LL | t!(unsafe {}); | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:313:13 | LL | unsafe {} @@ -113,9 +117,9 @@ LL | t!(); | ---- in this macro invocation | = help: consider adding a safety comment on the preceding line - = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:321:5 | LL | unsafe {} // SAFETY: @@ -123,7 +127,7 @@ LL | unsafe {} // SAFETY: | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:325:5 | LL | unsafe { @@ -131,7 +135,7 @@ LL | unsafe { | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:335:5 | LL | unsafe {}; @@ -139,7 +143,7 @@ LL | unsafe {}; | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:339:20 | LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); @@ -147,7 +151,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:346:5 | LL | unsafe impl A for () {} @@ -155,7 +159,7 @@ LL | unsafe impl A for () {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:353:9 | LL | unsafe impl B for (u32) {} @@ -163,7 +167,7 @@ LL | unsafe impl B for (u32) {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:374:13 | LL | unsafe impl T for $t {} @@ -173,9 +177,9 @@ LL | no_safety_comment!(()); | ---------------------- in this macro invocation | = help: consider adding a safety comment on the preceding line - = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:399:13 | LL | unsafe impl T for $t {} @@ -185,9 +189,9 @@ LL | no_safety_comment!(()); | ---------------------- in this macro invocation | = help: consider adding a safety comment on the preceding line - = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:407:5 | LL | unsafe impl T for (i32) {} @@ -195,7 +199,7 @@ LL | unsafe impl T for (i32) {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:399:13 | LL | unsafe impl T for $t {} @@ -205,9 +209,9 @@ LL | no_safety_comment!(u32); | ----------------------- in this macro invocation | = help: consider adding a safety comment on the preceding line - = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:413:5 | LL | unsafe impl T for (bool) {} @@ -215,7 +219,7 @@ LL | unsafe impl T for (bool) {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:459:5 | LL | unsafe impl NoComment for () {} @@ -223,7 +227,7 @@ LL | unsafe impl NoComment for () {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:463:19 | LL | /* SAFETY: */ unsafe impl InlineComment for () {} @@ -231,7 +235,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:467:5 | LL | unsafe impl TrailingComment for () {} // SAFETY: @@ -239,7 +243,7 @@ LL | unsafe impl TrailingComment for () {} // SAFETY: | = help: consider adding a safety comment on the preceding line -error: constant item has unnecessary safety comment +warning: constant item has unnecessary safety comment --> $DIR/undocumented_unsafe_blocks.rs:471:5 | LL | const BIG_NUMBER: i32 = 1000000; @@ -250,9 +254,13 @@ help: consider removing the safety comment | LL | // SAFETY: | ^^^^^^^^^^ - = note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/undocumented_unsafe_blocks.rs:3:45 + | +LL | #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:472:5 | LL | unsafe impl Interference for () {} @@ -260,7 +268,7 @@ LL | unsafe impl Interference for () {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:479:5 | LL | unsafe impl ImplInFn for () {} @@ -268,7 +276,7 @@ LL | unsafe impl ImplInFn for () {} | = help: consider adding a safety comment on the preceding line -error: unsafe impl missing a safety comment +warning: unsafe impl missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:488:1 | LL | unsafe impl CrateRoot for () {} @@ -276,7 +284,7 @@ LL | unsafe impl CrateRoot for () {} | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:498:9 | LL | unsafe {}; @@ -284,7 +292,7 @@ LL | unsafe {}; | = help: consider adding a safety comment on the preceding line -error: statement has unnecessary safety comment +warning: statement has unnecessary safety comment --> $DIR/undocumented_unsafe_blocks.rs:501:5 | LL | / let _ = { @@ -302,7 +310,7 @@ help: consider removing the safety comment LL | // SAFETY: this is more than one level away, so it should warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:502:12 | LL | if unsafe { true } { @@ -310,7 +318,7 @@ LL | if unsafe { true } { | = help: consider adding a safety comment on the preceding line -error: unsafe block missing a safety comment +warning: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:505:23 | LL | let bar = unsafe {}; @@ -318,5 +326,5 @@ LL | let bar = unsafe {}; | = help: consider adding a safety comment on the preceding line -error: aborting due to 36 previous errors +warning: 36 warnings emitted diff --git a/tests/ui/undropped_manually_drops.stderr b/tests/ui/undropped_manually_drops.stderr index 92611a9b7df4..41a1c9d14788 100644 --- a/tests/ui/undropped_manually_drops.stderr +++ b/tests/ui/undropped_manually_drops.stderr @@ -1,13 +1,17 @@ -error: the inner value of this ManuallyDrop will not be dropped +warning: the inner value of this ManuallyDrop will not be dropped --> $DIR/undropped_manually_drops.rs:14:5 | LL | drop(std::mem::ManuallyDrop::new(S)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: to drop a `ManuallyDrop`, use std::mem::ManuallyDrop::drop - = note: `-D clippy::undropped-manually-drops` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/undropped_manually_drops.rs:1:9 + | +LL | #![warn(clippy::undropped_manually_drops)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the inner value of this ManuallyDrop will not be dropped +warning: the inner value of this ManuallyDrop will not be dropped --> $DIR/undropped_manually_drops.rs:15:5 | LL | drop(manual1); @@ -15,5 +19,5 @@ LL | drop(manual1); | = help: to drop a `ManuallyDrop`, use std::mem::ManuallyDrop::drop -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unicode.fixed b/tests/ui/unicode.fixed index 94b4723452fa..e0c0909ec344 100644 --- a/tests/ui/unicode.fixed +++ b/tests/ui/unicode.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// compile-flags: --test +//@run-rustfix +//@compile-flags: --test #![allow(dead_code)] #[warn(clippy::invisible_characters)] @@ -19,7 +19,7 @@ fn canon() { } mod non_ascii_literal { - #![deny(clippy::non_ascii_literal)] + #![warn(clippy::non_ascii_literal)] fn uni() { print!("\u{dc}ben!"); @@ -38,7 +38,7 @@ mod non_ascii_literal { } mod issue_8263 { - #![deny(clippy::non_ascii_literal)] + #![warn(clippy::non_ascii_literal)] // Re-allow for a single test #[test] diff --git a/tests/ui/unicode.rs b/tests/ui/unicode.rs index 6ad0b255b948..69446c9b159b 100644 --- a/tests/ui/unicode.rs +++ b/tests/ui/unicode.rs @@ -1,5 +1,5 @@ -// run-rustfix -// compile-flags: --test +//@run-rustfix +//@compile-flags: --test #![allow(dead_code)] #[warn(clippy::invisible_characters)] @@ -19,7 +19,7 @@ fn canon() { } mod non_ascii_literal { - #![deny(clippy::non_ascii_literal)] + #![warn(clippy::non_ascii_literal)] fn uni() { print!("Üben!"); @@ -38,7 +38,7 @@ mod non_ascii_literal { } mod issue_8263 { - #![deny(clippy::non_ascii_literal)] + #![warn(clippy::non_ascii_literal)] // Re-allow for a single test #[test] diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index ea74a81451e3..0dcda4b78d13 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -1,66 +1,74 @@ -error: invisible character detected +warning: invisible character detected --> $DIR/unicode.rs:7:12 | LL | print!("Here >​< is a ZWS, and ​another"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{200B}< is a ZWS, and /u{200B}another"` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{200B}< is a ZWS, and \u{200B}another"` | - = note: `-D clippy::invisible-characters` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unicode.rs:5:8 + | +LL | #[warn(clippy::invisible_characters)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: invisible character detected +warning: invisible character detected --> $DIR/unicode.rs:9:12 | LL | print!("Here >­< is a SHY, and ­another"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{AD}< is a SHY, and /u{AD}another"` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{AD}< is a SHY, and \u{AD}another"` -error: invisible character detected +warning: invisible character detected --> $DIR/unicode.rs:11:12 | LL | print!("Here >⁠< is a WJ, and ⁠another"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >/u{2060}< is a WJ, and /u{2060}another"` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{2060}< is a WJ, and \u{2060}another"` -error: non-NFC Unicode sequence detected +warning: non-NFC Unicode sequence detected --> $DIR/unicode.rs:17:12 | LL | print!("̀àh?"); | ^^^^^ help: consider replacing the string with: `"̀àh?"` | - = note: `-D clippy::unicode-not-nfc` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unicode.rs:15:8 + | +LL | #[warn(clippy::unicode_not_nfc)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: literal non-ASCII character detected +warning: literal non-ASCII character detected --> $DIR/unicode.rs:25:16 | LL | print!("Üben!"); - | ^^^^^^^ help: consider replacing the string with: `"/u{dc}ben!"` + | ^^^^^^^ help: consider replacing the string with: `"\u{dc}ben!"` | note: the lint level is defined here --> $DIR/unicode.rs:22:13 | -LL | #![deny(clippy::non_ascii_literal)] +LL | #![warn(clippy::non_ascii_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: literal non-ASCII character detected +warning: literal non-ASCII character detected --> $DIR/unicode.rs:31:36 | LL | const _EMPTY_BLOCK: char = '▱'; - | ^^^ help: consider replacing the string with: `'/u{25b1}'` + | ^^^ help: consider replacing the string with: `'\u{25b1}'` -error: literal non-ASCII character detected +warning: literal non-ASCII character detected --> $DIR/unicode.rs:32:35 | LL | const _FULL_BLOCK: char = '▰'; - | ^^^ help: consider replacing the string with: `'/u{25b0}'` + | ^^^ help: consider replacing the string with: `'\u{25b0}'` -error: literal non-ASCII character detected +warning: literal non-ASCII character detected --> $DIR/unicode.rs:52:21 | LL | let _ = "悲しいかな、ここに日本語を書くことはできない。"; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"/u{60b2}/u{3057}/u{3044}/u{304b}/u{306a}/u{3001}/u{3053}/u{3053}/u{306b}/u{65e5}/u{672c}/u{8a9e}/u{3092}/u{66f8}/u{304f}/u{3053}/u{3068}/u{306f}/u{3067}/u{304d}/u{306a}/u{3044}/u{3002}"` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"\u{60b2}\u{3057}\u{3044}\u{304b}\u{306a}\u{3001}\u{3053}\u{3053}\u{306b}\u{65e5}\u{672c}\u{8a9e}\u{3092}\u{66f8}\u{304f}\u{3053}\u{3068}\u{306f}\u{3067}\u{304d}\u{306a}\u{3044}\u{3002}"` | note: the lint level is defined here --> $DIR/unicode.rs:41:17 | -LL | #![deny(clippy::non_ascii_literal)] +LL | #![warn(clippy::non_ascii_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/uninit.rs b/tests/ui/uninit.rs index 211317317086..3f583974f3c9 100644 --- a/tests/ui/uninit.rs +++ b/tests/ui/uninit.rs @@ -1,5 +1,6 @@ #![feature(stmt_expr_attributes)] #![allow(clippy::let_unit_value, invalid_value)] +#![warn(clippy::uninit_assumed_init)] use std::mem::{self, MaybeUninit}; diff --git a/tests/ui/uninit.stderr b/tests/ui/uninit.stderr index 15ef2349489f..d900273e09c9 100644 --- a/tests/ui/uninit.stderr +++ b/tests/ui/uninit.stderr @@ -1,22 +1,26 @@ -error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:7:29 +warning: this call for this type may be undefined behavior + --> $DIR/uninit.rs:8:29 | LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[deny(clippy::uninit_assumed_init)]` on by default +note: the lint level is defined here + --> $DIR/uninit.rs:3:9 + | +LL | #![warn(clippy::uninit_assumed_init)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:10:31 +warning: this call for this type may be undefined behavior + --> $DIR/uninit.rs:11:31 | LL | let _: [u8; 0] = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:25:29 +warning: this call for this type may be undefined behavior + --> $DIR/uninit.rs:26:29 | LL | let _: usize = unsafe { mem::MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/uninit_vec.stderr b/tests/ui/uninit_vec.stderr index 77fc689f0763..0e3906ca4bc3 100644 --- a/tests/ui/uninit_vec.stderr +++ b/tests/ui/uninit_vec.stderr @@ -1,4 +1,4 @@ -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:12:5 | LL | let mut vec: Vec = Vec::with_capacity(1000); @@ -8,9 +8,13 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ | = help: initialize the buffer or wrap the content in `MaybeUninit` - = note: `-D clippy::uninit-vec` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/uninit_vec.rs:1:9 + | +LL | #![warn(clippy::uninit_vec)] + | ^^^^^^^^^^^^^^^^^^ -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:18:5 | LL | vec.reserve(1000); @@ -21,7 +25,7 @@ LL | vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` -error: calling `set_len()` on empty `Vec` creates out-of-bound values +warning: calling `set_len()` on empty `Vec` creates out-of-bound values --> $DIR/uninit_vec.rs:24:5 | LL | let mut vec: Vec = Vec::new(); @@ -30,7 +34,7 @@ LL | unsafe { LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ -error: calling `set_len()` on empty `Vec` creates out-of-bound values +warning: calling `set_len()` on empty `Vec` creates out-of-bound values --> $DIR/uninit_vec.rs:30:5 | LL | let mut vec: Vec = Default::default(); @@ -39,7 +43,7 @@ LL | unsafe { LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ -error: calling `set_len()` on empty `Vec` creates out-of-bound values +warning: calling `set_len()` on empty `Vec` creates out-of-bound values --> $DIR/uninit_vec.rs:35:5 | LL | let mut vec: Vec = Vec::default(); @@ -48,7 +52,7 @@ LL | unsafe { LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:49:5 | LL | let mut vec: Vec = Vec::with_capacity(1000); @@ -59,7 +63,7 @@ LL | vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:58:5 | LL | my_vec.vec.reserve(1000); @@ -70,7 +74,7 @@ LL | my_vec.vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:63:5 | LL | my_vec.vec = Vec::with_capacity(1000); @@ -81,7 +85,7 @@ LL | my_vec.vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:42:9 | LL | let mut vec: Vec = Vec::with_capacity(1000); @@ -91,7 +95,7 @@ LL | vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` -error: calling `set_len()` immediately after reserving a buffer creates uninitialized values +warning: calling `set_len()` immediately after reserving a buffer creates uninitialized values --> $DIR/uninit_vec.rs:45:9 | LL | vec.reserve(1000); @@ -101,5 +105,5 @@ LL | vec.set_len(200); | = help: initialize the buffer or wrap the content in `MaybeUninit` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/uninlined_format_args.fixed b/tests/ui/uninlined_format_args.fixed index cbd5cc5fceef..3caee2ef881b 100644 --- a/tests/ui/uninlined_format_args.fixed +++ b/tests/ui/uninlined_format_args.fixed @@ -1,5 +1,5 @@ -// aux-build:proc_macro_with_span.rs -// run-rustfix +//@aux-build:proc_macro_with_span.rs:proc-macro +//@run-rustfix #![warn(clippy::uninlined_format_args)] #![allow(named_arguments_used_positionally, unused_imports, unused_macros, unused_variables)] #![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)] diff --git a/tests/ui/uninlined_format_args.rs b/tests/ui/uninlined_format_args.rs index cf0ea5be4813..d92abe144a41 100644 --- a/tests/ui/uninlined_format_args.rs +++ b/tests/ui/uninlined_format_args.rs @@ -1,5 +1,5 @@ -// aux-build:proc_macro_with_span.rs -// run-rustfix +//@aux-build:proc_macro_with_span.rs:proc-macro +//@run-rustfix #![warn(clippy::uninlined_format_args)] #![allow(named_arguments_used_positionally, unused_imports, unused_macros, unused_variables)] #![allow(clippy::eq_op, clippy::format_in_format_args, clippy::print_literal)] diff --git a/tests/ui/uninlined_format_args.stderr b/tests/ui/uninlined_format_args.stderr index a12abf8bef8a..0b73a8365ff3 100644 --- a/tests/ui/uninlined_format_args.stderr +++ b/tests/ui/uninlined_format_args.stderr @@ -1,17 +1,21 @@ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:40:5 | LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::uninlined-format-args` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/uninlined_format_args.rs:3:9 + | +LL | #![warn(clippy::uninlined_format_args)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to | LL - println!("val='{}'", local_i32); LL + println!("val='{local_i32}'"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:41:5 | LL | println!("val='{ }'", local_i32); // 3 spaces @@ -23,7 +27,7 @@ LL - println!("val='{ }'", local_i32); // 3 spaces LL + println!("val='{local_i32}'"); // 3 spaces | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:42:5 | LL | println!("val='{ }'", local_i32); // tab @@ -35,7 +39,7 @@ LL - println!("val='{ }'", local_i32); // tab LL + println!("val='{local_i32}'"); // tab | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:43:5 | LL | println!("val='{ }'", local_i32); // space+tab @@ -47,7 +51,7 @@ LL - println!("val='{ }'", local_i32); // space+tab LL + println!("val='{local_i32}'"); // space+tab | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:44:5 | LL | println!("val='{ }'", local_i32); // tab+space @@ -59,7 +63,7 @@ LL - println!("val='{ }'", local_i32); // tab+space LL + println!("val='{local_i32}'"); // tab+space | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:45:5 | LL | / println!( @@ -69,7 +73,7 @@ LL | | local_i32 LL | | ); | |_____^ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:50:5 | LL | println!("{}", local_i32); @@ -81,7 +85,7 @@ LL - println!("{}", local_i32); LL + println!("{local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:51:5 | LL | println!("{}", fn_arg); @@ -93,7 +97,7 @@ LL - println!("{}", fn_arg); LL + println!("{fn_arg}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:52:5 | LL | println!("{:?}", local_i32); @@ -105,7 +109,7 @@ LL - println!("{:?}", local_i32); LL + println!("{local_i32:?}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:53:5 | LL | println!("{:#?}", local_i32); @@ -117,7 +121,7 @@ LL - println!("{:#?}", local_i32); LL + println!("{local_i32:#?}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:54:5 | LL | println!("{:4}", local_i32); @@ -129,7 +133,7 @@ LL - println!("{:4}", local_i32); LL + println!("{local_i32:4}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:55:5 | LL | println!("{:04}", local_i32); @@ -141,7 +145,7 @@ LL - println!("{:04}", local_i32); LL + println!("{local_i32:04}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:56:5 | LL | println!("{:<3}", local_i32); @@ -153,7 +157,7 @@ LL - println!("{:<3}", local_i32); LL + println!("{local_i32:<3}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:57:5 | LL | println!("{:#010x}", local_i32); @@ -165,7 +169,7 @@ LL - println!("{:#010x}", local_i32); LL + println!("{local_i32:#010x}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:58:5 | LL | println!("{:.1}", local_f64); @@ -177,7 +181,7 @@ LL - println!("{:.1}", local_f64); LL + println!("{local_f64:.1}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:62:5 | LL | println!("{} {}", local_i32, local_f64); @@ -189,7 +193,7 @@ LL - println!("{} {}", local_i32, local_f64); LL + println!("{local_i32} {local_f64}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:64:5 | LL | println!("{}", val); @@ -201,7 +205,7 @@ LL - println!("{}", val); LL + println!("{val}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:65:5 | LL | println!("{}", v = val); @@ -213,31 +217,31 @@ LL - println!("{}", v = val); LL + println!("{val}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:67:5 | -LL | println!("val='{/t }'", local_i32); +LL | println!("val='{\t }'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: change this to | -LL - println!("val='{/t }'", local_i32); +LL - println!("val='{\t }'", local_i32); LL + println!("val='{local_i32}'"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:68:5 | -LL | println!("val='{/n }'", local_i32); +LL | println!("val='{\n }'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: change this to | -LL - println!("val='{/n }'", local_i32); +LL - println!("val='{\n }'", local_i32); LL + println!("val='{local_i32}'"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:69:5 | LL | println!("val='{local_i32}'", local_i32 = local_i32); @@ -249,7 +253,7 @@ LL - println!("val='{local_i32}'", local_i32 = local_i32); LL + println!("val='{local_i32}'"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:70:5 | LL | println!("val='{local_i32}'", local_i32 = fn_arg); @@ -261,7 +265,7 @@ LL - println!("val='{local_i32}'", local_i32 = fn_arg); LL + println!("val='{fn_arg}'"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:71:5 | LL | println!("{0}", local_i32); @@ -273,7 +277,7 @@ LL - println!("{0}", local_i32); LL + println!("{local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:72:5 | LL | println!("{0:?}", local_i32); @@ -285,7 +289,7 @@ LL - println!("{0:?}", local_i32); LL + println!("{local_i32:?}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:73:5 | LL | println!("{0:#?}", local_i32); @@ -297,7 +301,7 @@ LL - println!("{0:#?}", local_i32); LL + println!("{local_i32:#?}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:74:5 | LL | println!("{0:04}", local_i32); @@ -309,7 +313,7 @@ LL - println!("{0:04}", local_i32); LL + println!("{local_i32:04}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:75:5 | LL | println!("{0:<3}", local_i32); @@ -321,7 +325,7 @@ LL - println!("{0:<3}", local_i32); LL + println!("{local_i32:<3}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:76:5 | LL | println!("{0:#010x}", local_i32); @@ -333,7 +337,7 @@ LL - println!("{0:#010x}", local_i32); LL + println!("{local_i32:#010x}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:77:5 | LL | println!("{0:.1}", local_f64); @@ -345,7 +349,7 @@ LL - println!("{0:.1}", local_f64); LL + println!("{local_f64:.1}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:78:5 | LL | println!("{0} {0}", local_i32); @@ -357,7 +361,7 @@ LL - println!("{0} {0}", local_i32); LL + println!("{local_i32} {local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:79:5 | LL | println!("{1} {} {0} {}", local_i32, local_f64); @@ -369,7 +373,7 @@ LL - println!("{1} {} {0} {}", local_i32, local_f64); LL + println!("{local_f64} {local_i32} {local_i32} {local_f64}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:80:5 | LL | println!("{0} {1}", local_i32, local_f64); @@ -381,7 +385,7 @@ LL - println!("{0} {1}", local_i32, local_f64); LL + println!("{local_i32} {local_f64}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:81:5 | LL | println!("{1} {0}", local_i32, local_f64); @@ -393,7 +397,7 @@ LL - println!("{1} {0}", local_i32, local_f64); LL + println!("{local_f64} {local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:82:5 | LL | println!("{1} {0} {1} {0}", local_i32, local_f64); @@ -405,7 +409,7 @@ LL - println!("{1} {0} {1} {0}", local_i32, local_f64); LL + println!("{local_f64} {local_i32} {local_f64} {local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:84:5 | LL | println!("{v}", v = local_i32); @@ -417,7 +421,7 @@ LL - println!("{v}", v = local_i32); LL + println!("{local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:85:5 | LL | println!("{local_i32:0$}", width); @@ -429,7 +433,7 @@ LL - println!("{local_i32:0$}", width); LL + println!("{local_i32:width$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:86:5 | LL | println!("{local_i32:w$}", w = width); @@ -441,7 +445,7 @@ LL - println!("{local_i32:w$}", w = width); LL + println!("{local_i32:width$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:87:5 | LL | println!("{local_i32:.0$}", prec); @@ -453,7 +457,7 @@ LL - println!("{local_i32:.0$}", prec); LL + println!("{local_i32:.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:88:5 | LL | println!("{local_i32:.p$}", p = prec); @@ -465,7 +469,7 @@ LL - println!("{local_i32:.p$}", p = prec); LL + println!("{local_i32:.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:89:5 | LL | println!("{:0$}", v = val); @@ -477,7 +481,7 @@ LL - println!("{:0$}", v = val); LL + println!("{val:val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:90:5 | LL | println!("{0:0$}", v = val); @@ -489,7 +493,7 @@ LL - println!("{0:0$}", v = val); LL + println!("{val:val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:91:5 | LL | println!("{:0$.0$}", v = val); @@ -501,7 +505,7 @@ LL - println!("{:0$.0$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:92:5 | LL | println!("{0:0$.0$}", v = val); @@ -513,7 +517,7 @@ LL - println!("{0:0$.0$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:93:5 | LL | println!("{0:0$.v$}", v = val); @@ -525,7 +529,7 @@ LL - println!("{0:0$.v$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:94:5 | LL | println!("{0:v$.0$}", v = val); @@ -537,7 +541,7 @@ LL - println!("{0:v$.0$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:95:5 | LL | println!("{v:0$.0$}", v = val); @@ -549,7 +553,7 @@ LL - println!("{v:0$.0$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:96:5 | LL | println!("{v:v$.0$}", v = val); @@ -561,7 +565,7 @@ LL - println!("{v:v$.0$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:97:5 | LL | println!("{v:0$.v$}", v = val); @@ -573,7 +577,7 @@ LL - println!("{v:0$.v$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:98:5 | LL | println!("{v:v$.v$}", v = val); @@ -585,7 +589,7 @@ LL - println!("{v:v$.v$}", v = val); LL + println!("{val:val$.val$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:99:5 | LL | println!("{:0$}", width); @@ -597,7 +601,7 @@ LL - println!("{:0$}", width); LL + println!("{width:width$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:100:5 | LL | println!("{:1$}", local_i32, width); @@ -609,7 +613,7 @@ LL - println!("{:1$}", local_i32, width); LL + println!("{local_i32:width$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:101:5 | LL | println!("{:w$}", w = width); @@ -621,7 +625,7 @@ LL - println!("{:w$}", w = width); LL + println!("{width:width$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:102:5 | LL | println!("{:w$}", local_i32, w = width); @@ -633,7 +637,7 @@ LL - println!("{:w$}", local_i32, w = width); LL + println!("{local_i32:width$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:103:5 | LL | println!("{:.0$}", prec); @@ -645,7 +649,7 @@ LL - println!("{:.0$}", prec); LL + println!("{prec:.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:104:5 | LL | println!("{:.1$}", local_i32, prec); @@ -657,7 +661,7 @@ LL - println!("{:.1$}", local_i32, prec); LL + println!("{local_i32:.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:105:5 | LL | println!("{:.p$}", p = prec); @@ -669,7 +673,7 @@ LL - println!("{:.p$}", p = prec); LL + println!("{prec:.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:106:5 | LL | println!("{:.p$}", local_i32, p = prec); @@ -681,7 +685,7 @@ LL - println!("{:.p$}", local_i32, p = prec); LL + println!("{local_i32:.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:107:5 | LL | println!("{:0$.1$}", width, prec); @@ -693,7 +697,7 @@ LL - println!("{:0$.1$}", width, prec); LL + println!("{width:width$.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:108:5 | LL | println!("{:0$.w$}", width, w = prec); @@ -705,7 +709,7 @@ LL - println!("{:0$.w$}", width, w = prec); LL + println!("{width:width$.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:109:5 | LL | println!("{:1$.2$}", local_f64, width, prec); @@ -717,7 +721,7 @@ LL - println!("{:1$.2$}", local_f64, width, prec); LL + println!("{local_f64:width$.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:110:5 | LL | println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); @@ -729,7 +733,7 @@ LL - println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); LL + println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:111:5 | LL | / println!( @@ -738,7 +742,7 @@ LL | | local_i32, width, prec, LL | | ); | |_____^ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:122:5 | LL | println!("Width = {}, value with width = {:0$}", local_i32, local_f64); @@ -750,7 +754,7 @@ LL - println!("Width = {}, value with width = {:0$}", local_i32, local_f64); LL + println!("Width = {local_i32}, value with width = {local_f64:local_i32$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:123:5 | LL | println!("{:w$.p$}", local_i32, w = width, p = prec); @@ -762,7 +766,7 @@ LL - println!("{:w$.p$}", local_i32, w = width, p = prec); LL + println!("{local_i32:width$.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:124:5 | LL | println!("{:w$.p$}", w = width, p = prec); @@ -774,7 +778,7 @@ LL - println!("{:w$.p$}", w = width, p = prec); LL + println!("{width:width$.prec$}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:125:20 | LL | println!("{}", format!("{}", local_i32)); @@ -786,7 +790,7 @@ LL - println!("{}", format!("{}", local_i32)); LL + println!("{}", format!("{local_i32}")); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:143:5 | LL | / println!( @@ -796,7 +800,7 @@ LL | | val, LL | | ); | |_____^ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:148:5 | LL | println!("{}", /* comment with a comma , in it */ val); @@ -808,7 +812,7 @@ LL - println!("{}", /* comment with a comma , in it */ val); LL + println!("{val}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:154:9 | LL | panic!("p1 {}", local_i32); @@ -820,7 +824,7 @@ LL - panic!("p1 {}", local_i32); LL + panic!("p1 {local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:157:9 | LL | panic!("p2 {0}", local_i32); @@ -832,7 +836,7 @@ LL - panic!("p2 {0}", local_i32); LL + panic!("p2 {local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:160:9 | LL | panic!("p3 {local_i32}", local_i32 = local_i32); @@ -844,7 +848,7 @@ LL - panic!("p3 {local_i32}", local_i32 = local_i32); LL + panic!("p3 {local_i32}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args.rs:180:5 | LL | println!("expand='{}'", local_i32); @@ -856,5 +860,5 @@ LL - println!("expand='{}'", local_i32); LL + println!("expand='{local_i32}'"); | -error: aborting due to 72 previous errors +warning: 72 warnings emitted diff --git a/tests/ui/uninlined_format_args_panic.edition2018.fixed b/tests/ui/uninlined_format_args_panic.edition2018.fixed index 52b5343c351e..559050b3df62 100644 --- a/tests/ui/uninlined_format_args_panic.edition2018.fixed +++ b/tests/ui/uninlined_format_args_panic.edition2018.fixed @@ -1,7 +1,7 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix #![warn(clippy::uninlined_format_args)] diff --git a/tests/ui/uninlined_format_args_panic.edition2018.stderr b/tests/ui/uninlined_format_args_panic.edition2018.stderr index 2c8061259229..0bd2e6b9ac6a 100644 --- a/tests/ui/uninlined_format_args_panic.edition2018.stderr +++ b/tests/ui/uninlined_format_args_panic.edition2018.stderr @@ -1,15 +1,19 @@ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:11:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::uninlined-format-args` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/uninlined_format_args_panic.rs:6:9 + | +LL | #![warn(clippy::uninlined_format_args)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to | LL - println!("val='{}'", var); LL + println!("val='{var}'"); | -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/uninlined_format_args_panic.edition2021.fixed b/tests/ui/uninlined_format_args_panic.edition2021.fixed index ee72065e28ab..3a753b49caf3 100644 --- a/tests/ui/uninlined_format_args_panic.edition2021.fixed +++ b/tests/ui/uninlined_format_args_panic.edition2021.fixed @@ -1,7 +1,7 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix #![warn(clippy::uninlined_format_args)] diff --git a/tests/ui/uninlined_format_args_panic.edition2021.stderr b/tests/ui/uninlined_format_args_panic.edition2021.stderr index fc7b125080e7..e3533272feed 100644 --- a/tests/ui/uninlined_format_args_panic.edition2021.stderr +++ b/tests/ui/uninlined_format_args_panic.edition2021.stderr @@ -1,17 +1,21 @@ -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:11:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::uninlined-format-args` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/uninlined_format_args_panic.rs:6:9 + | +LL | #![warn(clippy::uninlined_format_args)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to | LL - println!("val='{}'", var); LL + println!("val='{var}'"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:14:9 | LL | panic!("p1 {}", var); @@ -23,7 +27,7 @@ LL - panic!("p1 {}", var); LL + panic!("p1 {var}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:17:9 | LL | panic!("p2 {0}", var); @@ -35,7 +39,7 @@ LL - panic!("p2 {0}", var); LL + panic!("p2 {var}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:20:9 | LL | panic!("p3 {var}", var = var); @@ -47,7 +51,7 @@ LL - panic!("p3 {var}", var = var); LL + panic!("p3 {var}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:30:5 | LL | assert!(var == 1, "p5 {}", var); @@ -59,7 +63,7 @@ LL - assert!(var == 1, "p5 {}", var); LL + assert!(var == 1, "p5 {var}"); | -error: variables can be used directly in the `format!` string +warning: variables can be used directly in the `format!` string --> $DIR/uninlined_format_args_panic.rs:31:5 | LL | debug_assert!(var == 1, "p6 {}", var); @@ -71,5 +75,5 @@ LL - debug_assert!(var == 1, "p6 {}", var); LL + debug_assert!(var == 1, "p6 {var}"); | -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/uninlined_format_args_panic.rs b/tests/ui/uninlined_format_args_panic.rs index b4a0a0f496e4..83fbb9afd2a1 100644 --- a/tests/ui/uninlined_format_args_panic.rs +++ b/tests/ui/uninlined_format_args_panic.rs @@ -1,7 +1,7 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix #![warn(clippy::uninlined_format_args)] diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs index 07e70873a813..275fcd5f3255 100644 --- a/tests/ui/unit_arg.rs +++ b/tests/ui/unit_arg.rs @@ -1,4 +1,4 @@ -// aux-build: proc_macro_with_span.rs +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::unit_arg)] #![allow(unused_must_use, unused_variables)] #![allow( diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index 74d4d2f4052f..cd4aa4e8d7dc 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,4 +1,4 @@ -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:62:5 | LL | / foo({ @@ -6,7 +6,11 @@ LL | | 1; LL | | }); | |______^ | - = note: `-D clippy::unit-arg` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unit_arg.rs:2:9 + | +LL | #![warn(clippy::unit_arg)] + | ^^^^^^^^^^^^^^^^ help: remove the semicolon from the last statement in the block | LL | 1 @@ -19,7 +23,7 @@ LL + }; LL ~ foo(()); | -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:65:5 | LL | foo(foo(1)); @@ -31,7 +35,7 @@ LL ~ foo(1); LL ~ foo(()); | -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:66:5 | LL | / foo({ @@ -53,7 +57,7 @@ LL + }; LL ~ foo(()); | -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:71:5 | LL | / b.bar({ @@ -73,7 +77,7 @@ LL + }; LL ~ b.bar(()); | -error: passing unit values to a function +warning: passing unit values to a function --> $DIR/unit_arg.rs:74:5 | LL | taking_multiple_units(foo(0), foo(1)); @@ -86,7 +90,7 @@ LL + foo(1); LL ~ taking_multiple_units((), ()); | -error: passing unit values to a function +warning: passing unit values to a function --> $DIR/unit_arg.rs:75:5 | LL | / taking_multiple_units(foo(0), { @@ -109,7 +113,7 @@ LL + }; LL ~ taking_multiple_units((), ()); | -error: passing unit values to a function +warning: passing unit values to a function --> $DIR/unit_arg.rs:79:5 | LL | / taking_multiple_units( @@ -145,7 +149,7 @@ LL + (), LL ~ ); | -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:90:13 | LL | None.or(Some(foo(2))); @@ -159,7 +163,7 @@ LL + Some(()) LL ~ }); | -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:93:5 | LL | foo(foo(())); @@ -171,7 +175,7 @@ LL ~ foo(()); LL ~ foo(()); | -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg.rs:130:5 | LL | Some(foo(1)) @@ -183,5 +187,5 @@ LL ~ foo(1); LL + Some(()) | -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/unit_arg_empty_blocks.fixed b/tests/ui/unit_arg_empty_blocks.fixed index 5787471a32ca..8c065115a74e 100644 --- a/tests/ui/unit_arg_empty_blocks.fixed +++ b/tests/ui/unit_arg_empty_blocks.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unit_arg)] #![allow(unused_must_use, unused_variables)] #![allow(clippy::no_effect, clippy::uninlined_format_args)] diff --git a/tests/ui/unit_arg_empty_blocks.rs b/tests/ui/unit_arg_empty_blocks.rs index 6a42c2ccf42b..af166b56ff48 100644 --- a/tests/ui/unit_arg_empty_blocks.rs +++ b/tests/ui/unit_arg_empty_blocks.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unit_arg)] #![allow(unused_must_use, unused_variables)] #![allow(clippy::no_effect, clippy::uninlined_format_args)] diff --git a/tests/ui/unit_arg_empty_blocks.stderr b/tests/ui/unit_arg_empty_blocks.stderr index c697dfb1efa2..eec1b2ffee66 100644 --- a/tests/ui/unit_arg_empty_blocks.stderr +++ b/tests/ui/unit_arg_empty_blocks.stderr @@ -1,4 +1,4 @@ -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg_empty_blocks.rs:17:5 | LL | foo({}); @@ -6,9 +6,13 @@ LL | foo({}); | | | help: use a unit literal instead: `()` | - = note: `-D clippy::unit-arg` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unit_arg_empty_blocks.rs:2:9 + | +LL | #![warn(clippy::unit_arg)] + | ^^^^^^^^^^^^^^^^ -error: passing a unit value to a function +warning: passing a unit value to a function --> $DIR/unit_arg_empty_blocks.rs:18:5 | LL | foo3({}, 2, 2); @@ -16,7 +20,7 @@ LL | foo3({}, 2, 2); | | | help: use a unit literal instead: `()` -error: passing unit values to a function +warning: passing unit values to a function --> $DIR/unit_arg_empty_blocks.rs:19:5 | LL | taking_two_units({}, foo(0)); @@ -28,7 +32,7 @@ LL ~ foo(0); LL ~ taking_two_units((), ()); | -error: passing unit values to a function +warning: passing unit values to a function --> $DIR/unit_arg_empty_blocks.rs:20:5 | LL | taking_three_units({}, foo(0), foo(1)); @@ -41,5 +45,5 @@ LL + foo(1); LL ~ taking_three_units((), (), ()); | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 41cf19ae685e..a35c22be553a 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,4 +1,4 @@ -error: ==-comparison of unit values detected. This will always be true +warning: ==-comparison of unit values detected. This will always be true --> $DIR/unit_cmp.rs:16:8 | LL | if { @@ -9,9 +9,13 @@ LL | | false; LL | | } {} | |_____^ | - = note: `-D clippy::unit-cmp` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unit_cmp.rs:1:9 + | +LL | #![warn(clippy::unit_cmp)] + | ^^^^^^^^^^^^^^^^ -error: >-comparison of unit values detected. This will always be false +warning: >-comparison of unit values detected. This will always be false --> $DIR/unit_cmp.rs:22:8 | LL | if { @@ -22,7 +26,7 @@ LL | | false; LL | | } {} | |_____^ -error: `assert_eq` of unit values detected. This will always succeed +warning: `assert_eq` of unit values detected. This will always succeed --> $DIR/unit_cmp.rs:28:5 | LL | / assert_eq!( @@ -34,7 +38,7 @@ LL | | } LL | | ); | |_____^ -error: `debug_assert_eq` of unit values detected. This will always succeed +warning: `debug_assert_eq` of unit values detected. This will always succeed --> $DIR/unit_cmp.rs:36:5 | LL | / debug_assert_eq!( @@ -46,7 +50,7 @@ LL | | } LL | | ); | |_____^ -error: `assert_ne` of unit values detected. This will always fail +warning: `assert_ne` of unit values detected. This will always fail --> $DIR/unit_cmp.rs:45:5 | LL | / assert_ne!( @@ -58,7 +62,7 @@ LL | | } LL | | ); | |_____^ -error: `debug_assert_ne` of unit values detected. This will always fail +warning: `debug_assert_ne` of unit values detected. This will always fail --> $DIR/unit_cmp.rs:53:5 | LL | / debug_assert_ne!( @@ -70,5 +74,5 @@ LL | | } LL | | ); | |_____^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/unit_hash.stderr b/tests/ui/unit_hash.stderr index 089d1212dd17..da453f408bf9 100644 --- a/tests/ui/unit_hash.stderr +++ b/tests/ui/unit_hash.stderr @@ -1,13 +1,17 @@ -error: this call to `hash` on the unit type will do nothing +warning: this call to `hash` on the unit type will do nothing --> $DIR/unit_hash.rs:19:23 | LL | Foo::Empty => ().hash(&mut state), | ^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` | = note: the implementation of `Hash` for `()` is a no-op - = note: `-D clippy::unit-hash` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unit_hash.rs:1:9 + | +LL | #![warn(clippy::unit_hash)] + | ^^^^^^^^^^^^^^^^^ -error: this call to `hash` on the unit type will do nothing +warning: this call to `hash` on the unit type will do nothing --> $DIR/unit_hash.rs:24:5 | LL | res.hash(&mut state); @@ -15,7 +19,7 @@ LL | res.hash(&mut state); | = note: the implementation of `Hash` for `()` is a no-op -error: this call to `hash` on the unit type will do nothing +warning: this call to `hash` on the unit type will do nothing --> $DIR/unit_hash.rs:27:5 | LL | do_nothing().hash(&mut state); @@ -23,5 +27,5 @@ LL | do_nothing().hash(&mut state); | = note: the implementation of `Hash` for `()` is a no-op -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/unit_return_expecting_ord.stderr b/tests/ui/unit_return_expecting_ord.stderr index 1d9564ce225e..4d7da1b106ac 100644 --- a/tests/ui/unit_return_expecting_ord.stderr +++ b/tests/ui/unit_return_expecting_ord.stderr @@ -1,4 +1,4 @@ -error: this closure returns the unit type which also implements Ord +warning: this closure returns the unit type which also implements Ord --> $DIR/unit_return_expecting_ord.rs:18:25 | LL | structs.sort_by_key(|s| { @@ -9,9 +9,13 @@ help: probably caused by this trailing semicolon | LL | double(s.field); | ^ - = note: `-D clippy::unit-return-expecting-ord` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unit_return_expecting_ord.rs:1:9 + | +LL | #![warn(clippy::unit_return_expecting_ord)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this closure returns the unit type which also implements PartialOrd +warning: this closure returns the unit type which also implements PartialOrd --> $DIR/unit_return_expecting_ord.rs:22:30 | LL | structs.is_sorted_by_key(|s| { @@ -23,17 +27,17 @@ help: probably caused by this trailing semicolon LL | double(s.field); | ^ -error: this closure returns the unit type which also implements PartialOrd +warning: this closure returns the unit type which also implements PartialOrd --> $DIR/unit_return_expecting_ord.rs:25:30 | LL | structs.is_sorted_by_key(|s| { | ^^^ -error: this closure returns the unit type which also implements Ord +warning: this closure returns the unit type which also implements Ord --> $DIR/unit_return_expecting_ord.rs:35:25 | LL | structs.sort_by_key(|s| unit(s.field)); | ^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unknown_attribute.rs b/tests/ui/unknown_attribute.rs index e993e63f8ed8..79ff6c2ef456 100644 --- a/tests/ui/unknown_attribute.rs +++ b/tests/ui/unknown_attribute.rs @@ -1,3 +1,3 @@ -#[clippy::unknown] +#[clippy::unknown] //~ ERROR: usage of unknown attribute #[clippy::cognitive_complexity = "1"] fn main() {} diff --git a/tests/ui/unknown_clippy_lints.fixed b/tests/ui/unknown_clippy_lints.fixed index 4249ff8a958d..b60042923ea1 100644 --- a/tests/ui/unknown_clippy_lints.fixed +++ b/tests/ui/unknown_clippy_lints.fixed @@ -1,18 +1,18 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::pedantic)] // Should suggest lowercase -#![allow(clippy::all)] -#![warn(clippy::cmp_nan)] +#![allow(clippy::All)] +#![warn(clippy::CMP_NAN)] // Should suggest similar clippy lint name -#[warn(clippy::if_not_else)] -#[warn(clippy::unnecessary_cast)] -#[warn(clippy::useless_transmute)] +#[warn(clippy::if_not_els)] +#[warn(clippy::UNNecsaRy_cAst)] +#[warn(clippy::useles_transute)] // Shouldn't suggest rustc lint name(`dead_code`) -#[warn(clippy::drop_copy)] +#[warn(clippy::dead_cod)] // Shouldn't suggest removed/deprecated clippy lint name(`unused_collect`) -#[warn(clippy::unused_self)] +#[warn(clippy::unused_colle)] // Shouldn't suggest renamed clippy lint name(`const_static_lifetime`) -#[warn(clippy::redundant_static_lifetimes)] +#[warn(clippy::const_static_lifetim)] fn main() {} diff --git a/tests/ui/unknown_clippy_lints.rs b/tests/ui/unknown_clippy_lints.rs index 5db345f54441..b60042923ea1 100644 --- a/tests/ui/unknown_clippy_lints.rs +++ b/tests/ui/unknown_clippy_lints.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::pedantic)] // Should suggest lowercase diff --git a/tests/ui/unknown_clippy_lints.stderr b/tests/ui/unknown_clippy_lints.stderr index 421bf5ffa9a7..e76be9f1e206 100644 --- a/tests/ui/unknown_clippy_lints.stderr +++ b/tests/ui/unknown_clippy_lints.stderr @@ -1,52 +1,52 @@ -error: unknown lint: `clippy::All` +warning: unknown lint: `clippy::All` --> $DIR/unknown_clippy_lints.rs:5:10 | LL | #![allow(clippy::All)] | ^^^^^^^^^^^ help: did you mean: `clippy::all` | - = note: `-D unknown-lints` implied by `-D warnings` + = note: `#[warn(unknown_lints)]` on by default -error: unknown lint: `clippy::CMP_NAN` +warning: unknown lint: `clippy::CMP_NAN` --> $DIR/unknown_clippy_lints.rs:6:9 | LL | #![warn(clippy::CMP_NAN)] | ^^^^^^^^^^^^^^^ help: did you mean: `clippy::cmp_nan` -error: unknown lint: `clippy::if_not_els` +warning: unknown lint: `clippy::if_not_els` --> $DIR/unknown_clippy_lints.rs:9:8 | LL | #[warn(clippy::if_not_els)] | ^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::if_not_else` -error: unknown lint: `clippy::UNNecsaRy_cAst` +warning: unknown lint: `clippy::UNNecsaRy_cAst` --> $DIR/unknown_clippy_lints.rs:10:8 | LL | #[warn(clippy::UNNecsaRy_cAst)] | ^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unnecessary_cast` -error: unknown lint: `clippy::useles_transute` +warning: unknown lint: `clippy::useles_transute` --> $DIR/unknown_clippy_lints.rs:11:8 | LL | #[warn(clippy::useles_transute)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::useless_transmute` -error: unknown lint: `clippy::dead_cod` +warning: unknown lint: `clippy::dead_cod` --> $DIR/unknown_clippy_lints.rs:13:8 | LL | #[warn(clippy::dead_cod)] | ^^^^^^^^^^^^^^^^ help: did you mean: `clippy::drop_copy` -error: unknown lint: `clippy::unused_colle` +warning: unknown lint: `clippy::unused_colle` --> $DIR/unknown_clippy_lints.rs:15:8 | LL | #[warn(clippy::unused_colle)] | ^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unused_self` -error: unknown lint: `clippy::const_static_lifetim` +warning: unknown lint: `clippy::const_static_lifetim` --> $DIR/unknown_clippy_lints.rs:17:8 | LL | #[warn(clippy::const_static_lifetim)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::redundant_static_lifetimes` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/unnecessary_cast.fixed b/tests/ui/unnecessary_cast.fixed index 2f7e2997e739..bcc231ea7bce 100644 --- a/tests/ui/unnecessary_cast.fixed +++ b/tests/ui/unnecessary_cast.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_cast)] #![allow( unused_must_use, diff --git a/tests/ui/unnecessary_cast.rs b/tests/ui/unnecessary_cast.rs index 54dd46ba59f1..282b2f1283ee 100644 --- a/tests/ui/unnecessary_cast.rs +++ b/tests/ui/unnecessary_cast.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_cast)] #![allow( unused_must_use, diff --git a/tests/ui/unnecessary_cast.stderr b/tests/ui/unnecessary_cast.stderr index fcee4ee2a65c..fccf4ee4f4af 100644 --- a/tests/ui/unnecessary_cast.stderr +++ b/tests/ui/unnecessary_cast.stderr @@ -1,190 +1,194 @@ -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:14:5 | LL | 1i32 as i32; | ^^^^^^^^^^^ help: try: `1_i32` | - = note: `-D clippy::unnecessary-cast` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_cast.rs:2:9 + | +LL | #![warn(clippy::unnecessary_cast)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: casting float literal to `f32` is unnecessary +warning: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:15:5 | LL | 1f32 as f32; | ^^^^^^^^^^^ help: try: `1_f32` -error: casting to the same type is unnecessary (`bool` -> `bool`) +warning: casting to the same type is unnecessary (`bool` -> `bool`) --> $DIR/unnecessary_cast.rs:16:5 | LL | false as bool; | ^^^^^^^^^^^^^ help: try: `false` -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:19:5 | LL | -1_i32 as i32; | ^^^^^^^^^^^^^ help: try: `-1_i32` -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:20:5 | LL | - 1_i32 as i32; | ^^^^^^^^^^^^^^ help: try: `- 1_i32` -error: casting float literal to `f32` is unnecessary +warning: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:21:5 | LL | -1f32 as f32; | ^^^^^^^^^^^^ help: try: `-1_f32` -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:22:5 | LL | 1_i32 as i32; | ^^^^^^^^^^^^ help: try: `1_i32` -error: casting float literal to `f32` is unnecessary +warning: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:23:5 | LL | 1_f32 as f32; | ^^^^^^^^^^^^ help: try: `1_f32` -error: casting integer literal to `f32` is unnecessary +warning: casting integer literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:64:9 | LL | 100 as f32; | ^^^^^^^^^^ help: try: `100_f32` -error: casting integer literal to `f64` is unnecessary +warning: casting integer literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:65:9 | LL | 100 as f64; | ^^^^^^^^^^ help: try: `100_f64` -error: casting integer literal to `f64` is unnecessary +warning: casting integer literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:66:9 | LL | 100_i32 as f64; | ^^^^^^^^^^^^^^ help: try: `100_f64` -error: casting integer literal to `f32` is unnecessary +warning: casting integer literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:67:17 | LL | let _ = -100 as f32; | ^^^^^^^^^^^ help: try: `-100_f32` -error: casting integer literal to `f64` is unnecessary +warning: casting integer literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:68:17 | LL | let _ = -100 as f64; | ^^^^^^^^^^^ help: try: `-100_f64` -error: casting integer literal to `f64` is unnecessary +warning: casting integer literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:69:17 | LL | let _ = -100_i32 as f64; | ^^^^^^^^^^^^^^^ help: try: `-100_f64` -error: casting float literal to `f32` is unnecessary +warning: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:70:9 | LL | 100. as f32; | ^^^^^^^^^^^ help: try: `100_f32` -error: casting float literal to `f64` is unnecessary +warning: casting float literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:71:9 | LL | 100. as f64; | ^^^^^^^^^^^ help: try: `100_f64` -error: casting integer literal to `u32` is unnecessary +warning: casting integer literal to `u32` is unnecessary --> $DIR/unnecessary_cast.rs:83:9 | LL | 1 as u32; | ^^^^^^^^ help: try: `1_u32` -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:84:9 | LL | 0x10 as i32; | ^^^^^^^^^^^ help: try: `0x10_i32` -error: casting integer literal to `usize` is unnecessary +warning: casting integer literal to `usize` is unnecessary --> $DIR/unnecessary_cast.rs:85:9 | LL | 0b10 as usize; | ^^^^^^^^^^^^^ help: try: `0b10_usize` -error: casting integer literal to `u16` is unnecessary +warning: casting integer literal to `u16` is unnecessary --> $DIR/unnecessary_cast.rs:86:9 | LL | 0o73 as u16; | ^^^^^^^^^^^ help: try: `0o73_u16` -error: casting integer literal to `u32` is unnecessary +warning: casting integer literal to `u32` is unnecessary --> $DIR/unnecessary_cast.rs:87:9 | LL | 1_000_000_000 as u32; | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32` -error: casting float literal to `f64` is unnecessary +warning: casting float literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:89:9 | LL | 1.0 as f64; | ^^^^^^^^^^ help: try: `1.0_f64` -error: casting float literal to `f32` is unnecessary +warning: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:90:9 | LL | 0.5 as f32; | ^^^^^^^^^^ help: try: `0.5_f32` -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:94:17 | LL | let _ = -1 as i32; | ^^^^^^^^^ help: try: `-1_i32` -error: casting float literal to `f32` is unnecessary +warning: casting float literal to `f32` is unnecessary --> $DIR/unnecessary_cast.rs:95:17 | LL | let _ = -1.0 as f32; | ^^^^^^^^^^^ help: try: `-1.0_f32` -error: casting to the same type is unnecessary (`i32` -> `i32`) +warning: casting to the same type is unnecessary (`i32` -> `i32`) --> $DIR/unnecessary_cast.rs:101:18 | LL | let _ = &(x as i32); | ^^^^^^^^^^ help: try: `{ x }` -error: casting integer literal to `i32` is unnecessary +warning: casting integer literal to `i32` is unnecessary --> $DIR/unnecessary_cast.rs:107:22 | LL | let _: i32 = -(1) as i32; | ^^^^^^^^^^^ help: try: `-1_i32` -error: casting integer literal to `i64` is unnecessary +warning: casting integer literal to `i64` is unnecessary --> $DIR/unnecessary_cast.rs:109:22 | LL | let _: i64 = -(1) as i64; | ^^^^^^^^^^^ help: try: `-1_i64` -error: casting float literal to `f64` is unnecessary +warning: casting float literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:116:22 | LL | let _: f64 = (-8.0 as f64).exp(); | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)` -error: casting float literal to `f64` is unnecessary +warning: casting float literal to `f64` is unnecessary --> $DIR/unnecessary_cast.rs:118:23 | LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior | ^^^^^^^^^^^^ help: try: `8.0_f64` -error: casting to the same type is unnecessary (`f32` -> `f32`) +warning: casting to the same type is unnecessary (`f32` -> `f32`) --> $DIR/unnecessary_cast.rs:126:20 | LL | let _num = foo() as f32; | ^^^^^^^^^^^^ help: try: `foo()` -error: aborting due to 31 previous errors +warning: 31 warnings emitted diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index 8b1629b19a76..5e0b43002b0f 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -1,5 +1,5 @@ // does not test any rustfixable lints -#![warn(clippy::clone_on_ref_ptr)] +#![warn(clippy::clone_on_ref_ptr, clippy::clone_double_ref)] #![allow(unused)] #![allow(clippy::redundant_clone, clippy::uninlined_format_args, clippy::unnecessary_wraps)] diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 6022d9fa4c5c..2d7b0bf4e54f 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,56 +1,64 @@ -error: using `.clone()` on a ref-counted pointer +warning: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:23:5 | LL | rc.clone(); | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` | - = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_clone.rs:2:9 + | +LL | #![warn(clippy::clone_on_ref_ptr, clippy::clone_double_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: using `.clone()` on a ref-counted pointer +warning: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:26:5 | LL | arc.clone(); | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` -error: using `.clone()` on a ref-counted pointer +warning: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:29:5 | LL | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` -error: using `.clone()` on a ref-counted pointer +warning: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:32:5 | LL | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` -error: using `.clone()` on a ref-counted pointer +warning: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:36:33 | LL | let _: Arc = x.clone(); | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` -error: using `clone` on type `T` which implements the `Copy` trait +warning: using `clone` on type `T` which implements the `Copy` trait --> $DIR/unnecessary_clone.rs:40:5 | LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` | - = note: `-D clippy::clone-on-copy` implied by `-D warnings` + = note: `#[warn(clippy::clone_on_copy)]` on by default -error: using `clone` on type `Option` which implements the `Copy` trait +warning: using `clone` on type `Option` which implements the `Copy` trait --> $DIR/unnecessary_clone.rs:42:5 | LL | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` -error: using `clone` on a double-reference; this will copy the reference of type `&Vec` instead of cloning the inner type +warning: using `clone` on a double-reference; this will copy the reference of type `&Vec` instead of cloning the inner type --> $DIR/unnecessary_clone.rs:48:22 | LL | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | - = note: `#[deny(clippy::clone_double_ref)]` on by default +note: the lint level is defined here + --> $DIR/unnecessary_clone.rs:2:35 + | +LL | #![warn(clippy::clone_on_ref_ptr, clippy::clone_double_ref)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try dereferencing it | LL | let z: &Vec<_> = &(*y).clone(); @@ -60,13 +68,13 @@ help: or try being explicit if you are sure, that you want to clone a reference LL | let z: &Vec<_> = <&Vec>::clone(y); | ~~~~~~~~~~~~~~~~~~~~~ -error: using `clone` on type `E` which implements the `Copy` trait +warning: using `clone` on type `E` which implements the `Copy` trait --> $DIR/unnecessary_clone.rs:84:20 | LL | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` -error: using `clone` on a double-reference; this will copy the reference of type `&[u8]` instead of cloning the inner type +warning: using `clone` on a double-reference; this will copy the reference of type `&[u8]` instead of cloning the inner type --> $DIR/unnecessary_clone.rs:89:22 | LL | let _ = &mut encoded.clone(); @@ -81,7 +89,7 @@ help: or try being explicit if you are sure, that you want to clone a reference LL | let _ = &mut <&[u8]>::clone(encoded); | ~~~~~~~~~~~~~~~~~~~~~~~ -error: using `clone` on a double-reference; this will copy the reference of type `&[u8]` instead of cloning the inner type +warning: using `clone` on a double-reference; this will copy the reference of type `&[u8]` instead of cloning the inner type --> $DIR/unnecessary_clone.rs:90:18 | LL | let _ = &encoded.clone(); @@ -96,11 +104,11 @@ help: or try being explicit if you are sure, that you want to clone a reference LL | let _ = &<&[u8]>::clone(encoded); | ~~~~~~~~~~~~~~~~~~~~~~~ -error: using `.clone()` on a ref-counted pointer +warning: using `.clone()` on a ref-counted pointer --> $DIR/unnecessary_clone.rs:108:14 | LL | Some(try_opt!(Some(rc)).clone()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `Rc::::clone(&try_opt!(Some(rc)))` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 5585b10ab903..87856515e334 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -1,12 +1,12 @@ -error: this `.filter_map` can be written more simply using `.filter` +warning: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:4:13 | LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings` + = note: `#[warn(clippy::unnecessary_filter_map)]` on by default -error: this `.filter_map` can be written more simply using `.filter` +warning: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:5:13 | LL | let _ = (0..4).filter_map(|x| { @@ -18,7 +18,7 @@ LL | | None LL | | }); | |______^ -error: this `.filter_map` can be written more simply using `.filter` +warning: this `.filter_map` can be written more simply using `.filter` --> $DIR/unnecessary_filter_map.rs:11:13 | LL | let _ = (0..4).filter_map(|x| match x { @@ -28,11 +28,11 @@ LL | | _ => Some(x), LL | | }); | |______^ -error: this `.filter_map` can be written more simply using `.map` +warning: this `.filter_map` can be written more simply using `.map` --> $DIR/unnecessary_filter_map.rs:16:13 | LL | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unnecessary_find_map.stderr b/tests/ui/unnecessary_find_map.stderr index fb33c122fe33..454607bf690c 100644 --- a/tests/ui/unnecessary_find_map.stderr +++ b/tests/ui/unnecessary_find_map.stderr @@ -1,12 +1,12 @@ -error: this `.find_map` can be written more simply using `.find` +warning: this `.find_map` can be written more simply using `.find` --> $DIR/unnecessary_find_map.rs:4:13 | LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unnecessary-find-map` implied by `-D warnings` + = note: `#[warn(clippy::unnecessary_find_map)]` on by default -error: this `.find_map` can be written more simply using `.find` +warning: this `.find_map` can be written more simply using `.find` --> $DIR/unnecessary_find_map.rs:5:13 | LL | let _ = (0..4).find_map(|x| { @@ -18,7 +18,7 @@ LL | | None LL | | }); | |______^ -error: this `.find_map` can be written more simply using `.find` +warning: this `.find_map` can be written more simply using `.find` --> $DIR/unnecessary_find_map.rs:11:13 | LL | let _ = (0..4).find_map(|x| match x { @@ -28,11 +28,11 @@ LL | | _ => Some(x), LL | | }); | |______^ -error: this `.find_map` can be written more simply using `.map(..).next()` +warning: this `.find_map` can be written more simply using `.map(..).next()` --> $DIR/unnecessary_find_map.rs:16:13 | LL | let _ = (0..4).find_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unnecessary_fold.fixed b/tests/ui/unnecessary_fold.fixed index 52300a3b6406..2bed14973caa 100644 --- a/tests/ui/unnecessary_fold.fixed +++ b/tests/ui/unnecessary_fold.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] diff --git a/tests/ui/unnecessary_fold.rs b/tests/ui/unnecessary_fold.rs index 4028d80c0a3c..a3cec8ea3d55 100644 --- a/tests/ui/unnecessary_fold.rs +++ b/tests/ui/unnecessary_fold.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index 22c44588ab7a..e46eb1859f2f 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,40 +1,40 @@ -error: this `.fold` can be written more succinctly using another method +warning: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:8:20 | LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` | - = note: `-D clippy::unnecessary-fold` implied by `-D warnings` + = note: `#[warn(clippy::unnecessary_fold)]` on by default -error: this `.fold` can be written more succinctly using another method +warning: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:10:20 | LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)` -error: this `.fold` can be written more succinctly using another method +warning: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:12:25 | LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` -error: this `.fold` can be written more succinctly using another method +warning: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:14:25 | LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` -error: this `.fold` can be written more succinctly using another method +warning: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:19:41 | LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` -error: this `.fold` can be written more succinctly using another method +warning: this `.fold` can be written more succinctly using another method --> $DIR/unnecessary_fold.rs:49:10 | LL | .fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/unnecessary_iter_cloned.fixed b/tests/ui/unnecessary_iter_cloned.fixed index e01e9f07bafd..a0f8dd1a200d 100644 --- a/tests/ui/unnecessary_iter_cloned.fixed +++ b/tests/ui/unnecessary_iter_cloned.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_assignments)] #![warn(clippy::unnecessary_to_owned)] diff --git a/tests/ui/unnecessary_iter_cloned.rs b/tests/ui/unnecessary_iter_cloned.rs index 6ef2966c8b76..98f2dfe75491 100644 --- a/tests/ui/unnecessary_iter_cloned.rs +++ b/tests/ui/unnecessary_iter_cloned.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_assignments)] #![warn(clippy::unnecessary_to_owned)] diff --git a/tests/ui/unnecessary_iter_cloned.stderr b/tests/ui/unnecessary_iter_cloned.stderr index 8f151e620a25..f39be4429456 100644 --- a/tests/ui/unnecessary_iter_cloned.stderr +++ b/tests/ui/unnecessary_iter_cloned.stderr @@ -1,10 +1,14 @@ -error: unnecessary use of `copied` +warning: unnecessary use of `copied` --> $DIR/unnecessary_iter_cloned.rs:31:22 | LL | for (t, path) in files.iter().copied() { | ^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unnecessary-to-owned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_iter_cloned.rs:4:9 + | +LL | #![warn(clippy::unnecessary_to_owned)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use | LL | for (t, path) in files { @@ -15,7 +19,7 @@ LL - let other = match get_file_path(&t) { LL + let other = match get_file_path(t) { | -error: unnecessary use of `copied` +warning: unnecessary use of `copied` --> $DIR/unnecessary_iter_cloned.rs:46:22 | LL | for (t, path) in files.iter().copied() { @@ -31,5 +35,5 @@ LL - let other = match get_file_path(&t) { LL + let other = match get_file_path(t) { | -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unnecessary_join.fixed b/tests/ui/unnecessary_join.fixed index 347953960257..e102df625998 100644 --- a/tests/ui/unnecessary_join.fixed +++ b/tests/ui/unnecessary_join.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_join)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/unnecessary_join.rs b/tests/ui/unnecessary_join.rs index 344918cd2a2e..b87c15bc1263 100644 --- a/tests/ui/unnecessary_join.rs +++ b/tests/ui/unnecessary_join.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_join)] #![allow(clippy::uninlined_format_args)] diff --git a/tests/ui/unnecessary_join.stderr b/tests/ui/unnecessary_join.stderr index e919a6d1d8aa..daad1b67fb18 100644 --- a/tests/ui/unnecessary_join.stderr +++ b/tests/ui/unnecessary_join.stderr @@ -1,4 +1,4 @@ -error: called `.collect::>().join("")` on an iterator +warning: called `.collect::>().join("")` on an iterator --> $DIR/unnecessary_join.rs:11:10 | LL | .collect::>() @@ -6,9 +6,13 @@ LL | .collect::>() LL | | .join(""); | |_________________^ help: try using: `collect::()` | - = note: `-D clippy::unnecessary-join` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_join.rs:2:9 + | +LL | #![warn(clippy::unnecessary_join)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: called `.collect::>().join("")` on an iterator +warning: called `.collect::>().join("")` on an iterator --> $DIR/unnecessary_join.rs:20:10 | LL | .collect::>() @@ -16,5 +20,5 @@ LL | .collect::>() LL | | .join(""); | |_________________^ help: try using: `collect::()` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unnecessary_lazy_eval.fixed b/tests/ui/unnecessary_lazy_eval.fixed index 22e9bd8bdc51..56d74ab97468 100644 --- a/tests/ui/unnecessary_lazy_eval.fixed +++ b/tests/ui/unnecessary_lazy_eval.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::unnecessary_lazy_evaluations)] #![allow(clippy::redundant_closure)] #![allow(clippy::bind_instead_of_map)] diff --git a/tests/ui/unnecessary_lazy_eval.rs b/tests/ui/unnecessary_lazy_eval.rs index 8726d84a23fc..4a59c6d7a1aa 100644 --- a/tests/ui/unnecessary_lazy_eval.rs +++ b/tests/ui/unnecessary_lazy_eval.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build: proc_macro_with_span.rs +//@run-rustfix +//@aux-build: proc_macro_with_span.rs:proc-macro #![warn(clippy::unnecessary_lazy_evaluations)] #![allow(clippy::redundant_closure)] #![allow(clippy::bind_instead_of_map)] diff --git a/tests/ui/unnecessary_lazy_eval.stderr b/tests/ui/unnecessary_lazy_eval.stderr index 0339755442c5..25fe38cf3f08 100644 --- a/tests/ui/unnecessary_lazy_eval.stderr +++ b/tests/ui/unnecessary_lazy_eval.stderr @@ -1,4 +1,4 @@ -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:56:13 | LL | let _ = opt.unwrap_or_else(|| 2); @@ -6,9 +6,13 @@ LL | let _ = opt.unwrap_or_else(|| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` | - = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_lazy_eval.rs:3:9 + | +LL | #![warn(clippy::unnecessary_lazy_evaluations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:57:13 | LL | let _ = opt.unwrap_or_else(|| astronomers_pi); @@ -16,7 +20,7 @@ LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | | | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:58:13 | LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); @@ -24,7 +28,7 @@ LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | | | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:60:13 | LL | let _ = opt.and_then(|_| ext_opt); @@ -32,7 +36,7 @@ LL | let _ = opt.and_then(|_| ext_opt); | | | help: use `and(..)` instead: `and(ext_opt)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:61:13 | LL | let _ = opt.or_else(|| ext_opt); @@ -40,7 +44,7 @@ LL | let _ = opt.or_else(|| ext_opt); | | | help: use `or(..)` instead: `or(ext_opt)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:62:13 | LL | let _ = opt.or_else(|| None); @@ -48,7 +52,7 @@ LL | let _ = opt.or_else(|| None); | | | help: use `or(..)` instead: `or(None)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:63:13 | LL | let _ = opt.get_or_insert_with(|| 2); @@ -56,7 +60,7 @@ LL | let _ = opt.get_or_insert_with(|| 2); | | | help: use `get_or_insert(..)` instead: `get_or_insert(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:64:13 | LL | let _ = opt.ok_or_else(|| 2); @@ -64,7 +68,7 @@ LL | let _ = opt.ok_or_else(|| 2); | | | help: use `ok_or(..)` instead: `ok_or(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:65:13 | LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); @@ -72,7 +76,7 @@ LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | | | help: use `unwrap_or(..)` instead: `unwrap_or(Some((1, 2)))` -error: unnecessary closure used with `bool::then` +warning: unnecessary closure used with `bool::then` --> $DIR/unnecessary_lazy_eval.rs:66:13 | LL | let _ = cond.then(|| astronomers_pi); @@ -80,7 +84,7 @@ LL | let _ = cond.then(|| astronomers_pi); | | | help: use `then_some(..)` instead: `then_some(astronomers_pi)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:69:13 | LL | let _ = Some(10).unwrap_or_else(|| 2); @@ -88,7 +92,7 @@ LL | let _ = Some(10).unwrap_or_else(|| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:70:13 | LL | let _ = Some(10).and_then(|_| ext_opt); @@ -96,7 +100,7 @@ LL | let _ = Some(10).and_then(|_| ext_opt); | | | help: use `and(..)` instead: `and(ext_opt)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:71:28 | LL | let _: Option = None.or_else(|| ext_opt); @@ -104,7 +108,7 @@ LL | let _: Option = None.or_else(|| ext_opt); | | | help: use `or(..)` instead: `or(ext_opt)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:72:13 | LL | let _ = None.get_or_insert_with(|| 2); @@ -112,7 +116,7 @@ LL | let _ = None.get_or_insert_with(|| 2); | | | help: use `get_or_insert(..)` instead: `get_or_insert(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:73:35 | LL | let _: Result = None.ok_or_else(|| 2); @@ -120,7 +124,7 @@ LL | let _: Result = None.ok_or_else(|| 2); | | | help: use `ok_or(..)` instead: `ok_or(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:74:28 | LL | let _: Option = None.or_else(|| None); @@ -128,7 +132,7 @@ LL | let _: Option = None.or_else(|| None); | | | help: use `or(..)` instead: `or(None)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:77:13 | LL | let _ = deep.0.unwrap_or_else(|| 2); @@ -136,7 +140,7 @@ LL | let _ = deep.0.unwrap_or_else(|| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:78:13 | LL | let _ = deep.0.and_then(|_| ext_opt); @@ -144,7 +148,7 @@ LL | let _ = deep.0.and_then(|_| ext_opt); | | | help: use `and(..)` instead: `and(ext_opt)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:79:13 | LL | let _ = deep.0.or_else(|| None); @@ -152,7 +156,7 @@ LL | let _ = deep.0.or_else(|| None); | | | help: use `or(..)` instead: `or(None)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:80:13 | LL | let _ = deep.0.get_or_insert_with(|| 2); @@ -160,7 +164,7 @@ LL | let _ = deep.0.get_or_insert_with(|| 2); | | | help: use `get_or_insert(..)` instead: `get_or_insert(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:81:13 | LL | let _ = deep.0.ok_or_else(|| 2); @@ -168,7 +172,7 @@ LL | let _ = deep.0.ok_or_else(|| 2); | | | help: use `ok_or(..)` instead: `ok_or(2)` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:105:28 | LL | let _: Option = None.or_else(|| Some(3)); @@ -176,7 +180,7 @@ LL | let _: Option = None.or_else(|| Some(3)); | | | help: use `or(..)` instead: `or(Some(3))` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:106:13 | LL | let _ = deep.0.or_else(|| Some(3)); @@ -184,7 +188,7 @@ LL | let _ = deep.0.or_else(|| Some(3)); | | | help: use `or(..)` instead: `or(Some(3))` -error: unnecessary closure used to substitute value for `Option::None` +warning: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:107:13 | LL | let _ = opt.or_else(|| Some(3)); @@ -192,7 +196,7 @@ LL | let _ = opt.or_else(|| Some(3)); | | | help: use `or(..)` instead: `or(Some(3))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:113:13 | LL | let _ = res2.unwrap_or_else(|_| 2); @@ -200,7 +204,7 @@ LL | let _ = res2.unwrap_or_else(|_| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:114:13 | LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); @@ -208,7 +212,7 @@ LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | | | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:115:13 | LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); @@ -216,7 +220,7 @@ LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | | | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:137:35 | LL | let _: Result = res.and_then(|_| Err(2)); @@ -224,7 +228,7 @@ LL | let _: Result = res.and_then(|_| Err(2)); | | | help: use `and(..)` instead: `and(Err(2))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:138:35 | LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); @@ -232,7 +236,7 @@ LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | | | help: use `and(..)` instead: `and(Err(astronomers_pi))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:139:35 | LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)); @@ -240,7 +244,7 @@ LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)) | | | help: use `and(..)` instead: `and(Err(ext_str.some_field))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:141:35 | LL | let _: Result = res.or_else(|_| Ok(2)); @@ -248,7 +252,7 @@ LL | let _: Result = res.or_else(|_| Ok(2)); | | | help: use `or(..)` instead: `or(Ok(2))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:142:35 | LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); @@ -256,7 +260,7 @@ LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | | | help: use `or(..)` instead: `or(Ok(astronomers_pi))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:143:35 | LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); @@ -264,7 +268,7 @@ LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | | | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval.rs:144:35 | LL | let _: Result = res. @@ -279,5 +283,5 @@ LL | | or_else(|_| Ok(ext_str.some_field)); | | | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` -error: aborting due to 34 previous errors +warning: 34 warnings emitted diff --git a/tests/ui/unnecessary_lazy_eval_unfixable.stderr b/tests/ui/unnecessary_lazy_eval_unfixable.stderr index 20acab6e844f..6ba8505c315a 100644 --- a/tests/ui/unnecessary_lazy_eval_unfixable.stderr +++ b/tests/ui/unnecessary_lazy_eval_unfixable.stderr @@ -1,4 +1,4 @@ -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval_unfixable.rs:12:13 | LL | let _ = Ok(1).unwrap_or_else(|()| 2); @@ -6,9 +6,13 @@ LL | let _ = Ok(1).unwrap_or_else(|()| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` | - = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_lazy_eval_unfixable.rs:1:9 + | +LL | #![warn(clippy::unnecessary_lazy_evaluations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval_unfixable.rs:16:13 | LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); @@ -16,7 +20,7 @@ LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` -error: unnecessary closure used to substitute value for `Result::Err` +warning: unnecessary closure used to substitute value for `Result::Err` --> $DIR/unnecessary_lazy_eval_unfixable.rs:17:13 | LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); @@ -24,5 +28,5 @@ LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); | | | help: use `unwrap_or(..)` instead: `unwrap_or(2)` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/unnecessary_operation.fixed b/tests/ui/unnecessary_operation.fixed index d37163570abe..2368ead3ff2c 100644 --- a/tests/ui/unnecessary_operation.fixed +++ b/tests/ui/unnecessary_operation.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(box_syntax)] #![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)] @@ -62,10 +62,10 @@ fn main() { get_number(); 5;get_number(); 42;get_number(); - assert!([42, 55].len() > get_usize()); + [42, 55][get_usize()]; 42;get_number(); get_number(); - assert!([42; 55].len() > get_usize()); + [42; 55][get_usize()]; get_number(); String::from("blah"); diff --git a/tests/ui/unnecessary_operation.rs b/tests/ui/unnecessary_operation.rs index a14fd4bca0ef..773836d526c8 100644 --- a/tests/ui/unnecessary_operation.rs +++ b/tests/ui/unnecessary_operation.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(box_syntax)] #![allow(clippy::deref_addrof, dead_code, unused, clippy::no_effect)] diff --git a/tests/ui/unnecessary_operation.stderr b/tests/ui/unnecessary_operation.stderr index f66d08ecb828..eaf8d034d670 100644 --- a/tests/ui/unnecessary_operation.stderr +++ b/tests/ui/unnecessary_operation.stderr @@ -1,114 +1,118 @@ -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:51:5 | LL | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | - = note: `-D clippy::unnecessary-operation` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_operation.rs:5:9 + | +LL | #![warn(clippy::unnecessary_operation)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:52:5 | LL | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:53:5 | LL | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:54:5 | LL | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:55:5 | LL | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:56:5 | LL | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:57:5 | LL | *&get_number(); | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:58:5 | LL | &get_number(); | ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:59:5 | LL | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:60:5 | LL | box get_number(); | ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:61:5 | LL | get_number()..; | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:62:5 | LL | ..get_number(); | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:63:5 | LL | 5..get_number(); | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:64:5 | LL | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:65:5 | LL | [42, 55][get_usize()]; | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:66:5 | LL | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:67:5 | LL | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:68:5 | LL | [42; 55][get_usize()]; | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:69:5 | LL | / { @@ -116,7 +120,7 @@ LL | | get_number() LL | | }; | |______^ help: statement can be reduced to: `get_number();` -error: unnecessary operation +warning: unnecessary operation --> $DIR/unnecessary_operation.rs:72:5 | LL | / FooString { @@ -124,5 +128,5 @@ LL | | s: String::from("blah"), LL | | }; | |______^ help: statement can be reduced to: `String::from("blah");` -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/unnecessary_owned_empty_strings.fixed b/tests/ui/unnecessary_owned_empty_strings.fixed index 40052c41039e..af12fd1d63d0 100644 --- a/tests/ui/unnecessary_owned_empty_strings.fixed +++ b/tests/ui/unnecessary_owned_empty_strings.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_owned_empty_strings)] diff --git a/tests/ui/unnecessary_owned_empty_strings.rs b/tests/ui/unnecessary_owned_empty_strings.rs index 2304dff5192b..a460b21af8c2 100644 --- a/tests/ui/unnecessary_owned_empty_strings.rs +++ b/tests/ui/unnecessary_owned_empty_strings.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_owned_empty_strings)] diff --git a/tests/ui/unnecessary_owned_empty_strings.stderr b/tests/ui/unnecessary_owned_empty_strings.stderr index 1eb198a8675e..d79ec3ab5522 100644 --- a/tests/ui/unnecessary_owned_empty_strings.stderr +++ b/tests/ui/unnecessary_owned_empty_strings.stderr @@ -1,16 +1,20 @@ -error: usage of `&String::new()` for a function expecting a `&str` argument +warning: usage of `&String::new()` for a function expecting a `&str` argument --> $DIR/unnecessary_owned_empty_strings.rs:12:22 | LL | ref_str_argument(&String::new()); | ^^^^^^^^^^^^^^ help: try: `""` | - = note: `-D clippy::unnecessary-owned-empty-strings` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_owned_empty_strings.rs:3:9 + | +LL | #![warn(clippy::unnecessary_owned_empty_strings)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of `&String::from("")` for a function expecting a `&str` argument +warning: usage of `&String::from("")` for a function expecting a `&str` argument --> $DIR/unnecessary_owned_empty_strings.rs:16:22 | LL | ref_str_argument(&String::from("")); | ^^^^^^^^^^^^^^^^^ help: try: `""` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unnecessary_safety_comment.stderr b/tests/ui/unnecessary_safety_comment.stderr index 7b2af67d64c7..0f08f5eeda77 100644 --- a/tests/ui/unnecessary_safety_comment.stderr +++ b/tests/ui/unnecessary_safety_comment.stderr @@ -1,4 +1,4 @@ -error: constant item has unnecessary safety comment +warning: constant item has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:6:5 | LL | const CONST: u32 = 0; @@ -9,9 +9,13 @@ help: consider removing the safety comment | LL | // SAFETY: | ^^^^^^^^^^ - = note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_safety_comment.rs:1:45 + | +LL | #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: static item has unnecessary safety comment +warning: static item has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:8:5 | LL | static STATIC: u32 = 0; @@ -23,7 +27,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ -error: struct has unnecessary safety comment +warning: struct has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:10:5 | LL | struct Struct; @@ -35,7 +39,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ -error: enum has unnecessary safety comment +warning: enum has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:12:5 | LL | enum Enum {} @@ -47,7 +51,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ -error: module has unnecessary safety comment +warning: module has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:14:5 | LL | mod module {} @@ -59,7 +63,7 @@ help: consider removing the safety comment LL | // SAFETY: | ^^^^^^^^^^ -error: impl has unnecessary safety comment +warning: impl has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:33:13 | LL | impl T for $t {} @@ -73,9 +77,9 @@ help: consider removing the safety comment | LL | // Safety: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `with_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `with_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) -error: expression has unnecessary safety comment +warning: expression has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:48:5 | LL | 24 @@ -87,7 +91,7 @@ help: consider removing the safety comment LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ -error: statement has unnecessary safety comment +warning: statement has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:42:5 | LL | let num = 42; @@ -99,7 +103,7 @@ help: consider removing the safety comment LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ -error: statement has unnecessary safety comment +warning: statement has unnecessary safety comment --> $DIR/unnecessary_safety_comment.rs:45:5 | LL | if num > 24 {} @@ -111,5 +115,5 @@ help: consider removing the safety comment LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/unnecessary_self_imports.fixed b/tests/ui/unnecessary_self_imports.fixed index 1185eaa1d552..02424bc12b00 100644 --- a/tests/ui/unnecessary_self_imports.fixed +++ b/tests/ui/unnecessary_self_imports.fixed @@ -1,10 +1,10 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_self_imports)] #![allow(unused_imports, dead_code)] use std::collections::hash_map::{self, *}; -use std::fs as alias; +use std::fs::{self as alias}; use std::io::{self, Read}; -use std::rc; +use std::rc::{self}; fn main() {} diff --git a/tests/ui/unnecessary_self_imports.rs b/tests/ui/unnecessary_self_imports.rs index 56bfbc09402a..02424bc12b00 100644 --- a/tests/ui/unnecessary_self_imports.rs +++ b/tests/ui/unnecessary_self_imports.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unnecessary_self_imports)] #![allow(unused_imports, dead_code)] diff --git a/tests/ui/unnecessary_self_imports.stderr b/tests/ui/unnecessary_self_imports.stderr index db805eb3680b..fd303cd31306 100644 --- a/tests/ui/unnecessary_self_imports.stderr +++ b/tests/ui/unnecessary_self_imports.stderr @@ -1,4 +1,4 @@ -error: import ending with `::{self}` +warning: import ending with `::{self}` --> $DIR/unnecessary_self_imports.rs:6:1 | LL | use std::fs::{self as alias}; @@ -7,9 +7,13 @@ LL | use std::fs::{self as alias}; | help: consider omitting `::{self}`: `fs as alias;` | = note: this will slightly change semantics; any non-module items at the same path will also be imported - = note: `-D clippy::unnecessary-self-imports` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_self_imports.rs:2:9 + | +LL | #![warn(clippy::unnecessary_self_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: import ending with `::{self}` +warning: import ending with `::{self}` --> $DIR/unnecessary_self_imports.rs:8:1 | LL | use std::rc::{self}; @@ -19,5 +23,5 @@ LL | use std::rc::{self}; | = note: this will slightly change semantics; any non-module items at the same path will also be imported -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unnecessary_sort_by.fixed b/tests/ui/unnecessary_sort_by.fixed index 21e2da474a82..722a0384bb82 100644 --- a/tests/ui/unnecessary_sort_by.fixed +++ b/tests/ui/unnecessary_sort_by.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::stable_sort_primitive)] @@ -17,8 +17,8 @@ fn unnecessary_sort_by() { vec.sort_unstable_by_key(|a| id(-a)); // Reverse examples vec.sort_by(|a, b| b.cmp(a)); // not linted to avoid suggesting `Reverse(b)` which would borrow - vec.sort_by_key(|b| std::cmp::Reverse((b + 5).abs())); - vec.sort_unstable_by_key(|b| std::cmp::Reverse(id(-b))); + vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs())); + vec.sort_unstable_by(|a, b| id(-b).cmp(&id(-a))); // Negative examples (shouldn't be changed) let c = &7; vec.sort_by(|a, b| (b - a).cmp(&(a - b))); @@ -91,8 +91,8 @@ mod issue_6001 { args.sort_by_key(|a| a.name()); args.sort_unstable_by_key(|a| a.name()); // Reverse - args.sort_by_key(|b| std::cmp::Reverse(b.name())); - args.sort_unstable_by_key(|b| std::cmp::Reverse(b.name())); + args.sort_by(|a, b| b.name().cmp(&a.name())); + args.sort_unstable_by(|a, b| b.name().cmp(&a.name())); } } diff --git a/tests/ui/unnecessary_sort_by.rs b/tests/ui/unnecessary_sort_by.rs index 3365bf6e119e..8a2158d5a841 100644 --- a/tests/ui/unnecessary_sort_by.rs +++ b/tests/ui/unnecessary_sort_by.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::stable_sort_primitive)] diff --git a/tests/ui/unnecessary_sort_by.stderr b/tests/ui/unnecessary_sort_by.stderr index 89da5e7ea8b9..3c2a9617c388 100644 --- a/tests/ui/unnecessary_sort_by.stderr +++ b/tests/ui/unnecessary_sort_by.stderr @@ -1,76 +1,76 @@ -error: use Vec::sort here instead +warning: use Vec::sort here instead --> $DIR/unnecessary_sort_by.rs:14:5 | LL | vec.sort_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()` | - = note: `-D clippy::unnecessary-sort-by` implied by `-D warnings` + = note: `#[warn(clippy::unnecessary_sort_by)]` on by default -error: use Vec::sort here instead +warning: use Vec::sort here instead --> $DIR/unnecessary_sort_by.rs:15:5 | LL | vec.sort_unstable_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable()` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:16:5 | LL | vec.sort_by(|a, b| (a + 5).abs().cmp(&(b + 5).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|a| (a + 5).abs())` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:17:5 | LL | vec.sort_unstable_by(|a, b| id(-a).cmp(&id(-b))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|a| id(-a))` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:20:5 | LL | vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|b| std::cmp::Reverse((b + 5).abs()))` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:21:5 | LL | vec.sort_unstable_by(|a, b| id(-b).cmp(&id(-a))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|b| std::cmp::Reverse(id(-b)))` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:31:5 | LL | vec.sort_by(|a, b| (***a).abs().cmp(&(***b).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|a| (***a).abs())` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:32:5 | LL | vec.sort_unstable_by(|a, b| (***a).abs().cmp(&(***b).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|a| (***a).abs())` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:91:9 | LL | args.sort_by(|a, b| a.name().cmp(&b.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|a| a.name())` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:92:9 | LL | args.sort_unstable_by(|a, b| a.name().cmp(&b.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_unstable_by_key(|a| a.name())` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:94:9 | LL | args.sort_by(|a, b| b.name().cmp(&a.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|b| std::cmp::Reverse(b.name()))` -error: use Vec::sort_by_key here instead +warning: use Vec::sort_by_key here instead --> $DIR/unnecessary_sort_by.rs:95:9 | LL | args.sort_unstable_by(|a, b| b.name().cmp(&a.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_unstable_by_key(|b| std::cmp::Reverse(b.name()))` -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/unnecessary_to_owned.fixed b/tests/ui/unnecessary_to_owned.fixed index 345f6d604c4f..66346f9d9aa0 100644 --- a/tests/ui/unnecessary_to_owned.fixed +++ b/tests/ui/unnecessary_to_owned.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::needless_borrow, clippy::ptr_arg)] #![warn(clippy::unnecessary_to_owned)] @@ -124,15 +124,15 @@ fn main() { let _ = x.join(x_ref); - let _ = slice.iter().copied(); - let _ = slice.iter().copied(); - let _ = [std::path::PathBuf::new()][..].iter().cloned(); - let _ = [std::path::PathBuf::new()][..].iter().cloned(); + let _ = slice.to_vec().into_iter(); + let _ = slice.to_owned().into_iter(); + let _ = [std::path::PathBuf::new()][..].to_vec().into_iter(); + let _ = [std::path::PathBuf::new()][..].to_owned().into_iter(); - let _ = slice.iter().copied(); - let _ = slice.iter().copied(); - let _ = [std::path::PathBuf::new()][..].iter().cloned(); - let _ = [std::path::PathBuf::new()][..].iter().cloned(); + let _ = IntoIterator::into_iter(slice.to_vec()); + let _ = IntoIterator::into_iter(slice.to_owned()); + let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_vec()); + let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_owned()); let _ = check_files(&[FileType::Account]); @@ -194,8 +194,8 @@ fn require_as_ref_slice_str, V: AsRef>(_: U, _: V) {} // `check_files` is based on: // https://github.com/breard-r/acmed/blob/1f0dcc32aadbc5e52de6d23b9703554c0f925113/acmed/src/storage.rs#L262 fn check_files(file_types: &[FileType]) -> bool { - for t in file_types { - let path = match get_file_path(t) { + for t in file_types.to_vec() { + let path = match get_file_path(&t) { Ok(p) => p, Err(_) => { return false; @@ -217,12 +217,12 @@ fn require_string(_: &String) {} #[clippy::msrv = "1.35"] fn _msrv_1_35() { // `copied` was stabilized in 1.36, so clippy should use `cloned`. - let _ = &["x"][..].iter().cloned(); + let _ = &["x"][..].to_vec().into_iter(); } #[clippy::msrv = "1.36"] fn _msrv_1_36() { - let _ = &["x"][..].iter().copied(); + let _ = &["x"][..].to_vec().into_iter(); } // https://github.com/rust-lang/rust-clippy/issues/8507 diff --git a/tests/ui/unnecessary_to_owned.rs b/tests/ui/unnecessary_to_owned.rs index 7eb53df39e5b..10588beb263b 100644 --- a/tests/ui/unnecessary_to_owned.rs +++ b/tests/ui/unnecessary_to_owned.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(clippy::needless_borrow, clippy::ptr_arg)] #![warn(clippy::unnecessary_to_owned)] diff --git a/tests/ui/unnecessary_to_owned.stderr b/tests/ui/unnecessary_to_owned.stderr index 4918fe355986..07fdae021817 100644 --- a/tests/ui/unnecessary_to_owned.stderr +++ b/tests/ui/unnecessary_to_owned.stderr @@ -1,4 +1,4 @@ -error: redundant clone +warning: redundant clone --> $DIR/unnecessary_to_owned.rs:150:64 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); @@ -9,9 +9,9 @@ note: this value is dropped without further use | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::redundant-clone` implied by `-D warnings` + = note: `#[warn(clippy::redundant_clone)]` on by default -error: redundant clone +warning: redundant clone --> $DIR/unnecessary_to_owned.rs:151:40 | LL | require_os_str(&OsString::from("x").to_os_string()); @@ -23,7 +23,7 @@ note: this value is dropped without further use LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/unnecessary_to_owned.rs:152:48 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); @@ -35,7 +35,7 @@ note: this value is dropped without further use LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/unnecessary_to_owned.rs:153:35 | LL | require_str(&String::from("x").to_string()); @@ -47,7 +47,7 @@ note: this value is dropped without further use LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^^^^^^ -error: redundant clone +warning: redundant clone --> $DIR/unnecessary_to_owned.rs:154:39 | LL | require_slice(&[String::from("x")].to_owned()); @@ -59,423 +59,427 @@ note: this value is dropped without further use LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^^^^^^^^^ -error: unnecessary use of `into_owned` +warning: unnecessary use of `into_owned` --> $DIR/unnecessary_to_owned.rs:59:36 | LL | require_c_str(&Cow::from(c_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this | - = note: `-D clippy::unnecessary-to-owned` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_to_owned.rs:4:9 + | +LL | #![warn(clippy::unnecessary_to_owned)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:60:19 | LL | require_c_str(&c_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `c_str` -error: unnecessary use of `to_os_string` +warning: unnecessary use of `to_os_string` --> $DIR/unnecessary_to_owned.rs:62:20 | LL | require_os_str(&os_str.to_os_string()); | ^^^^^^^^^^^^^^^^^^^^^^ help: use: `os_str` -error: unnecessary use of `into_owned` +warning: unnecessary use of `into_owned` --> $DIR/unnecessary_to_owned.rs:63:38 | LL | require_os_str(&Cow::from(os_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:64:20 | LL | require_os_str(&os_str.to_owned()); | ^^^^^^^^^^^^^^^^^^ help: use: `os_str` -error: unnecessary use of `to_path_buf` +warning: unnecessary use of `to_path_buf` --> $DIR/unnecessary_to_owned.rs:66:18 | LL | require_path(&path.to_path_buf()); | ^^^^^^^^^^^^^^^^^^^ help: use: `path` -error: unnecessary use of `into_owned` +warning: unnecessary use of `into_owned` --> $DIR/unnecessary_to_owned.rs:67:34 | LL | require_path(&Cow::from(path).into_owned()); | ^^^^^^^^^^^^^ help: remove this -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:68:18 | LL | require_path(&path.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `path` -error: unnecessary use of `to_string` +warning: unnecessary use of `to_string` --> $DIR/unnecessary_to_owned.rs:70:17 | LL | require_str(&s.to_string()); | ^^^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `into_owned` +warning: unnecessary use of `into_owned` --> $DIR/unnecessary_to_owned.rs:71:30 | LL | require_str(&Cow::from(s).into_owned()); | ^^^^^^^^^^^^^ help: remove this -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:72:17 | LL | require_str(&s.to_owned()); | ^^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_string` +warning: unnecessary use of `to_string` --> $DIR/unnecessary_to_owned.rs:73:17 | LL | require_str(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref.as_ref()` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:75:19 | LL | require_slice(&slice.to_vec()); | ^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `into_owned` +warning: unnecessary use of `into_owned` --> $DIR/unnecessary_to_owned.rs:76:36 | LL | require_slice(&Cow::from(slice).into_owned()); | ^^^^^^^^^^^^^ help: remove this -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:77:19 | LL | require_slice(&array.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `array.as_ref()` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:78:19 | LL | require_slice(&array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref.as_ref()` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:79:19 | LL | require_slice(&slice.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `into_owned` +warning: unnecessary use of `into_owned` --> $DIR/unnecessary_to_owned.rs:82:42 | LL | require_x(&Cow::::Owned(x.clone()).into_owned()); | ^^^^^^^^^^^^^ help: remove this -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:85:25 | LL | require_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:86:26 | LL | require_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:87:24 | LL | require_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:88:23 | LL | require_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:89:25 | LL | require_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:91:30 | LL | require_impl_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:92:31 | LL | require_impl_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:93:29 | LL | require_impl_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:94:28 | LL | require_impl_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:95:30 | LL | require_impl_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:97:29 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:97:43 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:98:29 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:98:47 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:100:26 | LL | require_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:101:27 | LL | require_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:102:25 | LL | require_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:103:24 | LL | require_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:104:24 | LL | require_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:105:26 | LL | require_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:106:26 | LL | require_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:107:26 | LL | require_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:109:31 | LL | require_impl_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:110:32 | LL | require_impl_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:111:30 | LL | require_impl_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:112:29 | LL | require_impl_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:113:29 | LL | require_impl_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:114:31 | LL | require_impl_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:115:31 | LL | require_impl_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:116:31 | LL | require_impl_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:118:30 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:118:44 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:119:30 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:119:44 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:120:30 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:120:44 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:121:30 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:121:48 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:122:30 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:122:52 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:123:30 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:123:48 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` -error: unnecessary use of `to_string` +warning: unnecessary use of `to_string` --> $DIR/unnecessary_to_owned.rs:125:20 | LL | let _ = x.join(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:127:13 | LL | let _ = slice.to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:128:13 | LL | let _ = slice.to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:129:13 | LL | let _ = [std::path::PathBuf::new()][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:130:13 | LL | let _ = [std::path::PathBuf::new()][..].to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:132:13 | LL | let _ = IntoIterator::into_iter(slice.to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:133:13 | LL | let _ = IntoIterator::into_iter(slice.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:134:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` -error: unnecessary use of `to_owned` +warning: unnecessary use of `to_owned` --> $DIR/unnecessary_to_owned.rs:135:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:197:14 | LL | for t in file_types.to_vec() { @@ -491,29 +495,29 @@ LL - let path = match get_file_path(&t) { LL + let path = match get_file_path(t) { | -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:220:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().cloned()` -error: unnecessary use of `to_vec` +warning: unnecessary use of `to_vec` --> $DIR/unnecessary_to_owned.rs:225:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()` -error: unnecessary use of `to_string` +warning: unnecessary use of `to_string` --> $DIR/unnecessary_to_owned.rs:272:24 | LL | Box::new(build(y.to_string())) | ^^^^^^^^^^^^^ help: use: `y` -error: unnecessary use of `to_string` +warning: unnecessary use of `to_string` --> $DIR/unnecessary_to_owned.rs:380:12 | LL | id("abc".to_string()) | ^^^^^^^^^^^^^^^^^ help: use: `"abc"` -error: aborting due to 79 previous errors +warning: 79 warnings emitted diff --git a/tests/ui/unnecessary_unsafety_doc.rs b/tests/ui/unnecessary_unsafety_doc.rs index c160e31afd33..458fda4e21ab 100644 --- a/tests/ui/unnecessary_unsafety_doc.rs +++ b/tests/ui/unnecessary_unsafety_doc.rs @@ -1,4 +1,4 @@ -// aux-build:doc_unsafe_macros.rs +//@aux-build:doc_unsafe_macros.rs #![allow(clippy::let_unit_value)] #![warn(clippy::unnecessary_safety_doc)] diff --git a/tests/ui/unnecessary_unsafety_doc.stderr b/tests/ui/unnecessary_unsafety_doc.stderr index 72898c93fa11..01e0f421ce0c 100644 --- a/tests/ui/unnecessary_unsafety_doc.stderr +++ b/tests/ui/unnecessary_unsafety_doc.stderr @@ -1,36 +1,40 @@ -error: safe function's docs have unnecessary `# Safety` section +warning: safe function's docs have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:19:1 | LL | pub fn apocalypse(universe: &mut ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unnecessary-safety-doc` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_unsafety_doc.rs:4:9 + | +LL | #![warn(clippy::unnecessary_safety_doc)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: safe function's docs have unnecessary `# Safety` section +warning: safe function's docs have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:45:5 | LL | pub fn republished() { | ^^^^^^^^^^^^^^^^^^^^ -error: safe function's docs have unnecessary `# Safety` section +warning: safe function's docs have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:58:5 | LL | fn documented(self); | ^^^^^^^^^^^^^^^^^^^^ -error: docs for safe trait have unnecessary `# Safety` section +warning: docs for safe trait have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:68:1 | LL | pub trait DocumentedSafeTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: safe function's docs have unnecessary `# Safety` section +warning: safe function's docs have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:96:5 | LL | pub fn documented() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: safe function's docs have unnecessary `# Safety` section +warning: safe function's docs have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:123:9 | LL | pub fn drive() { @@ -39,13 +43,13 @@ LL | pub fn drive() { LL | very_safe!(); | ------------ in this macro invocation | - = note: this error originates in the macro `very_safe` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `very_safe` (in Nightly builds, run with -Z macro-backtrace for more info) -error: docs for safe trait have unnecessary `# Safety` section +warning: docs for safe trait have unnecessary `# Safety` section --> $DIR/unnecessary_unsafety_doc.rs:147:1 | LL | pub trait DocumentedSafeTraitWithImplementationHeader { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/unnecessary_wraps.stderr b/tests/ui/unnecessary_wraps.stderr index a6a0b22cf689..fa6e842c5032 100644 --- a/tests/ui/unnecessary_wraps.stderr +++ b/tests/ui/unnecessary_wraps.stderr @@ -1,4 +1,4 @@ -error: this function's return value is unnecessarily wrapped by `Option` +warning: this function's return value is unnecessarily wrapped by `Option` --> $DIR/unnecessary_wraps.rs:8:1 | LL | / fn func1(a: bool, b: bool) -> Option { @@ -10,7 +10,11 @@ LL | | } LL | | } | |_^ | - = note: `-D clippy::unnecessary-wraps` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnecessary_wraps.rs:1:9 + | +LL | #![warn(clippy::unnecessary_wraps)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `Option` from the return type... | LL | fn func1(a: bool, b: bool) -> i32 { @@ -26,7 +30,7 @@ LL | } else { LL ~ return 1337; | -error: this function's return value is unnecessarily wrapped by `Option` +warning: this function's return value is unnecessarily wrapped by `Option` --> $DIR/unnecessary_wraps.rs:21:1 | LL | / fn func2(a: bool, b: bool) -> Option { @@ -48,7 +52,7 @@ LL | } LL ~ if a { 20 } else { 30 } | -error: this function's return value is unnecessarily wrapped by `Option` +warning: this function's return value is unnecessarily wrapped by `Option` --> $DIR/unnecessary_wraps.rs:39:1 | LL | / fn func5() -> Option { @@ -65,7 +69,7 @@ help: ...and then change returning expressions LL | 1 | -error: this function's return value is unnecessarily wrapped by `Result` +warning: this function's return value is unnecessarily wrapped by `Result` --> $DIR/unnecessary_wraps.rs:49:1 | LL | / fn func7() -> Result { @@ -82,7 +86,7 @@ help: ...and then change returning expressions LL | 1 | -error: this function's return value is unnecessarily wrapped by `Option` +warning: this function's return value is unnecessarily wrapped by `Option` --> $DIR/unnecessary_wraps.rs:77:5 | LL | / fn func12() -> Option { @@ -99,7 +103,7 @@ help: ...and then change returning expressions LL | 1 | -error: this function's return value is unnecessary +warning: this function's return value is unnecessary --> $DIR/unnecessary_wraps.rs:104:1 | LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> { @@ -126,7 +130,7 @@ LL | } else { LL ~ return ; | -error: this function's return value is unnecessary +warning: this function's return value is unnecessary --> $DIR/unnecessary_wraps.rs:117:1 | LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { @@ -152,5 +156,5 @@ LL | } else { LL ~ return ; | -error: aborting due to 7 previous errors +warning: 7 warnings emitted diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 6f7c31545696..d9a0e9464484 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,13 +1,17 @@ -error: you matched a field with a wildcard pattern, consider using `..` instead +warning: you matched a field with a wildcard pattern, consider using `..` instead --> $DIR/unneeded_field_pattern.rs:14:15 | LL | Foo { a: _, b: 0, .. } => {}, | ^^^^ | = help: try with `Foo { b: 0, .. }` - = note: `-D clippy::unneeded-field-pattern` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unneeded_field_pattern.rs:1:9 + | +LL | #![warn(clippy::unneeded_field_pattern)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: all the struct fields are matched to a wildcard pattern, consider using `..` +warning: all the struct fields are matched to a wildcard pattern, consider using `..` --> $DIR/unneeded_field_pattern.rs:16:9 | LL | Foo { a: _, b: _, c: _ } => {}, @@ -15,5 +19,5 @@ LL | Foo { a: _, b: _, c: _ } => {}, | = help: try with `Foo { .. }` instead -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unneeded_wildcard_pattern.fixed b/tests/ui/unneeded_wildcard_pattern.fixed index 12c3461c9557..22ce94917eeb 100644 --- a/tests/ui/unneeded_wildcard_pattern.fixed +++ b/tests/ui/unneeded_wildcard_pattern.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #![feature(stmt_expr_attributes)] -#![deny(clippy::unneeded_wildcard_pattern)] +#![warn(clippy::unneeded_wildcard_pattern)] fn main() { let t = (0, 1, 2, 3); diff --git a/tests/ui/unneeded_wildcard_pattern.rs b/tests/ui/unneeded_wildcard_pattern.rs index 4ac01d5d23b0..869b7189c067 100644 --- a/tests/ui/unneeded_wildcard_pattern.rs +++ b/tests/ui/unneeded_wildcard_pattern.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix #![feature(stmt_expr_attributes)] -#![deny(clippy::unneeded_wildcard_pattern)] +#![warn(clippy::unneeded_wildcard_pattern)] fn main() { let t = (0, 1, 2, 3); diff --git a/tests/ui/unneeded_wildcard_pattern.stderr b/tests/ui/unneeded_wildcard_pattern.stderr index 716d9ecff89a..98bcf7d4700d 100644 --- a/tests/ui/unneeded_wildcard_pattern.stderr +++ b/tests/ui/unneeded_wildcard_pattern.stderr @@ -1,4 +1,4 @@ -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:8:18 | LL | if let (0, .., _) = t {}; @@ -7,86 +7,86 @@ LL | if let (0, .., _) = t {}; note: the lint level is defined here --> $DIR/unneeded_wildcard_pattern.rs:3:9 | -LL | #![deny(clippy::unneeded_wildcard_pattern)] +LL | #![warn(clippy::unneeded_wildcard_pattern)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:9:16 | LL | if let (0, _, ..) = t {}; | ^^^ help: remove it -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:10:13 | LL | if let (_, .., 0) = t {}; | ^^^ help: remove it -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:11:15 | LL | if let (.., _, 0) = t {}; | ^^^ help: remove it -error: these patterns are unneeded as the `..` pattern can match those elements +warning: these patterns are unneeded as the `..` pattern can match those elements --> $DIR/unneeded_wildcard_pattern.rs:12:16 | LL | if let (0, _, _, ..) = t {}; | ^^^^^^ help: remove them -error: these patterns are unneeded as the `..` pattern can match those elements +warning: these patterns are unneeded as the `..` pattern can match those elements --> $DIR/unneeded_wildcard_pattern.rs:13:18 | LL | if let (0, .., _, _) = t {}; | ^^^^^^ help: remove them -error: these patterns are unneeded as the `..` pattern can match those elements +warning: these patterns are unneeded as the `..` pattern can match those elements --> $DIR/unneeded_wildcard_pattern.rs:22:22 | LL | if let (0, .., _, _,) = t {}; | ^^^^^^ help: remove them -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:29:19 | LL | if let S(0, .., _) = s {}; | ^^^ help: remove it -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:30:17 | LL | if let S(0, _, ..) = s {}; | ^^^ help: remove it -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:31:14 | LL | if let S(_, .., 0) = s {}; | ^^^ help: remove it -error: this pattern is unneeded as the `..` pattern can match that element +warning: this pattern is unneeded as the `..` pattern can match that element --> $DIR/unneeded_wildcard_pattern.rs:32:16 | LL | if let S(.., _, 0) = s {}; | ^^^ help: remove it -error: these patterns are unneeded as the `..` pattern can match those elements +warning: these patterns are unneeded as the `..` pattern can match those elements --> $DIR/unneeded_wildcard_pattern.rs:33:17 | LL | if let S(0, _, _, ..) = s {}; | ^^^^^^ help: remove them -error: these patterns are unneeded as the `..` pattern can match those elements +warning: these patterns are unneeded as the `..` pattern can match those elements --> $DIR/unneeded_wildcard_pattern.rs:34:19 | LL | if let S(0, .., _, _) = s {}; | ^^^^^^ help: remove them -error: these patterns are unneeded as the `..` pattern can match those elements +warning: these patterns are unneeded as the `..` pattern can match those elements --> $DIR/unneeded_wildcard_pattern.rs:43:23 | LL | if let S(0, .., _, _,) = s {}; | ^^^^^^ help: remove them -error: aborting due to 14 previous errors +warning: 14 warnings emitted diff --git a/tests/ui/unnested_or_patterns.fixed b/tests/ui/unnested_or_patterns.fixed index 0a8e7b34dfa4..8ec35ba4eea7 100644 --- a/tests/ui/unnested_or_patterns.fixed +++ b/tests/ui/unnested_or_patterns.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(box_patterns)] #![warn(clippy::unnested_or_patterns)] diff --git a/tests/ui/unnested_or_patterns.rs b/tests/ui/unnested_or_patterns.rs index 2c454adfe89d..efdb91b2402b 100644 --- a/tests/ui/unnested_or_patterns.rs +++ b/tests/ui/unnested_or_patterns.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(box_patterns)] #![warn(clippy::unnested_or_patterns)] diff --git a/tests/ui/unnested_or_patterns.stderr b/tests/ui/unnested_or_patterns.stderr index a1f193db555a..37de3de1928a 100644 --- a/tests/ui/unnested_or_patterns.stderr +++ b/tests/ui/unnested_or_patterns.stderr @@ -1,16 +1,20 @@ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:12:12 | LL | if let box 0 | box 2 = Box::new(0) {} | ^^^^^^^^^^^^^ | - = note: `-D clippy::unnested-or-patterns` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnested_or_patterns.rs:4:9 + | +LL | #![warn(clippy::unnested_or_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: nest the patterns | LL | if let box (0 | 2) = Box::new(0) {} | ~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:13:12 | LL | if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} @@ -21,7 +25,7 @@ help: nest the patterns LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:15:12 | LL | if let Some(1) | C0 | Some(2) = None {} @@ -32,7 +36,7 @@ help: nest the patterns LL | if let Some(1 | 2) | C0 = None {} | ~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:16:12 | LL | if let &mut 0 | &mut 2 = &mut 0 {} @@ -43,7 +47,7 @@ help: nest the patterns LL | if let &mut (0 | 2) = &mut 0 {} | ~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:17:12 | LL | if let x @ 0 | x @ 2 = 0 {} @@ -54,7 +58,7 @@ help: nest the patterns LL | if let x @ (0 | 2) = 0 {} | ~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:18:12 | LL | if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {} @@ -65,7 +69,7 @@ help: nest the patterns LL | if let (0, 1 | 2 | 3) = (0, 0) {} | ~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:19:12 | LL | if let (1, 0) | (2, 0) | (3, 0) = (0, 0) {} @@ -76,7 +80,7 @@ help: nest the patterns LL | if let (1 | 2 | 3, 0) = (0, 0) {} | ~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:20:12 | LL | if let (x, ..) | (x, 1) | (x, 2) = (0, 1) {} @@ -87,7 +91,7 @@ help: nest the patterns LL | if let (x, ..) | (x, 1 | 2) = (0, 1) {} | ~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:21:12 | LL | if let [0] | [1] = [0] {} @@ -98,7 +102,7 @@ help: nest the patterns LL | if let [0 | 1] = [0] {} | ~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:22:12 | LL | if let [x, 0] | [x, 1] = [0, 1] {} @@ -109,7 +113,7 @@ help: nest the patterns LL | if let [x, 0 | 1] = [0, 1] {} | ~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:23:12 | LL | if let [x, 0] | [x, 1] | [x, 2] = [0, 1] {} @@ -120,7 +124,7 @@ help: nest the patterns LL | if let [x, 0 | 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:24:12 | LL | if let [x, ..] | [x, 1] | [x, 2] = [0, 1] {} @@ -131,7 +135,7 @@ help: nest the patterns LL | if let [x, ..] | [x, 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:26:12 | LL | if let TS(0, x) | TS(1, x) = TS(0, 0) {} @@ -142,7 +146,7 @@ help: nest the patterns LL | if let TS(0 | 1, x) = TS(0, 0) {} | ~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:27:12 | LL | if let TS(1, 0) | TS(2, 0) | TS(3, 0) = TS(0, 0) {} @@ -153,7 +157,7 @@ help: nest the patterns LL | if let TS(1 | 2 | 3, 0) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:28:12 | LL | if let TS(x, ..) | TS(x, 1) | TS(x, 2) = TS(0, 0) {} @@ -164,7 +168,7 @@ help: nest the patterns LL | if let TS(x, ..) | TS(x, 1 | 2) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:33:12 | LL | if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {} @@ -175,7 +179,7 @@ help: nest the patterns LL | if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {} | ~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns.rs:44:12 | LL | if let [1] | [53] = [0] {} @@ -186,5 +190,5 @@ help: nest the patterns LL | if let [1 | 53] = [0] {} | ~~~~~~~~ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/unnested_or_patterns2.fixed b/tests/ui/unnested_or_patterns2.fixed index d3539d798157..de40e9367471 100644 --- a/tests/ui/unnested_or_patterns2.fixed +++ b/tests/ui/unnested_or_patterns2.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(box_patterns)] #![warn(clippy::unnested_or_patterns)] diff --git a/tests/ui/unnested_or_patterns2.rs b/tests/ui/unnested_or_patterns2.rs index 9cea5cdea699..87f66d26c467 100644 --- a/tests/ui/unnested_or_patterns2.rs +++ b/tests/ui/unnested_or_patterns2.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![feature(box_patterns)] #![warn(clippy::unnested_or_patterns)] diff --git a/tests/ui/unnested_or_patterns2.stderr b/tests/ui/unnested_or_patterns2.stderr index 41e8d3fc7092..66a09dd7b715 100644 --- a/tests/ui/unnested_or_patterns2.stderr +++ b/tests/ui/unnested_or_patterns2.stderr @@ -1,16 +1,20 @@ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:9:12 | LL | if let Some(Some(0)) | Some(Some(1)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unnested-or-patterns` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unnested_or_patterns2.rs:4:9 + | +LL | #![warn(clippy::unnested_or_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: nest the patterns | LL | if let Some(Some(0 | 1)) = None {} | ~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:10:12 | LL | if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {} @@ -21,7 +25,7 @@ help: nest the patterns LL | if let Some(Some(0 | 1 | 2)) = None {} | ~~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:11:12 | LL | if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {} @@ -32,7 +36,7 @@ help: nest the patterns LL | if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:12:12 | LL | if let Some(Some(0) | Some(1 | 2)) = None {} @@ -43,7 +47,7 @@ help: nest the patterns LL | if let Some(Some(0 | 1 | 2)) = None {} | ~~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:13:12 | LL | if let ((0,),) | ((1,) | (2,),) = ((0,),) {} @@ -54,7 +58,7 @@ help: nest the patterns LL | if let ((0 | 1 | 2,),) = ((0,),) {} | ~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:14:12 | LL | if let 0 | (1 | 2) = 0 {} @@ -65,7 +69,7 @@ help: nest the patterns LL | if let 0 | 1 | 2 = 0 {} | ~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:15:12 | LL | if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {} @@ -76,7 +80,7 @@ help: nest the patterns LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ -error: unnested or-patterns +warning: unnested or-patterns --> $DIR/unnested_or_patterns2.rs:16:12 | LL | if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {} @@ -87,5 +91,5 @@ help: nest the patterns LL | if let box box (0 | 2 | 4) = Box::new(Box::new(0)) {} | ~~~~~~~~~~~~~~~~~~~ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/unreadable_literal.fixed b/tests/ui/unreadable_literal.fixed index 13e5feb19263..f5e87648a231 100644 --- a/tests/ui/unreadable_literal.fixed +++ b/tests/ui/unreadable_literal.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unreadable_literal)] #![allow(unused_tuple_struct_fields)] diff --git a/tests/ui/unreadable_literal.rs b/tests/ui/unreadable_literal.rs index 82f04e7ced52..426bdf7d7328 100644 --- a/tests/ui/unreadable_literal.rs +++ b/tests/ui/unreadable_literal.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unreadable_literal)] #![allow(unused_tuple_struct_fields)] diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index 450121b1c5a9..639bf8ab6916 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -1,64 +1,68 @@ -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:34:17 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | - = note: `-D clippy::unreadable-literal` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unreadable_literal.rs:3:9 + | +LL | #![warn(clippy::unreadable_literal)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:34:31 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^ help: consider: `0x1234_5678_usize` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:34:49 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:34:61 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:36:20 | LL | let _bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:38:18 | LL | let _fail1 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:39:23 | LL | let _fail2: u32 = 0xBAFEBAFE; | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:40:18 | LL | let _fail3 = 0xabcdeff; | ^^^^^^^^^ help: consider: `0x0abc_deff` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:41:24 | LL | let _fail4: i128 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` -error: long literal lacking separators +warning: long literal lacking separators --> $DIR/unreadable_literal.rs:42:18 | LL | let _fail5 = 1.100300400; | ^^^^^^^^^^^ help: consider: `1.100_300_400` -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/unsafe_derive_deserialize.stderr b/tests/ui/unsafe_derive_deserialize.stderr index 8aaae2d7fff4..a79859ecb3da 100644 --- a/tests/ui/unsafe_derive_deserialize.stderr +++ b/tests/ui/unsafe_derive_deserialize.stderr @@ -1,39 +1,43 @@ -error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` +warning: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` --> $DIR/unsafe_derive_deserialize.rs:8:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ | = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html - = note: `-D clippy::unsafe-derive-deserialize` implied by `-D warnings` - = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) +note: the lint level is defined here + --> $DIR/unsafe_derive_deserialize.rs:1:9 + | +LL | #![warn(clippy::unsafe_derive_deserialize)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this warning originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) -error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` +warning: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` --> $DIR/unsafe_derive_deserialize.rs:16:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ | = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html - = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) -error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` +warning: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` --> $DIR/unsafe_derive_deserialize.rs:22:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ | = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html - = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) -error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` +warning: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` --> $DIR/unsafe_derive_deserialize.rs:30:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ | = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html - = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 4f871cbe41b0..cb9a42243a25 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -1,22 +1,26 @@ -error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCell` +warning: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCell` --> $DIR/unsafe_removed_from_name.rs:5:1 | LL | use std::cell::UnsafeCell as TotallySafeCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unsafe_removed_from_name.rs:3:9 + | +LL | #![warn(clippy::unsafe_removed_from_name)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCellAgain` +warning: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCellAgain` --> $DIR/unsafe_removed_from_name.rs:7:1 | LL | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: removed `unsafe` from the name of `Unsafe` in use as `LieAboutModSafety` +warning: removed `unsafe` from the name of `Unsafe` in use as `LieAboutModSafety` --> $DIR/unsafe_removed_from_name.rs:21:1 | LL | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/unseparated_prefix_literals.fixed b/tests/ui/unseparated_prefix_literals.fixed index f0c2ba7ccdfa..125120872670 100644 --- a/tests/ui/unseparated_prefix_literals.fixed +++ b/tests/ui/unseparated_prefix_literals.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:proc_macro_derive.rs +//@run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro #![warn(clippy::unseparated_literal_suffix)] #![allow(dead_code)] diff --git a/tests/ui/unseparated_prefix_literals.rs b/tests/ui/unseparated_prefix_literals.rs index f44880b41475..0a3ffc4784b2 100644 --- a/tests/ui/unseparated_prefix_literals.rs +++ b/tests/ui/unseparated_prefix_literals.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:proc_macro_derive.rs +//@run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro #![warn(clippy::unseparated_literal_suffix)] #![allow(dead_code)] diff --git a/tests/ui/unseparated_prefix_literals.stderr b/tests/ui/unseparated_prefix_literals.stderr index ab2f75e0c56d..1729f85c2cd8 100644 --- a/tests/ui/unseparated_prefix_literals.stderr +++ b/tests/ui/unseparated_prefix_literals.stderr @@ -1,48 +1,52 @@ -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:24:18 | LL | let _fail1 = 1234i32; | ^^^^^^^ help: add an underscore: `1234_i32` | - = note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unseparated_prefix_literals.rs:4:9 + | +LL | #![warn(clippy::unseparated_literal_suffix)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:25:18 | LL | let _fail2 = 1234u32; | ^^^^^^^ help: add an underscore: `1234_u32` -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:26:18 | LL | let _fail3 = 1234isize; | ^^^^^^^^^ help: add an underscore: `1234_isize` -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:27:18 | LL | let _fail4 = 1234usize; | ^^^^^^^^^ help: add an underscore: `1234_usize` -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:28:18 | LL | let _fail5 = 0x123isize; | ^^^^^^^^^^ help: add an underscore: `0x123_isize` -error: float type suffix should be separated by an underscore +warning: float type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:32:19 | LL | let _failf1 = 1.5f32; | ^^^^^^ help: add an underscore: `1.5_f32` -error: float type suffix should be separated by an underscore +warning: float type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:33:19 | LL | let _failf2 = 1f32; | ^^^^ help: add an underscore: `1_f32` -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:16:9 | LL | 42usize @@ -51,13 +55,13 @@ LL | 42usize LL | let _ = lit_from_macro!(); | ----------------- in this macro invocation | - = note: this error originates in the macro `lit_from_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `lit_from_macro` (in Nightly builds, run with -Z macro-backtrace for more info) -error: integer type suffix should be separated by an underscore +warning: integer type suffix should be separated by an underscore --> $DIR/unseparated_prefix_literals.rs:41:16 | LL | assert_eq!(4897u32, 32223); | ^^^^^^^ help: add an underscore: `4897_u32` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/unused_async.stderr b/tests/ui/unused_async.stderr index cff3eccbd32b..731c591798ab 100644 --- a/tests/ui/unused_async.stderr +++ b/tests/ui/unused_async.stderr @@ -1,4 +1,4 @@ -error: unused `async` for function with no await statements +warning: unused `async` for function with no await statements --> $DIR/unused_async.rs:6:1 | LL | / async fn foo() -> i32 { @@ -7,9 +7,13 @@ LL | | } | |_^ | = help: consider removing the `async` from this function - = note: `-D clippy::unused-async` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_async.rs:1:9 + | +LL | #![warn(clippy::unused_async)] + | ^^^^^^^^^^^^^^^^^^^^ -error: unused `async` for function with no await statements +warning: unused `async` for function with no await statements --> $DIR/unused_async.rs:17:5 | LL | / async fn unused(&self) -> i32 { @@ -19,5 +23,5 @@ LL | | } | = help: consider removing the `async` from this function -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unused_format_specs.fixed b/tests/ui/unused_format_specs.fixed index 2930722b42d9..5ea72b592ff7 100644 --- a/tests/ui/unused_format_specs.fixed +++ b/tests/ui/unused_format_specs.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unused_format_specs)] #![allow(unused)] diff --git a/tests/ui/unused_format_specs.rs b/tests/ui/unused_format_specs.rs index ee192a000d4b..4c4f01902efd 100644 --- a/tests/ui/unused_format_specs.rs +++ b/tests/ui/unused_format_specs.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unused_format_specs)] #![allow(unused)] diff --git a/tests/ui/unused_format_specs.stderr b/tests/ui/unused_format_specs.stderr index 7231c17e74c1..838c9f695f11 100644 --- a/tests/ui/unused_format_specs.stderr +++ b/tests/ui/unused_format_specs.stderr @@ -1,18 +1,22 @@ -error: empty precision specifier has no effect +warning: empty precision specifier has no effect --> $DIR/unused_format_specs.rs:8:17 | LL | println!("{:.}", 1.0); | ^ | = note: a precision specifier is not required to format floats - = note: `-D clippy::unused-format-specs` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_format_specs.rs:3:9 + | +LL | #![warn(clippy::unused_format_specs)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `.` | LL - println!("{:.}", 1.0); LL + println!("{}", 1.0); | -error: empty precision specifier has no effect +warning: empty precision specifier has no effect --> $DIR/unused_format_specs.rs:9:18 | LL | println!("{f:.} {f:.?}"); @@ -25,7 +29,7 @@ LL - println!("{f:.} {f:.?}"); LL + println!("{f} {f:.?}"); | -error: empty precision specifier has no effect +warning: empty precision specifier has no effect --> $DIR/unused_format_specs.rs:9:24 | LL | println!("{f:.} {f:.?}"); @@ -38,7 +42,7 @@ LL - println!("{f:.} {f:.?}"); LL + println!("{f:.} {f:?}"); | -error: empty precision specifier has no effect +warning: empty precision specifier has no effect --> $DIR/unused_format_specs.rs:11:17 | LL | println!("{:.}", 1); @@ -50,5 +54,5 @@ LL - println!("{:.}", 1); LL + println!("{}", 1); | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unused_format_specs_unfixable.stderr b/tests/ui/unused_format_specs_unfixable.stderr index 9f1890282e6a..fbfcc5c90abb 100644 --- a/tests/ui/unused_format_specs_unfixable.stderr +++ b/tests/ui/unused_format_specs_unfixable.stderr @@ -1,10 +1,14 @@ -error: format specifiers have no effect on `format_args!()` +warning: format specifiers have no effect on `format_args!()` --> $DIR/unused_format_specs_unfixable.rs:12:15 | LL | println!("{:5}.", format_args!("")); | ^^^^ | - = note: `-D clippy::unused-format-specs` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_format_specs_unfixable.rs:1:9 + | +LL | #![warn(clippy::unused_format_specs)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: for the width to apply consider using `format!()` | LL | println!("{:5}.", format!("")); @@ -15,7 +19,7 @@ LL - println!("{:5}.", format_args!("")); LL + println!("{}.", format_args!("")); | -error: format specifiers have no effect on `format_args!()` +warning: format specifiers have no effect on `format_args!()` --> $DIR/unused_format_specs_unfixable.rs:14:15 | LL | println!("{:.3}", format_args!("abcde")); @@ -31,7 +35,7 @@ LL - println!("{:.3}", format_args!("abcde")); LL + println!("{}", format_args!("abcde")); | -error: format specifiers have no effect on `format_args!()` +warning: format specifiers have no effect on `format_args!()` --> $DIR/unused_format_specs_unfixable.rs:16:15 | LL | println!("{:5}.", format_args_from_macro!()); @@ -48,7 +52,7 @@ LL - println!("{:5}.", format_args_from_macro!()); LL + println!("{}.", format_args_from_macro!()); | -error: format specifiers have no effect on `format_args!()` +warning: format specifiers have no effect on `format_args!()` --> $DIR/unused_format_specs_unfixable.rs:19:15 | LL | println!("{args:5}"); @@ -65,5 +69,5 @@ LL - println!("{args:5}"); LL + println!("{args}"); | -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 0865c5213f68..a6750cb3d54e 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -1,13 +1,17 @@ -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:9:5 | LL | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes - = note: `-D clippy::unused-io-amount` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_io_amount.rs:2:9 + | +LL | #![warn(clippy::unused_io_amount)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:11:5 | LL | s.read(&mut buf)?; @@ -15,7 +19,7 @@ LL | s.read(&mut buf)?; | = help: use `Read::read_exact` instead, or handle partial reads -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:16:5 | LL | s.write(b"test").unwrap(); @@ -23,7 +27,7 @@ LL | s.write(b"test").unwrap(); | = help: use `Write::write_all` instead, or handle partial writes -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:18:5 | LL | s.read(&mut buf).unwrap(); @@ -31,19 +35,19 @@ LL | s.read(&mut buf).unwrap(); | = help: use `Read::read_exact` instead, or handle partial reads -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:22:5 | LL | s.read_vectored(&mut [io::IoSliceMut::new(&mut [])])?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:23:5 | LL | s.write_vectored(&[io::IoSlice::new(&[])])?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:30:5 | LL | reader.read(&mut result).ok()?; @@ -51,7 +55,7 @@ LL | reader.read(&mut result).ok()?; | = help: use `Read::read_exact` instead, or handle partial reads -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:39:5 | LL | reader.read(&mut result).or_else(|err| Err(err))?; @@ -59,7 +63,7 @@ LL | reader.read(&mut result).or_else(|err| Err(err))?; | = help: use `Read::read_exact` instead, or handle partial reads -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:51:5 | LL | reader.read(&mut result).or(Err(Error::Kind))?; @@ -67,7 +71,7 @@ LL | reader.read(&mut result).or(Err(Error::Kind))?; | = help: use `Read::read_exact` instead, or handle partial reads -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:58:5 | LL | / reader @@ -79,7 +83,7 @@ LL | | .expect("error"); | = help: use `Read::read_exact` instead, or handle partial reads -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:67:5 | LL | s.write(b"ok").is_ok(); @@ -87,7 +91,7 @@ LL | s.write(b"ok").is_ok(); | = help: use `Write::write_all` instead, or handle partial writes -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:68:5 | LL | s.write(b"err").is_err(); @@ -95,7 +99,7 @@ LL | s.write(b"err").is_err(); | = help: use `Write::write_all` instead, or handle partial writes -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:70:5 | LL | s.read(&mut buf).is_ok(); @@ -103,7 +107,7 @@ LL | s.read(&mut buf).is_ok(); | = help: use `Read::read_exact` instead, or handle partial reads -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:71:5 | LL | s.read(&mut buf).is_err(); @@ -111,7 +115,7 @@ LL | s.read(&mut buf).is_err(); | = help: use `Read::read_exact` instead, or handle partial reads -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:75:5 | LL | w.write(b"hello world").await.unwrap(); @@ -119,7 +123,7 @@ LL | w.write(b"hello world").await.unwrap(); | = help: use `AsyncWriteExt::write_all` instead, or handle partial writes -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:80:5 | LL | r.read(&mut buf[..]).await.unwrap(); @@ -127,7 +131,7 @@ LL | r.read(&mut buf[..]).await.unwrap(); | = help: use `AsyncReadExt::read_exact` instead, or handle partial reads -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:93:9 | LL | w.write(b"hello world").await?; @@ -135,7 +139,7 @@ LL | w.write(b"hello world").await?; | = help: use `AsyncWriteExt::write_all` instead, or handle partial writes -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:101:9 | LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?; @@ -143,7 +147,7 @@ LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?; | = help: use `AsyncReadExt::read_exact` instead, or handle partial reads -error: written amount is not handled +warning: written amount is not handled --> $DIR/unused_io_amount.rs:109:5 | LL | w.write(b"hello world").await.unwrap(); @@ -151,7 +155,7 @@ LL | w.write(b"hello world").await.unwrap(); | = help: use `AsyncWriteExt::write_all` instead, or handle partial writes -error: read amount is not handled +warning: read amount is not handled --> $DIR/unused_io_amount.rs:114:5 | LL | r.read(&mut buf[..]).await.unwrap(); @@ -159,5 +163,5 @@ LL | r.read(&mut buf[..]).await.unwrap(); | = help: use `AsyncReadExt::read_exact` instead, or handle partial reads -error: aborting due to 20 previous errors +warning: 20 warnings emitted diff --git a/tests/ui/unused_peekable.stderr b/tests/ui/unused_peekable.stderr index 54788f2fa2f4..3fec9119dfc3 100644 --- a/tests/ui/unused_peekable.stderr +++ b/tests/ui/unused_peekable.stderr @@ -1,13 +1,17 @@ -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:14:9 | LL | let peekable = std::iter::empty::().peekable(); | ^^^^^^^^ | = help: consider removing the call to `peekable` - = note: `-D clippy::unused-peekable` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_peekable.rs:1:9 + | +LL | #![warn(clippy::unused_peekable)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:18:9 | LL | let new_local = old_local; @@ -15,7 +19,7 @@ LL | let new_local = old_local; | = help: consider removing the call to `peekable` -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:22:9 | LL | let by_mut_ref = &mut by_mut_ref_test; @@ -23,7 +27,7 @@ LL | let by_mut_ref = &mut by_mut_ref_test; | = help: consider removing the call to `peekable` -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:29:9 | LL | let peekable_from_fn = returns_peekable(); @@ -31,7 +35,7 @@ LL | let peekable_from_fn = returns_peekable(); | = help: consider removing the call to `peekable` -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:32:13 | LL | let mut peekable_using_iterator_method = std::iter::empty::().peekable(); @@ -39,7 +43,7 @@ LL | let mut peekable_using_iterator_method = std::iter::empty::().peek | = help: consider removing the call to `peekable` -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:37:9 | LL | let passed_along_ref = std::iter::empty::().peekable(); @@ -47,7 +51,7 @@ LL | let passed_along_ref = std::iter::empty::().peekable(); | = help: consider removing the call to `peekable` -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:42:9 | LL | let _by_ref = by_ref_test.by_ref(); @@ -55,7 +59,7 @@ LL | let _by_ref = by_ref_test.by_ref(); | = help: consider removing the call to `peekable` -error: `peek` never called on `Peekable` iterator +warning: `peek` never called on `Peekable` iterator --> $DIR/unused_peekable.rs:44:13 | LL | let mut peekable_in_for_loop = std::iter::empty::().peekable(); @@ -63,5 +67,5 @@ LL | let mut peekable_in_for_loop = std::iter::empty::().peekable(); | = help: consider removing the call to `peekable` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/unused_rounding.fixed b/tests/ui/unused_rounding.fixed index f6f734c05ed5..f02b55502a06 100644 --- a/tests/ui/unused_rounding.fixed +++ b/tests/ui/unused_rounding.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unused_rounding)] fn main() { diff --git a/tests/ui/unused_rounding.rs b/tests/ui/unused_rounding.rs index a0267d8144aa..c7bd4906d0b7 100644 --- a/tests/ui/unused_rounding.rs +++ b/tests/ui/unused_rounding.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unused_rounding)] fn main() { diff --git a/tests/ui/unused_rounding.stderr b/tests/ui/unused_rounding.stderr index b867996fe576..f2bee65b83e3 100644 --- a/tests/ui/unused_rounding.stderr +++ b/tests/ui/unused_rounding.stderr @@ -1,34 +1,38 @@ -error: used the `ceil` method with a whole number float +warning: used the `ceil` method with a whole number float --> $DIR/unused_rounding.rs:5:13 | LL | let _ = 1f32.ceil(); | ^^^^^^^^^^^ help: remove the `ceil` method call: `1f32` | - = note: `-D clippy::unused-rounding` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_rounding.rs:2:9 + | +LL | #![warn(clippy::unused_rounding)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: used the `floor` method with a whole number float +warning: used the `floor` method with a whole number float --> $DIR/unused_rounding.rs:6:13 | LL | let _ = 1.0f64.floor(); | ^^^^^^^^^^^^^^ help: remove the `floor` method call: `1.0f64` -error: used the `round` method with a whole number float +warning: used the `round` method with a whole number float --> $DIR/unused_rounding.rs:7:13 | LL | let _ = 1.00f32.round(); | ^^^^^^^^^^^^^^^ help: remove the `round` method call: `1.00f32` -error: used the `round` method with a whole number float +warning: used the `round` method with a whole number float --> $DIR/unused_rounding.rs:13:13 | LL | let _ = 3.0_f32.round(); | ^^^^^^^^^^^^^^^ help: remove the `round` method call: `3.0_f32` -error: used the `round` method with a whole number float +warning: used the `round` method with a whole number float --> $DIR/unused_rounding.rs:15:13 | LL | let _ = 3_3.0_0_f32.round(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `round` method call: `3_3.0_0_f32` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/unused_self.stderr b/tests/ui/unused_self.stderr index 919f9b6efdab..562ed6ac95d0 100644 --- a/tests/ui/unused_self.stderr +++ b/tests/ui/unused_self.stderr @@ -1,13 +1,17 @@ -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:11:29 | LL | fn unused_self_move(self) {} | ^^^^ | = help: consider refactoring to an associated function - = note: `-D clippy::unused-self` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unused_self.rs:1:9 + | +LL | #![warn(clippy::unused_self)] + | ^^^^^^^^^^^^^^^^^^^ -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:12:28 | LL | fn unused_self_ref(&self) {} @@ -15,7 +19,7 @@ LL | fn unused_self_ref(&self) {} | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:13:32 | LL | fn unused_self_mut_ref(&mut self) {} @@ -23,7 +27,7 @@ LL | fn unused_self_mut_ref(&mut self) {} | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:14:32 | LL | fn unused_self_pin_ref(self: Pin<&Self>) {} @@ -31,7 +35,7 @@ LL | fn unused_self_pin_ref(self: Pin<&Self>) {} | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:15:36 | LL | fn unused_self_pin_mut_ref(self: Pin<&mut Self>) {} @@ -39,7 +43,7 @@ LL | fn unused_self_pin_mut_ref(self: Pin<&mut Self>) {} | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:16:35 | LL | fn unused_self_pin_nested(self: Pin>) {} @@ -47,7 +51,7 @@ LL | fn unused_self_pin_nested(self: Pin>) {} | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:17:28 | LL | fn unused_self_box(self: Box) {} @@ -55,7 +59,7 @@ LL | fn unused_self_box(self: Box) {} | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:18:40 | LL | fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { @@ -63,7 +67,7 @@ LL | fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { | = help: consider refactoring to an associated function -error: unused `self` argument +warning: unused `self` argument --> $DIR/unused_self.rs:21:37 | LL | fn unused_self_class_method(&self) { @@ -71,5 +75,5 @@ LL | fn unused_self_class_method(&self) { | = help: consider refactoring to an associated function -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/unused_unit.fixed b/tests/ui/unused_unit.fixed index 3dd640b86f0b..d55026ec449a 100644 --- a/tests/ui/unused_unit.fixed +++ b/tests/ui/unused_unit.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // The output for humans should just highlight the whole span without showing // the suggested replacement, but we also want to test that suggested @@ -10,7 +10,7 @@ #![feature(closure_lifetime_binder)] #![rustfmt::skip] -#![deny(clippy::unused_unit)] +#![warn(clippy::unused_unit)] #![allow(dead_code)] #![allow(clippy::from_over_into)] diff --git a/tests/ui/unused_unit.rs b/tests/ui/unused_unit.rs index bddecf06fb76..f686aa96a5c0 100644 --- a/tests/ui/unused_unit.rs +++ b/tests/ui/unused_unit.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix // The output for humans should just highlight the whole span without showing // the suggested replacement, but we also want to test that suggested @@ -10,7 +10,7 @@ #![feature(closure_lifetime_binder)] #![rustfmt::skip] -#![deny(clippy::unused_unit)] +#![warn(clippy::unused_unit)] #![allow(dead_code)] #![allow(clippy::from_over_into)] diff --git a/tests/ui/unused_unit.stderr b/tests/ui/unused_unit.stderr index ce06738cfe47..74b1054fded5 100644 --- a/tests/ui/unused_unit.stderr +++ b/tests/ui/unused_unit.stderr @@ -1,4 +1,4 @@ -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:20:58 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () @@ -7,116 +7,116 @@ LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () note: the lint level is defined here --> $DIR/unused_unit.rs:13:9 | -LL | #![deny(clippy::unused_unit)] +LL | #![warn(clippy::unused_unit)] | ^^^^^^^^^^^^^^^^^^^ -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:20:28 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:21:18 | LL | where G: Fn() -> () { | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:22:26 | LL | let _y: &dyn Fn() -> () = &f; | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:29:18 | LL | fn into(self) -> () { | ^^^^^^ help: remove the `-> ()` -error: unneeded unit expression +warning: unneeded unit expression --> $DIR/unused_unit.rs:30:9 | LL | () | ^^ help: remove the final `()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:35:29 | LL | fn redundant (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:37:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:38:16 | LL | H: Fn() -> (); | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:42:29 | LL | fn redundant (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:44:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:45:16 | LL | H: Fn() -> () {} | ^^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:48:17 | LL | fn return_unit() -> () { () } | ^^^^^^ help: remove the `-> ()` -error: unneeded unit expression +warning: unneeded unit expression --> $DIR/unused_unit.rs:48:26 | LL | fn return_unit() -> () { () } | ^^ help: remove the final `()` -error: unneeded `()` +warning: unneeded `()` --> $DIR/unused_unit.rs:58:14 | LL | break(); | ^^ help: remove the `()` -error: unneeded `()` +warning: unneeded `()` --> $DIR/unused_unit.rs:60:11 | LL | return(); | ^^ help: remove the `()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:77:10 | LL | fn test()->(){} | ^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:80:11 | LL | fn test2() ->(){} | ^^^^^ help: remove the `-> ()` -error: unneeded unit return type +warning: unneeded unit return type --> $DIR/unused_unit.rs:83:11 | LL | fn test3()-> (){} | ^^^^^ help: remove the `-> ()` -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/unwrap.stderr b/tests/ui/unwrap.stderr index d49bf2b32283..7e0d1888a1cb 100644 --- a/tests/ui/unwrap.stderr +++ b/tests/ui/unwrap.stderr @@ -1,13 +1,17 @@ -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap.rs:5:13 | LL | let _ = opt.unwrap(); | ^^^^^^^^^^^^ | = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message - = note: `-D clippy::unwrap-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap.rs:1:9 + | +LL | #![warn(clippy::unwrap_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: used `unwrap()` on a `Result` value +warning: used `unwrap()` on a `Result` value --> $DIR/unwrap.rs:10:13 | LL | let _ = res.unwrap(); @@ -15,7 +19,7 @@ LL | let _ = res.unwrap(); | = help: if you don't want to handle the `Err` case gracefully, consider using `expect()` to provide a better panic message -error: used `unwrap_err()` on a `Result` value +warning: used `unwrap_err()` on a `Result` value --> $DIR/unwrap.rs:11:13 | LL | let _ = res.unwrap_err(); @@ -23,5 +27,5 @@ LL | let _ = res.unwrap_err(); | = help: if you don't want to handle the `Ok` case gracefully, consider using `expect_err()` to provide a better panic message -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/unwrap_expect_used.stderr b/tests/ui/unwrap_expect_used.stderr index fe4ecef11453..9ae8e6b2f8dc 100644 --- a/tests/ui/unwrap_expect_used.stderr +++ b/tests/ui/unwrap_expect_used.stderr @@ -1,22 +1,30 @@ -error: used `unwrap()` on an `Option` value +warning: used `unwrap()` on an `Option` value --> $DIR/unwrap_expect_used.rs:23:5 | LL | Some(3).unwrap(); | ^^^^^^^^^^^^^^^^ | = help: if this value is `None`, it will panic - = note: `-D clippy::unwrap-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap_expect_used.rs:1:9 + | +LL | #![warn(clippy::unwrap_used, clippy::expect_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: used `expect()` on an `Option` value +warning: used `expect()` on an `Option` value --> $DIR/unwrap_expect_used.rs:24:5 | LL | Some(3).expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: if this value is `None`, it will panic - = note: `-D clippy::expect-used` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap_expect_used.rs:1:30 + | +LL | #![warn(clippy::unwrap_used, clippy::expect_used)] + | ^^^^^^^^^^^^^^^^^^^ -error: used `unwrap()` on a `Result` value +warning: used `unwrap()` on a `Result` value --> $DIR/unwrap_expect_used.rs:31:5 | LL | a.unwrap(); @@ -24,7 +32,7 @@ LL | a.unwrap(); | = help: if this value is an `Err`, it will panic -error: used `expect()` on a `Result` value +warning: used `expect()` on a `Result` value --> $DIR/unwrap_expect_used.rs:32:5 | LL | a.expect("Hello world!"); @@ -32,7 +40,7 @@ LL | a.expect("Hello world!"); | = help: if this value is an `Err`, it will panic -error: used `unwrap_err()` on a `Result` value +warning: used `unwrap_err()` on a `Result` value --> $DIR/unwrap_expect_used.rs:33:5 | LL | a.unwrap_err(); @@ -40,7 +48,7 @@ LL | a.unwrap_err(); | = help: if this value is an `Ok`, it will panic -error: used `expect_err()` on a `Result` value +warning: used `expect_err()` on a `Result` value --> $DIR/unwrap_expect_used.rs:34:5 | LL | a.expect_err("Hello error!"); @@ -48,5 +56,5 @@ LL | a.expect_err("Hello error!"); | = help: if this value is an `Ok`, it will panic -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/unwrap_in_result.stderr b/tests/ui/unwrap_in_result.stderr index 40e6bfe087e7..965789b9522d 100644 --- a/tests/ui/unwrap_in_result.stderr +++ b/tests/ui/unwrap_in_result.stderr @@ -1,4 +1,4 @@ -error: used unwrap or expect in a function that returns result or option +warning: used unwrap or expect in a function that returns result or option --> $DIR/unwrap_in_result.rs:22:5 | LL | / fn bad_divisible_by_3(i_str: String) -> Result { @@ -16,9 +16,13 @@ note: potential non-recoverable error(s) | LL | let i = i_str.parse::().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: `-D clippy::unwrap-in-result` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap_in_result.rs:1:9 + | +LL | #![warn(clippy::unwrap_in_result)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: used unwrap or expect in a function that returns result or option +warning: used unwrap or expect in a function that returns result or option --> $DIR/unwrap_in_result.rs:32:5 | LL | / fn example_option_expect(i_str: String) -> Option { @@ -37,5 +41,5 @@ note: potential non-recoverable error(s) LL | let i = i_str.parse::().expect("not a number"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index c3a7464fd470..56e7992d27cc 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,16 +1,20 @@ -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/unwrap_or.rs:4:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` | - = note: `-D clippy::or-fun-call` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap_or.rs:1:22 + | +LL | #![warn(clippy::all, clippy::or_fun_call)] + | ^^^^^^^^^^^^^^^^^^^ -error: use of `unwrap_or` followed by a function call +warning: use of `unwrap_or` followed by a function call --> $DIR/unwrap_or.rs:8:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/unwrap_or_else_default.fixed b/tests/ui/unwrap_or_else_default.fixed index 84f779569ff9..59a0ca3f192f 100644 --- a/tests/ui/unwrap_or_else_default.fixed +++ b/tests/ui/unwrap_or_else_default.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unwrap_or_else_default)] #![allow(dead_code)] diff --git a/tests/ui/unwrap_or_else_default.rs b/tests/ui/unwrap_or_else_default.rs index 1735bd5808e5..97cafa336eda 100644 --- a/tests/ui/unwrap_or_else_default.rs +++ b/tests/ui/unwrap_or_else_default.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::unwrap_or_else_default)] #![allow(dead_code)] diff --git a/tests/ui/unwrap_or_else_default.stderr b/tests/ui/unwrap_or_else_default.stderr index d2b9212223f7..d76a55ceda5e 100644 --- a/tests/ui/unwrap_or_else_default.stderr +++ b/tests/ui/unwrap_or_else_default.stderr @@ -1,40 +1,44 @@ -error: use of `.unwrap_or_else(..)` to construct default value +warning: use of `.unwrap_or_else(..)` to construct default value --> $DIR/unwrap_or_else_default.rs:48:5 | LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_new.unwrap_or_default()` | - = note: `-D clippy::unwrap-or-else-default` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/unwrap_or_else_default.rs:3:9 + | +LL | #![warn(clippy::unwrap_or_else_default)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `.unwrap_or_else(..)` to construct default value +warning: use of `.unwrap_or_else(..)` to construct default value --> $DIR/unwrap_or_else_default.rs:62:5 | LL | with_real_default.unwrap_or_else(::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_real_default.unwrap_or_default()` -error: use of `.unwrap_or_else(..)` to construct default value +warning: use of `.unwrap_or_else(..)` to construct default value --> $DIR/unwrap_or_else_default.rs:65:5 | LL | with_default_trait.unwrap_or_else(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_default_trait.unwrap_or_default()` -error: use of `.unwrap_or_else(..)` to construct default value +warning: use of `.unwrap_or_else(..)` to construct default value --> $DIR/unwrap_or_else_default.rs:68:5 | LL | with_default_type.unwrap_or_else(u64::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_default_type.unwrap_or_default()` -error: use of `.unwrap_or_else(..)` to construct default value +warning: use of `.unwrap_or_else(..)` to construct default value --> $DIR/unwrap_or_else_default.rs:71:5 | LL | with_default_type.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `with_default_type.unwrap_or_default()` -error: use of `.unwrap_or_else(..)` to construct default value +warning: use of `.unwrap_or_else(..)` to construct default value --> $DIR/unwrap_or_else_default.rs:74:5 | LL | empty_string.unwrap_or_else(|| "".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `empty_string.unwrap_or_default()` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/upper_case_acronyms.stderr b/tests/ui/upper_case_acronyms.stderr index 74082ec16dd4..db02a79f18d6 100644 --- a/tests/ui/upper_case_acronyms.stderr +++ b/tests/ui/upper_case_acronyms.stderr @@ -1,70 +1,74 @@ -error: name `CWR` contains a capitalized acronym +warning: name `CWR` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:9:5 | LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` | - = note: `-D clippy::upper-case-acronyms` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/upper_case_acronyms.rs:1:9 + | +LL | #![warn(clippy::upper_case_acronyms)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: name `ECE` contains a capitalized acronym +warning: name `ECE` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:10:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` -error: name `URG` contains a capitalized acronym +warning: name `URG` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:11:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` -error: name `ACK` contains a capitalized acronym +warning: name `ACK` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:12:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` -error: name `PSH` contains a capitalized acronym +warning: name `PSH` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:13:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` -error: name `RST` contains a capitalized acronym +warning: name `RST` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:14:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` -error: name `SYN` contains a capitalized acronym +warning: name `SYN` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:15:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` -error: name `FIN` contains a capitalized acronym +warning: name `FIN` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:16:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` -error: name `WASD` contains a capitalized acronym +warning: name `WASD` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:36:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` -error: name `JSON` contains a capitalized acronym +warning: name `JSON` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:42:8 | LL | struct JSON; | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Json` -error: name `YAML` contains a capitalized acronym +warning: name `YAML` contains a capitalized acronym --> $DIR/upper_case_acronyms.rs:45:6 | LL | enum YAML { | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Yaml` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed index 3ac6217312a8..4179f21c5100 100644 --- a/tests/ui/use_self.fixed +++ b/tests/ui/use_self.fixed @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:proc_macro_derive.rs +//@run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro #![warn(clippy::use_self)] #![allow(dead_code, unreachable_code)] diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 9dc5d1e3f9b2..01a36def9e97 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:proc_macro_derive.rs +//@run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro #![warn(clippy::use_self)] #![allow(dead_code, unreachable_code)] diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index 48364c40c3b2..f353f17a978d 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,256 +1,260 @@ -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:22:21 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` | - = note: `-D clippy::use-self` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/use_self.rs:4:9 + | +LL | #![warn(clippy::use_self)] + | ^^^^^^^^^^^^^^^^ -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:23:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:25:22 | LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:26:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:31:25 | LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:32:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:97:24 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:97:55 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:112:13 | LL | TS(0) | ^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:147:29 | LL | fn bar() -> Bar { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:148:21 | LL | Bar { foo: Foo {} } | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:159:21 | LL | fn baz() -> Foo { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:160:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:177:21 | LL | let _ = Enum::B(42); | ^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:178:21 | LL | let _ = Enum::C { field: true }; | ^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:179:21 | LL | let _ = Enum::A; | ^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:221:13 | LL | nested::A::fun_1(); | ^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:222:13 | LL | nested::A::A; | ^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:224:13 | LL | nested::A {}; | ^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:243:13 | LL | TestStruct::from_something() | ^^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:257:25 | LL | async fn g() -> S { | ^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:258:13 | LL | S {} | ^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:262:16 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:262:22 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:285:29 | LL | fn foo(value: T) -> Foo { | ^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:286:13 | LL | Foo:: { value } | ^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:458:13 | LL | A::new::(submod::B {}) | ^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:495:13 | LL | S2::new() | ^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:532:17 | LL | Foo::Bar => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:533:17 | LL | Foo::Baz => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:539:20 | LL | if let Foo::Bar = self { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:563:17 | LL | Something::Num(n) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:564:17 | LL | Something::TupleNums(n, _m) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:565:17 | LL | Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:571:17 | LL | crate::issue8845::Something::Num(n) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:572:17 | LL | crate::issue8845::Something::TupleNums(n, _m) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:573:17 | LL | crate::issue8845::Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:589:17 | LL | let Foo(x) = self; | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:594:17 | LL | let crate::issue8845::Foo(x) = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:601:17 | LL | let Bar { x, .. } = self; | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:606:17 | LL | let crate::issue8845::Bar { x, .. } = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self.rs:645:17 | LL | E::A => {}, | ^ help: use the applicable keyword: `Self` -error: aborting due to 42 previous errors +warning: 42 warnings emitted diff --git a/tests/ui/use_self_trait.fixed b/tests/ui/use_self_trait.fixed index 4e779308d024..4623aeeb0eb2 100644 --- a/tests/ui/use_self_trait.fixed +++ b/tests/ui/use_self_trait.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::use_self)] #![allow(dead_code)] diff --git a/tests/ui/use_self_trait.rs b/tests/ui/use_self_trait.rs index 325dc73b21ea..d7d76dd96233 100644 --- a/tests/ui/use_self_trait.rs +++ b/tests/ui/use_self_trait.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::use_self)] #![allow(dead_code)] diff --git a/tests/ui/use_self_trait.stderr b/tests/ui/use_self_trait.stderr index 090729b9c3d5..cf40f04a0d7d 100644 --- a/tests/ui/use_self_trait.stderr +++ b/tests/ui/use_self_trait.stderr @@ -1,100 +1,104 @@ -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:21:18 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` | - = note: `-D clippy::use-self` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/use_self_trait.rs:3:9 + | +LL | #![warn(clippy::use_self)] + | ^^^^^^^^^^^^^^^^ -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:21:27 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:25:33 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:25:49 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:29:26 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:29:39 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:33:24 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:33:42 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:35:16 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:35:24 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:36:9 | LL | Bad::default() | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:41:19 | LL | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:43:23 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:43:31 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:50:9 | LL | Bad | ^^^ help: use the applicable keyword: `Self` -error: unnecessary structure name repetition +warning: unnecessary structure name repetition --> $DIR/use_self_trait.rs:147:13 | LL | std::fmt::Error // Should lint | ^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` -error: aborting due to 16 previous errors +warning: 16 warnings emitted diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index 8c29e15b1459..879e2e24ab34 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -1,4 +1,4 @@ -// aux-build:proc_macro_derive.rs +//@aux-build:proc_macro_derive.rs:proc-macro #![feature(rustc_private)] #![warn(clippy::all)] #![warn(clippy::used_underscore_binding)] diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 875fafe438a1..3895c486ded6 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,40 +1,44 @@ -error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used +warning: 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:5 | LL | _foo + 1 | ^^^^ | - = note: `-D clippy::used-underscore-binding` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/used_underscore_binding.rs:4:9 + | +LL | #![warn(clippy::used_underscore_binding)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used +warning: 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:29:20 | LL | println!("{}", _foo); | ^^^^ -error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used +warning: 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:30:16 | LL | 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 +warning: 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:30:22 | LL | 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 +warning: 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:43:5 | LL | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ -error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used +warning: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used --> $DIR/used_underscore_binding.rs:104:16 | LL | uses_i(_i); | ^^ -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/useless_asref.fixed b/tests/ui/useless_asref.fixed index 38e4b9201e6d..b37c71f01c4d 100644 --- a/tests/ui/useless_asref.fixed +++ b/tests/ui/useless_asref.fixed @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::useless_asref)] +//@run-rustfix +#![warn(clippy::useless_asref)] #![allow(clippy::explicit_auto_deref, clippy::uninlined_format_args)] use std::fmt::Debug; diff --git a/tests/ui/useless_asref.rs b/tests/ui/useless_asref.rs index f1e83f9d396c..7270621037cf 100644 --- a/tests/ui/useless_asref.rs +++ b/tests/ui/useless_asref.rs @@ -1,5 +1,5 @@ -// run-rustfix -#![deny(clippy::useless_asref)] +//@run-rustfix +#![warn(clippy::useless_asref)] #![allow(clippy::explicit_auto_deref, clippy::uninlined_format_args)] use std::fmt::Debug; diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 67ce8b64e0e3..f976f95ee37a 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,4 +1,4 @@ -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:43:18 | LL | foo_rstr(rstr.as_ref()); @@ -7,68 +7,68 @@ LL | foo_rstr(rstr.as_ref()); note: the lint level is defined here --> $DIR/useless_asref.rs:2:9 | -LL | #![deny(clippy::useless_asref)] +LL | #![warn(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:45:20 | LL | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try this: `rslice` -error: this call to `as_mut` does nothing +warning: this call to `as_mut` does nothing --> $DIR/useless_asref.rs:49:21 | LL | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:51:20 | LL | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:58:20 | LL | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:60:18 | LL | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` -error: this call to `as_mut` does nothing +warning: this call to `as_mut` does nothing --> $DIR/useless_asref.rs:65:21 | LL | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:67:20 | LL | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:71:16 | LL | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` -error: this call to `as_mut` does nothing +warning: this call to `as_mut` does nothing --> $DIR/useless_asref.rs:121:13 | LL | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try this: `mrt` -error: this call to `as_ref` does nothing +warning: this call to `as_ref` does nothing --> $DIR/useless_asref.rs:123:12 | LL | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try this: `mrt` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/useless_attribute.fixed b/tests/ui/useless_attribute.fixed index 871e4fb5c3a9..27498d9bc132 100644 --- a/tests/ui/useless_attribute.fixed +++ b/tests/ui/useless_attribute.fixed @@ -1,13 +1,13 @@ -// run-rustfix -// aux-build:proc_macro_derive.rs +//@run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro #![allow(unused)] #![warn(clippy::useless_attribute)] #![warn(unreachable_pub)] #![feature(rustc_private)] -#![allow(dead_code)] -#![cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#[allow(dead_code)] +#[cfg_attr(feature = "cargo-clippy", allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] @@ -18,7 +18,7 @@ extern crate rustc_middle; extern crate proc_macro_derive; fn test_indented_attr() { - #![allow(clippy::almost_swapped)] + #[allow(clippy::almost_swapped)] use std::collections::HashSet; let _ = HashSet::::default(); diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index cb50736ba395..27498d9bc132 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -1,5 +1,5 @@ -// run-rustfix -// aux-build:proc_macro_derive.rs +//@run-rustfix +//@aux-build:proc_macro_derive.rs:proc-macro #![allow(unused)] #![warn(clippy::useless_attribute)] diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index a7ea0df22945..83cb90c9fc8e 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,22 +1,26 @@ -error: useless lint attribute +warning: useless lint attribute --> $DIR/useless_attribute.rs:9:1 | LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` | - = note: `-D clippy::useless-attribute` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/useless_attribute.rs:5:9 + | +LL | #![warn(clippy::useless_attribute)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: useless lint attribute +warning: useless lint attribute --> $DIR/useless_attribute.rs:10:1 | LL | #[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 +warning: useless lint attribute --> $DIR/useless_attribute.rs:21:5 | LL | #[allow(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/useless_conversion.fixed b/tests/ui/useless_conversion.fixed index 94b206d8e58f..fcdfdcb3f65f 100644 --- a/tests/ui/useless_conversion.fixed +++ b/tests/ui/useless_conversion.fixed @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::useless_conversion)] +#![warn(clippy::useless_conversion)] #![allow(clippy::unnecessary_wraps)] fn test_generic(val: T) -> T { diff --git a/tests/ui/useless_conversion.rs b/tests/ui/useless_conversion.rs index c7ae927941bf..251c4d7bc527 100644 --- a/tests/ui/useless_conversion.rs +++ b/tests/ui/useless_conversion.rs @@ -1,6 +1,6 @@ -// run-rustfix +//@run-rustfix -#![deny(clippy::useless_conversion)] +#![warn(clippy::useless_conversion)] #![allow(clippy::unnecessary_wraps)] fn test_generic(val: T) -> T { diff --git a/tests/ui/useless_conversion.stderr b/tests/ui/useless_conversion.stderr index be067c6843ac..6f90a383be5f 100644 --- a/tests/ui/useless_conversion.stderr +++ b/tests/ui/useless_conversion.stderr @@ -1,4 +1,4 @@ -error: useless conversion to the same type: `T` +warning: useless conversion to the same type: `T` --> $DIR/useless_conversion.rs:7:13 | LL | let _ = T::from(val); @@ -7,116 +7,116 @@ LL | let _ = T::from(val); note: the lint level is defined here --> $DIR/useless_conversion.rs:3:9 | -LL | #![deny(clippy::useless_conversion)] +LL | #![warn(clippy::useless_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: useless conversion to the same type: `T` +warning: useless conversion to the same type: `T` --> $DIR/useless_conversion.rs:8:5 | LL | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` -error: useless conversion to the same type: `i32` +warning: useless conversion to the same type: `i32` --> $DIR/useless_conversion.rs:20:22 | LL | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` -error: useless conversion to the same type: `std::str::Lines<'_>` +warning: useless conversion to the same type: `std::str::Lines<'_>` --> $DIR/useless_conversion.rs:45:22 | LL | if Some("ok") == lines.into_iter().next() {} | ^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `lines` -error: useless conversion to the same type: `std::str::Lines<'_>` +warning: useless conversion to the same type: `std::str::Lines<'_>` --> $DIR/useless_conversion.rs:50:21 | LL | let mut lines = text.lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `text.lines()` -error: useless conversion to the same type: `std::str::Lines<'_>` +warning: useless conversion to the same type: `std::str::Lines<'_>` --> $DIR/useless_conversion.rs:56:22 | LL | if Some("ok") == text.lines().into_iter().next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `text.lines()` -error: useless conversion to the same type: `std::ops::Range` +warning: useless conversion to the same type: `std::ops::Range` --> $DIR/useless_conversion.rs:62:13 | LL | let _ = NUMBERS.into_iter().next(); | ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS` -error: useless conversion to the same type: `std::ops::Range` +warning: useless conversion to the same type: `std::ops::Range` --> $DIR/useless_conversion.rs:67:17 | LL | let mut n = NUMBERS.into_iter(); | ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion.rs:128:21 | LL | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion.rs:129:21 | LL | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion.rs:130:13 | LL | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion.rs:131:13 | LL | let _ = String::from(format!("A: {:04}", 123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` -error: useless conversion to the same type: `std::str::Lines<'_>` +warning: useless conversion to the same type: `std::str::Lines<'_>` --> $DIR/useless_conversion.rs:132:13 | LL | let _ = "".lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` -error: useless conversion to the same type: `std::vec::IntoIter` +warning: useless conversion to the same type: `std::vec::IntoIter` --> $DIR/useless_conversion.rs:133:13 | LL | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion.rs:134:21 | LL | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` -error: useless conversion to the same type: `i32` +warning: useless conversion to the same type: `i32` --> $DIR/useless_conversion.rs:139:13 | LL | let _ = i32::from(a + b) * 3; | ^^^^^^^^^^^^^^^^ help: consider removing `i32::from()`: `(a + b)` -error: useless conversion to the same type: `Foo<'a'>` +warning: useless conversion to the same type: `Foo<'a'>` --> $DIR/useless_conversion.rs:145:23 | LL | let _: Foo<'a'> = s2.into(); | ^^^^^^^^^ help: consider removing `.into()`: `s2` -error: useless conversion to the same type: `Foo<'a'>` +warning: useless conversion to the same type: `Foo<'a'>` --> $DIR/useless_conversion.rs:147:13 | LL | let _ = Foo::<'a'>::from(s3); | ^^^^^^^^^^^^^^^^^^^^ help: consider removing `Foo::<'a'>::from()`: `s3` -error: useless conversion to the same type: `std::vec::IntoIter>` +warning: useless conversion to the same type: `std::vec::IntoIter>` --> $DIR/useless_conversion.rs:149:13 | LL | let _ = vec![s4, s4, s4].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![s4, s4, s4].into_iter()` -error: aborting due to 19 previous errors +warning: 19 warnings emitted diff --git a/tests/ui/useless_conversion_try.rs b/tests/ui/useless_conversion_try.rs index 4acf5b5fa2d1..07c48a8e59d3 100644 --- a/tests/ui/useless_conversion_try.rs +++ b/tests/ui/useless_conversion_try.rs @@ -1,4 +1,4 @@ -#![deny(clippy::useless_conversion)] +#![warn(clippy::useless_conversion)] fn test_generic(val: T) -> T { let _ = T::try_from(val).unwrap(); diff --git a/tests/ui/useless_conversion_try.stderr b/tests/ui/useless_conversion_try.stderr index 9aef9dda6f68..9f70f4190cd1 100644 --- a/tests/ui/useless_conversion_try.stderr +++ b/tests/ui/useless_conversion_try.stderr @@ -1,4 +1,4 @@ -error: useless conversion to the same type: `T` +warning: useless conversion to the same type: `T` --> $DIR/useless_conversion_try.rs:4:13 | LL | let _ = T::try_from(val).unwrap(); @@ -8,10 +8,10 @@ LL | let _ = T::try_from(val).unwrap(); note: the lint level is defined here --> $DIR/useless_conversion_try.rs:1:9 | -LL | #![deny(clippy::useless_conversion)] +LL | #![warn(clippy::useless_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: useless conversion to the same type: `T` +warning: useless conversion to the same type: `T` --> $DIR/useless_conversion_try.rs:5:5 | LL | val.try_into().unwrap() @@ -19,7 +19,7 @@ LL | val.try_into().unwrap() | = help: consider removing `.try_into()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:27:21 | LL | let _: String = "foo".to_string().try_into().unwrap(); @@ -27,7 +27,7 @@ LL | let _: String = "foo".to_string().try_into().unwrap(); | = help: consider removing `.try_into()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:28:21 | LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); @@ -35,7 +35,7 @@ LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); | = help: consider removing `TryFrom::try_from()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:29:13 | LL | let _ = String::try_from("foo".to_string()).unwrap(); @@ -43,7 +43,7 @@ LL | let _ = String::try_from("foo".to_string()).unwrap(); | = help: consider removing `String::try_from()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:30:13 | LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); @@ -51,7 +51,7 @@ LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); | = help: consider removing `String::try_from()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:31:21 | LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); @@ -59,7 +59,7 @@ LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); | = help: consider removing `.try_into()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:32:21 | LL | let _: String = String::new().try_into().unwrap(); @@ -67,7 +67,7 @@ LL | let _: String = String::new().try_into().unwrap(); | = help: consider removing `.try_into()` -error: useless conversion to the same type: `std::string::String` +warning: useless conversion to the same type: `std::string::String` --> $DIR/useless_conversion_try.rs:33:27 | LL | let _: String = match String::from("_").try_into() { @@ -75,5 +75,5 @@ LL | let _: String = match String::from("_").try_into() { | = help: consider removing `.try_into()` -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/vec.fixed b/tests/ui/vec.fixed index 2518d8049150..d77a4dd8e0b0 100644 --- a/tests/ui/vec.fixed +++ b/tests/ui/vec.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::useless_vec)] #![allow(clippy::nonstandard_macro_braces, clippy::uninlined_format_args)] diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index e1492e2f3aef..dfed3a29a03e 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::useless_vec)] #![allow(clippy::nonstandard_macro_braces, clippy::uninlined_format_args)] diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index 7d1de05a5c83..262012891069 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,70 +1,74 @@ -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:28:14 | LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` | - = note: `-D clippy::useless-vec` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/vec.rs:2:9 + | +LL | #![warn(clippy::useless_vec)] + | ^^^^^^^^^^^^^^^^^^^ -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:30:18 | LL | on_mut_slice(&mut vec![]); | ^^^^^^^^^^^ help: you can use a slice directly: `&mut []` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:32:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:34:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:36:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:38:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:40:14 | LL | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:42:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:44:14 | LL | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:46:18 | LL | on_mut_slice(&mut vec![1; 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1; 2]` -error: useless use of `vec!` +warning: useless use of `vec!` --> $DIR/vec.rs:63:14 | LL | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` -error: aborting due to 11 previous errors +warning: 11 warnings emitted diff --git a/tests/ui/vec_box_sized.fixed b/tests/ui/vec_box_sized.fixed index a40d91fdb18a..0d0f710b558b 100644 --- a/tests/ui/vec_box_sized.fixed +++ b/tests/ui/vec_box_sized.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] diff --git a/tests/ui/vec_box_sized.rs b/tests/ui/vec_box_sized.rs index 843bbb64e719..fd3a7543ee1a 100644 --- a/tests/ui/vec_box_sized.rs +++ b/tests/ui/vec_box_sized.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(dead_code)] diff --git a/tests/ui/vec_box_sized.stderr b/tests/ui/vec_box_sized.stderr index c518267f0418..29e953c7d088 100644 --- a/tests/ui/vec_box_sized.stderr +++ b/tests/ui/vec_box_sized.stderr @@ -1,40 +1,40 @@ -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:12:14 | LL | const C: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` | - = note: `-D clippy::vec-box` implied by `-D warnings` + = note: `#[warn(clippy::vec_box)]` on by default -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:13:15 | LL | static S: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:16:21 | LL | sized_type: Vec>, | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:19:14 | LL | struct A(Vec>); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:20:18 | LL | struct B(Vec>>); | ^^^^^^^^^^^^^^^ help: try: `Vec` -error: `Vec` is already on the heap, the boxing is unnecessary +warning: `Vec` is already on the heap, the boxing is unnecessary --> $DIR/vec_box_sized.rs:48:23 | LL | pub fn f() -> Vec> { | ^^^^^^^^^^^ help: try: `Vec` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/vec_init_then_push.stderr b/tests/ui/vec_init_then_push.stderr index a9da1c520197..3b40d7a026e8 100644 --- a/tests/ui/vec_init_then_push.stderr +++ b/tests/ui/vec_init_then_push.stderr @@ -1,20 +1,24 @@ -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:5:5 | LL | / let mut def_err: Vec = Default::default(); LL | | def_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `let def_err: Vec = vec![..];` | - = note: `-D clippy::vec-init-then-push` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/vec_init_then_push.rs:2:9 + | +LL | #![warn(clippy::vec_init_then_push)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:8:5 | LL | / let mut new_err = Vec::::new(); LL | | new_err.push(1); | |____________________^ help: consider using the `vec![]` macro: `let mut new_err = vec![..];` -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:11:5 | LL | / let mut cap_err = Vec::with_capacity(2); @@ -23,14 +27,14 @@ LL | | cap_err.push(1); LL | | cap_err.push(2); | |____________________^ help: consider using the `vec![]` macro: `let mut cap_err = vec![..];` -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:23:5 | LL | / new_err = Vec::new(); LL | | new_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `new_err = vec![..];` -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:73:5 | LL | / let mut v = Vec::new(); @@ -38,7 +42,7 @@ LL | | v.push(x); LL | | v.push(1); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:81:5 | LL | / let mut v = Vec::new(); @@ -50,7 +54,7 @@ LL | | v.push(1); LL | | v.push(0); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:94:5 | LL | / let mut v2 = Vec::new(); @@ -62,12 +66,12 @@ LL | | v2.push(1); LL | | v2.push(0); | |_______________^ help: consider using the `vec![]` macro: `let mut v2 = vec![..];` -error: calls to `push` immediately after creation +warning: calls to `push` immediately after creation --> $DIR/vec_init_then_push.rs:109:5 | LL | / let mut v = Vec::new(); LL | | v.push((0i32, 0i32)); | |_________________________^ help: consider using the `vec![]` macro: `let v = vec![..];` -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/vec_resize_to_zero.stderr b/tests/ui/vec_resize_to_zero.stderr index 8851e9f38be4..e387dbd892cc 100644 --- a/tests/ui/vec_resize_to_zero.stderr +++ b/tests/ui/vec_resize_to_zero.stderr @@ -1,4 +1,4 @@ -error: emptying a vector with `resize` +warning: emptying a vector with `resize` --> $DIR/vec_resize_to_zero.rs:7:5 | LL | v.resize(0, 5); @@ -7,7 +7,11 @@ LL | v.resize(0, 5); | help: ...or you can empty the vector with: `clear()` | = help: the arguments may be inverted... - = note: `-D clippy::vec-resize-to-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/vec_resize_to_zero.rs:1:9 + | +LL | #![warn(clippy::vec_resize_to_zero)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +warning: 1 warning emitted diff --git a/tests/ui/verbose_file_reads.stderr b/tests/ui/verbose_file_reads.stderr index 44266c7c01f3..3ce1d7776ea7 100644 --- a/tests/ui/verbose_file_reads.stderr +++ b/tests/ui/verbose_file_reads.stderr @@ -1,13 +1,17 @@ -error: use of `File::read_to_end` +warning: use of `File::read_to_end` --> $DIR/verbose_file_reads.rs:23:5 | LL | f.read_to_end(&mut buffer)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider using `fs::read` instead - = note: `-D clippy::verbose-file-reads` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/verbose_file_reads.rs:1:9 + | +LL | #![warn(clippy::verbose_file_reads)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: use of `File::read_to_string` +warning: use of `File::read_to_string` --> $DIR/verbose_file_reads.rs:26:5 | LL | f.read_to_string(&mut string_buffer)?; @@ -15,5 +19,5 @@ LL | f.read_to_string(&mut string_buffer)?; | = help: consider using `fs::read_to_string` instead -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/vtable_address_comparisons.stderr b/tests/ui/vtable_address_comparisons.stderr index 14748f583f0c..54a3aae856c1 100644 --- a/tests/ui/vtable_address_comparisons.stderr +++ b/tests/ui/vtable_address_comparisons.stderr @@ -1,13 +1,17 @@ -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:14:13 | LL | let _ = a == b; | ^^^^^^ | = help: consider extracting and comparing data pointers only - = note: `-D clippy::vtable-address-comparisons` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/vtable_address_comparisons.rs:6:8 + | +LL | #[warn(clippy::vtable_address_comparisons)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:15:13 | LL | let _ = a != b; @@ -15,7 +19,7 @@ LL | let _ = a != b; | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:16:13 | LL | let _ = a < b; @@ -23,7 +27,7 @@ LL | let _ = a < b; | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:17:13 | LL | let _ = a <= b; @@ -31,7 +35,7 @@ LL | let _ = a <= b; | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:18:13 | LL | let _ = a > b; @@ -39,7 +43,7 @@ LL | let _ = a > b; | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:19:13 | LL | let _ = a >= b; @@ -47,7 +51,7 @@ LL | let _ = a >= b; | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:20:5 | LL | ptr::eq(a, b); @@ -55,7 +59,7 @@ LL | ptr::eq(a, b); | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:24:5 | LL | ptr::eq(a, b); @@ -63,7 +67,7 @@ LL | ptr::eq(a, b); | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:27:5 | LL | Rc::ptr_eq(&a, &a); @@ -71,7 +75,7 @@ LL | Rc::ptr_eq(&a, &a); | = help: consider extracting and comparing data pointers only -error: comparing trait object pointers compares a non-unique vtable address +warning: comparing trait object pointers compares a non-unique vtable address --> $DIR/vtable_address_comparisons.rs:30:5 | LL | Arc::ptr_eq(&a, &a); @@ -79,5 +83,5 @@ LL | Arc::ptr_eq(&a, &a); | = help: consider extracting and comparing data pointers only -error: aborting due to 10 previous errors +warning: 10 warnings emitted diff --git a/tests/ui/while_let_loop.stderr b/tests/ui/while_let_loop.stderr index 04808c0b3ada..49bf43a888fd 100644 --- a/tests/ui/while_let_loop.stderr +++ b/tests/ui/while_let_loop.stderr @@ -1,4 +1,4 @@ -error: this loop could be written as a `while let` loop +warning: this loop could be written as a `while let` loop --> $DIR/while_let_loop.rs:6:5 | LL | / loop { @@ -10,9 +10,13 @@ LL | | } LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` | - = note: `-D clippy::while-let-loop` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/while_let_loop.rs:1:9 + | +LL | #![warn(clippy::while_let_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^ -error: this loop could be written as a `while let` loop +warning: this loop could be written as a `while let` loop --> $DIR/while_let_loop.rs:23:5 | LL | / loop { @@ -23,7 +27,7 @@ LL | | }; LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` -error: this loop could be written as a `while let` loop +warning: this loop could be written as a `while let` loop --> $DIR/while_let_loop.rs:30:5 | LL | / loop { @@ -35,7 +39,7 @@ LL | | let _str = "foo"; LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` -error: this loop could be written as a `while let` loop +warning: this loop could be written as a `while let` loop --> $DIR/while_let_loop.rs:39:5 | LL | / loop { @@ -47,7 +51,7 @@ LL | | } LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` -error: this loop could be written as a `while let` loop +warning: this loop could be written as a `while let` loop --> $DIR/while_let_loop.rs:69:5 | LL | / loop { @@ -59,5 +63,5 @@ LL | | let _ = (e, l); LL | | } | |_____^ help: try: `while let Some(word) = "".split_whitespace().next() { .. }` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/while_let_on_iterator.fixed b/tests/ui/while_let_on_iterator.fixed index 5afa0a89f82c..c2f216a8911c 100644 --- a/tests/ui/while_let_on_iterator.fixed +++ b/tests/ui/while_let_on_iterator.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::while_let_on_iterator)] #![allow(dead_code, unreachable_code, unused_mut)] #![allow( diff --git a/tests/ui/while_let_on_iterator.rs b/tests/ui/while_let_on_iterator.rs index 3de586c9d8fd..971bd5f0c4a8 100644 --- a/tests/ui/while_let_on_iterator.rs +++ b/tests/ui/while_let_on_iterator.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![warn(clippy::while_let_on_iterator)] #![allow(dead_code, unreachable_code, unused_mut)] #![allow( diff --git a/tests/ui/while_let_on_iterator.stderr b/tests/ui/while_let_on_iterator.stderr index 4d98666190d6..3995fdaff28c 100644 --- a/tests/ui/while_let_on_iterator.stderr +++ b/tests/ui/while_let_on_iterator.stderr @@ -1,160 +1,164 @@ -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:14:5 | LL | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` | - = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/while_let_on_iterator.rs:2:9 + | +LL | #![warn(clippy::while_let_on_iterator)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:19:5 | LL | while let Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:24:5 | LL | while let Some(_) = iter.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in iter` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:100:9 | LL | while let Some([..]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [..] in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:107:9 | LL | while let Some([_x]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [_x] in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:120:9 | LL | while let Some(x @ [_]) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x @ [_] in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:140:9 | LL | while let Some(_) = y.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in y` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:197:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:208:5 | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:210:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:219:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:228:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:245:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:260:13 | LL | while let Some(i) = self.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:292:13 | LL | while let Some(i) = self.0.0.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.0.0.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:321:5 | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:333:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:347:5 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:358:5 | LL | while let Some(x) = it.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.0.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:393:5 | LL | while let Some(x) = s.x.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in s.x.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:400:5 | LL | while let Some(x) = x[0].next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in x[0].by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:408:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:418:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:428:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:438:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` -error: this loop could be written as a `for` loop +warning: this loop could be written as a `for` loop --> $DIR/while_let_on_iterator.rs:448:5 | LL | while let Some(..) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in it` -error: aborting due to 26 previous errors +warning: 26 warnings emitted diff --git a/tests/ui/wild_in_or_pats.stderr b/tests/ui/wild_in_or_pats.stderr index bd5860f45ca6..33c9ff8a3b56 100644 --- a/tests/ui/wild_in_or_pats.stderr +++ b/tests/ui/wild_in_or_pats.stderr @@ -1,13 +1,17 @@ -error: wildcard pattern covers any other pattern as it will match anyway +warning: wildcard pattern covers any other pattern as it will match anyway --> $DIR/wild_in_or_pats.rs:8:9 | LL | "bar" | _ => { | ^^^^^^^^^ | = help: consider handling `_` separately - = note: `-D clippy::wildcard-in-or-patterns` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wild_in_or_pats.rs:1:9 + | +LL | #![warn(clippy::wildcard_in_or_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: wildcard pattern covers any other pattern as it will match anyway +warning: wildcard pattern covers any other pattern as it will match anyway --> $DIR/wild_in_or_pats.rs:16:9 | LL | "bar" | "bar2" | _ => { @@ -15,7 +19,7 @@ LL | "bar" | "bar2" | _ => { | = help: consider handling `_` separately -error: wildcard pattern covers any other pattern as it will match anyway +warning: wildcard pattern covers any other pattern as it will match anyway --> $DIR/wild_in_or_pats.rs:24:9 | LL | _ | "bar" | _ => { @@ -23,7 +27,7 @@ LL | _ | "bar" | _ => { | = help: consider handling `_` separately -error: wildcard pattern covers any other pattern as it will match anyway +warning: wildcard pattern covers any other pattern as it will match anyway --> $DIR/wild_in_or_pats.rs:32:9 | LL | _ | "bar" => { @@ -31,5 +35,5 @@ LL | _ | "bar" => { | = help: consider handling `_` separately -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/wildcard_enum_match_arm.fixed b/tests/ui/wildcard_enum_match_arm.fixed index 293bf75a7176..3afbe1a5beca 100644 --- a/tests/ui/wildcard_enum_match_arm.fixed +++ b/tests/ui/wildcard_enum_match_arm.fixed @@ -1,6 +1,6 @@ -// run-rustfix -// aux-build:non-exhaustive-enum.rs -#![deny(clippy::wildcard_enum_match_arm)] +//@run-rustfix +//@aux-build:non-exhaustive-enum.rs +#![warn(clippy::wildcard_enum_match_arm)] #![allow(dead_code, unreachable_code, unused_variables)] #![allow( clippy::diverging_sub_expression, @@ -37,15 +37,15 @@ fn main() { let color = Color::Rgb(0, 0, 127); match color { Color::Red => println!("Red"), - Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan => eprintln!("Not red"), + _ => eprintln!("Not red"), }; match color { Color::Red => println!("Red"), - _not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan => eprintln!("Not red"), + _not_red => eprintln!("Not red"), }; let _str = match color { Color::Red => "Red".to_owned(), - not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan => format!("{:?}", not_red), + not_red => format!("{:?}", not_red), }; match color { Color::Red => {}, @@ -61,7 +61,7 @@ fn main() { }; match color { Color::Rgb(r, _, _) if r > 0 => "Some red", - Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan => "No red", + _ => "No red", }; match color { Color::Red | Color::Green | Color::Blue | Color::Cyan => {}, @@ -78,7 +78,7 @@ fn main() { let error_kind = ErrorKind::NotFound; match error_kind { ErrorKind::NotFound => {}, - ErrorKind::PermissionDenied | _ => {}, + _ => {}, } match error_kind { ErrorKind::NotFound => {}, @@ -96,7 +96,7 @@ fn main() { } match Enum::A { Enum::A => (), - Enum::B | Enum::__Private => (), + _ => (), } } } diff --git a/tests/ui/wildcard_enum_match_arm.rs b/tests/ui/wildcard_enum_match_arm.rs index decd86165f3a..3afbe1a5beca 100644 --- a/tests/ui/wildcard_enum_match_arm.rs +++ b/tests/ui/wildcard_enum_match_arm.rs @@ -1,6 +1,6 @@ -// run-rustfix -// aux-build:non-exhaustive-enum.rs -#![deny(clippy::wildcard_enum_match_arm)] +//@run-rustfix +//@aux-build:non-exhaustive-enum.rs +#![warn(clippy::wildcard_enum_match_arm)] #![allow(dead_code, unreachable_code, unused_variables)] #![allow( clippy::diverging_sub_expression, diff --git a/tests/ui/wildcard_enum_match_arm.stderr b/tests/ui/wildcard_enum_match_arm.stderr index 30d29aa4e77a..6a831bfc8b09 100644 --- a/tests/ui/wildcard_enum_match_arm.stderr +++ b/tests/ui/wildcard_enum_match_arm.stderr @@ -1,4 +1,4 @@ -error: wildcard match will also match any future added variants +warning: wildcard match will also match any future added variants --> $DIR/wildcard_enum_match_arm.rs:40:9 | LL | _ => eprintln!("Not red"), @@ -7,38 +7,38 @@ LL | _ => eprintln!("Not red"), note: the lint level is defined here --> $DIR/wildcard_enum_match_arm.rs:3:9 | -LL | #![deny(clippy::wildcard_enum_match_arm)] +LL | #![warn(clippy::wildcard_enum_match_arm)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: wildcard match will also match any future added variants +warning: wildcard match will also match any future added variants --> $DIR/wildcard_enum_match_arm.rs:44:9 | LL | _not_red => eprintln!("Not red"), | ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan` -error: wildcard match will also match any future added variants +warning: wildcard match will also match any future added variants --> $DIR/wildcard_enum_match_arm.rs:48:9 | LL | not_red => format!("{:?}", not_red), | ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan` -error: wildcard match will also match any future added variants +warning: wildcard match will also match any future added variants --> $DIR/wildcard_enum_match_arm.rs:64:9 | LL | _ => "No red", | ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` -error: wildcard matches known variants and will also match future added variants +warning: wildcard matches known variants and will also match future added variants --> $DIR/wildcard_enum_match_arm.rs:81:9 | LL | _ => {}, | ^ help: try this: `ErrorKind::PermissionDenied | _` -error: wildcard match will also match any future added variants +warning: wildcard match will also match any future added variants --> $DIR/wildcard_enum_match_arm.rs:99:13 | LL | _ => (), | ^ help: try this: `Enum::B | Enum::__Private` -error: aborting due to 6 previous errors +warning: 6 warnings emitted diff --git a/tests/ui/wildcard_imports.fixed b/tests/ui/wildcard_imports.fixed index 0baec6f0b641..152daacf9de9 100644 --- a/tests/ui/wildcard_imports.fixed +++ b/tests/ui/wildcard_imports.fixed @@ -1,6 +1,6 @@ // edition:2015 -// run-rustfix -// aux-build:wildcard_imports_helper.rs +//@run-rustfix +//@aux-build:wildcard_imports_helper.rs // the 2015 edition here is needed because edition 2018 changed the module system // (see https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html) which means the lint @@ -209,7 +209,7 @@ mod super_imports { } mod use_explicit_should_be_replaced { - use super_imports::foofoo; + use crate::super_imports::foofoo; fn with_explicit() { let _ = foofoo(); diff --git a/tests/ui/wildcard_imports.rs b/tests/ui/wildcard_imports.rs index db591d56ab4d..577eef197be0 100644 --- a/tests/ui/wildcard_imports.rs +++ b/tests/ui/wildcard_imports.rs @@ -1,6 +1,6 @@ // edition:2015 -// run-rustfix -// aux-build:wildcard_imports_helper.rs +//@run-rustfix +//@aux-build:wildcard_imports_helper.rs // the 2015 edition here is needed because edition 2018 changed the module system // (see https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html) which means the lint @@ -210,7 +210,7 @@ mod super_imports { } mod use_explicit_should_be_replaced { - use super_imports::*; + use crate::super_imports::*; fn with_explicit() { let _ = foofoo(); diff --git a/tests/ui/wildcard_imports.stderr b/tests/ui/wildcard_imports.stderr index 6b469cdfc444..aed1aa41b7d5 100644 --- a/tests/ui/wildcard_imports.stderr +++ b/tests/ui/wildcard_imports.stderr @@ -1,90 +1,94 @@ -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:15:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` | - = note: `-D clippy::wildcard-imports` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wildcard_imports.rs:9:9 + | +LL | #![warn(clippy::wildcard_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:16:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:17:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:19:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:23:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:24:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:95:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:101:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:102:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:113:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:113:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:120:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:149:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:158:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:159:9 | LL | use crate:: fn_mod:: @@ -92,41 +96,41 @@ LL | use crate:: fn_mod:: LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:170:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:205:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:213:13 | -LL | use super_imports::*; - | ^^^^^^^^^^^^^^^^ help: try: `super_imports::foofoo` +LL | use crate::super_imports::*; + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:222:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:231:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports.rs:239:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/wildcard_imports_2021.edition2018.fixed b/tests/ui/wildcard_imports_2021.edition2018.fixed index 6d534a10edcd..3aea013fb3a7 100644 --- a/tests/ui/wildcard_imports_2021.edition2018.fixed +++ b/tests/ui/wildcard_imports_2021.edition2018.fixed @@ -1,8 +1,8 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix -// aux-build:wildcard_imports_helper.rs +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix +//@aux-build:wildcard_imports_helper.rs #![warn(clippy::wildcard_imports)] #![allow(unused, clippy::unnecessary_wraps, clippy::let_unit_value)] diff --git a/tests/ui/wildcard_imports_2021.edition2018.stderr b/tests/ui/wildcard_imports_2021.edition2018.stderr index acca9f651b47..3af4717e6a58 100644 --- a/tests/ui/wildcard_imports_2021.edition2018.stderr +++ b/tests/ui/wildcard_imports_2021.edition2018.stderr @@ -1,90 +1,94 @@ -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:13:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` | - = note: `-D clippy::wildcard-imports` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wildcard_imports_2021.rs:7:9 + | +LL | #![warn(clippy::wildcard_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:14:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:15:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:16:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:19:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:21:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:91:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:97:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:98:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:109:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:109:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:116:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:145:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:154:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:155:9 | LL | use crate:: fn_mod:: @@ -92,41 +96,41 @@ LL | use crate:: fn_mod:: LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:166:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:201:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:209:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:218:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:227:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:235:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/wildcard_imports_2021.edition2021.fixed b/tests/ui/wildcard_imports_2021.edition2021.fixed index 6d534a10edcd..3aea013fb3a7 100644 --- a/tests/ui/wildcard_imports_2021.edition2021.fixed +++ b/tests/ui/wildcard_imports_2021.edition2021.fixed @@ -1,8 +1,8 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix -// aux-build:wildcard_imports_helper.rs +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix +//@aux-build:wildcard_imports_helper.rs #![warn(clippy::wildcard_imports)] #![allow(unused, clippy::unnecessary_wraps, clippy::let_unit_value)] diff --git a/tests/ui/wildcard_imports_2021.edition2021.stderr b/tests/ui/wildcard_imports_2021.edition2021.stderr index acca9f651b47..3af4717e6a58 100644 --- a/tests/ui/wildcard_imports_2021.edition2021.stderr +++ b/tests/ui/wildcard_imports_2021.edition2021.stderr @@ -1,90 +1,94 @@ -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:13:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` | - = note: `-D clippy::wildcard-imports` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wildcard_imports_2021.rs:7:9 + | +LL | #![warn(clippy::wildcard_imports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:14:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:15:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:16:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:19:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:21:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:91:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:97:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:98:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:109:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:109:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:116:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:145:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:154:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:155:9 | LL | use crate:: fn_mod:: @@ -92,41 +96,41 @@ LL | use crate:: fn_mod:: LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:166:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:201:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:209:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:218:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:227:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` -error: usage of wildcard import +warning: usage of wildcard import --> $DIR/wildcard_imports_2021.rs:235:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` -error: aborting due to 21 previous errors +warning: 21 warnings emitted diff --git a/tests/ui/wildcard_imports_2021.rs b/tests/ui/wildcard_imports_2021.rs index b5ed58e68136..40c2d07527d1 100644 --- a/tests/ui/wildcard_imports_2021.rs +++ b/tests/ui/wildcard_imports_2021.rs @@ -1,8 +1,8 @@ -// revisions: edition2018 edition2021 -//[edition2018] edition:2018 -//[edition2021] edition:2021 -// run-rustfix -// aux-build:wildcard_imports_helper.rs +//@revisions: edition2018 edition2021 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@run-rustfix +//@aux-build:wildcard_imports_helper.rs #![warn(clippy::wildcard_imports)] #![allow(unused, clippy::unnecessary_wraps, clippy::let_unit_value)] diff --git a/tests/ui/wildcard_imports_2021.stderr b/tests/ui/wildcard_imports_2021.stderr deleted file mode 100644 index 92f6d31530fa..000000000000 --- a/tests/ui/wildcard_imports_2021.stderr +++ /dev/null @@ -1,132 +0,0 @@ -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:9:5 - | -LL | use crate::fn_mod::*; - | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` - | - = note: `-D clippy::wildcard-imports` implied by `-D warnings` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:10:5 - | -LL | use crate::mod_mod::*; - | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:11:5 - | -LL | use crate::multi_fn_mod::*; - | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:12:5 - | -LL | use crate::struct_mod::*; - | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:15:5 - | -LL | use wildcard_imports_helper::inner::inner_for_self_import::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:17:5 - | -LL | use wildcard_imports_helper::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:87:13 - | -LL | use crate::fn_mod::*; - | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:93:75 - | -LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; - | ^ help: try: `inner_extern_foo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:94:13 - | -LL | use wildcard_imports_helper::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:105:20 - | -LL | use self::{inner::*, inner2::*}; - | ^^^^^^^^ help: try: `inner::inner_foo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:105:30 - | -LL | use self::{inner::*, inner2::*}; - | ^^^^^^^^^ help: try: `inner2::inner_bar` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:112:13 - | -LL | use wildcard_imports_helper::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:141:9 - | -LL | use crate::in_fn_test::*; - | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:150:9 - | -LL | use crate:: in_fn_test:: * ; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:151:9 - | -LL | use crate:: fn_mod:: - | _________^ -LL | | *; - | |_________^ help: try: `crate:: fn_mod::foo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:162:13 - | -LL | use super::*; - | ^^^^^^^^ help: try: `super::foofoo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:197:17 - | -LL | use super::*; - | ^^^^^^^^ help: try: `super::insidefoo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:205:13 - | -LL | use crate::super_imports::*; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:214:17 - | -LL | use super::super::*; - | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:223:13 - | -LL | use super::super::super_imports::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` - -error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:231:13 - | -LL | use super::*; - | ^^^^^^^^ help: try: `super::foofoo` - -error: aborting due to 21 previous errors - diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 1e306ae28a26..710884dfe7f0 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,17 +1,21 @@ -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:31:27 | LL | write!(v, "Hello {}", "world"); | ^^^^^^^ | - = note: `-D clippy::write-literal` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/write_literal.rs:1:9 + | +LL | #![warn(clippy::write_literal)] + | ^^^^^^^^^^^^^^^^^^^^^ help: try this | LL - write!(v, "Hello {}", "world"); LL + write!(v, "Hello world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:32:39 | LL | writeln!(v, "Hello {} {}", world, "world"); @@ -23,7 +27,7 @@ LL - writeln!(v, "Hello {} {}", world, "world"); LL + writeln!(v, "Hello {} world", world); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:33:29 | LL | writeln!(v, "Hello {}", "world"); @@ -35,7 +39,7 @@ LL - writeln!(v, "Hello {}", "world"); LL + writeln!(v, "Hello world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:34:29 | LL | writeln!(v, "{} {:.4}", "a literal", 5); @@ -47,7 +51,7 @@ LL - writeln!(v, "{} {:.4}", "a literal", 5); LL + writeln!(v, "a literal {:.4}", 5); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:39:28 | LL | writeln!(v, "{0} {1}", "hello", "world"); @@ -59,7 +63,7 @@ LL - writeln!(v, "{0} {1}", "hello", "world"); LL + writeln!(v, "hello {1}", "world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:39:37 | LL | writeln!(v, "{0} {1}", "hello", "world"); @@ -71,7 +75,7 @@ LL - writeln!(v, "{0} {1}", "hello", "world"); LL + writeln!(v, "{0} world", "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:40:37 | LL | writeln!(v, "{1} {0}", "hello", "world"); @@ -83,7 +87,7 @@ LL - writeln!(v, "{1} {0}", "hello", "world"); LL + writeln!(v, "world {0}", "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:40:28 | LL | writeln!(v, "{1} {0}", "hello", "world"); @@ -95,7 +99,7 @@ LL - writeln!(v, "{1} {0}", "hello", "world"); LL + writeln!(v, "{1} hello", "world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:43:38 | LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); @@ -107,7 +111,7 @@ LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); LL + writeln!(v, "hello {bar}", bar = "world"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:43:53 | LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); @@ -119,7 +123,7 @@ LL - writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); LL + writeln!(v, "{foo} world", foo = "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:44:53 | LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); @@ -131,7 +135,7 @@ LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); LL + writeln!(v, "world {foo}", foo = "hello"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal.rs:44:38 | LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); @@ -143,5 +147,5 @@ LL - writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); LL + writeln!(v, "{bar} hello", bar = "world"); | -error: aborting due to 12 previous errors +warning: 12 warnings emitted diff --git a/tests/ui/write_literal_2.stderr b/tests/ui/write_literal_2.stderr index d5956db9ff0b..1a20b6e1297b 100644 --- a/tests/ui/write_literal_2.stderr +++ b/tests/ui/write_literal_2.stderr @@ -1,17 +1,21 @@ -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:9:23 | LL | writeln!(v, "{}", "{hello}"); | ^^^^^^^^^ | - = note: `-D clippy::write-literal` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/write_literal_2.rs:2:9 + | +LL | #![warn(clippy::write_literal)] + | ^^^^^^^^^^^^^^^^^^^^^ help: try this | LL - writeln!(v, "{}", "{hello}"); LL + writeln!(v, "{{hello}}"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:10:24 | LL | writeln!(v, r"{}", r"{hello}"); @@ -23,19 +27,19 @@ LL - writeln!(v, r"{}", r"{hello}"); LL + writeln!(v, r"{{hello}}"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:11:23 | -LL | writeln!(v, "{}", '/''); +LL | writeln!(v, "{}", '\''); | ^^^^ | help: try this | -LL - writeln!(v, "{}", '/''); +LL - writeln!(v, "{}", '\''); LL + writeln!(v, "'"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:12:23 | LL | writeln!(v, "{}", '"'); @@ -44,41 +48,41 @@ LL | writeln!(v, "{}", '"'); help: try this | LL - writeln!(v, "{}", '"'); -LL + writeln!(v, "/""); +LL + writeln!(v, "\""); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:13:24 | LL | writeln!(v, r"{}", '"'); | ^^^ -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:14:24 | -LL | writeln!(v, r"{}", '/''); +LL | writeln!(v, r"{}", '\''); | ^^^^ | help: try this | -LL - writeln!(v, r"{}", '/''); +LL - writeln!(v, r"{}", '\''); LL + writeln!(v, r"'"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:18:9 | -LL | / "hello / +LL | / "hello \ LL | | world!" | |_______________^ | help: try this | -LL ~ "some hello / +LL ~ "some hello \ LL ~ world!" | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:25:9 | LL | "1", "2", "3", @@ -86,11 +90,11 @@ LL | "1", "2", "3", | help: try this | -LL ~ "some 1/ -LL ~ {} / {}", "2", "3", +LL ~ "some 1\ +LL ~ {} \\ {}", "2", "3", | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:25:14 | LL | "1", "2", "3", @@ -98,11 +102,11 @@ LL | "1", "2", "3", | help: try this | -LL ~ 2 / {}", +LL ~ 2 \\ {}", LL ~ "1", "3", | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:25:19 | LL | "1", "2", "3", @@ -110,81 +114,81 @@ LL | "1", "2", "3", | help: try this | -LL ~ {} / 3", +LL ~ {} \\ 3", LL ~ "1", "2", | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:27:23 | -LL | writeln!(v, "{}", "/"); +LL | writeln!(v, "{}", "\\"); | ^^^^ | help: try this | -LL - writeln!(v, "{}", "/"); -LL + writeln!(v, "/"); +LL - writeln!(v, "{}", "\\"); +LL + writeln!(v, "\\"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:28:24 | -LL | writeln!(v, r"{}", "/"); +LL | writeln!(v, r"{}", "\\"); | ^^^^ | help: try this | -LL - writeln!(v, r"{}", "/"); -LL + writeln!(v, r"/"); +LL - writeln!(v, r"{}", "\\"); +LL + writeln!(v, r"\"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:29:26 | -LL | writeln!(v, r#"{}"#, "/"); +LL | writeln!(v, r#"{}"#, "\\"); | ^^^^ | help: try this | -LL - writeln!(v, r#"{}"#, "/"); -LL + writeln!(v, r#"/"#); +LL - writeln!(v, r#"{}"#, "\\"); +LL + writeln!(v, r#"\"#); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:30:23 | -LL | writeln!(v, "{}", r"/"); +LL | writeln!(v, "{}", r"\"); | ^^^^ | help: try this | -LL - writeln!(v, "{}", r"/"); -LL + writeln!(v, "/"); +LL - writeln!(v, "{}", r"\"); +LL + writeln!(v, "\\"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:31:23 | -LL | writeln!(v, "{}", "/r"); +LL | writeln!(v, "{}", "\r"); | ^^^^ | help: try this | -LL - writeln!(v, "{}", "/r"); -LL + writeln!(v, "/r"); +LL - writeln!(v, "{}", "\r"); +LL + writeln!(v, "\r"); | -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:32:28 | LL | writeln!(v, r#"{}{}"#, '#', '"'); // hard mode | ^^^ -error: literal with an empty format string +warning: literal with an empty format string --> $DIR/write_literal_2.rs:32:33 | LL | writeln!(v, r#"{}{}"#, '#', '"'); // hard mode | ^^^ -error: aborting due to 17 previous errors +warning: 17 warnings emitted diff --git a/tests/ui/write_with_newline.fixed b/tests/ui/write_with_newline.fixed new file mode 100644 index 000000000000..0a10e526a2f5 --- /dev/null +++ b/tests/ui/write_with_newline.fixed @@ -0,0 +1,63 @@ +// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 +// //@run-rustfix + +#![allow(clippy::write_literal)] +#![warn(clippy::write_with_newline)] + +use std::io::Write; + +fn main() { + let mut v = Vec::new(); + + // These should fail + writeln!(v, "Hello"); + writeln!(v, "Hello {}", "world"); + writeln!(v, "Hello {} {}", "world", "#2"); + writeln!(v, "{}", 1265); + writeln!(v); + + // These should be fine + write!(v, ""); + write!(v, "Hello"); + writeln!(v, "Hello"); + writeln!(v, "Hello\n"); + writeln!(v, "Hello {}\n", "world"); + write!(v, "Issue\n{}", 1265); + write!(v, "{}", 1265); + write!(v, "\n{}", 1275); + write!(v, "\n\n"); + write!(v, "like eof\n\n"); + write!(v, "Hello {} {}\n\n", "world", "#2"); + writeln!(v, "\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126 + writeln!(v, "\nbla\n\n"); // #3126 + + // Escaping + write!(v, "\\n"); // #3514 + writeln!(v, "\\"); // should fail + write!(v, "\\\\n"); + + // Raw strings + write!(v, r"\n"); // #3778 + + // Literal newlines should also fail + writeln!( + v + ); + writeln!( + v + ); + + // Don't warn on CRLF (#4208) + write!(v, "\r\n"); + write!(v, "foo\r\n"); + writeln!(v, "\\r"); // warns + write!(v, "foo\rbar\n"); + + // Ignore expanded format strings + macro_rules! newline { + () => { + "\n" + }; + } + write!(v, newline!()); +} diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs index b79364c8758c..0ab73eed62c8 100644 --- a/tests/ui/write_with_newline.rs +++ b/tests/ui/write_with_newline.rs @@ -1,5 +1,5 @@ // FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934 -// // run-rustfix +// //@run-rustfix #![allow(clippy::write_literal)] #![warn(clippy::write_with_newline)] @@ -54,7 +54,7 @@ fn main() { // Don't warn on CRLF (#4208) write!(v, "\r\n"); write!(v, "foo\r\n"); - write!(v, "\\r\n"); //~ ERROR + write!(v, "\\r\n"); // warns write!(v, "foo\rbar\n"); // Ignore expanded format strings diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index 2baaea166d8e..c75ef7bc4556 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,77 +1,81 @@ -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:13:5 | -LL | write!(v, "Hello/n"); +LL | write!(v, "Hello\n"); | ^^^^^^^^^^^^^^^^^^^^ | - = note: `-D clippy::write-with-newline` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/write_with_newline.rs:5:9 + | +LL | #![warn(clippy::write_with_newline)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `writeln!` instead | -LL - write!(v, "Hello/n"); +LL - write!(v, "Hello\n"); LL + writeln!(v, "Hello"); | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:14:5 | -LL | write!(v, "Hello {}/n", "world"); +LL | write!(v, "Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `writeln!` instead | -LL - write!(v, "Hello {}/n", "world"); +LL - write!(v, "Hello {}\n", "world"); LL + writeln!(v, "Hello {}", "world"); | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:15:5 | -LL | write!(v, "Hello {} {}/n", "world", "#2"); +LL | write!(v, "Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: use `writeln!` instead | -LL - write!(v, "Hello {} {}/n", "world", "#2"); +LL - write!(v, "Hello {} {}\n", "world", "#2"); LL + writeln!(v, "Hello {} {}", "world", "#2"); | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:16:5 | -LL | write!(v, "{}/n", 1265); +LL | write!(v, "{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: use `writeln!` instead | -LL - write!(v, "{}/n", 1265); +LL - write!(v, "{}\n", 1265); LL + writeln!(v, "{}", 1265); | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:17:5 | -LL | write!(v, "/n"); +LL | write!(v, "\n"); | ^^^^^^^^^^^^^^^ | help: use `writeln!` instead | -LL - write!(v, "/n"); +LL - write!(v, "\n"); LL + writeln!(v); | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:36:5 | -LL | write!(v, "//n"); // should fail +LL | write!(v, "\\\n"); // should fail | ^^^^^^^^^^^^^^^^^ | help: use `writeln!` instead | -LL - write!(v, "//n"); // should fail -LL + writeln!(v, "/"); // should fail +LL - write!(v, "\\\n"); // should fail +LL + writeln!(v, "\\"); // should fail | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:43:5 | LL | / write!( @@ -87,7 +91,7 @@ LL ~ writeln!( LL ~ v | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:48:5 | LL | / write!( @@ -103,17 +107,17 @@ LL ~ writeln!( LL ~ v | -error: using `write!()` with a format string that ends in a single newline +warning: using `write!()` with a format string that ends in a single newline --> $DIR/write_with_newline.rs:57:5 | -LL | write!(v, "/r/n"); //~ ERROR +LL | write!(v, "\\r\n"); // warns | ^^^^^^^^^^^^^^^^^^ | help: use `writeln!` instead | -LL - write!(v, "/r/n"); //~ ERROR -LL + writeln!(v, "/r"); //~ ERROR +LL - write!(v, "\\r\n"); // warns +LL + writeln!(v, "\\r"); // warns | -error: aborting due to 9 previous errors +warning: 9 warnings emitted diff --git a/tests/ui/writeln_empty_string.fixed b/tests/ui/writeln_empty_string.fixed index e7d94acd130d..45dedd9ead6a 100644 --- a/tests/ui/writeln_empty_string.fixed +++ b/tests/ui/writeln_empty_string.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_must_use)] #![warn(clippy::writeln_empty_string)] diff --git a/tests/ui/writeln_empty_string.rs b/tests/ui/writeln_empty_string.rs index 662c62f02116..3b9f51a15d2f 100644 --- a/tests/ui/writeln_empty_string.rs +++ b/tests/ui/writeln_empty_string.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix #![allow(unused_must_use)] #![warn(clippy::writeln_empty_string)] diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 25e69ec48e7e..461286f1f5c2 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,4 +1,4 @@ -error: empty string literal in `writeln!` +warning: empty string literal in `writeln!` --> $DIR/writeln_empty_string.rs:11:5 | LL | writeln!(v, ""); @@ -6,9 +6,13 @@ LL | writeln!(v, ""); | | | help: remove the empty string | - = note: `-D clippy::writeln-empty-string` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/writeln_empty_string.rs:4:9 + | +LL | #![warn(clippy::writeln_empty_string)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: empty string literal in `writeln!` +warning: empty string literal in `writeln!` --> $DIR/writeln_empty_string.rs:14:5 | LL | writeln!(suggestion, ""); @@ -16,5 +20,5 @@ LL | writeln!(suggestion, ""); | | | help: remove the empty string -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index d002e55c5708..35f32d70b355 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,13 +1,17 @@ -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:16:17 | LL | fn from_i32(self) {} | ^^^^ | = help: consider choosing a less ambiguous name - = note: `-D clippy::wrong-self-convention` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wrong_self_convention.rs:1:9 + | +LL | #![warn(clippy::wrong_self_convention)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:22:21 | LL | pub fn from_i64(self) {} @@ -15,7 +19,7 @@ LL | pub fn from_i64(self) {} | = help: consider choosing a less ambiguous name -error: methods called `as_*` usually take `self` by reference or `self` by mutable reference +warning: methods called `as_*` usually take `self` by reference or `self` by mutable reference --> $DIR/wrong_self_convention.rs:34:15 | LL | fn as_i32(self) {} @@ -23,7 +27,7 @@ LL | fn as_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods called `into_*` usually take `self` by value +warning: methods called `into_*` usually take `self` by value --> $DIR/wrong_self_convention.rs:36:17 | LL | fn into_i32(&self) {} @@ -31,7 +35,7 @@ LL | fn into_i32(&self) {} | = help: consider choosing a less ambiguous name -error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` +warning: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` --> $DIR/wrong_self_convention.rs:38:15 | LL | fn is_i32(self) {} @@ -39,7 +43,7 @@ LL | fn is_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference +warning: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference --> $DIR/wrong_self_convention.rs:40:15 | LL | fn to_i32(self) {} @@ -47,7 +51,7 @@ LL | fn to_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:42:17 | LL | fn from_i32(self) {} @@ -55,7 +59,7 @@ LL | fn from_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods called `as_*` usually take `self` by reference or `self` by mutable reference +warning: methods called `as_*` usually take `self` by reference or `self` by mutable reference --> $DIR/wrong_self_convention.rs:44:19 | LL | pub fn as_i64(self) {} @@ -63,7 +67,7 @@ LL | pub fn as_i64(self) {} | = help: consider choosing a less ambiguous name -error: methods called `into_*` usually take `self` by value +warning: methods called `into_*` usually take `self` by value --> $DIR/wrong_self_convention.rs:45:21 | LL | pub fn into_i64(&self) {} @@ -71,7 +75,7 @@ LL | pub fn into_i64(&self) {} | = help: consider choosing a less ambiguous name -error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` +warning: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` --> $DIR/wrong_self_convention.rs:46:19 | LL | pub fn is_i64(self) {} @@ -79,7 +83,7 @@ LL | pub fn is_i64(self) {} | = help: consider choosing a less ambiguous name -error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference +warning: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference --> $DIR/wrong_self_convention.rs:47:19 | LL | pub fn to_i64(self) {} @@ -87,7 +91,7 @@ LL | pub fn to_i64(self) {} | = help: consider choosing a less ambiguous name -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:48:21 | LL | pub fn from_i64(self) {} @@ -95,7 +99,7 @@ LL | pub fn from_i64(self) {} | = help: consider choosing a less ambiguous name -error: methods called `as_*` usually take `self` by reference or `self` by mutable reference +warning: methods called `as_*` usually take `self` by reference or `self` by mutable reference --> $DIR/wrong_self_convention.rs:93:19 | LL | fn as_i32(self) {} @@ -103,7 +107,7 @@ LL | fn as_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods called `into_*` usually take `self` by value +warning: methods called `into_*` usually take `self` by value --> $DIR/wrong_self_convention.rs:96:25 | LL | fn into_i32_ref(&self) {} @@ -111,7 +115,7 @@ LL | fn into_i32_ref(&self) {} | = help: consider choosing a less ambiguous name -error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` +warning: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` --> $DIR/wrong_self_convention.rs:98:19 | LL | fn is_i32(self) {} @@ -119,7 +123,7 @@ LL | fn is_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:102:21 | LL | fn from_i32(self) {} @@ -127,7 +131,7 @@ LL | fn from_i32(self) {} | = help: consider choosing a less ambiguous name -error: methods called `as_*` usually take `self` by reference or `self` by mutable reference +warning: methods called `as_*` usually take `self` by reference or `self` by mutable reference --> $DIR/wrong_self_convention.rs:117:19 | LL | fn as_i32(self); @@ -135,7 +139,7 @@ LL | fn as_i32(self); | = help: consider choosing a less ambiguous name -error: methods called `into_*` usually take `self` by value +warning: methods called `into_*` usually take `self` by value --> $DIR/wrong_self_convention.rs:120:25 | LL | fn into_i32_ref(&self); @@ -143,7 +147,7 @@ LL | fn into_i32_ref(&self); | = help: consider choosing a less ambiguous name -error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` +warning: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` --> $DIR/wrong_self_convention.rs:122:19 | LL | fn is_i32(self); @@ -151,7 +155,7 @@ LL | fn is_i32(self); | = help: consider choosing a less ambiguous name -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:126:21 | LL | fn from_i32(self); @@ -159,7 +163,7 @@ LL | fn from_i32(self); | = help: consider choosing a less ambiguous name -error: methods called `into_*` usually take `self` by value +warning: methods called `into_*` usually take `self` by value --> $DIR/wrong_self_convention.rs:144:25 | LL | fn into_i32_ref(&self); @@ -167,7 +171,7 @@ LL | fn into_i32_ref(&self); | = help: consider choosing a less ambiguous name -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention.rs:150:21 | LL | fn from_i32(self); @@ -175,7 +179,7 @@ LL | fn from_i32(self); | = help: consider choosing a less ambiguous name -error: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value +warning: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value --> $DIR/wrong_self_convention.rs:174:22 | LL | fn to_u64_v2(&self) -> u64 { @@ -183,7 +187,7 @@ LL | fn to_u64_v2(&self) -> u64 { | = help: consider choosing a less ambiguous name -error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference +warning: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference --> $DIR/wrong_self_convention.rs:183:19 | LL | fn to_u64(self) -> u64 { @@ -191,5 +195,5 @@ LL | fn to_u64(self) -> u64 { | = help: consider choosing a less ambiguous name -error: aborting due to 24 previous errors +warning: 24 warnings emitted diff --git a/tests/ui/wrong_self_convention2.stderr b/tests/ui/wrong_self_convention2.stderr index 8de10e7be69c..3d0f5c1e1d1b 100644 --- a/tests/ui/wrong_self_convention2.stderr +++ b/tests/ui/wrong_self_convention2.stderr @@ -1,13 +1,17 @@ -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention2.rs:54:29 | LL | pub fn from_be_self(self) -> Self { | ^^^^ | = help: consider choosing a less ambiguous name - = note: `-D clippy::wrong-self-convention` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wrong_self_convention2.rs:1:9 + | +LL | #![warn(clippy::wrong_self_convention)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: methods called `from_*` usually take no `self` +warning: methods called `from_*` usually take no `self` --> $DIR/wrong_self_convention2.rs:63:25 | LL | fn from_be_self(self) -> Self; @@ -15,5 +19,5 @@ LL | fn from_be_self(self) -> Self; | = help: consider choosing a less ambiguous name -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/wrong_self_conventions_mut.stderr b/tests/ui/wrong_self_conventions_mut.stderr index 3d009083cee3..da179d58b906 100644 --- a/tests/ui/wrong_self_conventions_mut.stderr +++ b/tests/ui/wrong_self_conventions_mut.stderr @@ -1,13 +1,17 @@ -error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference +warning: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference --> $DIR/wrong_self_conventions_mut.rs:14:24 | LL | pub fn to_many(&mut self) -> Option<&mut [T]> { | ^^^^^^^^^ | = help: consider choosing a less ambiguous name - = note: `-D clippy::wrong-self-convention` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/wrong_self_conventions_mut.rs:1:9 + | +LL | #![warn(clippy::wrong_self_convention)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: methods with the following characteristics: (`to_*` and `*_mut`) usually take `self` by mutable reference +warning: methods with the following characteristics: (`to_*` and `*_mut`) usually take `self` by mutable reference --> $DIR/wrong_self_conventions_mut.rs:22:28 | LL | pub fn to_many_mut(&self) -> Option<&[T]> { @@ -15,5 +19,5 @@ LL | pub fn to_many_mut(&self) -> Option<&[T]> { | = help: consider choosing a less ambiguous name -error: aborting due to 2 previous errors +warning: 2 warnings emitted diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 2793d1606445..358f6940e111 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,13 +1,17 @@ -error: constant division of `0.0` with `0.0` will always result in NaN +warning: constant division of `0.0` with `0.0` will always result in NaN --> $DIR/zero_div_zero.rs:4:15 | LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = help: consider using `f64::NAN` if you would like a constant representing NaN - = note: `-D clippy::zero-divided-by-zero` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/zero_div_zero.rs:2:8 + | +LL | #[warn(clippy::zero_divided_by_zero)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: constant division of `0.0` with `0.0` will always result in NaN +warning: constant division of `0.0` with `0.0` will always result in NaN --> $DIR/zero_div_zero.rs:5:19 | LL | let f64_nan = 0.0 / 0.0f64; @@ -15,7 +19,7 @@ LL | let f64_nan = 0.0 / 0.0f64; | = help: consider using `f64::NAN` if you would like a constant representing NaN -error: constant division of `0.0` with `0.0` will always result in NaN +warning: constant division of `0.0` with `0.0` will always result in NaN --> $DIR/zero_div_zero.rs:6:25 | LL | let other_f64_nan = 0.0f64 / 0.0; @@ -23,7 +27,7 @@ LL | let other_f64_nan = 0.0f64 / 0.0; | = help: consider using `f64::NAN` if you would like a constant representing NaN -error: constant division of `0.0` with `0.0` will always result in NaN +warning: constant division of `0.0` with `0.0` will always result in NaN --> $DIR/zero_div_zero.rs:7:28 | LL | let one_more_f64_nan = 0.0f64 / 0.0f64; @@ -31,5 +35,5 @@ LL | let one_more_f64_nan = 0.0f64 / 0.0f64; | = help: consider using `f64::NAN` if you would like a constant representing NaN -error: aborting due to 4 previous errors +warning: 4 warnings emitted diff --git a/tests/ui/zero_offset.rs b/tests/ui/zero_offset.rs index fd9ac1fa7663..a5f0891256b9 100644 --- a/tests/ui/zero_offset.rs +++ b/tests/ui/zero_offset.rs @@ -1,4 +1,5 @@ #[allow(clippy::borrow_as_ptr)] +#[warn(clippy::zst_offset)] fn main() { unsafe { let m = &mut () as *mut (); diff --git a/tests/ui/zero_offset.stderr b/tests/ui/zero_offset.stderr index 481a446571ab..d8ba59129beb 100644 --- a/tests/ui/zero_offset.stderr +++ b/tests/ui/zero_offset.stderr @@ -1,52 +1,56 @@ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:5:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:6:9 | LL | m.offset(0); | ^^^^^^^^^^^ | - = note: `#[deny(clippy::zst_offset)]` on by default +note: the lint level is defined here + --> $DIR/zero_offset.rs:2:8 + | +LL | #[warn(clippy::zst_offset)] + | ^^^^^^^^^^^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:6:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:7:9 | LL | m.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:7:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:8:9 | LL | m.sub(0); | ^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:8:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:9:9 | LL | m.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:11:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:12:9 | LL | c.offset(0); | ^^^^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:12:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:13:9 | LL | c.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:13:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:14:9 | LL | c.sub(0); | ^^^^^^^^ -error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:14:9 +warning: offset calculation on zero-sized value + --> $DIR/zero_offset.rs:15:9 | LL | c.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +warning: 8 warnings emitted diff --git a/tests/ui/zero_ptr.fixed b/tests/ui/zero_ptr.fixed index 489aa4121a3a..bed38ecafc7e 100644 --- a/tests/ui/zero_ptr.fixed +++ b/tests/ui/zero_ptr.fixed @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix pub fn foo(_const: *const f32, _mut: *mut i64) {} fn main() { diff --git a/tests/ui/zero_ptr.rs b/tests/ui/zero_ptr.rs index c3b55ef9ebd9..b7b778915a8f 100644 --- a/tests/ui/zero_ptr.rs +++ b/tests/ui/zero_ptr.rs @@ -1,4 +1,4 @@ -// run-rustfix +//@run-rustfix pub fn foo(_const: *const f32, _mut: *mut i64) {} fn main() { diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 4ee5e9a26168..6616cc8f71c3 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -1,34 +1,34 @@ -error: `0 as *const _` detected +warning: `0 as *const _` detected --> $DIR/zero_ptr.rs:5:13 | LL | let _ = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null::()` | - = note: `-D clippy::zero-ptr` implied by `-D warnings` + = note: `#[warn(clippy::zero_ptr)]` on by default -error: `0 as *mut _` detected +warning: `0 as *mut _` detected --> $DIR/zero_ptr.rs:6:13 | LL | let _ = 0 as *mut f64; | ^^^^^^^^^^^^^ help: try: `std::ptr::null_mut::()` -error: `0 as *const _` detected +warning: `0 as *const _` detected --> $DIR/zero_ptr.rs:7:24 | LL | let _: *const u8 = 0 as *const _; | ^^^^^^^^^^^^^ help: try: `std::ptr::null()` -error: `0 as *const _` detected +warning: `0 as *const _` detected --> $DIR/zero_ptr.rs:10:9 | LL | foo(0 as *const _, 0 as *mut _); | ^^^^^^^^^^^^^ help: try: `std::ptr::null()` -error: `0 as *mut _` detected +warning: `0 as *mut _` detected --> $DIR/zero_ptr.rs:10:24 | LL | foo(0 as *const _, 0 as *mut _); | ^^^^^^^^^^^ help: try: `std::ptr::null_mut()` -error: aborting due to 5 previous errors +warning: 5 warnings emitted diff --git a/tests/ui/zero_ptr_no_std.fixed b/tests/ui/zero_ptr_no_std.fixed index 8906c776977a..404ef86c0ed3 100644 --- a/tests/ui/zero_ptr_no_std.fixed +++ b/tests/ui/zero_ptr_no_std.fixed @@ -1,8 +1,8 @@ -// run-rustfix +//@run-rustfix #![feature(lang_items, start, libc)] #![no_std] -#![deny(clippy::zero_ptr)] +#![warn(clippy::zero_ptr)] #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { diff --git a/tests/ui/zero_ptr_no_std.rs b/tests/ui/zero_ptr_no_std.rs index 379c1b18d299..07660e9610b5 100644 --- a/tests/ui/zero_ptr_no_std.rs +++ b/tests/ui/zero_ptr_no_std.rs @@ -1,8 +1,8 @@ -// run-rustfix +//@run-rustfix #![feature(lang_items, start, libc)] #![no_std] -#![deny(clippy::zero_ptr)] +#![warn(clippy::zero_ptr)] #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { diff --git a/tests/ui/zero_ptr_no_std.stderr b/tests/ui/zero_ptr_no_std.stderr index d92bb4a6528d..6398d6c3d99e 100644 --- a/tests/ui/zero_ptr_no_std.stderr +++ b/tests/ui/zero_ptr_no_std.stderr @@ -1,4 +1,4 @@ -error: `0 as *const _` detected +warning: `0 as *const _` detected --> $DIR/zero_ptr_no_std.rs:9:13 | LL | let _ = 0 as *const usize; @@ -7,20 +7,20 @@ LL | let _ = 0 as *const usize; note: the lint level is defined here --> $DIR/zero_ptr_no_std.rs:5:9 | -LL | #![deny(clippy::zero_ptr)] +LL | #![warn(clippy::zero_ptr)] | ^^^^^^^^^^^^^^^^ -error: `0 as *mut _` detected +warning: `0 as *mut _` detected --> $DIR/zero_ptr_no_std.rs:10:13 | LL | let _ = 0 as *mut f64; | ^^^^^^^^^^^^^ help: try: `core::ptr::null_mut::()` -error: `0 as *const _` detected +warning: `0 as *const _` detected --> $DIR/zero_ptr_no_std.rs:11:24 | LL | let _: *const u8 = 0 as *const _; | ^^^^^^^^^^^^^ help: try: `core::ptr::null()` -error: aborting due to 3 previous errors +warning: 3 warnings emitted diff --git a/tests/ui/zero_sized_btreemap_values.stderr b/tests/ui/zero_sized_btreemap_values.stderr index c6ba6fa76f05..ce5795056d55 100644 --- a/tests/ui/zero_sized_btreemap_values.stderr +++ b/tests/ui/zero_sized_btreemap_values.stderr @@ -1,13 +1,17 @@ -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:5:28 | LL | const CONST_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^^ | = help: consider using a set instead - = note: `-D clippy::zero-sized-map-values` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/zero_sized_btreemap_values.rs:1:9 + | +LL | #![warn(clippy::zero_sized_map_values)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:8:30 | LL | static STATIC_NOT_OK: Option> = None; @@ -15,7 +19,7 @@ LL | static STATIC_NOT_OK: Option> = None; | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:11:17 | LL | type NotOkMap = BTreeMap; @@ -23,7 +27,7 @@ LL | type NotOkMap = BTreeMap; | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:15:11 | LL | NotOk(BTreeMap), @@ -31,7 +35,7 @@ LL | NotOk(BTreeMap), | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:20:13 | LL | not_ok: BTreeMap, @@ -39,7 +43,7 @@ LL | not_ok: BTreeMap, | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:22:22 | LL | also_not_ok: Vec>, @@ -47,7 +51,7 @@ LL | also_not_ok: Vec>, | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:30:30 | LL | fn weird_map(&self, map: BTreeMap); @@ -55,7 +59,7 @@ LL | fn weird_map(&self, map: BTreeMap); | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:38:25 | LL | fn not_ok(&self) -> BTreeMap { @@ -63,7 +67,7 @@ LL | fn not_ok(&self) -> BTreeMap { | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:55:14 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { @@ -71,7 +75,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:55:50 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { @@ -79,7 +83,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:64:35 | LL | let _: BTreeMap = BTreeMap::new(); @@ -87,7 +91,7 @@ LL | let _: BTreeMap = BTreeMap::new(); | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:64:12 | LL | let _: BTreeMap = BTreeMap::new(); @@ -95,7 +99,7 @@ LL | let _: BTreeMap = BTreeMap::new(); | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_btreemap_values.rs:67:12 | LL | let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect(); @@ -103,5 +107,5 @@ LL | let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect(); | = help: consider using a set instead -error: aborting due to 13 previous errors +warning: 13 warnings emitted diff --git a/tests/ui/zero_sized_hashmap_values.stderr b/tests/ui/zero_sized_hashmap_values.stderr index 75bdeb42ec0d..93f113069f0d 100644 --- a/tests/ui/zero_sized_hashmap_values.stderr +++ b/tests/ui/zero_sized_hashmap_values.stderr @@ -1,13 +1,17 @@ -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:5:28 | LL | const CONST_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^ | = help: consider using a set instead - = note: `-D clippy::zero-sized-map-values` implied by `-D warnings` +note: the lint level is defined here + --> $DIR/zero_sized_hashmap_values.rs:1:9 + | +LL | #![warn(clippy::zero_sized_map_values)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:8:30 | LL | static STATIC_NOT_OK: Option> = None; @@ -15,7 +19,7 @@ LL | static STATIC_NOT_OK: Option> = None; | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:11:17 | LL | type NotOkMap = HashMap; @@ -23,7 +27,7 @@ LL | type NotOkMap = HashMap; | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:15:11 | LL | NotOk(HashMap), @@ -31,7 +35,7 @@ LL | NotOk(HashMap), | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:20:13 | LL | not_ok: HashMap, @@ -39,7 +43,7 @@ LL | not_ok: HashMap, | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:22:22 | LL | also_not_ok: Vec>, @@ -47,7 +51,7 @@ LL | also_not_ok: Vec>, | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:30:30 | LL | fn weird_map(&self, map: HashMap); @@ -55,7 +59,7 @@ LL | fn weird_map(&self, map: HashMap); | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:38:25 | LL | fn not_ok(&self) -> HashMap { @@ -63,7 +67,7 @@ LL | fn not_ok(&self) -> HashMap { | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:55:14 | LL | fn test(map: HashMap, key: &str) -> HashMap { @@ -71,7 +75,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:55:49 | LL | fn test(map: HashMap, key: &str) -> HashMap { @@ -79,7 +83,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:64:34 | LL | let _: HashMap = HashMap::new(); @@ -87,7 +91,7 @@ LL | let _: HashMap = HashMap::new(); | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:64:12 | LL | let _: HashMap = HashMap::new(); @@ -95,7 +99,7 @@ LL | let _: HashMap = HashMap::new(); | = help: consider using a set instead -error: map with zero-sized value type +warning: map with zero-sized value type --> $DIR/zero_sized_hashmap_values.rs:67:12 | LL | let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect(); @@ -103,5 +107,5 @@ LL | let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect(); | = help: consider using a set instead -error: aborting due to 13 previous errors +warning: 13 warnings emitted