Use upstream cov-mark

This commit is contained in:
Laurențiu Nicola
2021-03-08 22:19:44 +02:00
parent c5189a22cc
commit fc9eed4836
101 changed files with 354 additions and 514 deletions

View File

@@ -13,7 +13,6 @@ use syntax::{
ast::{self, AstNode, AttrsOwner},
match_ast, AstToken, SmolStr, SyntaxNode,
};
use test_utils::mark;
use tt::Subtree;
use crate::{
@@ -177,7 +176,7 @@ impl RawAttrs {
if cfg_options.check(&cfg) == Some(false) {
None
} else {
mark::hit!(cfg_attr_active);
cov_mark::hit!(cfg_attr_active);
let attr = ast::Attr::parse(&format!("#[{}]", attr)).ok()?;
let hygiene = Hygiene::new_unhygienic(); // FIXME

View File

@@ -20,7 +20,6 @@ use la_arena::{Arena, ArenaMap};
use profile::Count;
use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, AstPtr};
use test_utils::mark;
pub(crate) use lower::LowerCtx;
@@ -105,7 +104,7 @@ impl Expander {
macro_call: ast::MacroCall,
) -> ExpandResult<Option<(Mark, T)>> {
if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT {
mark::hit!(your_stack_belongs_to_me);
cov_mark::hit!(your_stack_belongs_to_me);
return ExpandResult::str_err("reached recursion limit during macro expansion".into());
}

View File

@@ -19,7 +19,6 @@ use syntax::{
},
AstNode, AstPtr, SyntaxNodePtr,
};
use test_utils::mark;
use crate::{
adt::StructKind,
@@ -286,7 +285,7 @@ impl ExprCollector<'_> {
None => self.collect_expr_opt(condition.expr()),
// if let -- desugar to match
Some(pat) => {
mark::hit!(infer_resolve_while_let);
cov_mark::hit!(infer_resolve_while_let);
let pat = self.collect_pat(pat);
let match_expr = self.collect_expr_opt(condition.expr());
let placeholder_pat = self.missing_pat();

View File

@@ -186,7 +186,7 @@ mod tests {
use base_db::{fixture::WithFixture, FileId, SourceDatabase};
use hir_expand::{name::AsName, InFile};
use syntax::{algo::find_node_at_offset, ast, AstNode};
use test_utils::{assert_eq_text, extract_offset, mark};
use test_utils::{assert_eq_text, extract_offset};
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
@@ -454,7 +454,7 @@ fn foo() {
#[test]
fn while_let_desugaring() {
mark::check!(infer_resolve_while_let);
cov_mark::check!(infer_resolve_while_let);
do_check_local_name(
r#"
fn test() {

View File

@@ -2,7 +2,6 @@ mod block;
use base_db::{fixture::WithFixture, SourceDatabase};
use expect_test::Expect;
use test_utils::mark;
use crate::{test_db::TestDB, ModuleDefId};
@@ -48,7 +47,7 @@ fn check_at(ra_fixture: &str, expect: Expect) {
#[test]
fn your_stack_belongs_to_me() {
mark::check!(your_stack_belongs_to_me);
cov_mark::check!(your_stack_belongs_to_me);
lower(
"
macro_rules! n_nuple {

View File

@@ -165,16 +165,16 @@ fn macro_resolve() {
check_at(
r#"
//- /lib.rs crate:lib deps:core
use core::mark;
use core::cov_mark;
fn f() {
fn nested() {
mark::hit!(Hit);
cov_mark::hit!(Hit);
$0
}
}
//- /core.rs crate:core
pub mod mark {
pub mod cov_mark {
#[macro_export]
macro_rules! _hit {
($name:ident) => {
@@ -193,8 +193,8 @@ pub mod mark {
nested: v
crate
cov_mark: t
f: v
mark: t
"#]],
);
}
@@ -264,7 +264,7 @@ fn main() {
fn underscore_import() {
// This used to panic, because the default (private) visibility inside block expressions would
// point into the containing `DefMap`, which visibilities should never be able to do.
mark::check!(adjust_vis_in_block_def_map);
cov_mark::check!(adjust_vis_in_block_def_map);
check_at(
r#"
mod m {

View File

@@ -4,7 +4,6 @@ use std::iter;
use hir_expand::name::{known, AsName, Name};
use rustc_hash::FxHashSet;
use test_utils::mark;
use crate::nameres::DefMap;
use crate::{
@@ -215,7 +214,7 @@ fn find_path_inner(
best_path_len - 1,
prefixed,
)?;
mark::hit!(partially_imported);
cov_mark::hit!(partially_imported);
path.push_segment(info.path.segments.last().unwrap().clone());
Some(path)
})
@@ -235,7 +234,7 @@ fn find_path_inner(
// that correctly (FIXME).
if let Some(item_module) = item.as_module_def_id().and_then(|did| did.module(db)) {
if item_module.def_map(db).block_id().is_some() && prefixed.is_some() {
mark::hit!(prefixed_in_block_expression);
cov_mark::hit!(prefixed_in_block_expression);
prefixed = Some(PrefixKind::Plain);
}
}
@@ -252,18 +251,18 @@ fn find_path_inner(
fn select_best_path(old_path: ModPath, new_path: ModPath, prefer_no_std: bool) -> ModPath {
if old_path.starts_with_std() && new_path.can_start_with_std() {
if prefer_no_std {
mark::hit!(prefer_no_std_paths);
cov_mark::hit!(prefer_no_std_paths);
new_path
} else {
mark::hit!(prefer_std_paths);
cov_mark::hit!(prefer_std_paths);
old_path
}
} else if new_path.starts_with_std() && old_path.can_start_with_std() {
if prefer_no_std {
mark::hit!(prefer_no_std_paths);
cov_mark::hit!(prefer_no_std_paths);
old_path
} else {
mark::hit!(prefer_std_paths);
cov_mark::hit!(prefer_std_paths);
new_path
}
} else if new_path.len() < old_path.len() {
@@ -364,7 +363,6 @@ mod tests {
use base_db::fixture::WithFixture;
use hir_expand::hygiene::Hygiene;
use syntax::ast::AstNode;
use test_utils::mark;
use crate::test_db::TestDB;
@@ -522,7 +520,7 @@ mod tests {
#[test]
fn partially_imported() {
mark::check!(partially_imported);
cov_mark::check!(partially_imported);
// Tests that short paths are used even for external items, when parts of the path are
// already in scope.
let code = r#"
@@ -686,7 +684,7 @@ mod tests {
#[test]
fn prefer_std_paths_over_alloc() {
mark::check!(prefer_std_paths);
cov_mark::check!(prefer_std_paths);
let code = r#"
//- /main.rs crate:main deps:alloc,std
$0
@@ -712,7 +710,7 @@ mod tests {
#[test]
fn prefer_core_paths_over_std() {
mark::check!(prefer_no_std_paths);
cov_mark::check!(prefer_no_std_paths);
let code = r#"
//- /main.rs crate:main deps:core,std
#![no_std]
@@ -842,7 +840,7 @@ mod tests {
#[test]
fn inner_items_from_inner_module() {
mark::check!(prefixed_in_block_expression);
cov_mark::check!(prefixed_in_block_expression);
check_found_path(
r#"
fn main() {

View File

@@ -8,7 +8,6 @@ use hir_expand::name::Name;
use indexmap::{map::Entry, IndexMap};
use itertools::Itertools;
use rustc_hash::{FxHashSet, FxHasher};
use test_utils::mark;
use crate::{
db::DefDatabase, item_scope::ItemInNs, visibility::Visibility, AssocItemId, ModuleDefId,
@@ -193,7 +192,7 @@ impl ImportMap {
// cannot use associated type aliases directly: need a `<Struct as Trait>::TypeAlias`
// qualifier, ergo no need to store it for imports in import_map
AssocItemId::TypeAliasId(_) => {
mark::hit!(type_aliases_ignored);
cov_mark::hit!(type_aliases_ignored);
continue;
}
};
@@ -463,7 +462,6 @@ fn item_import_kind(item: ItemInNs) -> Option<ImportKind> {
mod tests {
use base_db::{fixture::WithFixture, SourceDatabase, Upcast};
use expect_test::{expect, Expect};
use test_utils::mark;
use crate::{test_db::TestDB, AssocContainerId, Lookup};
@@ -801,7 +799,7 @@ mod tests {
#[test]
fn fuzzy_import_trait_and_assoc_items() {
mark::check!(type_aliases_ignored);
cov_mark::check!(type_aliases_ignored);
let ra_fixture = r#"
//- /main.rs crate:main deps:dep
//- /dep.rs crate:dep

View File

@@ -9,7 +9,6 @@ use hir_expand::MacroDefKind;
use once_cell::sync::Lazy;
use rustc_hash::{FxHashMap, FxHashSet};
use stdx::format_to;
use test_utils::mark;
use crate::{
db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, ImplId,
@@ -237,7 +236,7 @@ impl ItemScope {
if $glob_imports.$field.contains(&$lookup)
&& matches!($def_import_type, ImportType::Named) =>
{
mark::hit!(import_shadowed);
cov_mark::hit!(import_shadowed);
$glob_imports.$field.remove(&$lookup);
if let Some(fld) = $def.$field {
entry.insert(fld);

View File

@@ -25,7 +25,6 @@ use profile::Count;
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use syntax::{ast, match_ast, SyntaxKind};
use test_utils::mark;
use crate::{
attr::{Attrs, RawAttrs},

View File

@@ -466,7 +466,7 @@ impl Ctx {
.collect()
})
.unwrap_or_else(|| {
mark::hit!(name_res_works_for_broken_modules);
cov_mark::hit!(name_res_works_for_broken_modules);
Box::new([]) as Box<[_]>
}),
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,6 @@ use std::iter;
use either::Either;
use hir_expand::{hygiene::Hygiene, name::AsName};
use syntax::ast::{self, NameOwner};
use test_utils::mark;
use crate::path::{ImportAlias, ModPath, PathKind};
@@ -54,7 +53,7 @@ pub(crate) fn lower_use_tree(
// FIXME: report errors somewhere
// We get here if we do
} else if is_glob {
mark::hit!(glob_enum_group);
cov_mark::hit!(glob_enum_group);
if let Some(prefix) = prefix {
cb(prefix, &tree, is_glob, None)
}