From 382ee2fa037a3ec293d332dd70f04975396b5513 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 18 Dec 2020 20:01:02 +0100 Subject: Add test --- crates/hir_def/src/nameres/tests/diagnostics.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crates') diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index 1a7b98831..4093f8bd0 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs @@ -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() {} + "#, + ); +} -- cgit v1.2.3