aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs7
-rw-r--r--crates/ra_hir/src/ty/tests/data/0003_paths.rs10
-rw-r--r--crates/ra_hir/src/ty/tests/data/0003_paths.txt9
3 files changed, 25 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 0880b51bc..e0458327a 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,5 +1,8 @@
1use std::fmt::Write; 1use std::fmt::Write;
2use std::path::{PathBuf}; 2use std::path::{PathBuf};
3use std::sync::Once;
4
5use flexi_logger::Logger;
3 6
4use ra_db::{SyntaxDatabase}; 7use ra_db::{SyntaxDatabase};
5use ra_syntax::ast::{self, AstNode}; 8use ra_syntax::ast::{self, AstNode};
@@ -22,7 +25,7 @@ fn infer_file(content: &str) -> String {
22 let func = source_binder::function_from_source(&db, file_id, fn_def) 25 let func = source_binder::function_from_source(&db, file_id, fn_def)
23 .unwrap() 26 .unwrap()
24 .unwrap(); 27 .unwrap();
25 let inference_result = func.infer(&db); 28 let inference_result = func.infer(&db).unwrap();
26 for (syntax_ptr, ty) in &inference_result.type_for { 29 for (syntax_ptr, ty) in &inference_result.type_for {
27 let node = syntax_ptr.resolve(&source_file); 30 let node = syntax_ptr.resolve(&source_file);
28 write!( 31 write!(
@@ -58,6 +61,8 @@ fn ellipsize(mut text: String, max_len: usize) -> String {
58 61
59#[test] 62#[test]
60pub fn infer_tests() { 63pub fn infer_tests() {
64 static INIT: Once = Once::new();
65 INIT.call_once(|| Logger::with_env().start().unwrap());
61 dir_tests(&test_data_dir(), &["."], |text, _path| infer_file(text)); 66 dir_tests(&test_data_dir(), &["."], |text, _path| infer_file(text));
62} 67}
63 68
diff --git a/crates/ra_hir/src/ty/tests/data/0003_paths.rs b/crates/ra_hir/src/ty/tests/data/0003_paths.rs
new file mode 100644
index 000000000..e8b11198b
--- /dev/null
+++ b/crates/ra_hir/src/ty/tests/data/0003_paths.rs
@@ -0,0 +1,10 @@
1fn a() -> u32 { 1 }
2
3mod b {
4 fn c() -> u32 { 1 }
5}
6
7fn test() {
8 a();
9 b::c();
10}
diff --git a/crates/ra_hir/src/ty/tests/data/0003_paths.txt b/crates/ra_hir/src/ty/tests/data/0003_paths.txt
new file mode 100644
index 000000000..3a53370a2
--- /dev/null
+++ b/crates/ra_hir/src/ty/tests/data/0003_paths.txt
@@ -0,0 +1,9 @@
1[16; 17) '1': [unknown]
2[14; 19) '{ 1 }': [unknown]
3[47; 52) '{ 1 }': [unknown]
4[49; 50) '1': [unknown]
5[81; 87) 'b::c()': [unknown]
6[66; 90) '{ ...c(); }': ()
7[72; 73) 'a': fn() -> u32
8[72; 75) 'a()': [unknown]
9[81; 85) 'b::c': fn() -> u32