rust/clippy_tests/examples/panic.rs

44 lines
690 B
Rust
Raw Normal View History

2015-12-23 15:37:52 -06:00
#![feature(plugin)]
#![plugin(clippy)]
#![warn(panic_params)]
2015-12-23 15:37:52 -06:00
fn missing() {
if true {
2017-02-08 07:58:07 -06:00
panic!("{}");
} else if false {
2017-02-08 07:58:07 -06:00
panic!("{:?}");
} else {
2017-02-08 07:58:07 -06:00
assert!(true, "here be missing values: {}");
}
2015-12-23 15:37:52 -06:00
}
fn ok_single() {
2015-12-23 15:37:52 -06:00
panic!("foo bar");
}
fn ok_inner() {
// Test for #768
assert!("foo bar".contains(&format!("foo {}", "bar")));
}
2015-12-23 15:37:52 -06:00
fn ok_multiple() {
panic!("{}", "This is {ok}");
}
fn ok_bracket() {
match 42 {
1337 => panic!("{so is this"),
666 => panic!("so is this}"),
_ => panic!("}so is that{"),
}
}
2015-12-23 15:37:52 -06:00
fn main() {
missing();
ok_single();
2015-12-23 15:37:52 -06:00
ok_multiple();
ok_bracket();
ok_inner();
2015-12-23 15:37:52 -06:00
}