aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-06 23:03:30 +0000
committerFlorian Diebold <[email protected]>2019-01-06 23:05:19 +0000
commit2dfb5e6ac03e9cc6973dffe9ad69e858510604ee (patch)
tree7c33751c8d61debbed276bd1e56046ce230c43e5 /crates/ra_analysis
parent71f7d82e45145281b9aec5bcdc694524864e552b (diff)
Improve types for node_expr / node_pat
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/completion/complete_dot.rs12
-rw-r--r--crates/ra_analysis/src/hover.rs4
2 files changed, 6 insertions, 10 deletions
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 @@
1use ra_db::LocalSyntaxPtr;
2use ra_syntax::ast::AstNode;
3use hir::{Ty, Def}; 1use hir::{Ty, Def};
4 2
5use crate::Cancelable; 3use crate::Cancelable;
@@ -13,12 +11,10 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
13 }; 11 };
14 let infer_result = function.infer(ctx.db)?; 12 let infer_result = function.infer(ctx.db)?;
15 let syntax_mapping = function.body_syntax_mapping(ctx.db)?; 13 let syntax_mapping = function.body_syntax_mapping(ctx.db)?;
16 let expr = 14 let expr = match syntax_mapping.node_expr(receiver) {
17 if let Some(expr) = syntax_mapping.syntax_expr(LocalSyntaxPtr::new(receiver.syntax())) { 15 Some(expr) => expr,
18 expr 16 None => return Ok(()),
19 } else { 17 };
20 return Ok(());
21 };
22 let receiver_ty = infer_result[expr].clone(); 18 let receiver_ty = infer_result[expr].clone();
23 if !ctx.is_method_call { 19 if !ctx.is_method_call {
24 complete_fields(acc, ctx, receiver_ty)?; 20 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<Option
65 )?); 65 )?);
66 let infer = function.infer(db)?; 66 let infer = function.infer(db)?;
67 let syntax_mapping = function.body_syntax_mapping(db)?; 67 let syntax_mapping = function.body_syntax_mapping(db)?;
68 if let Some(expr) = syntax_mapping.node_expr(node) { 68 if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) {
69 Ok(Some(infer[expr].to_string())) 69 Ok(Some(infer[expr].to_string()))
70 } else if let Some(pat) = syntax_mapping.node_pat(node) { 70 } else if let Some(pat) = ast::Pat::cast(node).and_then(|p| syntax_mapping.node_pat(p)) {
71 Ok(Some(infer[pat].to_string())) 71 Ok(Some(infer[pat].to_string()))
72 } else { 72 } else {
73 Ok(None) 73 Ok(None)