From cf494a515ff70675a4531585aa24a792f5b5e896 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 19 Mar 2021 18:24:04 +0100 Subject: Fix handling of `#![cfg]` in outline module file --- crates/hir_def/src/nameres/tests/mod_resolution.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/hir_def/src/nameres/tests') diff --git a/crates/hir_def/src/nameres/tests/mod_resolution.rs b/crates/hir_def/src/nameres/tests/mod_resolution.rs index dfbbad1f9..16a2cd27a 100644 --- a/crates/hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/hir_def/src/nameres/tests/mod_resolution.rs @@ -819,3 +819,22 @@ pub mod hash { pub trait Hash {} } "#]], ); } + +#[test] +fn cfg_in_module_file() { + // Inner `#![cfg]` in a module file makes the whole module disappear. + check( + r#" +//- /main.rs +mod module; + +//- /module.rs +#![cfg(NEVER)] + +struct AlsoShoulntAppear; + "#, + expect![[r#" + crate + "#]], + ) +} -- cgit v1.2.3