diff options
Diffstat (limited to 'crates/ra_assists/src/handlers/add_explicit_type.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_explicit_type.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 2cb9d2f48..a63ef48b1 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -51,14 +51,13 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> { | |||
51 | } | 51 | } |
52 | } | 52 | } |
53 | // Infer type | 53 | // Infer type |
54 | let db = ctx.db; | 54 | let ty = ctx.sema.type_of_expr(&expr)?; |
55 | let analyzer = ctx.source_analyzer(stmt.syntax(), None); | ||
56 | let ty = analyzer.type_of(db, &expr)?; | ||
57 | // Assist not applicable if the type is unknown | 55 | // Assist not applicable if the type is unknown |
58 | if ty.contains_unknown() { | 56 | if ty.contains_unknown() { |
59 | return None; | 57 | return None; |
60 | } | 58 | } |
61 | 59 | ||
60 | let db = ctx.db; | ||
62 | ctx.add_assist( | 61 | ctx.add_assist( |
63 | AssistId("add_explicit_type"), | 62 | AssistId("add_explicit_type"), |
64 | format!("Insert explicit type '{}'", ty.display(db)), | 63 | format!("Insert explicit type '{}'", ty.display(db)), |