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 or disallowed_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.
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
unwrap_usedordisallowed_methodsDrawbacks
No response
Example
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 asclippy::may_panicUnlike
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.