Skip to content

Commit 382ee2f

Browse files
Add test
1 parent d42d1d3 commit 382ee2f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/hir_def/src/nameres/tests/diagnostics.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,19 @@ fn inactive_item() {
119119
"#,
120120
);
121121
}
122+
123+
/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
124+
#[test]
125+
fn inactive_via_cfg_attr() {
126+
check_diagnostics(
127+
r#"
128+
//- /lib.rs
129+
#[cfg_attr(not(never), cfg(no))] fn f() {}
130+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
131+
132+
#[cfg_attr(not(never), cfg(not(no)))] fn f() {}
133+
134+
#[cfg_attr(never, cfg(no))] fn g() {}
135+
"#,
136+
);
137+
}

0 commit comments

Comments
 (0)