]> git.lizzy.rs Git - rust.git/commitdiff
Add test
authorJonas Schievink <jonasschievink@gmail.com>
Fri, 18 Dec 2020 19:01:02 +0000 (20:01 +0100)
committerJonas Schievink <jonasschievink@gmail.com>
Fri, 18 Dec 2020 19:01:02 +0000 (20:01 +0100)
crates/hir_def/src/nameres/tests/diagnostics.rs

index 1a7b988318e895ee0103779dafcb66d0c3d7ca25..4093f8bd0b446009c1cbed5af96292dff3d7a806 100644 (file)
@@ -119,3 +119,19 @@ fn inactive_item() {
         "#,
     );
 }
+
+/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
+#[test]
+fn inactive_via_cfg_attr() {
+    check_diagnostics(
+        r#"
+        //- /lib.rs
+          #[cfg_attr(not(never), cfg(no))] fn f() {}
+        //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
+
+          #[cfg_attr(not(never), cfg(not(no)))] fn f() {}
+
+          #[cfg_attr(never, cfg(no))] fn g() {}
+        "#,
+    );
+}