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