-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix manual_assert for
#![no_std]
and Rust 2021
- Loading branch information
Showing
12 changed files
with
230 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// revisions: edition2018 edition2021 | ||
// [edition2018] edition:2018 | ||
// [edition2021] edition:2021 | ||
// run-rustfix | ||
#![warn(clippy::manual_assert)] | ||
|
||
fn main() { | ||
let a = vec![1, 2, 3]; | ||
let c = Some(2); | ||
if !a.is_empty() | ||
&& a.len() == 3 | ||
&& c != None | ||
&& !a.is_empty() | ||
&& a.len() == 3 | ||
&& !a.is_empty() | ||
&& a.len() == 3 | ||
&& !a.is_empty() | ||
&& a.len() == 3 | ||
{ | ||
panic!("qaqaq{:?}", a); | ||
} | ||
assert!(a.is_empty(), "qaqaq{:?}", a); | ||
assert!(a.is_empty(), "qwqwq"); | ||
if a.len() == 3 { | ||
println!("qwq"); | ||
println!("qwq"); | ||
println!("qwq"); | ||
} | ||
if let Some(b) = c { | ||
panic!("orz {}", b); | ||
} | ||
if a.len() == 3 { | ||
panic!("qaqaq"); | ||
} else { | ||
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// revisions: edition2018 edition2021 | ||
// [edition2018] edition:2018 | ||
// [edition2021] edition:2021 | ||
// run-rustfix | ||
#![warn(clippy::manual_assert)] | ||
|
||
fn main() { | ||
let a = vec![1, 2, 3]; | ||
let c = Some(2); | ||
if !a.is_empty() | ||
&& a.len() == 3 | ||
&& c != None | ||
&& !a.is_empty() | ||
&& a.len() == 3 | ||
&& !a.is_empty() | ||
&& a.len() == 3 | ||
&& !a.is_empty() | ||
&& a.len() == 3 | ||
{ | ||
panic!("qaqaq{:?}", a); | ||
} | ||
assert!(a.is_empty(), "qaqaq{:?}", a); | ||
assert!(a.is_empty(), "qwqwq"); | ||
if a.len() == 3 { | ||
println!("qwq"); | ||
println!("qwq"); | ||
println!("qwq"); | ||
} | ||
if let Some(b) = c { | ||
panic!("orz {}", b); | ||
} | ||
if a.len() == 3 { | ||
panic!("qaqaq"); | ||
} else { | ||
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:22:5 | ||
| | ||
LL | / if !a.is_empty() { | ||
LL | | panic!("qaqaq{:?}", a); | ||
LL | | } | ||
| |_____^ help: try: `assert!(a.is_empty(), "qaqaq{:?}", a);` | ||
| | ||
= note: `-D clippy::manual-assert` implied by `-D warnings` | ||
|
||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:25:5 | ||
| | ||
LL | / if !a.is_empty() { | ||
LL | | panic!("qwqwq"); | ||
LL | | } | ||
| |_____^ help: try: `assert!(a.is_empty(), "qwqwq");` | ||
|
||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:42:5 | ||
| | ||
LL | / if b.is_empty() { | ||
LL | | panic!("panic1"); | ||
LL | | } | ||
| |_____^ help: try: `assert!(!b.is_empty(), "panic1");` | ||
|
||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:45:5 | ||
| | ||
LL | / if b.is_empty() && a.is_empty() { | ||
LL | | panic!("panic2"); | ||
LL | | } | ||
| |_____^ help: try: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` | ||
|
||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:48:5 | ||
| | ||
LL | / if a.is_empty() && !b.is_empty() { | ||
LL | | panic!("panic3"); | ||
LL | | } | ||
| |_____^ help: try: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` | ||
|
||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:51:5 | ||
| | ||
LL | / if b.is_empty() || a.is_empty() { | ||
LL | | panic!("panic4"); | ||
LL | | } | ||
| |_____^ help: try: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` | ||
|
||
error: only a `panic!` in `if`-then statement | ||
--> $DIR/manual_assert.rs:54:5 | ||
| | ||
LL | / if a.is_empty() || !b.is_empty() { | ||
LL | | panic!("panic5"); | ||
LL | | } | ||
| |_____^ help: try: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` | ||
|
||
error: aborting due to 7 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error: `Err(_)` matches all errors | ||
--> $DIR/match_wild_err_arm.rs:14:9 | ||
| | ||
LL | Err(_) => panic!("err"), | ||
| ^^^^^^ | ||
| | ||
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings` | ||
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable | ||
|
||
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 `.except(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 `.except(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 `.except(msg)` if the error case is unreachable | ||
|
||
error: aborting due to 4 previous errors | ||
|
Oops, something went wrong.