aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-28 18:29:36 +0100
committerAleksey Kladov <[email protected]>2018-08-28 18:29:36 +0100
commitb00a4d43ecd4af49a2870718a9d5b8d49084a285 (patch)
tree865f970d2d409bd17566d32a6b5e33eefa27ffe8 /crates
parent4c1f17af7d0085636434a8bc85e62434eb128516 (diff)
Dont diagnose inline mods
Diffstat (limited to 'crates')
-rw-r--r--crates/libanalysis/src/module_map.rs6
-rw-r--r--crates/libanalysis/tests/tests.rs13
2 files changed, 19 insertions, 0 deletions
diff --git a/crates/libanalysis/src/module_map.rs b/crates/libanalysis/src/module_map.rs
index b65569c46..47c0018e1 100644
--- a/crates/libanalysis/src/module_map.rs
+++ b/crates/libanalysis/src/module_map.rs
@@ -220,6 +220,12 @@ impl Link {
220 } 220 }
221 221
222 fn resolve(&mut self, file_resolver: &FileResolver) { 222 fn resolve(&mut self, file_resolver: &FileResolver) {
223 if !self.ast().has_semi() {
224 self.problem = None;
225 self.points_to = Vec::new();
226 return;
227 }
228
223 let mod_name = file_resolver.file_stem(self.owner.0); 229 let mod_name = file_resolver.file_stem(self.owner.0);
224 let is_dir_owner = 230 let is_dir_owner =
225 mod_name == "mod" || mod_name == "lib" || mod_name == "main"; 231 mod_name == "mod" || mod_name == "lib" || mod_name == "main";
diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs
index e378ab986..e05aa8895 100644
--- a/crates/libanalysis/tests/tests.rs
+++ b/crates/libanalysis/tests/tests.rs
@@ -79,6 +79,19 @@ fn test_unresolved_module_diagnostic() {
79} 79}
80 80
81#[test] 81#[test]
82fn test_unresolved_module_diagnostic_no_diag_for_inline_mode() {
83 let mut world = WorldState::new();
84 world.change_file(FileId(1), Some("mod foo {}".to_string()));
85
86 let snap = world.snapshot(FileMap(&[(1, "/lib.rs")]));
87 let diagnostics = snap.diagnostics(FileId(1)).unwrap();
88 assert_eq_dbg(
89 r#"[]"#,
90 &diagnostics,
91 );
92}
93
94#[test]
82fn test_resolve_parent_module() { 95fn test_resolve_parent_module() {
83 let mut world = WorldState::new(); 96 let mut world = WorldState::new();
84 world.change_file(FileId(1), Some("mod foo;".to_string())); 97 world.change_file(FileId(1), Some("mod foo;".to_string()));