]> git.lizzy.rs Git - rust.git/blob - tests/ui/assertions_on_constants.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / assertions_on_constants.rs
1 #![allow(non_fmt_panics, clippy::needless_bool)]
2
3 macro_rules! assert_const {
4     ($len:expr) => {
5         assert!($len > 0);
6         debug_assert!($len < 0);
7     };
8 }
9 fn main() {
10     assert!(true);
11     assert!(false);
12     assert!(true, "true message");
13     assert!(false, "false message");
14
15     let msg = "panic message";
16     assert!(false, "{}", msg.to_uppercase());
17
18     const B: bool = true;
19     assert!(B);
20
21     const C: bool = false;
22     assert!(C);
23     assert!(C, "C message");
24
25     debug_assert!(true);
26     // Don't lint this, since there is no better way for expressing "Only panic in debug mode".
27     debug_assert!(false); // #3948
28     assert_const!(3);
29     assert_const!(-1);
30
31     // Don't lint if based on `cfg!(..)`:
32     assert!(cfg!(feature = "hey") || cfg!(not(feature = "asdf")));
33
34     let flag: bool = cfg!(not(feature = "asdf"));
35     assert!(flag);
36
37     const CFG_FLAG: &bool = &cfg!(feature = "hey");
38     assert!(!CFG_FLAG);
39 }