aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/fill_match_arms.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/fill_match_arms.rs')
-rw-r--r--crates/ra_assists/src/fill_match_arms.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs
index 6a22b0af5..da67ab667 100644
--- a/crates/ra_assists/src/fill_match_arms.rs
+++ b/crates/ra_assists/src/fill_match_arms.rs
@@ -1,7 +1,7 @@
1use std::fmt::Write; 1use std::fmt::Write;
2 2
3use hir::{ 3use hir::{
4 AdtDef, Ty, FieldSource, source_binder, 4 AdtDef, FieldSource, source_binder,
5 db::HirDatabase, 5 db::HirDatabase,
6}; 6};
7use ra_syntax::ast::{self, AstNode}; 7use ra_syntax::ast::{self, AstNode};
@@ -26,14 +26,10 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As
26 let source_map = function.body_source_map(ctx.db); 26 let source_map = function.body_source_map(ctx.db);
27 let node_expr = source_map.node_expr(expr)?; 27 let node_expr = source_map.node_expr(expr)?;
28 let match_expr_ty = infer_result[node_expr].clone(); 28 let match_expr_ty = infer_result[node_expr].clone();
29 let enum_def = match match_expr_ty { 29 let enum_def = match_expr_ty.autoderef(ctx.db).find_map(|ty| match ty.as_adt() {
30 Ty::Adt { def_id: AdtDef::Enum(e), .. } => e, 30 Some((AdtDef::Enum(e), _)) => Some(e),
31 Ty::Ref(adt, _) => match *adt { 31 _ => None,
32 Ty::Adt { def_id: AdtDef::Enum(e), .. } => e, 32 })?;
33 _ => return None,
34 },
35 _ => return None,
36 };
37 let enum_name = enum_def.name(ctx.db)?; 33 let enum_name = enum_def.name(ctx.db)?;
38 let db = ctx.db; 34 let db = ctx.db;
39 35