aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-19 13:53:16 +0100
committerAleksey Kladov <[email protected]>2019-07-19 14:09:32 +0100
commitf9d9e0a1f75b48813fe816a1e2a6c30146a36503 (patch)
tree254e13d1f0fb3072d02ba58f918de043a5cfcded /crates/ra_hir/src
parente4188899962774713707629d4e15255e3bc9c85e (diff)
several highlighting cleanups
* make stuff more type-safe by using `BindPat` instead of just `Pat` * don't add `mut` into binding hash * reset shadow counter when we enter a function
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/source_binder.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index e7bc4df97..55eb7da35 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -181,7 +181,7 @@ pub enum PathResolution {
181 /// An item 181 /// An item
182 Def(crate::ModuleDef), 182 Def(crate::ModuleDef),
183 /// A local binding (only value namespace) 183 /// A local binding (only value namespace)
184 LocalBinding(Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>), 184 LocalBinding(Either<AstPtr<ast::BindPat>, AstPtr<ast::SelfParam>>),
185 /// A generic parameter 185 /// A generic parameter
186 GenericParam(u32), 186 GenericParam(u32),
187 SelfType(crate::ImplBlock), 187 SelfType(crate::ImplBlock),
@@ -307,7 +307,18 @@ impl SourceAnalyzer {
307 let res = match res { 307 let res = match res {
308 crate::Resolution::Def(it) => PathResolution::Def(it), 308 crate::Resolution::Def(it) => PathResolution::Def(it),
309 crate::Resolution::LocalBinding(it) => { 309 crate::Resolution::LocalBinding(it) => {
310 PathResolution::LocalBinding(self.body_source_map.as_ref()?.pat_syntax(it)?) 310 // We get a `PatId` from resolver, but it actually can only
311 // point at `BindPat`, and not at the arbitrary pattern.
312 let pat_ptr = self.body_source_map.as_ref()?.pat_syntax(it)?;
313 let pat_ptr = match pat_ptr {
314 Either::A(pat) => {
315 let pat: AstPtr<ast::BindPat> =
316 pat.cast_checking_kind(|kind| kind == BIND_PAT).unwrap();
317 Either::A(pat)
318 }
319 Either::B(self_param) => Either::B(self_param),
320 };
321 PathResolution::LocalBinding(pat_ptr)
311 } 322 }
312 crate::Resolution::GenericParam(it) => PathResolution::GenericParam(it), 323 crate::Resolution::GenericParam(it) => PathResolution::GenericParam(it),
313 crate::Resolution::SelfType(it) => PathResolution::SelfType(it), 324 crate::Resolution::SelfType(it) => PathResolution::SelfType(it),