Restore crate_def_map marks

This commit is contained in:
Aleksey Kladov 2019-11-03 23:44:23 +03:00
parent 6fba51c5fc
commit 73fcf9a2d6
9 changed files with 41 additions and 26 deletions

View file

@ -17,6 +17,8 @@ pub mod diagnostics;
#[cfg(test)]
mod test_db;
#[cfg(test)]
mod marks;
// FIXME: this should be private
pub mod nameres;

View file

@ -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
);

View file

@ -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) => {

View file

@ -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);
}
}

View file

@ -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<Module>, use_item: ast::UseItem) {

View file

@ -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

View file

@ -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

View file

@ -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#"

View file

@ -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