diff --git a/tests/ui/manual_assert.edition2018.fixed b/tests/ui/manual_assert.edition2018.fixed index 26e3b8f63e7..c9a819ba535 100644 --- a/tests/ui/manual_assert.edition2018.fixed +++ b/tests/ui/manual_assert.edition2018.fixed @@ -1,6 +1,6 @@ // revisions: edition2018 edition2021 -// [edition2018] edition:2018 -// [edition2021] edition:2021 +//[edition2018] edition:2018 +//[edition2021] edition:2021 // run-rustfix #![warn(clippy::manual_assert)] @@ -29,7 +29,9 @@ fn main() { panic!("qaqaq{:?}", a); } assert!(a.is_empty(), "qaqaq{:?}", a); - assert!(a.is_empty(), "qwqwq"); + if !a.is_empty() { + panic!("qwqwq"); + } if a.len() == 3 { println!("qwq"); println!("qwq"); @@ -44,21 +46,32 @@ fn main() { println!("qwq"); } let b = vec![1, 2, 3]; - assert!(!b.is_empty(), "panic1"); - assert!(!(b.is_empty() && a.is_empty()), "panic2"); - assert!(!(a.is_empty() && !b.is_empty()), "panic3"); - assert!(!(b.is_empty() || a.is_empty()), "panic4"); - assert!(!(a.is_empty() || !b.is_empty()), "panic5"); + if b.is_empty() { + panic!("panic1"); + } + if b.is_empty() && a.is_empty() { + panic!("panic2"); + } + if a.is_empty() && !b.is_empty() { + panic!("panic3"); + } + if b.is_empty() || a.is_empty() { + panic!("panic4"); + } + if a.is_empty() || !b.is_empty() { + panic!("panic5"); + } assert!(!a.is_empty(), "with expansion {}", one!()); } fn issue7730(a: u8) { // Suggestion should preserve comment - // comment -/* this is a + if a > 2 { + // comment + /* this is a multiline comment */ -/// Doc comment -// comment after `panic!` -assert!(!(a > 2), "panic with comment"); + /// Doc comment + panic!("panic with comment") // comment after `panic!` + } } diff --git a/tests/ui/manual_assert.edition2018.stderr b/tests/ui/manual_assert.edition2018.stderr index 7718588fdf6..c4e6bcd92fc 100644 --- a/tests/ui/manual_assert.edition2018.stderr +++ b/tests/ui/manual_assert.edition2018.stderr @@ -12,84 +12,6 @@ help: try instead LL | assert!(a.is_empty(), "qaqaq{:?}", a); | -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:34:5 - | -LL | / if !a.is_empty() { -LL | | panic!("qwqwq"); -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(a.is_empty(), "qwqwq"); - | - -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:51:5 - | -LL | / if b.is_empty() { -LL | | panic!("panic1"); -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(!b.is_empty(), "panic1"); - | - -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:54:5 - | -LL | / if b.is_empty() && a.is_empty() { -LL | | panic!("panic2"); -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(!(b.is_empty() && a.is_empty()), "panic2"); - | - -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:57:5 - | -LL | / if a.is_empty() && !b.is_empty() { -LL | | panic!("panic3"); -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(!(a.is_empty() && !b.is_empty()), "panic3"); - | - -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:60:5 - | -LL | / if b.is_empty() || a.is_empty() { -LL | | panic!("panic4"); -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(!(b.is_empty() || a.is_empty()), "panic4"); - | - -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:63:5 - | -LL | / if a.is_empty() || !b.is_empty() { -LL | | panic!("panic5"); -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(!(a.is_empty() || !b.is_empty()), "panic5"); - | - error: only a `panic!` in `if`-then statement --> $DIR/manual_assert.rs:66:5 | @@ -103,22 +25,5 @@ help: try instead LL | assert!(!a.is_empty(), "with expansion {}", one!()); | -error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:73:5 - | -LL | / if a > 2 { -LL | | // comment -LL | | /* this is a -LL | | multiline -... | -LL | | panic!("panic with comment") // comment after `panic!` -LL | | } - | |_____^ - | -help: try instead - | -LL | assert!(!(a > 2), "panic with comment"); - | - -error: aborting due to 9 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/manual_assert.edition2021.fixed b/tests/ui/manual_assert.edition2021.fixed index 26e3b8f63e7..2f62de51cad 100644 --- a/tests/ui/manual_assert.edition2021.fixed +++ b/tests/ui/manual_assert.edition2021.fixed @@ -1,6 +1,6 @@ // revisions: edition2018 edition2021 -// [edition2018] edition:2018 -// [edition2021] edition:2021 +//[edition2018] edition:2018 +//[edition2021] edition:2021 // run-rustfix #![warn(clippy::manual_assert)] diff --git a/tests/ui/manual_assert.rs b/tests/ui/manual_assert.rs index 8c37753071d..6a4cc2468d4 100644 --- a/tests/ui/manual_assert.rs +++ b/tests/ui/manual_assert.rs @@ -1,6 +1,6 @@ // revisions: edition2018 edition2021 -// [edition2018] edition:2018 -// [edition2021] edition:2021 +//[edition2018] edition:2018 +//[edition2021] edition:2021 // run-rustfix #![warn(clippy::manual_assert)] diff --git a/tests/ui/match_wild_err_arm.edition2021.stderr b/tests/ui/match_wild_err_arm.edition2021.stderr deleted file mode 100644 index 525533bf07b..00000000000 --- a/tests/ui/match_wild_err_arm.edition2021.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:14: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` - -error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:20:9 - | -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 - --> $DIR/match_wild_err_arm.rs:26:9 - | -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 - --> $DIR/match_wild_err_arm.rs:34:9 - | -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 - diff --git a/tests/ui/match_wild_err_arm.rs b/tests/ui/match_wild_err_arm.rs index 0a86144b95d..823be65efe0 100644 --- a/tests/ui/match_wild_err_arm.rs +++ b/tests/ui/match_wild_err_arm.rs @@ -1,6 +1,3 @@ -// revisions: edition2018 edition2021 -// [edition2018] edition:2018 -// [edition2021] edition:2021 #![feature(exclusive_range_pattern)] #![allow(clippy::match_same_arms)] #![warn(clippy::match_wild_err_arm)] diff --git a/tests/ui/match_wild_err_arm.edition2018.stderr b/tests/ui/match_wild_err_arm.stderr similarity index 86% rename from tests/ui/match_wild_err_arm.edition2018.stderr rename to tests/ui/match_wild_err_arm.stderr index 525533bf07b..b016d682698 100644 --- a/tests/ui/match_wild_err_arm.edition2018.stderr +++ b/tests/ui/match_wild_err_arm.stderr @@ -1,5 +1,5 @@ error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:14:9 + --> $DIR/match_wild_err_arm.rs:11:9 | LL | Err(_) => panic!("err"), | ^^^^^^ @@ -8,7 +8,7 @@ LL | Err(_) => panic!("err"), = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:20:9 + --> $DIR/match_wild_err_arm.rs:17:9 | LL | Err(_) => panic!(), | ^^^^^^ @@ -16,7 +16,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 - --> $DIR/match_wild_err_arm.rs:26:9 + --> $DIR/match_wild_err_arm.rs:23:9 | LL | Err(_) => { | ^^^^^^ @@ -24,7 +24,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 - --> $DIR/match_wild_err_arm.rs:34:9 + --> $DIR/match_wild_err_arm.rs:31:9 | LL | Err(_e) => panic!(), | ^^^^^^^ diff --git a/tests/ui/uninlined_format_args_2021.rs b/tests/ui/uninlined_format_args_2021.rs deleted file mode 100644 index 960b159dc36..00000000000 --- a/tests/ui/uninlined_format_args_2021.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-rustfix -// edition:2021 - -#![warn(clippy::uninlined_format_args)] - -fn main() { - let var = 1; - - println!("val='{}'", var); - - if var > 0 { - panic!("p1 {}", var); - } - if var > 0 { - panic!("p2 {0}", var); - } - if var > 0 { - panic!("p3 {var}", var = var); - } - if var > 0 { - panic!("p4 {var}"); - } -} diff --git a/tests/ui/uninlined_format_args_2018.fixed b/tests/ui/uninlined_format_args_panic.edition2018.fixed similarity index 80% rename from tests/ui/uninlined_format_args_2018.fixed rename to tests/ui/uninlined_format_args_panic.edition2018.fixed index 2acccc25dd2..96cc0877960 100644 --- a/tests/ui/uninlined_format_args_2018.fixed +++ b/tests/ui/uninlined_format_args_panic.edition2018.fixed @@ -1,5 +1,7 @@ +// revisions: edition2018 edition2021 +//[edition2018] edition:2018 +//[edition2021] edition:2021 // run-rustfix -// edition:2018 #![warn(clippy::uninlined_format_args)] diff --git a/tests/ui/uninlined_format_args_2018.stderr b/tests/ui/uninlined_format_args_panic.edition2018.stderr similarity index 88% rename from tests/ui/uninlined_format_args_2018.stderr rename to tests/ui/uninlined_format_args_panic.edition2018.stderr index 43e21326d32..2c806125922 100644 --- a/tests/ui/uninlined_format_args_2018.stderr +++ b/tests/ui/uninlined_format_args_panic.edition2018.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_2018.rs:9:5 + --> $DIR/uninlined_format_args_panic.rs:11:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninlined_format_args_2021.fixed b/tests/ui/uninlined_format_args_panic.edition2021.fixed similarity index 64% rename from tests/ui/uninlined_format_args_2021.fixed rename to tests/ui/uninlined_format_args_panic.edition2021.fixed index 0a9a4ee407e..faf8ca4d3a7 100644 --- a/tests/ui/uninlined_format_args_2021.fixed +++ b/tests/ui/uninlined_format_args_panic.edition2021.fixed @@ -1,5 +1,7 @@ +// revisions: edition2018 edition2021 +//[edition2018] edition:2018 +//[edition2021] edition:2021 // run-rustfix -// edition:2021 #![warn(clippy::uninlined_format_args)] @@ -17,7 +19,11 @@ fn main() { if var > 0 { panic!("p3 {var}"); } - if var > 0 { - panic!("p4 {var}"); + + #[allow(non_fmt_panics)] + { + if var > 0 { + panic!("p4 {var}"); + } } } diff --git a/tests/ui/uninlined_format_args_2021.stderr b/tests/ui/uninlined_format_args_panic.edition2021.stderr similarity index 85% rename from tests/ui/uninlined_format_args_2021.stderr rename to tests/ui/uninlined_format_args_panic.edition2021.stderr index bc2572650cc..0f09c45f413 100644 --- a/tests/ui/uninlined_format_args_2021.stderr +++ b/tests/ui/uninlined_format_args_panic.edition2021.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_2021.rs:9:5 + --> $DIR/uninlined_format_args_panic.rs:11:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL + println!("val='{var}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_2021.rs:12:9 + --> $DIR/uninlined_format_args_panic.rs:14:9 | LL | panic!("p1 {}", var); | ^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL + panic!("p1 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_2021.rs:15:9 + --> $DIR/uninlined_format_args_panic.rs:17:9 | LL | panic!("p2 {0}", var); | ^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL + panic!("p2 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_2021.rs:18:9 + --> $DIR/uninlined_format_args_panic.rs:20:9 | LL | panic!("p3 {var}", var = var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninlined_format_args_2018.rs b/tests/ui/uninlined_format_args_panic.rs similarity index 80% rename from tests/ui/uninlined_format_args_2018.rs rename to tests/ui/uninlined_format_args_panic.rs index e3c91778202..6421c5bbed2 100644 --- a/tests/ui/uninlined_format_args_2018.rs +++ b/tests/ui/uninlined_format_args_panic.rs @@ -1,5 +1,7 @@ +// revisions: edition2018 edition2021 +//[edition2018] edition:2018 +//[edition2021] edition:2021 // run-rustfix -// edition:2018 #![warn(clippy::uninlined_format_args)]