diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index ecc63f376..87d6bcaec 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -4,7 +4,7 @@ use std::fmt::Write; | |||
4 | use insta::assert_snapshot_matches; | 4 | use insta::assert_snapshot_matches; |
5 | 5 | ||
6 | use ra_db::{SourceDatabase, salsa::Database, FilePosition}; | 6 | use ra_db::{SourceDatabase, salsa::Database, FilePosition}; |
7 | use ra_syntax::{algo, ast::{self, AstNode}}; | 7 | use ra_syntax::{algo, ast::{self, AstNode}, SyntaxKind::*}; |
8 | use test_utils::covers; | 8 | use test_utils::covers; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -12,7 +12,8 @@ use crate::{ | |||
12 | mock::MockDatabase, | 12 | mock::MockDatabase, |
13 | ty::display::HirDisplay, | 13 | ty::display::HirDisplay, |
14 | ty::InferenceResult, | 14 | ty::InferenceResult, |
15 | expr::BodySourceMap | 15 | expr::BodySourceMap, |
16 | SourceAnalyzer, | ||
16 | }; | 17 | }; |
17 | 18 | ||
18 | // These tests compare the inference results for all expressions in a file | 19 | // These tests compare the inference results for all expressions in a file |
@@ -1862,14 +1863,14 @@ fn test() { | |||
1862 | @r###" | 1863 | @r###" |
1863 | [49; 50) '0': u32 | 1864 | [49; 50) '0': u32 |
1864 | [80; 83) '101': u32 | 1865 | [80; 83) '101': u32 |
1865 | [126; 128) '99': u32 | ||
1866 | [95; 213) '{ ...NST; }': () | 1866 | [95; 213) '{ ...NST; }': () |
1867 | [138; 139) 'x': {unknown} | 1867 | [138; 139) 'x': {unknown} |
1868 | [142; 153) 'LOCAL_CONST': {unknown} | 1868 | [142; 153) 'LOCAL_CONST': {unknown} |
1869 | [163; 164) 'z': u32 | 1869 | [163; 164) 'z': u32 |
1870 | [167; 179) 'GLOBAL_CONST': u32 | 1870 | [167; 179) 'GLOBAL_CONST': u32 |
1871 | [189; 191) 'id': u32 | 1871 | [189; 191) 'id': u32 |
1872 | [194; 210) 'Foo::A..._CONST': u32"### | 1872 | [194; 210) 'Foo::A..._CONST': u32 |
1873 | [126; 128) '99': u32"### | ||
1873 | ); | 1874 | ); |
1874 | } | 1875 | } |
1875 | 1876 | ||
@@ -1891,8 +1892,6 @@ fn test() { | |||
1891 | @r###" | 1892 | @r###" |
1892 | [29; 32) '101': u32 | 1893 | [29; 32) '101': u32 |
1893 | [70; 73) '101': u32 | 1894 | [70; 73) '101': u32 |
1894 | [118; 120) '99': u32 | ||
1895 | [161; 163) '99': u32 | ||
1896 | [85; 280) '{ ...MUT; }': () | 1895 | [85; 280) '{ ...MUT; }': () |
1897 | [173; 174) 'x': {unknown} | 1896 | [173; 174) 'x': {unknown} |
1898 | [177; 189) 'LOCAL_STATIC': {unknown} | 1897 | [177; 189) 'LOCAL_STATIC': {unknown} |
@@ -1901,7 +1900,9 @@ fn test() { | |||
1901 | [229; 230) 'z': u32 | 1900 | [229; 230) 'z': u32 |
1902 | [233; 246) 'GLOBAL_STATIC': u32 | 1901 | [233; 246) 'GLOBAL_STATIC': u32 |
1903 | [256; 257) 'w': u32 | 1902 | [256; 257) 'w': u32 |
1904 | [260; 277) 'GLOBAL...IC_MUT': u32"### | 1903 | [260; 277) 'GLOBAL...IC_MUT': u32 |
1904 | [118; 120) '99': u32 | ||
1905 | [161; 163) '99': u32"### | ||
1905 | ); | 1906 | ); |
1906 | } | 1907 | } |
1907 | 1908 | ||
@@ -2350,25 +2351,11 @@ fn infer(content: &str) -> String { | |||
2350 | } | 2351 | } |
2351 | }; | 2352 | }; |
2352 | 2353 | ||
2353 | for const_def in source_file.syntax().descendants().filter_map(ast::ConstDef::cast) { | 2354 | for node in source_file.syntax().descendants() { |
2354 | let konst = source_binder::const_from_source(&db, file_id, const_def).unwrap(); | 2355 | if node.kind() == FN_DEF || node.kind() == CONST_DEF || node.kind() == STATIC_DEF { |
2355 | let inference_result = konst.infer(&db); | 2356 | let analyzer = SourceAnalyzer::new(&db, file_id, node, None); |
2356 | let body_source_map = konst.body_source_map(&db); | 2357 | infer_def(analyzer.inference_result(), analyzer.body_source_map()); |
2357 | infer_def(inference_result, body_source_map) | 2358 | } |
2358 | } | ||
2359 | |||
2360 | for static_def in source_file.syntax().descendants().filter_map(ast::StaticDef::cast) { | ||
2361 | let static_ = source_binder::static_from_source(&db, file_id, static_def).unwrap(); | ||
2362 | let inference_result = static_.infer(&db); | ||
2363 | let body_source_map = static_.body_source_map(&db); | ||
2364 | infer_def(inference_result, body_source_map) | ||
2365 | } | ||
2366 | |||
2367 | for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) { | ||
2368 | let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); | ||
2369 | let inference_result = func.infer(&db); | ||
2370 | let body_source_map = func.body_source_map(&db); | ||
2371 | infer_def(inference_result, body_source_map) | ||
2372 | } | 2359 | } |
2373 | 2360 | ||
2374 | acc.truncate(acc.trim_end().len()); | 2361 | acc.truncate(acc.trim_end().len()); |