aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/lib.rs2
-rw-r--r--crates/ra_hir_def/src/marks.rs14
-rw-r--r--crates/ra_hir_def/src/nameres.rs8
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs15
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs4
-rw-r--r--crates/ra_hir_def/src/nameres/tests.rs8
-rw-r--r--crates/ra_hir_def/src/nameres/tests/globs.rs4
-rw-r--r--crates/ra_hir_def/src/nameres/tests/macros.rs10
-rw-r--r--crates/ra_hir_def/src/nameres/tests/mod_resolution.rs2
9 files changed, 41 insertions, 26 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index 02bd808fc..63ed2a098 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -17,6 +17,8 @@ pub mod diagnostics;
17 17
18#[cfg(test)] 18#[cfg(test)]
19mod test_db; 19mod test_db;
20#[cfg(test)]
21mod marks;
20 22
21// FIXME: this should be private 23// FIXME: this should be private
22pub mod nameres; 24pub mod nameres;
diff --git a/crates/ra_hir_def/src/marks.rs b/crates/ra_hir_def/src/marks.rs
new file mode 100644
index 000000000..0b99eac71
--- /dev/null
+++ b/crates/ra_hir_def/src/marks.rs
@@ -0,0 +1,14 @@
1//! See test_utils/src/marks.rs
2
3test_utils::marks!(
4 bogus_paths
5 name_res_works_for_broken_modules
6 can_import_enum_variant
7 glob_enum
8 glob_across_crates
9 std_prelude
10 macro_rules_from_other_crates_are_visible_with_macro_use
11 prelude_is_macro_use
12 macro_dollar_crate_self
13 macro_dollar_crate_other
14);
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index b3640da3d..b5c682219 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -18,7 +18,7 @@ use ra_db::{CrateId, Edition, FileId};
18use ra_prof::profile; 18use ra_prof::profile;
19use ra_syntax::ast; 19use ra_syntax::ast;
20use rustc_hash::{FxHashMap, FxHashSet}; 20use rustc_hash::{FxHashMap, FxHashSet};
21// use test_utils::tested_by; 21use test_utils::tested_by;
22 22
23use crate::{ 23use crate::{
24 builtin_type::BuiltinType, 24 builtin_type::BuiltinType,
@@ -263,12 +263,12 @@ impl CrateDefMap {
263 let mut curr_per_ns: PerNs = match path.kind { 263 let mut curr_per_ns: PerNs = match path.kind {
264 PathKind::DollarCrate(krate) => { 264 PathKind::DollarCrate(krate) => {
265 if krate == self.krate { 265 if krate == self.krate {
266 // tested_by!(macro_dollar_crate_self); 266 tested_by!(macro_dollar_crate_self);
267 PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) 267 PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into())
268 } else { 268 } else {
269 let def_map = db.crate_def_map(krate); 269 let def_map = db.crate_def_map(krate);
270 let module = ModuleId { krate, module_id: def_map.root }; 270 let module = ModuleId { krate, module_id: def_map.root };
271 // tested_by!(macro_dollar_crate_other); 271 tested_by!(macro_dollar_crate_other);
272 PerNs::types(module.into()) 272 PerNs::types(module.into())
273 } 273 }
274 } 274 }
@@ -369,7 +369,7 @@ impl CrateDefMap {
369 } 369 }
370 ModuleDefId::AdtId(AdtId::EnumId(e)) => { 370 ModuleDefId::AdtId(AdtId::EnumId(e)) => {
371 // enum variant 371 // enum variant
372 // tested_by!(can_import_enum_variant); 372 tested_by!(can_import_enum_variant);
373 let enum_data = db.enum_data(e); 373 let enum_data = db.enum_data(e);
374 match enum_data.variant(&segment.name) { 374 match enum_data.variant(&segment.name) {
375 Some(local_id) => { 375 Some(local_id) => {
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 0bc36910c..3b61d9895 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -8,7 +8,7 @@ use ra_cfg::CfgOptions;
8use ra_db::{CrateId, FileId}; 8use ra_db::{CrateId, FileId};
9use ra_syntax::{ast, SmolStr}; 9use ra_syntax::{ast, SmolStr};
10use rustc_hash::FxHashMap; 10use rustc_hash::FxHashMap;
11// use test_utils::tested_by; 11use test_utils::tested_by;
12 12
13use crate::{ 13use crate::{
14 attr::Attr, 14 attr::Attr,
@@ -218,7 +218,7 @@ where
218 ); 218 );
219 219
220 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { 220 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() {
221 // tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use); 221 tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use);
222 self.import_all_macros_exported(current_module_id, m.krate); 222 self.import_all_macros_exported(current_module_id, m.krate);
223 } 223 }
224 } 224 }
@@ -294,10 +294,10 @@ where
294 match def.take_types() { 294 match def.take_types() {
295 Some(ModuleDefId::ModuleId(m)) => { 295 Some(ModuleDefId::ModuleId(m)) => {
296 if import.is_prelude { 296 if import.is_prelude {
297 // tested_by!(std_prelude); 297 tested_by!(std_prelude);
298 self.def_map.prelude = Some(m); 298 self.def_map.prelude = Some(m);
299 } else if m.krate != self.def_map.krate { 299 } else if m.krate != self.def_map.krate {
300 // tested_by!(glob_across_crates); 300 tested_by!(glob_across_crates);
301 // glob import from other crate => we can just import everything once 301 // glob import from other crate => we can just import everything once
302 let item_map = self.db.crate_def_map(m.krate); 302 let item_map = self.db.crate_def_map(m.krate);
303 let scope = &item_map[m.module_id].scope; 303 let scope = &item_map[m.module_id].scope;
@@ -332,7 +332,7 @@ where
332 } 332 }
333 } 333 }
334 Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => { 334 Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => {
335 // tested_by!(glob_enum); 335 tested_by!(glob_enum);
336 // glob import from enum => just import all the variants 336 // glob import from enum => just import all the variants
337 let enum_data = self.db.enum_data(e); 337 let enum_data = self.db.enum_data(e);
338 let resolutions = enum_data 338 let resolutions = enum_data
@@ -373,8 +373,7 @@ where
373 let resolution = Resolution { def, import: Some(import_id) }; 373 let resolution = Resolution { def, import: Some(import_id) };
374 self.update(module_id, Some(import_id), &[(name, resolution)]); 374 self.update(module_id, Some(import_id), &[(name, resolution)]);
375 } 375 }
376 // tested_by!(bogus_paths), 376 None => tested_by!(bogus_paths),
377 None => (),
378 } 377 }
379 } 378 }
380 } 379 }
@@ -534,7 +533,7 @@ where
534 // Prelude module is always considered to be `#[macro_use]`. 533 // Prelude module is always considered to be `#[macro_use]`.
535 if let Some(prelude_module) = self.def_collector.def_map.prelude { 534 if let Some(prelude_module) = self.def_collector.def_map.prelude {
536 if prelude_module.krate != self.def_collector.def_map.krate { 535 if prelude_module.krate != self.def_collector.def_map.krate {
537 // tested_by!(prelude_is_macro_use); 536 tested_by!(prelude_is_macro_use);
538 self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); 537 self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate);
539 } 538 }
540 } 539 }
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 86c05d602..cb47fa317 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -14,6 +14,7 @@ use ra_syntax::{
14 ast::{self, AttrsOwner, NameOwner}, 14 ast::{self, AttrsOwner, NameOwner},
15 AstNode, AstPtr, SourceFile, 15 AstNode, AstPtr, SourceFile,
16}; 16};
17use test_utils::tested_by;
17 18
18use crate::{attr::Attr, db::DefDatabase2, path::Path, FileAstId, HirFileId, ModuleSource, Source}; 19use crate::{attr::Attr, db::DefDatabase2, path::Path, FileAstId, HirFileId, ModuleSource, Source};
19 20
@@ -297,8 +298,7 @@ impl RawItemsCollector {
297 self.push_item(current_module, attrs, RawItemKind::Module(item)); 298 self.push_item(current_module, attrs, RawItemKind::Module(item));
298 return; 299 return;
299 } 300 }
300 // FIXME: restore this mark once we complete hir splitting 301 tested_by!(name_res_works_for_broken_modules);
301 // tested_by!(name_res_works_for_broken_modules);
302 } 302 }
303 303
304 fn add_use_item(&mut self, current_module: Option<Module>, use_item: ast::UseItem) { 304 fn add_use_item(&mut self, current_module: Option<Module>, use_item: ast::UseItem) {
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index f9a8edd43..52bd0aa91 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -8,7 +8,7 @@ use std::sync::Arc;
8 8
9use insta::assert_snapshot; 9use insta::assert_snapshot;
10use ra_db::{fixture::WithFixture, SourceDatabase}; 10use ra_db::{fixture::WithFixture, SourceDatabase};
11// use test_utils::covers; 11use test_utils::covers;
12 12
13use crate::{db::DefDatabase2, nameres::*, test_db::TestDB, CrateModuleId}; 13use crate::{db::DefDatabase2, nameres::*, test_db::TestDB, CrateModuleId};
14 14
@@ -104,7 +104,7 @@ fn crate_def_map_smoke_test() {
104 104
105#[test] 105#[test]
106fn bogus_paths() { 106fn bogus_paths() {
107 // covers!(bogus_paths); 107 covers!(bogus_paths);
108 let map = def_map( 108 let map = def_map(
109 " 109 "
110 //- /lib.rs 110 //- /lib.rs
@@ -219,7 +219,7 @@ fn re_exports() {
219 219
220#[test] 220#[test]
221fn std_prelude() { 221fn std_prelude() {
222 // covers!(std_prelude); 222 covers!(std_prelude);
223 let map = def_map( 223 let map = def_map(
224 " 224 "
225 //- /main.rs crate:main deps:test_crate 225 //- /main.rs crate:main deps:test_crate
@@ -243,7 +243,7 @@ fn std_prelude() {
243 243
244#[test] 244#[test]
245fn can_import_enum_variant() { 245fn can_import_enum_variant() {
246 // covers!(can_import_enum_variant); 246 covers!(can_import_enum_variant);
247 let map = def_map( 247 let map = def_map(
248 " 248 "
249 //- /lib.rs 249 //- /lib.rs
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs
index cf4a2a851..5b03fe365 100644
--- a/crates/ra_hir_def/src/nameres/tests/globs.rs
+++ b/crates/ra_hir_def/src/nameres/tests/globs.rs
@@ -75,7 +75,7 @@ fn glob_2() {
75 75
76#[test] 76#[test]
77fn glob_across_crates() { 77fn glob_across_crates() {
78 // covers!(glob_across_crates); 78 covers!(glob_across_crates);
79 let map = def_map( 79 let map = def_map(
80 " 80 "
81 //- /main.rs crate:main deps:test_crate 81 //- /main.rs crate:main deps:test_crate
@@ -94,7 +94,7 @@ fn glob_across_crates() {
94 94
95#[test] 95#[test]
96fn glob_enum() { 96fn glob_enum() {
97 // covers!(glob_enum); 97 covers!(glob_enum);
98 let map = def_map( 98 let map = def_map(
99 " 99 "
100 //- /lib.rs 100 //- /lib.rs
diff --git a/crates/ra_hir_def/src/nameres/tests/macros.rs b/crates/ra_hir_def/src/nameres/tests/macros.rs
index 9bb3895ad..704065633 100644
--- a/crates/ra_hir_def/src/nameres/tests/macros.rs
+++ b/crates/ra_hir_def/src/nameres/tests/macros.rs
@@ -175,7 +175,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
175 175
176#[test] 176#[test]
177fn macro_rules_from_other_crates_are_visible_with_macro_use() { 177fn macro_rules_from_other_crates_are_visible_with_macro_use() {
178 // covers!(macro_rules_from_other_crates_are_visible_with_macro_use); 178 covers!(macro_rules_from_other_crates_are_visible_with_macro_use);
179 let map = def_map( 179 let map = def_map(
180 " 180 "
181 //- /main.rs crate:main deps:foo 181 //- /main.rs crate:main deps:foo
@@ -225,7 +225,7 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() {
225 225
226#[test] 226#[test]
227fn prelude_is_macro_use() { 227fn prelude_is_macro_use() {
228 // covers!(prelude_is_macro_use); 228 covers!(prelude_is_macro_use);
229 let map = def_map( 229 let map = def_map(
230 " 230 "
231 //- /main.rs crate:main deps:foo 231 //- /main.rs crate:main deps:foo
@@ -507,8 +507,8 @@ fn path_qualified_macros() {
507 507
508#[test] 508#[test]
509fn macro_dollar_crate_is_correct_in_item() { 509fn macro_dollar_crate_is_correct_in_item() {
510 // covers!(macro_dollar_crate_self); 510 covers!(macro_dollar_crate_self);
511 // covers!(macro_dollar_crate_other); 511 covers!(macro_dollar_crate_other);
512 let map = def_map( 512 let map = def_map(
513 " 513 "
514 //- /main.rs crate:main deps:foo 514 //- /main.rs crate:main deps:foo
@@ -566,7 +566,7 @@ fn macro_dollar_crate_is_correct_in_item() {
566 566
567#[test] 567#[test]
568fn macro_dollar_crate_is_correct_in_indirect_deps() { 568fn macro_dollar_crate_is_correct_in_indirect_deps() {
569 // covers!(macro_dollar_crate_other); 569 covers!(macro_dollar_crate_other);
570 // From std 570 // From std
571 let map = def_map( 571 let map = def_map(
572 r#" 572 r#"
diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
index 8d804a63e..dee364a14 100644
--- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
@@ -2,7 +2,7 @@ use super::*;
2 2
3#[test] 3#[test]
4fn name_res_works_for_broken_modules() { 4fn name_res_works_for_broken_modules() {
5 // covers!(name_res_works_for_broken_modules); 5 covers!(name_res_works_for_broken_modules);
6 let map = def_map( 6 let map = def_map(
7 " 7 "
8 //- /lib.rs 8 //- /lib.rs