]> git.lizzy.rs Git - rust.git/commitdiff
Test that cfg-gated if-exprs are not type-checked
authorAaron Hill <aa1ronham@gmail.com>
Wed, 19 Feb 2020 16:01:51 +0000 (11:01 -0500)
committerAaron Hill <aa1ronham@gmail.com>
Wed, 4 Mar 2020 21:43:14 +0000 (16:43 -0500)
src/test/ui/if-attrs/cfg-false-if-attr.rs

index 2932ec1a23195514df275ef58bdf163a0ad9e978..1f77a1bb3427db868b975ebdf12473ab5e147542 100644 (file)
@@ -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) => {}
 }