diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-04 19:59:21 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-04 19:59:21 +0000 |
commit | de046bf4572a75cf534a2342358a422b2f18d01c (patch) | |
tree | 87f58e72537569806e689a6be4c404a496431360 /crates/hir_def/src/resolver.rs | |
parent | 4c1fcda0f8183060de5a341fffa2b30e65bdb52f (diff) | |
parent | 5d99ba1d9a5acf02a5cd50e456f164bd80b523b5 (diff) |
Merge #7559
7559: Make `ModPath`'s representation private r=jonas-schievink a=jonas-schievink
This lets us switch out the `Vec` for something more efficient
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/resolver.rs')
-rw-r--r-- | crates/hir_def/src/resolver.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index 9021ea712..f9ad50301 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs | |||
@@ -164,7 +164,7 @@ impl Resolver { | |||
164 | db: &dyn DefDatabase, | 164 | db: &dyn DefDatabase, |
165 | path: &ModPath, | 165 | path: &ModPath, |
166 | ) -> Option<(TypeNs, Option<usize>)> { | 166 | ) -> Option<(TypeNs, Option<usize>)> { |
167 | let first_name = path.segments.first()?; | 167 | let first_name = path.segments().first()?; |
168 | let skip_to_mod = path.kind != PathKind::Plain; | 168 | let skip_to_mod = path.kind != PathKind::Plain; |
169 | for scope in self.scopes.iter().rev() { | 169 | for scope in self.scopes.iter().rev() { |
170 | match scope { | 170 | match scope { |
@@ -179,7 +179,7 @@ impl Resolver { | |||
179 | 179 | ||
180 | Scope::GenericParams { params, def } => { | 180 | Scope::GenericParams { params, def } => { |
181 | if let Some(local_id) = params.find_type_by_name(first_name) { | 181 | if let Some(local_id) = params.find_type_by_name(first_name) { |
182 | let idx = if path.segments.len() == 1 { None } else { Some(1) }; | 182 | let idx = if path.segments().len() == 1 { None } else { Some(1) }; |
183 | return Some(( | 183 | return Some(( |
184 | TypeNs::GenericParam(TypeParamId { local_id, parent: *def }), | 184 | TypeNs::GenericParam(TypeParamId { local_id, parent: *def }), |
185 | idx, | 185 | idx, |
@@ -188,13 +188,13 @@ impl Resolver { | |||
188 | } | 188 | } |
189 | Scope::ImplDefScope(impl_) => { | 189 | Scope::ImplDefScope(impl_) => { |
190 | if first_name == &name![Self] { | 190 | if first_name == &name![Self] { |
191 | let idx = if path.segments.len() == 1 { None } else { Some(1) }; | 191 | let idx = if path.segments().len() == 1 { None } else { Some(1) }; |
192 | return Some((TypeNs::SelfType(*impl_), idx)); | 192 | return Some((TypeNs::SelfType(*impl_), idx)); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | Scope::AdtScope(adt) => { | 195 | Scope::AdtScope(adt) => { |
196 | if first_name == &name![Self] { | 196 | if first_name == &name![Self] { |
197 | let idx = if path.segments.len() == 1 { None } else { Some(1) }; | 197 | let idx = if path.segments().len() == 1 { None } else { Some(1) }; |
198 | return Some((TypeNs::AdtSelfType(*adt), idx)); | 198 | return Some((TypeNs::AdtSelfType(*adt), idx)); |
199 | } | 199 | } |
200 | } | 200 | } |
@@ -270,9 +270,9 @@ impl Resolver { | |||
270 | db: &dyn DefDatabase, | 270 | db: &dyn DefDatabase, |
271 | path: &ModPath, | 271 | path: &ModPath, |
272 | ) -> Option<ResolveValueResult> { | 272 | ) -> Option<ResolveValueResult> { |
273 | let n_segments = path.segments.len(); | 273 | let n_segments = path.segments().len(); |
274 | let tmp = name![self]; | 274 | let tmp = name![self]; |
275 | let first_name = if path.is_self() { &tmp } else { path.segments.first()? }; | 275 | let first_name = if path.is_self() { &tmp } else { path.segments().first()? }; |
276 | let skip_to_mod = path.kind != PathKind::Plain && !path.is_self(); | 276 | let skip_to_mod = path.kind != PathKind::Plain && !path.is_self(); |
277 | for scope in self.scopes.iter().rev() { | 277 | for scope in self.scopes.iter().rev() { |
278 | match scope { | 278 | match scope { |