-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lintsG-Rust-for-LinuxIssues related to Rust-for-Linux wants and bugfixesIssues related to Rust-for-Linux wants and bugfixes
Description
What it does
Reports on functions marked as panic-able (for example, .expect()
) in the config file or with a special #[clippy::may_panic]
.
Advantage
- Ensures that specially critical code is handled with the requirement that it won't panic
- Allows for more flexibility than
unwrap_used
ordisallowed_methods
Drawbacks
No response
Example
#[clippy::may_panic]
fn dangerous(v: Vec<usize>) -> usize {
v[1]
}
fn foo() {
let v = vec![];
let _ = dangerous(v);
}
Comparison with existing lints
Unlike unwrap_used
, this allows for any function marked such as that.
Compared disallowed_methods
, this allows for any function call and gives a specific reason.
Unlike indexing_slicing
, this works for any function marked as clippy::may_panic
Unlike unreachable
/unimplemented
, this works for any functions marked with the attribute.
Additional Context
This was requested by the Rust-for-Linux project, giving it priority. I will mentor anyone trying to implement it.
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsG-Rust-for-LinuxIssues related to Rust-for-Linux wants and bugfixesIssues related to Rust-for-Linux wants and bugfixes