From fc9eed4836dfc88fe2893c81b015ab440cea2ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 8 Mar 2021 22:19:44 +0200 Subject: Use upstream cov-mark --- crates/hir_def/src/nameres/collector.rs | 17 ++++++++--------- crates/hir_def/src/nameres/mod_resolution.rs | 3 +-- crates/hir_def/src/nameres/path_resolution.rs | 11 +++++------ crates/hir_def/src/nameres/tests.rs | 9 ++++----- crates/hir_def/src/nameres/tests/diagnostics.rs | 5 ++--- crates/hir_def/src/nameres/tests/globs.rs | 8 ++++---- crates/hir_def/src/nameres/tests/macros.rs | 10 +++++----- crates/hir_def/src/nameres/tests/mod_resolution.rs | 4 ++-- 8 files changed, 31 insertions(+), 36 deletions(-) (limited to 'crates/hir_def/src/nameres') diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index e51d89b43..3bb69d935 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -18,7 +18,6 @@ use hir_expand::{ use hir_expand::{InFile, MacroCallLoc}; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::ast; -use test_utils::mark; use tt::{Leaf, TokenTree}; use crate::{ @@ -462,7 +461,7 @@ impl DefCollector<'_> { let res = self.def_map.resolve_name_in_extern_prelude(&extern_crate.name); if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { - mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use); + cov_mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use); self.import_all_macros_exported(current_module_id, m.krate); } } @@ -571,10 +570,10 @@ impl DefCollector<'_> { match def.take_types() { Some(ModuleDefId::ModuleId(m)) => { if import.is_prelude { - mark::hit!(std_prelude); + cov_mark::hit!(std_prelude); self.def_map.prelude = Some(m); } else if m.krate != self.def_map.krate { - mark::hit!(glob_across_crates); + cov_mark::hit!(glob_across_crates); // glob import from other crate => we can just import everything once let item_map = m.def_map(self.db); let scope = &item_map[m.local_id].scope; @@ -626,7 +625,7 @@ impl DefCollector<'_> { } } Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => { - mark::hit!(glob_enum); + cov_mark::hit!(glob_enum); // glob import from enum => just import all the variants // XXX: urgh, so this works by accident! Here, we look at @@ -675,7 +674,7 @@ impl DefCollector<'_> { self.update(module_id, &[(name, def)], vis, ImportType::Named); } - None => mark::hit!(bogus_paths), + None => cov_mark::hit!(bogus_paths), } } } @@ -738,7 +737,7 @@ impl DefCollector<'_> { if max_vis == old_vis { false } else { - mark::hit!(upgrade_underscore_visibility); + cov_mark::hit!(upgrade_underscore_visibility); true } } @@ -866,7 +865,7 @@ impl DefCollector<'_> { depth: usize, ) { if depth > EXPANSION_DEPTH_LIMIT { - mark::hit!(macro_expansion_overflow); + cov_mark::hit!(macro_expansion_overflow); log::warn!("macro expansion is too deep"); return; } @@ -1009,7 +1008,7 @@ impl ModCollector<'_, '_> { // 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 { - mark::hit!(prelude_is_macro_use); + cov_mark::hit!(prelude_is_macro_use); self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); } } diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs index af3262439..d5de9899c 100644 --- a/crates/hir_def/src/nameres/mod_resolution.rs +++ b/crates/hir_def/src/nameres/mod_resolution.rs @@ -2,7 +2,6 @@ use base_db::{AnchoredPath, FileId}; use hir_expand::name::Name; use syntax::SmolStr; -use test_utils::mark; use crate::{db::DefDatabase, HirFileId}; @@ -28,7 +27,7 @@ impl ModDir { let depth = self.depth + 1; if depth > MOD_DEPTH_LIMIT { log::error!("MOD_DEPTH_LIMIT exceeded"); - mark::hit!(circular_mods); + cov_mark::hit!(circular_mods); return None; } Some(ModDir { dir_path, root_non_dir_owner, depth }) diff --git a/crates/hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs index dd1db0094..8258dcffb 100644 --- a/crates/hir_def/src/nameres/path_resolution.rs +++ b/crates/hir_def/src/nameres/path_resolution.rs @@ -13,7 +13,6 @@ use base_db::Edition; use hir_expand::name; use hir_expand::name::Name; -use test_utils::mark; use crate::{ db::DefDatabase, @@ -63,7 +62,7 @@ impl ResolvePathResult { impl DefMap { pub(super) fn resolve_name_in_extern_prelude(&self, name: &Name) -> PerNs { if name == &name!(self) { - mark::hit!(extern_crate_self_as); + cov_mark::hit!(extern_crate_self_as); return PerNs::types(self.module_id(self.root).into(), Visibility::Public); } self.extern_prelude @@ -101,7 +100,7 @@ impl DefMap { // DefMap they're written in, so we restrict them when that happens. if let Visibility::Module(m) = vis { if self.block_id() != m.block { - mark::hit!(adjust_vis_in_block_def_map); + cov_mark::hit!(adjust_vis_in_block_def_map); vis = Visibility::Module(self.module_id(self.root())); log::debug!("visibility {:?} points outside DefMap, adjusting to {:?}", m, vis); } @@ -169,12 +168,12 @@ impl DefMap { let mut curr_per_ns: PerNs = match path.kind { PathKind::DollarCrate(krate) => { if krate == self.krate { - mark::hit!(macro_dollar_crate_self); + cov_mark::hit!(macro_dollar_crate_self); PerNs::types(self.crate_root(db).into(), Visibility::Public) } else { let def_map = db.crate_def_map(krate); let module = def_map.module_id(def_map.root); - mark::hit!(macro_dollar_crate_other); + cov_mark::hit!(macro_dollar_crate_other); PerNs::types(module.into(), Visibility::Public) } } @@ -310,7 +309,7 @@ impl DefMap { } ModuleDefId::AdtId(AdtId::EnumId(e)) => { // enum variant - mark::hit!(can_import_enum_variant); + cov_mark::hit!(can_import_enum_variant); let enum_data = db.enum_data(e); match enum_data.variant(&segment) { Some(local_id) => { diff --git a/crates/hir_def/src/nameres/tests.rs b/crates/hir_def/src/nameres/tests.rs index bd3e2701b..de3aa4f9a 100644 --- a/crates/hir_def/src/nameres/tests.rs +++ b/crates/hir_def/src/nameres/tests.rs @@ -9,7 +9,6 @@ use std::sync::Arc; use base_db::{fixture::WithFixture, SourceDatabase}; use expect_test::{expect, Expect}; -use test_utils::mark; use crate::{db::DefDatabase, test_db::TestDB}; @@ -136,7 +135,7 @@ mod m { #[test] fn bogus_paths() { - mark::check!(bogus_paths); + cov_mark::check!(bogus_paths); check( r#" //- /lib.rs @@ -243,7 +242,7 @@ pub struct Baz; #[test] fn std_prelude() { - mark::check!(std_prelude); + cov_mark::check!(std_prelude); check( r#" //- /main.rs crate:main deps:test_crate @@ -267,7 +266,7 @@ pub enum Foo { Bar, Baz }; #[test] fn can_import_enum_variant() { - mark::check!(can_import_enum_variant); + cov_mark::check!(can_import_enum_variant); check( r#" enum E { V } @@ -628,7 +627,7 @@ use crate::reex::*; #[test] fn underscore_pub_crate_reexport() { - mark::check!(upgrade_underscore_visibility); + cov_mark::check!(upgrade_underscore_visibility); check( r#" //- /main.rs crate:main deps:lib diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index e8e72e5ef..d5ef8ceb5 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs @@ -1,5 +1,4 @@ use base_db::fixture::WithFixture; -use test_utils::mark; use crate::test_db::TestDB; @@ -63,7 +62,7 @@ fn unresolved_extern_crate() { #[test] fn extern_crate_self_as() { - mark::check!(extern_crate_self_as); + cov_mark::check!(extern_crate_self_as); check_diagnostics( r" //- /lib.rs @@ -140,7 +139,7 @@ fn inactive_item() { /// Tests that `cfg` attributes behind `cfg_attr` is handled properly. #[test] fn inactive_via_cfg_attr() { - mark::check!(cfg_attr_active); + cov_mark::check!(cfg_attr_active); check_diagnostics( r#" //- /lib.rs diff --git a/crates/hir_def/src/nameres/tests/globs.rs b/crates/hir_def/src/nameres/tests/globs.rs index 2ae836e3c..17426d54d 100644 --- a/crates/hir_def/src/nameres/tests/globs.rs +++ b/crates/hir_def/src/nameres/tests/globs.rs @@ -148,7 +148,7 @@ pub(crate) struct PubCrateStruct; #[test] fn glob_across_crates() { - mark::check!(glob_across_crates); + cov_mark::check!(glob_across_crates); check( r#" //- /main.rs crate:main deps:test_crate @@ -184,7 +184,7 @@ struct Foo; #[test] fn glob_enum() { - mark::check!(glob_enum); + cov_mark::check!(glob_enum); check( r#" enum Foo { Bar, Baz } @@ -201,7 +201,7 @@ use self::Foo::*; #[test] fn glob_enum_group() { - mark::check!(glob_enum_group); + cov_mark::check!(glob_enum_group); check( r#" enum Foo { Bar, Baz } @@ -218,7 +218,7 @@ use self::Foo::{*}; #[test] fn glob_shadowed_def() { - mark::check!(import_shadowed); + cov_mark::check!(import_shadowed); check( r#" //- /lib.rs diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index 36ed5e8ce..f65a655bf 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs @@ -210,7 +210,7 @@ macro_rules! bar { #[test] fn macro_rules_from_other_crates_are_visible_with_macro_use() { - mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use); + cov_mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use); check( r#" //- /main.rs crate:main deps:foo @@ -260,7 +260,7 @@ mod priv_mod { #[test] fn prelude_is_macro_use() { - mark::check!(prelude_is_macro_use); + cov_mark::check!(prelude_is_macro_use); check( r#" //- /main.rs crate:main deps:foo @@ -550,7 +550,7 @@ mod m { #[test] fn macro_dollar_crate_is_correct_in_item() { - mark::check!(macro_dollar_crate_self); + cov_mark::check!(macro_dollar_crate_self); check( r#" //- /main.rs crate:main deps:foo @@ -608,7 +608,7 @@ struct Baz; #[test] fn macro_dollar_crate_is_correct_in_indirect_deps() { - mark::check!(macro_dollar_crate_other); + cov_mark::check!(macro_dollar_crate_other); // From std check( r#" @@ -686,7 +686,7 @@ pub trait Clone {} #[test] fn macro_expansion_overflow() { - mark::check!(macro_expansion_overflow); + cov_mark::check!(macro_expansion_overflow); check( r#" macro_rules! a { diff --git a/crates/hir_def/src/nameres/tests/mod_resolution.rs b/crates/hir_def/src/nameres/tests/mod_resolution.rs index e80b593aa..dfbbad1f9 100644 --- a/crates/hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/hir_def/src/nameres/tests/mod_resolution.rs @@ -2,7 +2,7 @@ use super::*; #[test] fn name_res_works_for_broken_modules() { - mark::check!(name_res_works_for_broken_modules); + cov_mark::check!(name_res_works_for_broken_modules); check( r" //- /lib.rs @@ -774,7 +774,7 @@ struct X; #[test] fn circular_mods() { - mark::check!(circular_mods); + cov_mark::check!(circular_mods); compute_crate_def_map( r#" //- /lib.rs -- cgit v1.2.3