-
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.
Auto merge of #4657 - Licenser:additional-restrictions, r=flip1995
Additional restrictions Add restriction lints for `panic!`, `unreachable!`, `todo!` and `.expect(...)` changelog: Add 5 new `restriction` lints: `panic`, `unreachable`, `todo`, `option_expect_used`, `result_expect_used`
- Loading branch information
Showing
16 changed files
with
342 additions
and
39 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
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,16 @@ | ||
#![warn(clippy::option_expect_used, clippy::result_expect_used)] | ||
|
||
fn expect_option() { | ||
let opt = Some(0); | ||
let _ = opt.expect(""); | ||
} | ||
|
||
fn expect_result() { | ||
let res: Result<u8, ()> = Ok(0); | ||
let _ = res.expect(""); | ||
} | ||
|
||
fn main() { | ||
expect_option(); | ||
expect_result(); | ||
} |
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,18 @@ | ||
error: used expect() on an Option value. If this value is an None it will panic | ||
--> $DIR/expect.rs:5:13 | ||
| | ||
LL | let _ = opt.expect(""); | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::option-expect-used` implied by `-D warnings` | ||
|
||
error: used expect() on a Result value. If this value is an Err it will panic | ||
--> $DIR/expect.rs:10:13 | ||
| | ||
LL | let _ = res.expect(""); | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::result-expect-used` implied by `-D warnings` | ||
|
||
error: aborting due to 2 previous errors | ||
|
Oops, something went wrong.