Fix edition revision ui tests

This commit is contained in:
Alex Macleod 2022-10-13 11:40:13 +00:00
parent 42bdfa23d3
commit 124caeb9a2
13 changed files with 55 additions and 188 deletions

View File

@ -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!`
}
}

View File

@ -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

View File

@ -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)]

View File

@ -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)]

View File

@ -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

View File

@ -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)]

View File

@ -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!(),
| ^^^^^^^

View File

@ -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}");
}
}

View File

@ -1,5 +1,7 @@
// revisions: edition2018 edition2021
//[edition2018] edition:2018
//[edition2021] edition:2021
// run-rustfix
// edition:2018
#![warn(clippy::uninlined_format_args)]

View File

@ -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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -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}");
}
}
}

View File

@ -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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,7 @@
// revisions: edition2018 edition2021
//[edition2018] edition:2018
//[edition2021] edition:2021
// run-rustfix
// edition:2018
#![warn(clippy::uninlined_format_args)]