From 543d4ef7c536648704848f6df11c4a1ef31e11bc Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 16 Apr 2021 19:28:22 +0200 Subject: Fix primitive shadowing with inner items --- crates/hir_def/src/nameres/path_resolution.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index ccc9f22eb..c984148c3 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs @@ -387,7 +387,13 @@ impl DefMap { .get_legacy_macro(name) .map_or_else(PerNs::none, |m| PerNs::macros(m, Visibility::Public)); let from_scope = self[module].scope.get(name); - let from_builtin = BUILTIN_SCOPE.get(name).copied().unwrap_or_else(PerNs::none); + let from_builtin = match self.block { + Some(_) => { + // Only resolve to builtins in the root `DefMap`. + PerNs::none() + } + None => BUILTIN_SCOPE.get(name).copied().unwrap_or_else(PerNs::none), + }; let from_scope_or_builtin = match shadow { BuiltinShadowMode::Module => from_scope.or(from_builtin), BuiltinShadowMode::Other => { -- cgit v1.2.3