diff options
author | Florian Diebold <[email protected]> | 2019-03-17 18:37:09 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-03-21 21:17:00 +0000 |
commit | 8a5fbf471305894094726834f7701747fce9c961 (patch) | |
tree | d210d1a25099ca381bac2f0f2f3247fbd69b366d /crates/ra_assists/src | |
parent | 7a8ba535422a4e3d2b649acde75b5c400ef5e7c6 (diff) |
Remove the old variants replaced by Ty::Apply
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/fill_match_arms.rs | 14 | ||||
-rw-r--r-- | crates/ra_assists/src/fill_struct_fields.rs | 6 |
2 files changed, 8 insertions, 12 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 @@ | |||
1 | use std::fmt::Write; | 1 | use std::fmt::Write; |
2 | 2 | ||
3 | use hir::{ | 3 | use hir::{ |
4 | AdtDef, Ty, FieldSource, source_binder, | 4 | AdtDef, FieldSource, source_binder, |
5 | db::HirDatabase, | 5 | db::HirDatabase, |
6 | }; | 6 | }; |
7 | use ra_syntax::ast::{self, AstNode}; | 7 | use 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 | ||
diff --git a/crates/ra_assists/src/fill_struct_fields.rs b/crates/ra_assists/src/fill_struct_fields.rs index 6e61a58fc..c7790dc72 100644 --- a/crates/ra_assists/src/fill_struct_fields.rs +++ b/crates/ra_assists/src/fill_struct_fields.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::fmt::Write; | 1 | use std::fmt::Write; |
2 | 2 | ||
3 | use hir::{AdtDef, Ty, db::HirDatabase, source_binder::function_from_child_node}; | 3 | use hir::{AdtDef, db::HirDatabase, source_binder::function_from_child_node}; |
4 | 4 | ||
5 | use ra_syntax::ast::{self, AstNode}; | 5 | use ra_syntax::ast::{self, AstNode}; |
6 | 6 | ||
@@ -60,8 +60,8 @@ where | |||
60 | let source_map = function.body_source_map(self.ctx.db); | 60 | let source_map = function.body_source_map(self.ctx.db); |
61 | let node_expr = source_map.node_expr(self.struct_lit.into())?; | 61 | let node_expr = source_map.node_expr(self.struct_lit.into())?; |
62 | let struct_lit_ty = infer_result[node_expr].clone(); | 62 | let struct_lit_ty = infer_result[node_expr].clone(); |
63 | let struct_def = match struct_lit_ty { | 63 | let struct_def = match struct_lit_ty.as_adt() { |
64 | Ty::Adt { def_id: AdtDef::Struct(s), .. } => s, | 64 | Some((AdtDef::Struct(s), _)) => s, |
65 | _ => return None, | 65 | _ => return None, |
66 | }; | 66 | }; |
67 | self.struct_fields = struct_def | 67 | self.struct_fields = struct_def |