diff options
Diffstat (limited to 'crates/ra_assists/src/fill_struct_fields.rs')
-rw-r--r-- | crates/ra_assists/src/fill_struct_fields.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_assists/src/fill_struct_fields.rs b/crates/ra_assists/src/fill_struct_fields.rs index c7790dc72..e23cccbb8 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, db::HirDatabase, source_binder::function_from_child_node}; | 3 | use hir::{AdtDef, db::HirDatabase}; |
4 | 4 | ||
5 | use ra_syntax::ast::{self, AstNode}; | 5 | use ra_syntax::ast::{self, AstNode}; |
6 | 6 | ||
@@ -51,15 +51,12 @@ where | |||
51 | } | 51 | } |
52 | 52 | ||
53 | fn evaluate_struct_def_fields(&mut self) -> Option<()> { | 53 | fn evaluate_struct_def_fields(&mut self) -> Option<()> { |
54 | let function = function_from_child_node( | 54 | let analyzer = hir::SourceAnalyser::new( |
55 | self.ctx.db, | 55 | self.ctx.db, |
56 | self.ctx.frange.file_id, | 56 | self.ctx.frange.file_id, |
57 | self.struct_lit.syntax(), | 57 | self.struct_lit.syntax(), |
58 | )?; | 58 | ); |
59 | let infer_result = function.infer(self.ctx.db); | 59 | let struct_lit_ty = analyzer.type_of(self.ctx.db, self.struct_lit.into())?; |
60 | let source_map = function.body_source_map(self.ctx.db); | ||
61 | let node_expr = source_map.node_expr(self.struct_lit.into())?; | ||
62 | let struct_lit_ty = infer_result[node_expr].clone(); | ||
63 | let struct_def = match struct_lit_ty.as_adt() { | 60 | let struct_def = match struct_lit_ty.as_adt() { |
64 | Some((AdtDef::Struct(s), _)) => s, | 61 | Some((AdtDef::Struct(s), _)) => s, |
65 | _ => return None, | 62 | _ => return None, |