rust-clippy/tests/compile-fail/panic.rs

37 lines
685 B
Rust
Raw Normal View History

2015-12-23 21:37:52 +00:00
#![feature(plugin)]
#![plugin(clippy)]
#[deny(panic_params)]
fn missing() {
if true {
panic!("{}"); //~ERROR: You probably are missing some parameter
} else {
panic!("{:?}"); //~ERROR: You probably are missing some parameter
}
2015-12-23 21:37:52 +00:00
}
fn ok_single() {
2015-12-23 21:37:52 +00:00
panic!("foo bar");
}
fn ok_multiple() {
panic!("{}", "This is {ok}");
}
fn ok_bracket() {
// the match is just here because of #759, it serves no other purpose for the lint
match 42 {
1337 => panic!("{so is this"),
666 => panic!("so is this}"),
_ => panic!("}so is that{"),
}
}
2015-12-23 21:37:52 +00:00
fn main() {
missing();
ok_single();
2015-12-23 21:37:52 +00:00
ok_multiple();
ok_bracket();
2015-12-23 21:37:52 +00:00
}