about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-02-05 19:06:08 +0100
committerflip1995 <hello@philkrones.com>2019-02-05 19:37:54 +0100
commitcb2d987ed4d4074e67ec307cbf5bfe289e876a3b (patch)
treea41d4d57651b4cf3d555a807f2c7120d5af1a3a6
parent446e2ecfb72cf91c8389a42357a168de77dd414b (diff)
downloadrust-cb2d987ed4d4074e67ec307cbf5bfe289e876a3b.tar.gz
rust-cb2d987ed4d4074e67ec307cbf5bfe289e876a3b.zip
Add tests for assertion_on_constants macro check
-rw-r--r--tests/ui/assertions_on_constants.rs11
-rw-r--r--tests/ui/assertions_on_constants.stderr23
2 files changed, 27 insertions, 7 deletions
diff --git a/tests/ui/assertions_on_constants.rs b/tests/ui/assertions_on_constants.rs
index daeceebd3a2..0d2953c7ed8 100644
--- a/tests/ui/assertions_on_constants.rs
+++ b/tests/ui/assertions_on_constants.rs
@@ -1,3 +1,10 @@
+macro_rules! assert_const {
+    ($len:expr) => {
+        assert!($len > 0);
+        debug_assert!($len < 0);
+    };
+}
+
 fn main() {
     assert!(true);
     assert!(false);
@@ -9,4 +16,8 @@ fn main() {
 
     const C: bool = false;
     assert!(C);
+
+    debug_assert!(true);
+    assert_const!(3);
+    assert_const!(-1);
 }
diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr
index e8001acceb1..adfa326abac 100644
--- a/tests/ui/assertions_on_constants.stderr
+++ b/tests/ui/assertions_on_constants.stderr
@@ -1,5 +1,5 @@
 error: assert!(true) will be optimized out by the compiler
-  --> $DIR/assertions_on_constants.rs:2:5
+  --> $DIR/assertions_on_constants.rs:9:5
    |
 LL |     assert!(true);
    |     ^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     assert!(true);
    = help: remove it
 
 error: assert!(false) should probably be replaced
-  --> $DIR/assertions_on_constants.rs:3:5
+  --> $DIR/assertions_on_constants.rs:10:5
    |
 LL |     assert!(false);
    |     ^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL |     assert!(false);
    = help: use panic!() or unreachable!()
 
 error: assert!(true) will be optimized out by the compiler
-  --> $DIR/assertions_on_constants.rs:4:5
+  --> $DIR/assertions_on_constants.rs:11:5
    |
 LL |     assert!(true, "true message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL |     assert!(true, "true message");
    = help: remove it
 
 error: assert!(false) should probably be replaced
-  --> $DIR/assertions_on_constants.rs:5:5
+  --> $DIR/assertions_on_constants.rs:12:5
    |
 LL |     assert!(false, "false message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL |     assert!(false, "false message");
    = help: use panic!() or unreachable!()
 
 error: assert!(const: true) will be optimized out by the compiler
-  --> $DIR/assertions_on_constants.rs:8:5
+  --> $DIR/assertions_on_constants.rs:15:5
    |
 LL |     assert!(B);
    |     ^^^^^^^^^^^
@@ -40,12 +40,21 @@ LL |     assert!(B);
    = help: remove it
 
 error: assert!(const: false) should probably be replaced
-  --> $DIR/assertions_on_constants.rs:11:5
+  --> $DIR/assertions_on_constants.rs:18:5
    |
 LL |     assert!(C);
    |     ^^^^^^^^^^^
    |
    = help: use panic!() or unreachable!()
 
-error: aborting due to 6 previous errors
+error: assert!(true) will be optimized out by the compiler
+  --> $DIR/assertions_on_constants.rs:20:5
+   |
+LL |     debug_assert!(true);
+   |     ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: remove it
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to 7 previous errors