diff options
author | Jonas Schievink <[email protected]> | 2021-02-05 14:14:33 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-02-05 14:14:33 +0000 |
commit | 6239fe47306b6fa5a33e92e82d1e4dba76e4503f (patch) | |
tree | 836731a12104b925f4b801c7a8afa7fc7ca54280 /crates/hir_def | |
parent | ac5958485e5e77b020b3ebe0c100df5a5fe6ca08 (diff) |
Fix merging of `segment_index` in path resolution
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/nameres/path_resolution.rs | 7 |
1 files 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 f2b59172d..036e389b0 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs | |||
@@ -108,7 +108,6 @@ impl DefMap { | |||
108 | shadow: BuiltinShadowMode, | 108 | shadow: BuiltinShadowMode, |
109 | ) -> ResolvePathResult { | 109 | ) -> ResolvePathResult { |
110 | let mut result = ResolvePathResult::empty(ReachedFixedPoint::No); | 110 | let mut result = ResolvePathResult::empty(ReachedFixedPoint::No); |
111 | result.segment_index = Some(usize::max_value()); | ||
112 | 111 | ||
113 | let mut arc; | 112 | let mut arc; |
114 | let mut current_map = self; | 113 | let mut current_map = self; |
@@ -128,7 +127,11 @@ impl DefMap { | |||
128 | } | 127 | } |
129 | // FIXME: this doesn't seem right; what if the different namespace resolutions come from different crates? | 128 | // FIXME: this doesn't seem right; what if the different namespace resolutions come from different crates? |
130 | result.krate = result.krate.or(new.krate); | 129 | result.krate = result.krate.or(new.krate); |
131 | result.segment_index = result.segment_index.min(new.segment_index); | 130 | result.segment_index = match (result.segment_index, new.segment_index) { |
131 | (Some(idx), None) => Some(idx), | ||
132 | (Some(old), Some(new)) => Some(old.max(new)), | ||
133 | (None, new) => new, | ||
134 | }; | ||
132 | 135 | ||
133 | match ¤t_map.block { | 136 | match ¤t_map.block { |
134 | Some(block) => { | 137 | Some(block) => { |