Skip to content

Commit

Permalink
Bless tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Feb 1, 2023
1 parent f7d59b2 commit ecd98ba
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 25 deletions.
35 changes: 11 additions & 24 deletions tests/ui/manual_assert.edition2018.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ fn main() {
panic!("qaqaq{:?}", a);
}
assert!(a.is_empty(), "qaqaq{:?}", a);
if !a.is_empty() {
panic!("qwqwq");
}
assert!(a.is_empty(), "qwqwq");
if a.len() == 3 {
println!("qwq");
println!("qwq");
Expand All @@ -46,21 +44,11 @@ fn main() {
println!("qwq");
}
let b = vec![1, 2, 3];
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!(!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");
assert!(!a.is_empty(), "with expansion {}", one!());
if a.is_empty() {
let _ = 0;
Expand All @@ -71,12 +59,11 @@ fn main() {

fn issue7730(a: u8) {
// Suggestion should preserve comment
if a > 2 {
// comment
/* this is a
// comment
/* this is a
multiline
comment */
/// Doc comment
panic!("panic with comment") // comment after `panic!`
}
/// Doc comment
// comment after `panic!`
assert!(!(a > 2), "panic with comment");
}
67 changes: 66 additions & 1 deletion tests/ui/manual_assert.edition2018.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,54 @@ LL | | }
|
= note: `-D clippy::manual-assert` implied by `-D warnings`

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: `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: `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: `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: `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: `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: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");`

error: only a `panic!` in `if`-then statement
--> $DIR/manual_assert.rs:66:5
|
Expand All @@ -16,5 +64,22 @@ LL | | panic!("with expansion {}", one!())
LL | | }
| |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());`

error: aborting due to 2 previous errors
error: only a `panic!` in `if`-then statement
--> $DIR/manual_assert.rs:78: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

0 comments on commit ecd98ba

Please sign in to comment.