aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/either.rs6
-rw-r--r--crates/ra_hir/src/source_binder.rs14
2 files changed, 11 insertions, 9 deletions
diff --git a/crates/ra_hir/src/either.rs b/crates/ra_hir/src/either.rs
index 71c53ebc0..439e6ec87 100644
--- a/crates/ra_hir/src/either.rs
+++ b/crates/ra_hir/src/either.rs
@@ -25,6 +25,12 @@ impl<A, B> Either<A, B> {
25 Either::B(b) => Either::B(f2(b)), 25 Either::B(b) => Either::B(f2(b)),
26 } 26 }
27 } 27 }
28 pub fn map_a<U, F>(self, f: F) -> Either<U, B>
29 where
30 F: FnOnce(A) -> U,
31 {
32 self.map(f, |it| it)
33 }
28 pub fn a(self) -> Option<A> { 34 pub fn a(self) -> Option<A> {
29 match self { 35 match self {
30 Either::A(it) => Some(it), 36 Either::A(it) => Some(it),
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 55eb7da35..df67d2c39 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -309,15 +309,11 @@ impl SourceAnalyzer {
309 crate::Resolution::LocalBinding(it) => { 309 crate::Resolution::LocalBinding(it) => {
310 // We get a `PatId` from resolver, but it actually can only 310 // We get a `PatId` from resolver, but it actually can only
311 // point at `BindPat`, and not at the arbitrary pattern. 311 // point at `BindPat`, and not at the arbitrary pattern.
312 let pat_ptr = self.body_source_map.as_ref()?.pat_syntax(it)?; 312 let pat_ptr = self
313 let pat_ptr = match pat_ptr { 313 .body_source_map
314 Either::A(pat) => { 314 .as_ref()?
315 let pat: AstPtr<ast::BindPat> = 315 .pat_syntax(it)?
316 pat.cast_checking_kind(|kind| kind == BIND_PAT).unwrap(); 316 .map_a(|ptr| ptr.cast::<ast::BindPat>().unwrap());
317 Either::A(pat)
318 }
319 Either::B(self_param) => Either::B(self_param),
320 };
321 PathResolution::LocalBinding(pat_ptr) 317 PathResolution::LocalBinding(pat_ptr)
322 } 318 }
323 crate::Resolution::GenericParam(it) => PathResolution::GenericParam(it), 319 crate::Resolution::GenericParam(it) => PathResolution::GenericParam(it),