diff options
Diffstat (limited to 'crates/ra_assists/src/fill_match_arms.rs')
-rw-r--r-- | crates/ra_assists/src/fill_match_arms.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs index da67ab667..45e327cd4 100644 --- a/crates/ra_assists/src/fill_match_arms.rs +++ b/crates/ra_assists/src/fill_match_arms.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::fmt::Write; | 1 | use std::fmt::Write; |
2 | 2 | ||
3 | use hir::{ | 3 | use hir::{ |
4 | AdtDef, FieldSource, source_binder, | 4 | AdtDef, FieldSource, |
5 | db::HirDatabase, | 5 | db::HirDatabase, |
6 | }; | 6 | }; |
7 | use ra_syntax::ast::{self, AstNode}; | 7 | use ra_syntax::ast::{self, AstNode}; |
@@ -20,12 +20,8 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As | |||
20 | } | 20 | } |
21 | 21 | ||
22 | let expr = match_expr.expr()?; | 22 | let expr = match_expr.expr()?; |
23 | let function = | 23 | let analyzer = hir::SourceAnalyzer::new(ctx.db, ctx.frange.file_id, expr.syntax(), None); |
24 | source_binder::function_from_child_node(ctx.db, ctx.frange.file_id, expr.syntax())?; | 24 | let match_expr_ty = analyzer.type_of(ctx.db, expr)?; |
25 | let infer_result = function.infer(ctx.db); | ||
26 | let source_map = function.body_source_map(ctx.db); | ||
27 | let node_expr = source_map.node_expr(expr)?; | ||
28 | let match_expr_ty = infer_result[node_expr].clone(); | ||
29 | let enum_def = match_expr_ty.autoderef(ctx.db).find_map(|ty| match ty.as_adt() { | 25 | let enum_def = match_expr_ty.autoderef(ctx.db).find_map(|ty| match ty.as_adt() { |
30 | Some((AdtDef::Enum(e), _)) => Some(e), | 26 | Some((AdtDef::Enum(e), _)) => Some(e), |
31 | _ => None, | 27 | _ => None, |