aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 25a354947..e46f309ae 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -4,8 +4,9 @@ use std::path::{PathBuf, Path};
4use std::fs; 4use std::fs;
5 5
6use salsa::Database; 6use salsa::Database;
7use rustc_hash::FxHashMap;
7 8
8use ra_db::{SyntaxDatabase}; 9use ra_db::SyntaxDatabase;
9use ra_syntax::ast::{self, AstNode}; 10use ra_syntax::ast::{self, AstNode};
10use test_utils::{project_dir, assert_eq_text, read_text}; 11use test_utils::{project_dir, assert_eq_text, read_text};
11 12
@@ -193,7 +194,25 @@ fn infer(content: &str) -> String {
193 .unwrap() 194 .unwrap()
194 .unwrap(); 195 .unwrap();
195 let inference_result = func.infer(&db).unwrap(); 196 let inference_result = func.infer(&db).unwrap();
196 for (syntax_ptr, ty) in &inference_result.type_of { 197 let body_syntax_mapping = func.body_syntax_mapping(&db).unwrap();
198 let mut types = FxHashMap::default();
199 for (pat, ty) in &inference_result.type_of_pat {
200 let syntax_ptr = if let Some(sp) = body_syntax_mapping.pat_syntax(*pat) {
201 sp
202 } else {
203 continue;
204 };
205 types.insert(syntax_ptr, ty);
206 }
207 for (expr, ty) in &inference_result.type_of_expr {
208 let syntax_ptr = if let Some(sp) = body_syntax_mapping.expr_syntax(*expr) {
209 sp
210 } else {
211 continue;
212 };
213 types.insert(syntax_ptr, ty);
214 }
215 for (syntax_ptr, ty) in &types {
197 let node = syntax_ptr.resolve(&source_file); 216 let node = syntax_ptr.resolve(&source_file);
198 write!( 217 write!(
199 acc, 218 acc,
@@ -246,7 +265,6 @@ fn test_data_dir() -> PathBuf {
246} 265}
247 266
248#[test] 267#[test]
249#[should_panic] // TODO this should work once hir::Expr is used
250fn typing_whitespace_inside_a_function_should_not_invalidate_types() { 268fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
251 let (mut db, pos) = MockDatabase::with_position( 269 let (mut db, pos) = MockDatabase::with_position(
252 " 270 "