From 6239fe47306b6fa5a33e92e82d1e4dba76e4503f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 5 Feb 2021 15:14:33 +0100 Subject: [PATCH] Fix merging of `segment_index` in path resolution --- crates/hir_def/src/nameres/path_resolution.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index f2b59172dce..036e389b01d 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs @@ -108,7 +108,6 @@ pub(super) fn resolve_path_fp_with_macro( shadow: BuiltinShadowMode, ) -> ResolvePathResult { let mut result = ResolvePathResult::empty(ReachedFixedPoint::No); - result.segment_index = Some(usize::max_value()); let mut arc; let mut current_map = self; @@ -128,7 +127,11 @@ pub(super) fn resolve_path_fp_with_macro( } // FIXME: this doesn't seem right; what if the different namespace resolutions come from different crates? result.krate = result.krate.or(new.krate); - result.segment_index = result.segment_index.min(new.segment_index); + result.segment_index = match (result.segment_index, new.segment_index) { + (Some(idx), None) => Some(idx), + (Some(old), Some(new)) => Some(old.max(new)), + (None, new) => new, + }; match ¤t_map.block { Some(block) => {