diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-06 14:19:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-06 14:19:58 +0000 |
commit | 1cc6879576b04850db3dd8aa1df0cf7c8f270503 (patch) | |
tree | 9221e6742315cc0faa8cdec5d44852afcf7d28e1 /crates/ra_hir_ty/src/tests.rs | |
parent | 5947c1f8b52deb4fcfd97970ba6eb473f092cb94 (diff) | |
parent | 57da3df99a52ccedd7a684d2053db766e5681a61 (diff) |
Merge #3489
3489: More robust expression lowering r=matklad a=matklad
Closes #2236
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 087edcc92..7e9547340 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -11,8 +11,13 @@ use std::fmt::Write; | |||
11 | use std::sync::Arc; | 11 | use std::sync::Arc; |
12 | 12 | ||
13 | use hir_def::{ | 13 | use hir_def::{ |
14 | body::BodySourceMap, child_by_source::ChildBySource, db::DefDatabase, item_scope::ItemScope, | 14 | body::{BodySourceMap, SyntheticSyntax}, |
15 | keys, nameres::CrateDefMap, AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, | 15 | child_by_source::ChildBySource, |
16 | db::DefDatabase, | ||
17 | item_scope::ItemScope, | ||
18 | keys, | ||
19 | nameres::CrateDefMap, | ||
20 | AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, | ||
16 | }; | 21 | }; |
17 | use hir_expand::InFile; | 22 | use hir_expand::InFile; |
18 | use insta::assert_snapshot; | 23 | use insta::assert_snapshot; |
@@ -67,20 +72,20 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { | |||
67 | 72 | ||
68 | for (pat, ty) in inference_result.type_of_pat.iter() { | 73 | for (pat, ty) in inference_result.type_of_pat.iter() { |
69 | let syntax_ptr = match body_source_map.pat_syntax(pat) { | 74 | let syntax_ptr = match body_source_map.pat_syntax(pat) { |
70 | Some(sp) => { | 75 | Ok(sp) => { |
71 | sp.map(|ast| ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr())) | 76 | sp.map(|ast| ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr())) |
72 | } | 77 | } |
73 | None => continue, | 78 | Err(SyntheticSyntax) => continue, |
74 | }; | 79 | }; |
75 | types.push((syntax_ptr, ty)); | 80 | types.push((syntax_ptr, ty)); |
76 | } | 81 | } |
77 | 82 | ||
78 | for (expr, ty) in inference_result.type_of_expr.iter() { | 83 | for (expr, ty) in inference_result.type_of_expr.iter() { |
79 | let syntax_ptr = match body_source_map.expr_syntax(expr) { | 84 | let syntax_ptr = match body_source_map.expr_syntax(expr) { |
80 | Some(sp) => { | 85 | Ok(sp) => { |
81 | sp.map(|ast| ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr())) | 86 | sp.map(|ast| ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr())) |
82 | } | 87 | } |
83 | None => continue, | 88 | Err(SyntheticSyntax) => continue, |
84 | }; | 89 | }; |
85 | types.push((syntax_ptr, ty)); | 90 | types.push((syntax_ptr, ty)); |
86 | if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr) { | 91 | if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr) { |