Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/macro_expansion_tests/proc_macros.rs')
-rw-r--r--crates/hir-def/src/macro_expansion_tests/proc_macros.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
index 70e3e1ed4e..a43c0eb9d7 100644
--- a/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
+++ b/crates/hir-def/src/macro_expansion_tests/proc_macros.rs
@@ -5,7 +5,7 @@
//! in-memory macros.
use expect_test::expect;
-use crate::macro_expansion_tests::check;
+use crate::macro_expansion_tests::{check, check_errors};
#[test]
fn attribute_macro_attr_censoring() {
@@ -216,3 +216,21 @@ struct S;
#[doc = "doc attr"] struct S;"##]],
);
}
+
+#[test]
+fn cfg_evaluated_before_attr_macros() {
+ check_errors(
+ r#"
+//- proc_macros: disallow_cfg
+
+use proc_macros::disallow_cfg;
+
+#[disallow_cfg] #[cfg(false)] fn foo() {}
+// True cfg are kept.
+// #[disallow_cfg] #[cfg(true)] fn bar() {}
+#[disallow_cfg] #[cfg_attr(false, inline)] fn baz() {}
+#[disallow_cfg] #[cfg_attr(true, inline)] fn qux() {}
+ "#,
+ expect![[r#""#]],
+ );
+}