If my function may cause panic at runtime, Can i detect it using clippy ?
No, panics cannot be detected by clippy. You can look for common sources of panics, such as indexing, Option/Result::unwrap/expect
or other functions like it, but there is not a surefire way to detect panics. You can grep
through your code for panic
/unreachable
/unimplemented
but that's about all.
If your code does panic, you can set the RUST_BACKTRACE
enviornment variable to 1
, and that will give you back traces for your panics.
1 Like
The no-panic
crate can provide a way to catch functions that panic.
2 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.