diff options
Diffstat (limited to 'crates/ra_assists/src/add_explicit_type.rs')
-rw-r--r-- | crates/ra_assists/src/add_explicit_type.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/crates/ra_assists/src/add_explicit_type.rs b/crates/ra_assists/src/add_explicit_type.rs index 1dc59bb87..c50db4e21 100644 --- a/crates/ra_assists/src/add_explicit_type.rs +++ b/crates/ra_assists/src/add_explicit_type.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | use hir::{ | 1 | use hir::{ |
2 | HirDisplay, Ty, | 2 | HirDisplay, Ty, |
3 | db::HirDatabase, | 3 | db::HirDatabase, |
4 | source_binder::function_from_child_node, | ||
5 | }; | 4 | }; |
6 | use ra_syntax::{ | 5 | use ra_syntax::{ |
7 | SyntaxKind, | 6 | SyntaxKind, |
@@ -30,11 +29,8 @@ pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option< | |||
30 | } | 29 | } |
31 | // Infer type | 30 | // Infer type |
32 | let db = ctx.db; | 31 | let db = ctx.db; |
33 | let func = function_from_child_node(db, ctx.frange.file_id, pat.syntax())?; | 32 | let analyzer = hir::SourceAnalyser::new(db, ctx.frange.file_id, stmt.syntax()); |
34 | let inference_res = func.infer(db); | 33 | let ty = analyzer.type_of(db, expr)?; |
35 | let source_map = func.body_source_map(db); | ||
36 | let expr_id = source_map.node_expr(expr.into())?; | ||
37 | let ty = inference_res[expr_id].clone(); | ||
38 | // Assist not applicable if the type is unknown | 34 | // Assist not applicable if the type is unknown |
39 | if is_unknown(&ty) { | 35 | if is_unknown(&ty) { |
40 | return None; | 36 | return None; |