2018-10-06 11:18:06 -05:00
|
|
|
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
|
2018-07-28 10:34:52 -05:00
|
|
|
#![feature(tool_lints)]
|
2017-09-18 05:47:33 -05:00
|
|
|
|
|
|
|
|
2018-07-28 10:34:52 -05:00
|
|
|
#![warn(clippy::panic_params, clippy::unimplemented)]
|
2015-12-23 15:37:52 -06:00
|
|
|
|
|
|
|
fn missing() {
|
2016-03-12 14:23:01 -06:00
|
|
|
if true {
|
2017-02-08 07:58:07 -06:00
|
|
|
panic!("{}");
|
2016-03-15 15:02:08 -05:00
|
|
|
} else if false {
|
2017-02-08 07:58:07 -06:00
|
|
|
panic!("{:?}");
|
2016-03-12 14:23:01 -06:00
|
|
|
} else {
|
2017-02-08 07:58:07 -06:00
|
|
|
assert!(true, "here be missing values: {}");
|
2016-03-12 14:23:01 -06:00
|
|
|
}
|
2018-05-06 10:26:47 -05:00
|
|
|
|
|
|
|
panic!("{{{this}}}");
|
2015-12-23 15:37:52 -06:00
|
|
|
}
|
|
|
|
|
2016-03-12 14:23:01 -06:00
|
|
|
fn ok_single() {
|
2015-12-23 15:37:52 -06:00
|
|
|
panic!("foo bar");
|
|
|
|
}
|
|
|
|
|
2016-03-15 15:02:08 -05:00
|
|
|
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}");
|
|
|
|
}
|
|
|
|
|
2016-03-12 14:23:01 -06:00
|
|
|
fn ok_bracket() {
|
|
|
|
match 42 {
|
|
|
|
1337 => panic!("{so is this"),
|
|
|
|
666 => panic!("so is this}"),
|
|
|
|
_ => panic!("}so is that{"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-21 16:23:54 -05:00
|
|
|
const ONE : u32= 1;
|
|
|
|
|
|
|
|
fn ok_nomsg() {
|
|
|
|
assert!({ 1 == ONE });
|
|
|
|
assert!(if 1 == ONE { ONE == 1 } else { false });
|
|
|
|
}
|
|
|
|
|
2018-05-06 10:26:47 -05: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 09:43:05 -05:00
|
|
|
fn unimplemented() {
|
2018-05-24 12:26:04 -05:00
|
|
|
let a = 2;
|
2018-05-23 09:43:05 -05:00
|
|
|
unimplemented!();
|
2018-05-24 12:26:04 -05:00
|
|
|
let b = a + 2;
|
2018-05-23 09:43:05 -05:00
|
|
|
}
|
|
|
|
|
2015-12-23 15:37:52 -06:00
|
|
|
fn main() {
|
|
|
|
missing();
|
2016-03-12 14:23:01 -06:00
|
|
|
ok_single();
|
2015-12-23 15:37:52 -06:00
|
|
|
ok_multiple();
|
2016-03-12 14:23:01 -06:00
|
|
|
ok_bracket();
|
2016-03-15 15:02:08 -05:00
|
|
|
ok_inner();
|
2017-08-21 16:23:54 -05:00
|
|
|
ok_nomsg();
|
2018-05-06 10:26:47 -05:00
|
|
|
ok_escaped();
|
2018-05-23 09:43:05 -05:00
|
|
|
unimplemented();
|
2015-12-23 15:37:52 -06:00
|
|
|
}
|