aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/fill_match_arms.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-22 05:32:48 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-22 05:32:48 +0000
commit9c6c6a7cb51b701585827c1a39d36450ddb5cd51 (patch)
treec5e4c46da389accd0b03b3b285f5057265f65f65 /crates/ra_assists/src/fill_match_arms.rs
parent51323a852a8979a71c21725b3b2771224132b85f (diff)
parent1ee779d1f74f48d9f3098001c63108b794dbc0b5 (diff)
Merge #988
988: Consolidate Ty variants into a new variant Ty::Apply r=matklad a=flodiebold This gets us a lot closer to Chalk. It also introduces a lot of boilerplate, though, especially when matching :/ A lot of this can probably be refactored to be nicer, though. Co-authored-by: Florian Diebold <[email protected]>
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