From 2dfb5e6ac03e9cc6973dffe9ad69e858510604ee Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 7 Jan 2019 00:03:30 +0100 Subject: Improve types for node_expr / node_pat --- crates/ra_analysis/src/completion/complete_dot.rs | 12 ++++-------- crates/ra_analysis/src/hover.rs | 4 ++-- crates/ra_hir/src/expr.rs | 10 +++++----- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/src/completion/complete_dot.rs b/crates/ra_analysis/src/completion/complete_dot.rs index ef3f4271b..54ce1b638 100644 --- a/crates/ra_analysis/src/completion/complete_dot.rs +++ b/crates/ra_analysis/src/completion/complete_dot.rs @@ -1,5 +1,3 @@ -use ra_db::LocalSyntaxPtr; -use ra_syntax::ast::AstNode; use hir::{Ty, Def}; use crate::Cancelable; @@ -13,12 +11,10 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca }; let infer_result = function.infer(ctx.db)?; let syntax_mapping = function.body_syntax_mapping(ctx.db)?; - let expr = - if let Some(expr) = syntax_mapping.syntax_expr(LocalSyntaxPtr::new(receiver.syntax())) { - expr - } else { - return Ok(()); - }; + let expr = match syntax_mapping.node_expr(receiver) { + Some(expr) => expr, + None => return Ok(()), + }; let receiver_ty = infer_result[expr].clone(); if !ctx.is_method_call { complete_fields(acc, ctx, receiver_ty)?; diff --git a/crates/ra_analysis/src/hover.rs b/crates/ra_analysis/src/hover.rs index 067e5c12d..06632df4f 100644 --- a/crates/ra_analysis/src/hover.rs +++ b/crates/ra_analysis/src/hover.rs @@ -65,9 +65,9 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Cancelable