]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/assertions_on_constants.rs
Add test for not linting on assert!(cfg!(..)).
[rust.git] / tests / ui / assertions_on_constants.rs
index 0d2953c7ed8143ccdf1afef0a2057153923d3561..6617ca183a8cb2cbd37c0fa60c3b4fe1a1eb23cc 100644 (file)
@@ -1,3 +1,5 @@
+#![allow(non_fmt_panic)]
+
 macro_rules! assert_const {
     ($len:expr) => {
         assert!($len > 0);
@@ -11,13 +13,22 @@ fn main() {
     assert!(true, "true message");
     assert!(false, "false message");
 
+    let msg = "panic message";
+    assert!(false, msg.to_uppercase());
+
     const B: bool = true;
     assert!(B);
 
     const C: bool = false;
     assert!(C);
+    assert!(C, "C message");
 
     debug_assert!(true);
+    // Don't lint this, since there is no better way for expressing "Only panic in debug mode".
+    debug_assert!(false); // #3948
     assert_const!(3);
     assert_const!(-1);
+
+    // Don't lint on this:
+    assert!(cfg!(feature = "hey") || cfg!(not(feature = "asdf")));
 }