about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-02-19 11:01:51 -0500
committerAaron Hill <aa1ronham@gmail.com>2020-03-04 16:43:14 -0500
commit1b681d6652bacce6b741ca66725f25b9afb16bc8 (patch)
tree76db49b0ab06a5a55cffe246bc03d2dadef100bd
parent7f19358c9ef51a130e0177d327eaac5adc6d73ad (diff)
downloadrust-1b681d6652bacce6b741ca66725f25b9afb16bc8.tar.gz
rust-1b681d6652bacce6b741ca66725f25b9afb16bc8.zip
Test that cfg-gated if-exprs are not type-checked
-rw-r--r--src/test/ui/if-attrs/cfg-false-if-attr.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/ui/if-attrs/cfg-false-if-attr.rs b/src/test/ui/if-attrs/cfg-false-if-attr.rs
index 2932ec1a231..1f77a1bb342 100644
--- a/src/test/ui/if-attrs/cfg-false-if-attr.rs
+++ b/src/test/ui/if-attrs/cfg-false-if-attr.rs
@@ -19,6 +19,18 @@ fn if_let() {
     #[attr] if let Some(_) = Some(true) {}
 }
 
+fn bar() {
+    #[cfg(FALSE)]
+    if true {
+        let x: () = true; // Should not error due to the #[cfg(FALSE)]
+    }
+
+    #[cfg_attr(not(unset_attr), cfg(FALSE))]
+    if true {
+        let a: () = true; // Should not error due to the applied #[cfg(FALSE)]
+    }
+}
+
 macro_rules! custom_macro {
     ($expr:expr) => {}
 }