From c2622c922887368788674d1735a7705fc345a5b9 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 10 Mar 2021 16:33:18 +0100 Subject: Prefer names from outer DefMap over extern prelude --- crates/hir_def/src/nameres/path_resolution.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'crates/hir_def/src') diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index 8258dcffb..db459b1ed 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs @@ -156,7 +156,7 @@ impl DefMap { } } - pub(super) fn resolve_path_fp_with_macro_single( + fn resolve_path_fp_with_macro_single( &self, db: &dyn DefDatabase, mode: ResolveMode, @@ -384,10 +384,16 @@ impl DefMap { } } }; - let from_extern_prelude = self - .extern_prelude - .get(name) - .map_or(PerNs::none(), |&it| PerNs::types(it, Visibility::Public)); + // Give precedence to names in outer `DefMap`s over the extern prelude; only check prelude + // from the crate DefMap. + let from_extern_prelude = match self.block { + Some(_) => PerNs::none(), + None => self + .extern_prelude + .get(name) + .map_or(PerNs::none(), |&it| PerNs::types(it, Visibility::Public)), + }; + let from_prelude = self.resolve_in_prelude(db, name); from_legacy_macro.or(from_scope_or_builtin).or(from_extern_prelude).or(from_prelude) -- cgit v1.2.3