diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/either.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 14 |
3 files changed, 12 insertions, 14 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/expr.rs b/crates/ra_hir/src/expr.rs index 70af3f119..66cb9633b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -564,11 +564,7 @@ where | |||
564 | .else_branch() | 564 | .else_branch() |
565 | .map(|b| match b { | 565 | .map(|b| match b { |
566 | ast::ElseBranch::Block(it) => self.collect_block(it), | 566 | ast::ElseBranch::Block(it) => self.collect_block(it), |
567 | ast::ElseBranch::IfExpr(elif) => { | 567 | ast::ElseBranch::IfExpr(elif) => self.collect_expr(elif.into()), |
568 | let expr: ast::Expr = | ||
569 | ast::Expr::cast(elif.syntax().clone()).unwrap(); | ||
570 | self.collect_expr(expr) | ||
571 | } | ||
572 | }) | 568 | }) |
573 | .unwrap_or_else(|| self.empty_block()); | 569 | .unwrap_or_else(|| self.empty_block()); |
574 | let placeholder_pat = self.pats.alloc(Pat::Missing); | 570 | let placeholder_pat = self.pats.alloc(Pat::Missing); |
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), |