Closed
Description
What it does
For a #[test]
that has #[should_panic]
, this lint would fire unless given a reason, e.g. #[should_panic = "No such file or directory"]
.
Advantage
This prevents a should-panic test from accepting another reason when it fires, and there are many reasons such a test could panic.
Drawbacks
It could fire on tests that are genuinely expecting many possible panic reasons and don't care which one fires. These are probably very few in practice, but it could justify making it a "pedantic" lint.
Example
#[should_panic]
fn test_can_panic() {
panic!("yup")
}
Could be written as:
#[should_panic = "yup"]
fn test_can_panic() {
panic!("yup")
}