diff options
author | Phil Ellison <[email protected]> | 2019-08-12 20:39:11 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-25 10:56:23 +0100 |
commit | 200470692ff1023024f0d4a6c35deb43d3045f10 (patch) | |
tree | 4243427223e07a9136c764e43c2dbf59f9a73772 /crates/ra_hir/src | |
parent | c8911e872eb46f811f645190e154b504fac157df (diff) |
Cast SyntaxNodePtr to AstPtr directly
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/expr/validation.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index fce1c2f14..e35990d2e 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -145,21 +145,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
145 | if params.len() == 2 && ¶ms[0] == &mismatch.actual { | 145 | if params.len() == 2 && ¶ms[0] == &mismatch.actual { |
146 | let source_map = self.func.body_source_map(db); | 146 | let source_map = self.func.body_source_map(db); |
147 | let file_id = self.func.source(db).file_id; | 147 | let file_id = self.func.source(db).file_id; |
148 | let parse = db.parse(file_id.original_file(db)); | ||
149 | let source_file = parse.tree(); | ||
150 | let expr_syntax = source_map.expr_syntax(id); | ||
151 | if expr_syntax.is_none() { | ||
152 | return; | ||
153 | } | ||
154 | let expr_syntax = expr_syntax.unwrap(); | ||
155 | let node = expr_syntax.to_node(source_file.syntax()); | ||
156 | let ast = ast::Expr::cast(node); | ||
157 | if ast.is_none() { | ||
158 | return; | ||
159 | } | ||
160 | let ast = ast.unwrap(); | ||
161 | 148 | ||
162 | self.sink.push(MissingOkInTailExpr { file: file_id, expr: AstPtr::new(&ast) }); | 149 | if let Some(expr) = source_map.expr_syntax(id).and_then(|n| n.cast::<ast::Expr>()) { |
150 | self.sink.push(MissingOkInTailExpr { file: file_id, expr }); | ||
151 | } | ||
163 | } | 152 | } |
164 | } | 153 | } |
165 | } | 154 | } |