From 73fcf9a2d6ae14afa4e822370c0a46bf1d336081 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 3 Nov 2019 23:44:23 +0300 Subject: Restore crate_def_map marks --- crates/ra_hir_def/src/lib.rs | 2 ++ crates/ra_hir_def/src/marks.rs | 14 ++++++++++++++ crates/ra_hir_def/src/nameres.rs | 8 ++++---- crates/ra_hir_def/src/nameres/collector.rs | 15 +++++++-------- crates/ra_hir_def/src/nameres/raw.rs | 4 ++-- crates/ra_hir_def/src/nameres/tests.rs | 8 ++++---- crates/ra_hir_def/src/nameres/tests/globs.rs | 4 ++-- crates/ra_hir_def/src/nameres/tests/macros.rs | 10 +++++----- crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | 2 +- 9 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 crates/ra_hir_def/src/marks.rs (limited to 'crates') 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; #[cfg(test)] mod test_db; +#[cfg(test)] +mod marks; // FIXME: this should be private pub 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 @@ +//! See test_utils/src/marks.rs + +test_utils::marks!( + bogus_paths + name_res_works_for_broken_modules + can_import_enum_variant + glob_enum + glob_across_crates + std_prelude + macro_rules_from_other_crates_are_visible_with_macro_use + prelude_is_macro_use + macro_dollar_crate_self + macro_dollar_crate_other +); 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}; use ra_prof::profile; use ra_syntax::ast; use rustc_hash::{FxHashMap, FxHashSet}; -// use test_utils::tested_by; +use test_utils::tested_by; use crate::{ builtin_type::BuiltinType, @@ -263,12 +263,12 @@ impl CrateDefMap { let mut curr_per_ns: PerNs = match path.kind { PathKind::DollarCrate(krate) => { if krate == self.krate { - // tested_by!(macro_dollar_crate_self); + tested_by!(macro_dollar_crate_self); PerNs::types(ModuleId { krate: self.krate, module_id: self.root }.into()) } else { let def_map = db.crate_def_map(krate); let module = ModuleId { krate, module_id: def_map.root }; - // tested_by!(macro_dollar_crate_other); + tested_by!(macro_dollar_crate_other); PerNs::types(module.into()) } } @@ -369,7 +369,7 @@ impl CrateDefMap { } ModuleDefId::AdtId(AdtId::EnumId(e)) => { // enum variant - // tested_by!(can_import_enum_variant); + tested_by!(can_import_enum_variant); let enum_data = db.enum_data(e); match enum_data.variant(&segment.name) { 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; use ra_db::{CrateId, FileId}; use ra_syntax::{ast, SmolStr}; use rustc_hash::FxHashMap; -// use test_utils::tested_by; +use test_utils::tested_by; use crate::{ attr::Attr, @@ -218,7 +218,7 @@ where ); if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { - // tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use); + tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use); self.import_all_macros_exported(current_module_id, m.krate); } } @@ -294,10 +294,10 @@ where match def.take_types() { Some(ModuleDefId::ModuleId(m)) => { if import.is_prelude { - // tested_by!(std_prelude); + tested_by!(std_prelude); self.def_map.prelude = Some(m); } else if m.krate != self.def_map.krate { - // tested_by!(glob_across_crates); + tested_by!(glob_across_crates); // glob import from other crate => we can just import everything once let item_map = self.db.crate_def_map(m.krate); let scope = &item_map[m.module_id].scope; @@ -332,7 +332,7 @@ where } } Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => { - // tested_by!(glob_enum); + tested_by!(glob_enum); // glob import from enum => just import all the variants let enum_data = self.db.enum_data(e); let resolutions = enum_data @@ -373,8 +373,7 @@ where let resolution = Resolution { def, import: Some(import_id) }; self.update(module_id, Some(import_id), &[(name, resolution)]); } - // tested_by!(bogus_paths), - None => (), + None => tested_by!(bogus_paths), } } } @@ -534,7 +533,7 @@ where // Prelude module is always considered to be `#[macro_use]`. if let Some(prelude_module) = self.def_collector.def_map.prelude { if prelude_module.krate != self.def_collector.def_map.krate { - // tested_by!(prelude_is_macro_use); + tested_by!(prelude_is_macro_use); self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); } } 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::{ ast::{self, AttrsOwner, NameOwner}, AstNode, AstPtr, SourceFile, }; +use test_utils::tested_by; use crate::{attr::Attr, db::DefDatabase2, path::Path, FileAstId, HirFileId, ModuleSource, Source}; @@ -297,8 +298,7 @@ impl RawItemsCollector { self.push_item(current_module, attrs, RawItemKind::Module(item)); return; } - // FIXME: restore this mark once we complete hir splitting - // tested_by!(name_res_works_for_broken_modules); + tested_by!(name_res_works_for_broken_modules); } fn add_use_item(&mut self, current_module: Option, 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; use insta::assert_snapshot; use ra_db::{fixture::WithFixture, SourceDatabase}; -// use test_utils::covers; +use test_utils::covers; use crate::{db::DefDatabase2, nameres::*, test_db::TestDB, CrateModuleId}; @@ -104,7 +104,7 @@ fn crate_def_map_smoke_test() { #[test] fn bogus_paths() { - // covers!(bogus_paths); + covers!(bogus_paths); let map = def_map( " //- /lib.rs @@ -219,7 +219,7 @@ fn re_exports() { #[test] fn std_prelude() { - // covers!(std_prelude); + covers!(std_prelude); let map = def_map( " //- /main.rs crate:main deps:test_crate @@ -243,7 +243,7 @@ fn std_prelude() { #[test] fn can_import_enum_variant() { - // covers!(can_import_enum_variant); + covers!(can_import_enum_variant); let map = def_map( " //- /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() { #[test] fn glob_across_crates() { - // covers!(glob_across_crates); + covers!(glob_across_crates); let map = def_map( " //- /main.rs crate:main deps:test_crate @@ -94,7 +94,7 @@ fn glob_across_crates() { #[test] fn glob_enum() { - // covers!(glob_enum); + covers!(glob_enum); let map = def_map( " //- /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() { #[test] fn macro_rules_from_other_crates_are_visible_with_macro_use() { - // covers!(macro_rules_from_other_crates_are_visible_with_macro_use); + covers!(macro_rules_from_other_crates_are_visible_with_macro_use); let map = def_map( " //- /main.rs crate:main deps:foo @@ -225,7 +225,7 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() { #[test] fn prelude_is_macro_use() { - // covers!(prelude_is_macro_use); + covers!(prelude_is_macro_use); let map = def_map( " //- /main.rs crate:main deps:foo @@ -507,8 +507,8 @@ fn path_qualified_macros() { #[test] fn macro_dollar_crate_is_correct_in_item() { - // covers!(macro_dollar_crate_self); - // covers!(macro_dollar_crate_other); + covers!(macro_dollar_crate_self); + covers!(macro_dollar_crate_other); let map = def_map( " //- /main.rs crate:main deps:foo @@ -566,7 +566,7 @@ fn macro_dollar_crate_is_correct_in_item() { #[test] fn macro_dollar_crate_is_correct_in_indirect_deps() { - // covers!(macro_dollar_crate_other); + covers!(macro_dollar_crate_other); // From std let map = def_map( 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::*; #[test] fn name_res_works_for_broken_modules() { - // covers!(name_res_works_for_broken_modules); + covers!(name_res_works_for_broken_modules); let map = def_map( " //- /lib.rs -- cgit v1.2.3