2018-07-28 17:34:52 +02:00
|
|
|
#![warn(clippy::panic_params, clippy::unimplemented)]
|
2019-01-23 09:49:02 +01:00
|
|
|
#![allow(clippy::assertions_on_constants)]
|
2015-12-23 22:37:52 +01:00
|
|
|
fn missing() {
|
2016-03-12 21:23:01 +01:00
|
|
|
if true {
|
2017-02-08 14:58:07 +01:00
|
|
|
panic!("{}");
|
2016-03-15 21:02:08 +01:00
|
|
|
} else if false {
|
2017-02-08 14:58:07 +01:00
|
|
|
panic!("{:?}");
|
2016-03-12 21:23:01 +01:00
|
|
|
} else {
|
2017-02-08 14:58:07 +01:00
|
|
|
assert!(true, "here be missing values: {}");
|
2016-03-12 21:23:01 +01:00
|
|
|
}
|
2018-05-06 17:26:47 +02:00
|
|
|
|
|
|
|
panic!("{{{this}}}");
|
2015-12-23 22:37:52 +01:00
|
|
|
}
|
|
|
|
|
2016-03-12 21:23:01 +01:00
|
|
|
fn ok_single() {
|
2015-12-23 22:37:52 +01:00
|
|
|
panic!("foo bar");
|
|
|
|
}
|
|
|
|
|
2016-03-15 21:02:08 +01:00
|
|
|
fn ok_inner() {
|
|
|
|
// Test for #768
|
|
|
|
assert!("foo bar".contains(&format!("foo {}", "bar")));
|
|
|
|
}
|
|
|
|
|
2015-12-23 22:37:52 +01:00
|
|
|
fn ok_multiple() {
|
|
|
|
panic!("{}", "This is {ok}");
|
|
|
|
}
|
|
|
|
|
2016-03-12 21:23:01 +01:00
|
|
|
fn ok_bracket() {
|
|
|
|
match 42 {
|
|
|
|
1337 => panic!("{so is this"),
|
|
|
|
666 => panic!("so is this}"),
|
|
|
|
_ => panic!("}so is that{"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
const ONE: u32 = 1;
|
2017-08-21 23:23:54 +02:00
|
|
|
|
|
|
|
fn ok_nomsg() {
|
|
|
|
assert!({ 1 == ONE });
|
|
|
|
assert!(if 1 == ONE { ONE == 1 } else { false });
|
|
|
|
}
|
|
|
|
|
2018-05-06 17:26:47 +02:00
|
|
|
fn ok_escaped() {
|
|
|
|
panic!("{{ why should this not be ok? }}");
|
|
|
|
panic!(" or {{ that ?");
|
|
|
|
panic!(" or }} this ?");
|
|
|
|
panic!(" {or {{ that ?");
|
|
|
|
panic!(" }or }} this ?");
|
|
|
|
panic!("{{ test }");
|
|
|
|
panic!("{case }}");
|
|
|
|
}
|
|
|
|
|
2018-05-23 16:43:05 +02:00
|
|
|
fn unimplemented() {
|
2018-05-24 19:26:04 +02:00
|
|
|
let a = 2;
|
2018-05-23 16:43:05 +02:00
|
|
|
unimplemented!();
|
2018-05-24 19:26:04 +02:00
|
|
|
let b = a + 2;
|
2018-05-23 16:43:05 +02:00
|
|
|
}
|
|
|
|
|
2015-12-23 22:37:52 +01:00
|
|
|
fn main() {
|
|
|
|
missing();
|
2016-03-12 21:23:01 +01:00
|
|
|
ok_single();
|
2015-12-23 22:37:52 +01:00
|
|
|
ok_multiple();
|
2016-03-12 21:23:01 +01:00
|
|
|
ok_bracket();
|
2016-03-15 21:02:08 +01:00
|
|
|
ok_inner();
|
2017-08-21 23:23:54 +02:00
|
|
|
ok_nomsg();
|
2018-05-06 17:26:47 +02:00
|
|
|
ok_escaped();
|
2018-05-23 16:43:05 +02:00
|
|
|
unimplemented();
|
2015-12-23 22:37:52 +01:00
|
|
|
}
|