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/Cargo.toml | 1 + crates/hir_def/src/attr.rs | 3 +- crates/hir_def/src/body.rs | 3 +- crates/hir_def/src/body/lower.rs | 3 +- crates/hir_def/src/body/scope.rs | 4 +- crates/hir_def/src/body/tests.rs | 3 +- crates/hir_def/src/body/tests/block.rs | 10 +-- crates/hir_def/src/find_path.rs | 22 +++--- crates/hir_def/src/import_map.rs | 6 +- crates/hir_def/src/item_scope.rs | 3 +- crates/hir_def/src/item_tree.rs | 1 - crates/hir_def/src/item_tree/lower.rs | 2 +- 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 +- crates/hir_def/src/path/lower/lower_use.rs | 3 +- crates/hir_ty/Cargo.toml | 1 + crates/hir_ty/src/diagnostics/decl_check.rs | 11 ++- crates/hir_ty/src/infer/coerce.rs | 5 +- crates/hir_ty/src/infer/expr.rs | 3 +- crates/hir_ty/src/infer/pat.rs | 3 +- crates/hir_ty/src/infer/unify.rs | 8 +-- crates/hir_ty/src/lower.rs | 5 +- crates/hir_ty/src/method_resolution.rs | 2 +- crates/hir_ty/src/tests/coercion.rs | 5 +- crates/hir_ty/src/tests/method_resolution.rs | 2 +- crates/hir_ty/src/tests/patterns.rs | 3 +- crates/hir_ty/src/tests/regression.rs | 7 +- crates/hir_ty/src/tests/simple.rs | 3 +- crates/hir_ty/src/tests/traits.rs | 5 +- crates/ide/Cargo.toml | 1 + crates/ide/src/hover.rs | 9 ++- crates/ide/src/join_lines.rs | 8 +-- crates/ide/src/matching_brace.rs | 5 +- crates/ide/src/parent_module.rs | 6 +- crates/ide/src/references/rename.rs | 58 ++++++++-------- crates/ide/src/runnables.rs | 8 +-- crates/ide/src/typing/on_enter.rs | 8 +-- crates/ide_assists/Cargo.toml | 1 + crates/ide_assists/src/handlers/add_turbo_fish.rs | 22 +++--- crates/ide_assists/src/handlers/apply_demorgan.rs | 10 ++- .../ide_assists/src/handlers/change_visibility.rs | 7 +- .../ide_assists/src/handlers/extract_function.rs | 21 +++--- .../ide_assists/src/handlers/extract_variable.rs | 15 ++--- crates/ide_assists/src/handlers/fill_match_arms.rs | 6 +- .../handlers/generate_default_from_enum_variant.rs | 11 ++- .../src/handlers/generate_default_from_new.rs | 17 +++-- .../src/handlers/generate_from_impl_for_enum.rs | 7 +- .../src/handlers/infer_function_return_type.rs | 37 +++++----- crates/ide_assists/src/handlers/inline_function.rs | 5 +- .../src/handlers/inline_local_variable.rs | 19 +++--- .../src/handlers/move_module_to_file.rs | 5 +- .../ide_assists/src/handlers/pull_assignment_up.rs | 13 ++-- crates/ide_assists/src/handlers/qualify_path.rs | 17 +++-- crates/ide_assists/src/handlers/raw_string.rs | 7 +- .../src/handlers/remove_unused_param.rs | 6 +- crates/ide_assists/src/handlers/reorder_fields.rs | 7 +- crates/ide_assists/src/handlers/reorder_impl.rs | 7 +- .../src/handlers/replace_for_loop_with_for_each.rs | 5 +- .../handlers/replace_qualified_name_with_use.rs | 5 +- crates/ide_assists/src/handlers/unmerge_use.rs | 5 +- .../src/handlers/wrap_return_type_in_result.rs | 5 +- crates/ide_completion/Cargo.toml | 1 + crates/ide_completion/src/completions/dot.rs | 6 +- crates/ide_completion/src/completions/flyimport.rs | 10 ++- crates/ide_completion/src/completions/keyword.rs | 14 ++-- .../src/completions/qualified_path.rs | 6 +- .../src/completions/unqualified_path.rs | 12 ++-- crates/ide_completion/src/context.rs | 4 +- crates/ide_completion/src/render.rs | 18 +++-- crates/ide_completion/src/render/builder_ext.rs | 9 ++- crates/ide_completion/src/render/enum_variant.rs | 7 +- crates/ide_completion/src/render/function.rs | 11 ++- crates/ide_completion/src/render/macro_.rs | 7 +- crates/ide_db/Cargo.toml | 1 + crates/ide_db/src/call_info.rs | 5 +- crates/ide_db/src/call_info/tests.rs | 4 +- crates/ide_db/src/helpers/insert_use.rs | 7 +- crates/ide_db/src/helpers/insert_use/tests.rs | 6 +- crates/ide_ssr/Cargo.toml | 1 + crates/ide_ssr/src/matching.rs | 3 +- crates/ide_ssr/src/parsing.rs | 3 +- crates/ide_ssr/src/replacing.rs | 4 +- crates/ide_ssr/src/resolving.rs | 9 ++- crates/ide_ssr/src/search.rs | 5 +- crates/ide_ssr/src/tests.rs | 20 +++--- crates/mbe/Cargo.toml | 1 + crates/mbe/src/lib.rs | 5 +- crates/mbe/src/tests.rs | 6 +- crates/proc_macro_srv/src/proc_macro/bridge/mod.rs | 2 +- crates/syntax/Cargo.toml | 1 + crates/syntax/src/algo.rs | 26 ++++---- crates/test_utils/src/lib.rs | 2 - crates/test_utils/src/mark.rs | 78 ---------------------- 99 files changed, 338 insertions(+), 513 deletions(-) delete mode 100644 crates/test_utils/src/mark.rs (limited to 'crates') diff --git a/crates/hir_def/Cargo.toml b/crates/hir_def/Cargo.toml index 535221294..2f07b6d01 100644 --- a/crates/hir_def/Cargo.toml +++ b/crates/hir_def/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" log = "0.4.8" once_cell = "1.3.1" rustc-hash = "1.1.0" diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index 24ffa6c3a..b716d5f6e 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -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 diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 16e1bac40..b1a3fe1cb 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -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> { 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()); } diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 40beb2f7a..d4abe819d 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -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(); diff --git a/crates/hir_def/src/body/scope.rs b/crates/hir_def/src/body/scope.rs index 210b4a617..1bbb54fc6 100644 --- a/crates/hir_def/src/body/scope.rs +++ b/crates/hir_def/src/body/scope.rs @@ -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() { diff --git a/crates/hir_def/src/body/tests.rs b/crates/hir_def/src/body/tests.rs index bb43569d7..991a32b15 100644 --- a/crates/hir_def/src/body/tests.rs +++ b/crates/hir_def/src/body/tests.rs @@ -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 { diff --git a/crates/hir_def/src/body/tests/block.rs b/crates/hir_def/src/body/tests/block.rs index 8bca72a17..3b6ba4cde 100644 --- a/crates/hir_def/src/body/tests/block.rs +++ b/crates/hir_def/src/body/tests/block.rs @@ -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 { diff --git a/crates/hir_def/src/find_path.rs b/crates/hir_def/src/find_path.rs index 3a98ffbaa..de08e2737 100644 --- a/crates/hir_def/src/find_path.rs +++ b/crates/hir_def/src/find_path.rs @@ -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() { diff --git a/crates/hir_def/src/import_map.rs b/crates/hir_def/src/import_map.rs index e1c28bc83..369bc3350 100644 --- a/crates/hir_def/src/import_map.rs +++ b/crates/hir_def/src/import_map.rs @@ -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 `::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 { 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 diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs index 4e5daa2ff..919933813 100644 --- a/crates/hir_def/src/item_scope.rs +++ b/crates/hir_def/src/item_scope.rs @@ -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); diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 3233b1957..6bb334573 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs @@ -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}, diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 8f2f0b340..240fdacf9 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -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<[_]> }), } 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 diff --git a/crates/hir_def/src/path/lower/lower_use.rs b/crates/hir_def/src/path/lower/lower_use.rs index d584b0b70..e2965b033 100644 --- a/crates/hir_def/src/path/lower/lower_use.rs +++ b/crates/hir_def/src/path/lower/lower_use.rs @@ -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) } diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index 1127eef05..6131ebee8 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" itertools = "0.10.0" arrayvec = "0.5.1" smallvec = "1.2.0" diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index 6773ddea3..e230f9765 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs @@ -28,7 +28,6 @@ use syntax::{ ast::{self, NameOwner}, AstNode, AstPtr, }; -use test_utils::mark; use crate::{ db::HirDatabase, @@ -93,7 +92,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { fn validate_func(&mut self, func: FunctionId) { let data = self.db.function_data(func); if data.is_extern { - mark::hit!(extern_func_incorrect_case_ignored); + cov_mark::hit!(extern_func_incorrect_case_ignored); return; } @@ -625,7 +624,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { fn validate_static(&mut self, static_id: StaticId) { let data = self.db.static_data(static_id); if data.is_extern { - mark::hit!(extern_static_incorrect_case_ignored); + cov_mark::hit!(extern_static_incorrect_case_ignored); return; } @@ -673,8 +672,6 @@ impl<'a, 'b> DeclValidator<'a, 'b> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::diagnostics::tests::check_diagnostics; #[test] @@ -889,8 +886,8 @@ fn main() { #[test] fn ignores_extern_items() { - mark::check!(extern_func_incorrect_case_ignored); - mark::check!(extern_static_incorrect_case_ignored); + cov_mark::check!(extern_func_incorrect_case_ignored); + cov_mark::check!(extern_static_incorrect_case_ignored); check_diagnostics( r#" extern { diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index cf0a3add4..7e8846f27 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -6,7 +6,6 @@ use chalk_ir::{Mutability, TyVariableKind}; use hir_def::lang_item::LangItemTarget; -use test_utils::mark; use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty}; @@ -35,7 +34,7 @@ impl<'a> InferenceContext<'a> { ty1.clone() } else { if let (Ty::FnDef(..), Ty::FnDef(..)) = (ty1, ty2) { - mark::hit!(coerce_fn_reification); + cov_mark::hit!(coerce_fn_reification); // Special case: two function types. Try to coerce both to // pointers to have a chance at getting a match. See // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 @@ -45,7 +44,7 @@ impl<'a> InferenceContext<'a> { let ptr_ty2 = Ty::fn_ptr(sig2); self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) } else { - mark::hit!(coerce_merge_fail_fallback); + cov_mark::hit!(coerce_merge_fail_fallback); ty1.clone() } } diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index ec2c13154..262177ffb 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -12,7 +12,6 @@ use hir_def::{ }; use hir_expand::name::{name, Name}; use syntax::ast::RangeOp; -use test_utils::mark; use crate::{ autoderef, @@ -565,7 +564,7 @@ impl<'a> InferenceContext<'a> { let ret = op::binary_op_return_ty(*op, lhs_ty.clone(), rhs_ty.clone()); if ret == Ty::Unknown { - mark::hit!(infer_expr_inner_binary_operator_overload); + cov_mark::hit!(infer_expr_inner_binary_operator_overload); self.resolve_associated_type_with_params( lhs_ty, diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 987793e2e..a0ac8d80f 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -10,7 +10,6 @@ use hir_def::{ FieldId, }; use hir_expand::name::Name; -use test_utils::mark; use super::{BindingMode, Expectation, InferenceContext}; use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Substs, Ty}; @@ -108,7 +107,7 @@ impl<'a> InferenceContext<'a> { } } } else if let Pat::Ref { .. } = &body[pat] { - mark::hit!(match_ergonomics_ref); + cov_mark::hit!(match_ergonomics_ref); // When you encounter a `&pat` pattern, reset to Move. // This is so that `w` is by value: `let (_, &w) = &(1, &2);` default_bm = BindingMode::Move; diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 99a89a7f3..54fcfed10 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -5,8 +5,6 @@ use std::borrow::Cow; use chalk_ir::{FloatTy, IntTy, TyVariableKind}; use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; -use test_utils::mark; - use super::{InferenceContext, Obligation}; use crate::{ BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferenceVar, Scalar, @@ -387,7 +385,7 @@ impl InferenceTable { // more than once for i in 0..3 { if i > 0 { - mark::hit!(type_var_resolves_to_int_var); + cov_mark::hit!(type_var_resolves_to_int_var); } match &*ty { Ty::InferenceVar(tv, _) => { @@ -416,7 +414,7 @@ impl InferenceTable { Ty::InferenceVar(tv, kind) => { let inner = tv.to_inner(); if tv_stack.contains(&inner) { - mark::hit!(type_var_cycles_resolve_as_possible); + cov_mark::hit!(type_var_cycles_resolve_as_possible); // recursive type return self.type_variable_table.fallback_value(tv, kind); } @@ -443,7 +441,7 @@ impl InferenceTable { Ty::InferenceVar(tv, kind) => { let inner = tv.to_inner(); if tv_stack.contains(&inner) { - mark::hit!(type_var_cycles_resolve_completely); + cov_mark::hit!(type_var_cycles_resolve_completely); // recursive type return self.type_variable_table.fallback_value(tv, kind); } diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 5fe5b8ad1..b90fdc382 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -24,7 +24,6 @@ use hir_expand::name::Name; use la_arena::ArenaMap; use smallvec::SmallVec; use stdx::impl_from; -use test_utils::mark; use crate::{ db::HirDatabase, @@ -760,7 +759,7 @@ fn assoc_type_bindings_from_type_bound<'a>( impl ReturnTypeImplTrait { fn from_hir(ctx: &TyLoweringContext, bounds: &[TypeBound]) -> Self { - mark::hit!(lower_rpit); + cov_mark::hit!(lower_rpit); let self_ty = Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)); let predicates = ctx.with_shifted_in(DebruijnIndex::ONE, |ctx| { bounds @@ -935,7 +934,7 @@ impl TraitEnvironment { // add `Self: Trait` to the environment in trait // function default implementations (and hypothetical code // inside consts or type aliases) - test_utils::mark::hit!(trait_self_implements_self); + cov_mark::hit!(trait_self_implements_self); let substs = Substs::type_params(db, trait_id); let trait_ref = TraitRef { trait_: trait_id, substs }; let pred = GenericPredicate::Implemented(trait_ref); diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index dfcf346fb..24db33c49 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -588,7 +588,7 @@ fn iterate_inherent_methods( // already happens in `is_valid_candidate` above; if not, we // check it here if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() { - test_utils::mark::hit!(impl_self_type_match_without_receiver); + cov_mark::hit!(impl_self_type_match_without_receiver); continue; } if callback(&self_ty.value, item) { diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs index 7bc6c79f3..63d9d4e0b 100644 --- a/crates/hir_ty/src/tests/coercion.rs +++ b/crates/hir_ty/src/tests/coercion.rs @@ -1,5 +1,4 @@ use expect_test::expect; -use test_utils::mark; use super::{check_infer, check_infer_with_mismatches}; @@ -381,7 +380,7 @@ fn infer_match_second_coerce() { #[test] fn coerce_merge_one_by_one1() { - mark::check!(coerce_merge_fail_fallback); + cov_mark::check!(coerce_merge_fail_fallback); check_infer( r" @@ -589,7 +588,7 @@ fn coerce_fn_item_to_fn_ptr() { #[test] fn coerce_fn_items_in_match_arms() { - mark::check!(coerce_fn_reification); + cov_mark::check!(coerce_fn_reification); check_infer_with_mismatches( r" diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index a9901d7b8..4e3f9a9b6 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -913,7 +913,7 @@ fn test() { S2.into(); } #[test] fn method_resolution_overloaded_method() { - test_utils::mark::check!(impl_self_type_match_without_receiver); + cov_mark::check!(impl_self_type_match_without_receiver); check_types( r#" struct Wrapper(T); diff --git a/crates/hir_ty/src/tests/patterns.rs b/crates/hir_ty/src/tests/patterns.rs index 2053d8f56..5da19ba5f 100644 --- a/crates/hir_ty/src/tests/patterns.rs +++ b/crates/hir_ty/src/tests/patterns.rs @@ -1,5 +1,4 @@ use expect_test::expect; -use test_utils::mark; use super::{check_infer, check_infer_with_mismatches}; @@ -197,7 +196,7 @@ fn infer_pattern_match_ergonomics() { #[test] fn infer_pattern_match_ergonomics_ref() { - mark::check!(match_ergonomics_ref); + cov_mark::check!(match_ergonomics_ref); check_infer( r#" fn test() { diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index cffe8630b..69314e245 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -1,5 +1,4 @@ use expect_test::expect; -use test_utils::mark; use super::{check_infer, check_types}; @@ -87,8 +86,8 @@ fn bug_651() { #[test] fn recursive_vars() { - mark::check!(type_var_cycles_resolve_completely); - mark::check!(type_var_cycles_resolve_as_possible); + cov_mark::check!(type_var_cycles_resolve_completely); + cov_mark::check!(type_var_cycles_resolve_as_possible); check_infer( r#" fn test() { @@ -166,7 +165,7 @@ fn infer_std_crash_1() { #[test] fn infer_std_crash_2() { - mark::check!(type_var_resolves_to_int_var); + cov_mark::check!(type_var_resolves_to_int_var); // caused "equating two type variables, ...", taken from std check_infer( r#" diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs index 2947857a5..f5069eba5 100644 --- a/crates/hir_ty/src/tests/simple.rs +++ b/crates/hir_ty/src/tests/simple.rs @@ -1,5 +1,4 @@ use expect_test::expect; -use test_utils::mark; use super::{check_infer, check_types}; @@ -2314,7 +2313,7 @@ fn generic_default_depending_on_other_type_arg_forward() { #[test] fn infer_operator_overload() { - mark::check!(infer_expr_inner_binary_operator_overload); + cov_mark::check!(infer_expr_inner_binary_operator_overload); check_infer( r#" diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 1298e5a88..528092082 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -1,5 +1,4 @@ use expect_test::expect; -use test_utils::mark; use super::{check_infer, check_infer_with_mismatches, check_types}; @@ -319,7 +318,7 @@ fn infer_from_bound_2() { #[test] fn trait_default_method_self_bound_implements_trait() { - mark::check!(trait_self_implements_self); + cov_mark::check!(trait_self_implements_self); check_infer( r#" trait Trait { @@ -1189,7 +1188,7 @@ fn impl_trait() { #[test] fn simple_return_pos_impl_trait() { - mark::check!(lower_rpit); + cov_mark::check!(lower_rpit); check_infer( r#" trait Trait { diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index f6aaaeda4..f7c5efaf3 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" either = "1.5.3" indexmap = "1.4.0" itertools = "0.10.0" diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index a9454cfa3..5d1cc2052 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -11,7 +11,6 @@ use ide_db::{ use itertools::Itertools; use stdx::format_to; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; -use test_utils::mark; use crate::{ display::{macro_label, ShortLabel, TryToNav}, @@ -193,8 +192,8 @@ fn runnable_action( ModuleDef::Function(func) => { let src = func.source(sema.db)?; if src.file_id != file_id.into() { - mark::hit!(hover_macro_generated_struct_fn_doc_comment); - mark::hit!(hover_macro_generated_struct_fn_doc_attr); + cov_mark::hit!(hover_macro_generated_struct_fn_doc_comment); + cov_mark::hit!(hover_macro_generated_struct_fn_doc_attr); return None; } @@ -2101,7 +2100,7 @@ pub fn fo$0o() {} #[test] fn test_hover_macro_generated_struct_fn_doc_comment() { - mark::check!(hover_macro_generated_struct_fn_doc_comment); + cov_mark::check!(hover_macro_generated_struct_fn_doc_comment); check( r#" @@ -2139,7 +2138,7 @@ fn foo() { let bar = Bar; bar.fo$0o(); } #[test] fn test_hover_macro_generated_struct_fn_doc_attr() { - mark::check!(hover_macro_generated_struct_fn_doc_attr); + cov_mark::check!(hover_macro_generated_struct_fn_doc_attr); check( r#" diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index 7fcae13e0..20a920ddb 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs @@ -7,7 +7,7 @@ use syntax::{ SyntaxKind::{self, USE_TREE, WHITESPACE}, SyntaxNode, SyntaxToken, TextRange, TextSize, T, }; -use test_utils::mark; + use text_edit::{TextEdit, TextEditBuilder}; // Feature: Join Lines @@ -60,7 +60,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS let mut string_open_quote = false; if let Some(string) = ast::String::cast(token.clone()) { if let Some(range) = string.open_quote_text_range() { - mark::hit!(join_string_literal); + cov_mark::hit!(join_string_literal); string_open_quote = range.end() == offset; } } @@ -206,7 +206,7 @@ fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { #[cfg(test)] mod tests { use syntax::SourceFile; - use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range, mark}; + use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range}; use super::*; @@ -786,7 +786,7 @@ fn foo() { #[test] fn join_string_literal() { - mark::check!(join_string_literal); + cov_mark::check!(join_string_literal); check_join_lines( r#" fn main() { diff --git a/crates/ide/src/matching_brace.rs b/crates/ide/src/matching_brace.rs index 1bfa1439d..000c412d9 100644 --- a/crates/ide/src/matching_brace.rs +++ b/crates/ide/src/matching_brace.rs @@ -2,7 +2,6 @@ use syntax::{ ast::{self, AstNode}, SourceFile, SyntaxKind, TextSize, T, }; -use test_utils::mark; // Feature: Matching Brace // @@ -28,7 +27,7 @@ pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option 92 } }", "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }", diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs index ddbaf22b7..03d71b380 100644 --- a/crates/ide/src/parent_module.rs +++ b/crates/ide/src/parent_module.rs @@ -5,7 +5,6 @@ use syntax::{ algo::find_node_at_offset, ast::{self, AstNode}, }; -use test_utils::mark; use crate::NavigationTarget; @@ -33,7 +32,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec Vec { #[cfg(test)] mod tests { use ide_db::base_db::FileRange; - use test_utils::mark; use crate::fixture; @@ -92,7 +90,7 @@ $0// empty #[test] fn test_resolve_parent_module_on_module_decl() { - mark::check!(test_resolve_parent_module_on_module_decl); + cov_mark::check!(test_resolve_parent_module_on_module_decl); check( r#" //- /lib.rs diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 1919639a3..05c73de88 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs @@ -14,7 +14,7 @@ use syntax::{ ast::{self, NameOwner}, lex_single_syntax_kind, AstNode, SyntaxKind, SyntaxNode, T, }; -use test_utils::mark; + use text_edit::TextEdit; use crate::{display::TryToNav, FilePosition, FileSystemEdit, RangeInfo, SourceChange, TextRange}; @@ -226,34 +226,36 @@ fn rename_reference( | (IdentifierKind::Ident, _) if def_is_lbl_or_lt => { - mark::hit!(rename_not_a_lifetime_ident_ref); + cov_mark::hit!(rename_not_a_lifetime_ident_ref); bail!("Invalid name `{}`: not a lifetime identifier", new_name) } - (IdentifierKind::Lifetime, _) if def_is_lbl_or_lt => mark::hit!(rename_lifetime), + (IdentifierKind::Lifetime, _) if def_is_lbl_or_lt => cov_mark::hit!(rename_lifetime), (IdentifierKind::Lifetime, _) => { - mark::hit!(rename_not_an_ident_ref); + cov_mark::hit!(rename_not_an_ident_ref); bail!("Invalid name `{}`: not an identifier", new_name) } (IdentifierKind::ToSelf, Definition::Local(local)) if local.is_self(sema.db) => { // no-op - mark::hit!(rename_self_to_self); + cov_mark::hit!(rename_self_to_self); return Ok(SourceChange::default()); } (ident_kind, Definition::Local(local)) if local.is_self(sema.db) => { - mark::hit!(rename_self_to_param); + cov_mark::hit!(rename_self_to_param); return rename_self_to_param(sema, local, new_name, ident_kind); } (IdentifierKind::ToSelf, Definition::Local(local)) => { - mark::hit!(rename_to_self); + cov_mark::hit!(rename_to_self); return rename_to_self(sema, local); } (IdentifierKind::ToSelf, _) => bail!("Invalid name `{}`: not an identifier", new_name), - (IdentifierKind::Ident, _) | (IdentifierKind::Underscore, _) => mark::hit!(rename_ident), + (IdentifierKind::Ident, _) | (IdentifierKind::Underscore, _) => { + cov_mark::hit!(rename_ident) + } } let usages = def.usages(sema).all(); if !usages.is_empty() && ident_kind == IdentifierKind::Underscore { - mark::hit!(rename_underscore_multiple); + cov_mark::hit!(rename_underscore_multiple); bail!("Cannot rename reference to `_` as it is being referenced multiple times"); } let mut source_change = SourceChange::default(); @@ -444,7 +446,7 @@ fn source_edit_from_name_ref( (Some(field_name), Some(init)) => { if field_name == *name_ref { if init.text() == new_name { - mark::hit!(test_rename_field_put_init_shorthand); + cov_mark::hit!(test_rename_field_put_init_shorthand); // same names, we can use a shorthand here instead. // we do not want to erase attributes hence this range start let s = field_name.syntax().text_range().start(); @@ -453,7 +455,7 @@ fn source_edit_from_name_ref( } } else if init == *name_ref { if field_name.text() == new_name { - mark::hit!(test_rename_local_put_init_shorthand); + cov_mark::hit!(test_rename_local_put_init_shorthand); // same names, we can use a shorthand here instead. // we do not want to erase attributes hence this range start let s = field_name.syntax().text_range().start(); @@ -467,12 +469,12 @@ fn source_edit_from_name_ref( // FIXME: instead of splitting the shorthand, recursively trigger a rename of the // other name https://github.com/rust-analyzer/rust-analyzer/issues/6547 (None, Some(_)) if matches!(def, Definition::Field(_)) => { - mark::hit!(test_rename_field_in_field_shorthand); + cov_mark::hit!(test_rename_field_in_field_shorthand); let s = name_ref.syntax().text_range().start(); Some((TextRange::empty(s), format!("{}: ", new_name))) } (None, Some(_)) if matches!(def, Definition::Local(_)) => { - mark::hit!(test_rename_local_in_field_shorthand); + cov_mark::hit!(test_rename_local_in_field_shorthand); let s = name_ref.syntax().text_range().end(); Some((TextRange::empty(s), format!(": {}", new_name))) } @@ -486,7 +488,7 @@ fn source_edit_from_name_ref( (Some(field_name), Some(ast::Pat::IdentPat(pat))) if field_name == *name_ref => { // field name is being renamed if pat.name().map_or(false, |it| it.text() == new_name) { - mark::hit!(test_rename_field_put_init_shorthand_pat); + cov_mark::hit!(test_rename_field_put_init_shorthand_pat); // same names, we can use a shorthand here instead/ // we do not want to erase attributes hence this range start let s = field_name.syntax().text_range().start(); @@ -538,7 +540,7 @@ fn source_edit_from_def( mod tests { use expect_test::{expect, Expect}; use stdx::trim_indent; - use test_utils::{assert_eq_text, mark}; + use test_utils::assert_eq_text; use text_edit::TextEdit; use crate::{fixture, FileId}; @@ -627,7 +629,7 @@ mod tests { #[test] fn test_rename_to_invalid_identifier_lifetime() { - mark::check!(rename_not_an_ident_ref); + cov_mark::check!(rename_not_an_ident_ref); check( "'foo", r#"fn main() { let i$0 = 1; }"#, @@ -637,7 +639,7 @@ mod tests { #[test] fn test_rename_to_invalid_identifier_lifetime2() { - mark::check!(rename_not_a_lifetime_ident_ref); + cov_mark::check!(rename_not_a_lifetime_ident_ref); check( "foo", r#"fn main<'a>(_: &'a$0 ()) {}"#, @@ -647,7 +649,7 @@ mod tests { #[test] fn test_rename_to_underscore_invalid() { - mark::check!(rename_underscore_multiple); + cov_mark::check!(rename_underscore_multiple); check( "_", r#"fn main(foo$0: ()) {foo;}"#, @@ -666,7 +668,7 @@ mod tests { #[test] fn test_rename_for_local() { - mark::check!(rename_ident); + cov_mark::check!(rename_ident); check( "k", r#" @@ -829,7 +831,7 @@ impl Foo { #[test] fn test_rename_field_in_field_shorthand() { - mark::check!(test_rename_field_in_field_shorthand); + cov_mark::check!(test_rename_field_in_field_shorthand); check( "j", r#" @@ -855,7 +857,7 @@ impl Foo { #[test] fn test_rename_local_in_field_shorthand() { - mark::check!(test_rename_local_in_field_shorthand); + cov_mark::check!(test_rename_local_in_field_shorthand); check( "j", r#" @@ -1261,7 +1263,7 @@ fn foo(f: foo::Foo) { #[test] fn test_parameter_to_self() { - mark::check!(rename_to_self); + cov_mark::check!(rename_to_self); check( "self", r#" @@ -1401,7 +1403,7 @@ impl Foo { #[test] fn test_owned_self_to_parameter() { - mark::check!(rename_self_to_param); + cov_mark::check!(rename_self_to_param); check( "foo", r#" @@ -1454,7 +1456,7 @@ impl Foo { #[test] fn test_rename_field_put_init_shorthand() { - mark::check!(test_rename_field_put_init_shorthand); + cov_mark::check!(test_rename_field_put_init_shorthand); check( "bar", r#" @@ -1476,7 +1478,7 @@ fn foo(bar: i32) -> Foo { #[test] fn test_rename_local_put_init_shorthand() { - mark::check!(test_rename_local_put_init_shorthand); + cov_mark::check!(test_rename_local_put_init_shorthand); check( "i", r#" @@ -1498,7 +1500,7 @@ fn foo(i: i32) -> Foo { #[test] fn test_struct_field_pat_into_shorthand() { - mark::check!(test_rename_field_put_init_shorthand_pat); + cov_mark::check!(test_rename_field_put_init_shorthand_pat); check( "baz", r#" @@ -1610,7 +1612,7 @@ fn foo(foo: Foo) { #[test] fn test_rename_lifetimes() { - mark::check!(rename_lifetime); + cov_mark::check!(rename_lifetime); check( "'yeeee", r#" @@ -1698,7 +1700,7 @@ fn foo<'a>() -> &'a () { #[test] fn test_self_to_self() { - mark::check!(rename_self_to_self); + cov_mark::check!(rename_self_to_self); check( "self", r#" diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 65f60891e..280565563 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs @@ -9,7 +9,6 @@ use syntax::{ ast::{self, AstNode, AttrsOwner}, match_ast, SyntaxNode, }; -use test_utils::mark; use crate::{ display::{ToNav, TryToNav}, @@ -130,7 +129,9 @@ fn runnables_mod(sema: &Semantics, acc: &mut Vec, module if let hir::ModuleDef::Module(submodule) = def { match submodule.definition_source(sema.db).value { hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule), - hir::ModuleSource::SourceFile(_) => mark::hit!(dont_recurse_in_outline_submodules), + hir::ModuleSource::SourceFile(_) => { + cov_mark::hit!(dont_recurse_in_outline_submodules) + } hir::ModuleSource::BlockExpr(_) => {} // inner items aren't runnable } } @@ -328,7 +329,6 @@ fn has_test_function_or_multiple_test_submodules( #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::fixture; @@ -1056,7 +1056,7 @@ mod tests { #[test] fn dont_recurse_in_outline_submodules() { - mark::check!(dont_recurse_in_outline_submodules); + cov_mark::check!(dont_recurse_in_outline_submodules); check( r#" //- /lib.rs diff --git a/crates/ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs index 63cd51b69..978c479de 100644 --- a/crates/ide/src/typing/on_enter.rs +++ b/crates/ide/src/typing/on_enter.rs @@ -9,7 +9,7 @@ use syntax::{ SyntaxKind::*, SyntaxToken, TextRange, TextSize, TokenAtOffset, }; -use test_utils::mark; + use text_edit::TextEdit; // Feature: On Enter @@ -55,7 +55,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option Option { #[cfg(test)] mod tests { use stdx::trim_indent; - use test_utils::{assert_eq_text, mark}; + use test_utils::assert_eq_text; use crate::fixture; @@ -238,7 +238,7 @@ fn main() { #[test] fn continues_end_of_line_comment_with_space() { - mark::check!(continues_end_of_line_comment_with_space); + cov_mark::check!(continues_end_of_line_comment_with_space); do_check( r#" fn main() { diff --git a/crates/ide_assists/Cargo.toml b/crates/ide_assists/Cargo.toml index a34bdd6c3..3bf0099a9 100644 --- a/crates/ide_assists/Cargo.toml +++ b/crates/ide_assists/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" rustc-hash = "1.1.0" itertools = "0.10.0" either = "1.6.1" diff --git a/crates/ide_assists/src/handlers/add_turbo_fish.rs b/crates/ide_assists/src/handlers/add_turbo_fish.rs index a08b55ebb..3b6efbab4 100644 --- a/crates/ide_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ide_assists/src/handlers/add_turbo_fish.rs @@ -1,6 +1,5 @@ use ide_db::defs::{Definition, NameRefClass}; use syntax::{ast, AstNode, SyntaxKind, T}; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -30,13 +29,13 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( if arg_list.args().count() > 0 { return None; } - mark::hit!(add_turbo_fish_after_call); - mark::hit!(add_type_ascription_after_call); + cov_mark::hit!(add_turbo_fish_after_call); + cov_mark::hit!(add_type_ascription_after_call); arg_list.l_paren_token()?.prev_token().filter(|it| it.kind() == SyntaxKind::IDENT) })?; let next_token = ident.next_token()?; if next_token.kind() == T![::] { - mark::hit!(add_turbo_fish_one_fish_is_enough); + cov_mark::hit!(add_turbo_fish_one_fish_is_enough); return None; } let name_ref = ast::NameRef::cast(ident.parent())?; @@ -50,7 +49,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( }; let generics = hir::GenericDef::Function(fun).params(ctx.sema.db); if generics.is_empty() { - mark::hit!(add_turbo_fish_non_generic); + cov_mark::hit!(add_turbo_fish_non_generic); return None; } @@ -67,7 +66,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( }, )? } else { - mark::hit!(add_type_ascription_already_typed); + cov_mark::hit!(add_type_ascription_already_typed); } } @@ -87,7 +86,6 @@ mod tests { use crate::tests::{check_assist, check_assist_by_label, check_assist_not_applicable}; use super::*; - use test_utils::mark; #[test] fn add_turbo_fish_function() { @@ -110,7 +108,7 @@ fn main() { #[test] fn add_turbo_fish_after_call() { - mark::check!(add_turbo_fish_after_call); + cov_mark::check!(add_turbo_fish_after_call); check_assist( add_turbo_fish, r#" @@ -155,7 +153,7 @@ fn main() { #[test] fn add_turbo_fish_one_fish_is_enough() { - mark::check!(add_turbo_fish_one_fish_is_enough); + cov_mark::check!(add_turbo_fish_one_fish_is_enough); check_assist_not_applicable( add_turbo_fish, r#" @@ -169,7 +167,7 @@ fn main() { #[test] fn add_turbo_fish_non_generic() { - mark::check!(add_turbo_fish_non_generic); + cov_mark::check!(add_turbo_fish_non_generic); check_assist_not_applicable( add_turbo_fish, r#" @@ -203,7 +201,7 @@ fn main() { #[test] fn add_type_ascription_after_call() { - mark::check!(add_type_ascription_after_call); + cov_mark::check!(add_type_ascription_after_call); check_assist_by_label( add_turbo_fish, r#" @@ -250,7 +248,7 @@ fn main() { #[test] fn add_type_ascription_already_typed() { - mark::check!(add_type_ascription_already_typed); + cov_mark::check!(add_type_ascription_already_typed); check_assist( add_turbo_fish, r#" diff --git a/crates/ide_assists/src/handlers/apply_demorgan.rs b/crates/ide_assists/src/handlers/apply_demorgan.rs index 128b1eb56..a1c339603 100644 --- a/crates/ide_assists/src/handlers/apply_demorgan.rs +++ b/crates/ide_assists/src/handlers/apply_demorgan.rs @@ -1,5 +1,4 @@ use syntax::ast::{self, AstNode}; -use test_utils::mark; use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists}; @@ -64,10 +63,10 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( edit.replace(lhs_range, not_lhs.syntax().text()); edit.replace(rhs_range, not_rhs.syntax().text()); if let Some(neg_expr) = neg_expr { - mark::hit!(demorgan_double_negation); + cov_mark::hit!(demorgan_double_negation); edit.replace(neg_expr.op_token().unwrap().text_range(), ""); } else { - mark::hit!(demorgan_double_parens); + cov_mark::hit!(demorgan_double_parens); edit.replace(paren_expr.l_paren_token().unwrap().text_range(), "!("); } } else { @@ -90,7 +89,6 @@ fn opposite_logic_op(kind: ast::BinOp) -> Option<&'static str> { #[cfg(test)] mod tests { use ide_db::helpers::FamousDefs; - use test_utils::mark; use super::*; @@ -188,13 +186,13 @@ fn f() { #[test] fn demorgan_doesnt_double_negation() { - mark::check!(demorgan_double_negation); + cov_mark::check!(demorgan_double_negation); check_assist(apply_demorgan, "fn f() { !(x ||$0 x) }", "fn f() { (!x && !x) }") } #[test] fn demorgan_doesnt_double_parens() { - mark::check!(demorgan_double_parens); + cov_mark::check!(demorgan_double_parens); check_assist(apply_demorgan, "fn f() { (x ||$0 x) }", "fn f() { !(!x && !x) }") } } diff --git a/crates/ide_assists/src/handlers/change_visibility.rs b/crates/ide_assists/src/handlers/change_visibility.rs index ac8c44124..ec99a5505 100644 --- a/crates/ide_assists/src/handlers/change_visibility.rs +++ b/crates/ide_assists/src/handlers/change_visibility.rs @@ -4,7 +4,6 @@ use syntax::{ SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, VISIBILITY}, T, }; -use test_utils::mark; use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; @@ -56,7 +55,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { } else if let Some(field_name) = ctx.find_node_at_offset::() { let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?; if field.name()? != field_name { - mark::hit!(change_visibility_field_false_positive); + cov_mark::hit!(change_visibility_field_false_positive); return None; } if field.visibility().is_some() { @@ -110,8 +109,6 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; use super::*; @@ -139,7 +136,7 @@ mod tests { #[test] fn change_visibility_field_false_positive() { - mark::check!(change_visibility_field_false_positive); + cov_mark::check!(change_visibility_field_false_positive); check_assist_not_applicable( change_visibility, r"struct S { field: [(); { let $0x = ();}] }", diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index 8779d8bd1..dd4501709 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs @@ -20,7 +20,6 @@ use syntax::{ SyntaxKind::{self, BLOCK_EXPR, BREAK_EXPR, COMMENT, PATH_EXPR, RETURN_EXPR}, SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, WalkEvent, T, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -59,7 +58,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option let node = ctx.covering_element(); if node.kind() == COMMENT { - mark::hit!(extract_function_in_comment_is_not_applicable); + cov_mark::hit!(extract_function_in_comment_is_not_applicable); return None; } @@ -197,14 +196,14 @@ fn external_control_flow(ctx: &AssistContext, body: &FunctionBody) -> Option return None, }, (Some(_), _, _, _) => { - mark::hit!(external_control_flow_try_and_bc); + cov_mark::hit!(external_control_flow_try_and_bc); return None; } (None, Some(r), None, None) => match r.expr() { @@ -212,11 +211,11 @@ fn external_control_flow(ctx: &AssistContext, body: &FunctionBody) -> Option Some(FlowKind::Return), }, (None, Some(_), _, _) => { - mark::hit!(external_control_flow_return_and_bc); + cov_mark::hit!(external_control_flow_return_and_bc); return None; } (None, None, Some(_), Some(_)) => { - mark::hit!(external_control_flow_break_and_continue); + cov_mark::hit!(external_control_flow_break_and_continue); return None; } (None, None, Some(b), None) => match b.expr() { @@ -1837,7 +1836,7 @@ fn $0fun_name(n: u32) -> u32 { #[test] fn in_comment_is_not_applicable() { - mark::check!(extract_function_in_comment_is_not_applicable); + cov_mark::check!(extract_function_in_comment_is_not_applicable); check_assist_not_applicable(extract_function, r"fn main() { 1 + /* $0comment$0 */ 1; }"); } @@ -2822,7 +2821,7 @@ fn $0fun_name(n: i32) -> Result { #[test] fn break_and_continue() { - mark::check!(external_control_flow_break_and_continue); + cov_mark::check!(external_control_flow_break_and_continue); check_assist_not_applicable( extract_function, r##" @@ -2842,7 +2841,7 @@ fn foo() { #[test] fn return_and_break() { - mark::check!(external_control_flow_return_and_bc); + cov_mark::check!(external_control_flow_return_and_bc); check_assist_not_applicable( extract_function, r##" @@ -3341,7 +3340,7 @@ fn $0fun_name() -> Result { #[test] fn try_and_break() { - mark::check!(external_control_flow_try_and_bc); + cov_mark::check!(external_control_flow_try_and_bc); check_assist_not_applicable( extract_function, r##" @@ -3363,7 +3362,7 @@ fn foo() -> Option<()> { #[test] fn try_and_return_ok() { - mark::check!(external_control_flow_try_and_return_non_err); + cov_mark::check!(external_control_flow_try_and_return_non_err); check_assist_not_applicable( extract_function, r##" diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs index 312ac7ac4..7a32483dc 100644 --- a/crates/ide_assists/src/handlers/extract_variable.rs +++ b/crates/ide_assists/src/handlers/extract_variable.rs @@ -6,7 +6,6 @@ use syntax::{ }, SyntaxNode, }; -use test_utils::mark; use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists}; @@ -32,7 +31,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option } let node = ctx.covering_element(); if node.kind() == COMMENT { - mark::hit!(extract_var_in_comment_is_not_applicable); + cov_mark::hit!(extract_var_in_comment_is_not_applicable); return None; } let to_extract = node.ancestors().find_map(valid_target_expr)?; @@ -69,7 +68,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option format_to!(buf, "{}", to_extract.syntax()); if let Anchor::Replace(stmt) = anchor { - mark::hit!(test_extract_var_expr_stmt); + cov_mark::hit!(test_extract_var_expr_stmt); if stmt.semicolon_token().is_none() { buf.push_str(";"); } @@ -142,7 +141,7 @@ impl Anchor { node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.tail_expr()) { if expr.syntax() == &node { - mark::hit!(test_extract_var_last_expr); + cov_mark::hit!(test_extract_var_last_expr); return Some(Anchor::Before(node)); } } @@ -175,8 +174,6 @@ impl Anchor { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; use super::*; @@ -199,13 +196,13 @@ fn foo() { #[test] fn extract_var_in_comment_is_not_applicable() { - mark::check!(extract_var_in_comment_is_not_applicable); + cov_mark::check!(extract_var_in_comment_is_not_applicable); check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }"); } #[test] fn test_extract_var_expr_stmt() { - mark::check!(test_extract_var_expr_stmt); + cov_mark::check!(test_extract_var_expr_stmt); check_assist( extract_variable, r#" @@ -250,7 +247,7 @@ fn foo() { #[test] fn test_extract_var_last_expr() { - mark::check!(test_extract_var_last_expr); + cov_mark::check!(test_extract_var_last_expr); check_assist( extract_variable, r#" diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs index 7086e47d2..878b3a3fa 100644 --- a/crates/ide_assists/src/handlers/fill_match_arms.rs +++ b/crates/ide_assists/src/handlers/fill_match_arms.rs @@ -5,7 +5,6 @@ use ide_db::helpers::{mod_path_to_ast, FamousDefs}; use ide_db::RootDatabase; use itertools::Itertools; use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; -use test_utils::mark; use crate::{ utils::{does_pat_match_variant, render_snippet, Cursor}, @@ -62,7 +61,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< .collect::>(); if Some(enum_def) == FamousDefs(&ctx.sema, Some(module.krate())).core_option_Option() { // Match `Some` variant first. - mark::hit!(option_order); + cov_mark::hit!(option_order); variants.reverse() } variants @@ -195,7 +194,6 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::Variant) -> Optio #[cfg(test)] mod tests { use ide_db::helpers::FamousDefs; - use test_utils::mark; use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; @@ -730,7 +728,7 @@ fn main() { #[test] fn option_order() { - mark::check!(option_order); + cov_mark::check!(option_order); let before = r#" fn foo(opt: Option) { match opt$0 { diff --git a/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs b/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs index 6a2ab9596..588ee1350 100644 --- a/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs @@ -1,7 +1,6 @@ use ide_db::helpers::FamousDefs; use ide_db::RootDatabase; use syntax::ast::{self, AstNode, NameOwner}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -38,12 +37,12 @@ pub(crate) fn generate_default_from_enum_variant( let variant_name = variant.name()?; let enum_name = variant.parent_enum().name()?; if !matches!(variant.kind(), ast::StructKind::Unit) { - mark::hit!(test_gen_default_on_non_unit_variant_not_implemented); + cov_mark::hit!(test_gen_default_on_non_unit_variant_not_implemented); return None; } if existing_default_impl(&ctx.sema, &variant).is_some() { - mark::hit!(test_gen_default_impl_already_exists); + cov_mark::hit!(test_gen_default_impl_already_exists); return None; } @@ -89,8 +88,6 @@ fn existing_default_impl( #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -127,7 +124,7 @@ impl Default for Variant { #[test] fn test_generate_default_already_implemented() { - mark::check!(test_gen_default_impl_already_exists); + cov_mark::check!(test_gen_default_impl_already_exists); check_not_applicable( r#" enum Variant { @@ -146,7 +143,7 @@ impl Default for Variant { #[test] fn test_add_from_impl_no_element() { - mark::check!(test_gen_default_on_non_unit_variant_not_implemented); + cov_mark::check!(test_gen_default_on_non_unit_variant_not_implemented); check_not_applicable( r#" enum Variant { diff --git a/crates/ide_assists/src/handlers/generate_default_from_new.rs b/crates/ide_assists/src/handlers/generate_default_from_new.rs index fa1254579..81c54ba3e 100644 --- a/crates/ide_assists/src/handlers/generate_default_from_new.rs +++ b/crates/ide_assists/src/handlers/generate_default_from_new.rs @@ -7,7 +7,6 @@ use syntax::{ ast::{self, Impl, NameOwner}, AstNode, }; -use test_utils::mark; // Assist: generate_default_from_new // @@ -43,19 +42,19 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext) let fn_name = fn_node.name()?; if fn_name.text() != "new" { - mark::hit!(other_function_than_new); + cov_mark::hit!(other_function_than_new); return None; } if fn_node.param_list()?.params().next().is_some() { - mark::hit!(new_function_with_parameters); + cov_mark::hit!(new_function_with_parameters); return None; } let impl_ = fn_node.syntax().ancestors().into_iter().find_map(ast::Impl::cast)?; if is_default_implemented(ctx, &impl_) { - mark::hit!(default_block_is_already_present); - mark::hit!(struct_in_module_with_default); + cov_mark::hit!(default_block_is_already_present); + cov_mark::hit!(struct_in_module_with_default); return None; } @@ -178,7 +177,7 @@ impl Default for Test { #[test] fn new_function_with_parameters() { - mark::check!(new_function_with_parameters); + cov_mark::check!(new_function_with_parameters); check_not_applicable( r#" struct Example { _inner: () } @@ -194,7 +193,7 @@ impl Example { #[test] fn other_function_than_new() { - mark::check!(other_function_than_new); + cov_mark::check!(other_function_than_new); check_not_applicable( r#" struct Example { _inner: () } @@ -211,7 +210,7 @@ impl Example { #[test] fn default_block_is_already_present() { - mark::check!(default_block_is_already_present); + cov_mark::check!(default_block_is_already_present); check_not_applicable( r#" struct Example { _inner: () } @@ -340,7 +339,7 @@ impl Default for Example { #[test] fn struct_in_module_with_default() { - mark::check!(struct_in_module_with_default); + cov_mark::check!(struct_in_module_with_default); check_not_applicable( r#" mod test { diff --git a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs index d9388a737..c13c6eebe 100644 --- a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs +++ b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs @@ -1,7 +1,6 @@ use ide_db::helpers::FamousDefs; use ide_db::RootDatabase; use syntax::ast::{self, AstNode, NameOwner}; -use test_utils::mark; use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists}; @@ -44,7 +43,7 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext }; if existing_from_impl(&ctx.sema, &variant).is_some() { - mark::hit!(test_add_from_impl_already_exists); + cov_mark::hit!(test_add_from_impl_already_exists); return None; } @@ -103,8 +102,6 @@ fn existing_from_impl( #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -172,7 +169,7 @@ impl From for A { #[test] fn test_add_from_impl_already_exists() { - mark::check!(test_add_from_impl_already_exists); + cov_mark::check!(test_add_from_impl_already_exists); check_not_applicable( r#" enum A { $0One(u32), } diff --git a/crates/ide_assists/src/handlers/infer_function_return_type.rs b/crates/ide_assists/src/handlers/infer_function_return_type.rs index 5279af1f3..66113751c 100644 --- a/crates/ide_assists/src/handlers/infer_function_return_type.rs +++ b/crates/ide_assists/src/handlers/infer_function_return_type.rs @@ -1,6 +1,5 @@ use hir::HirDisplay; use syntax::{ast, AstNode, TextRange, TextSize}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -42,7 +41,7 @@ pub(crate) fn infer_function_return_type(acc: &mut Assists, ctx: &AssistContext) } } if let FnType::Closure { wrap_expr: true } = fn_type { - mark::hit!(wrap_closure_non_block_expr); + cov_mark::hit!(wrap_closure_non_block_expr); // `|x| x` becomes `|x| -> T x` which is invalid, so wrap it in a block builder.replace(tail_expr.syntax().text_range(), &format!("{{{}}}", tail_expr)); } @@ -61,13 +60,13 @@ fn ret_ty_to_action(ret_ty: Option, insert_pos: TextSize) -> Optio match ret_ty { Some(ret_ty) => match ret_ty.ty() { Some(ast::Type::InferType(_)) | None => { - mark::hit!(existing_infer_ret_type); - mark::hit!(existing_infer_ret_type_closure); + cov_mark::hit!(existing_infer_ret_type); + cov_mark::hit!(existing_infer_ret_type_closure); Some(InsertOrReplace::Replace(ret_ty.syntax().text_range())) } _ => { - mark::hit!(existing_ret_type); - mark::hit!(existing_ret_type_closure); + cov_mark::hit!(existing_ret_type); + cov_mark::hit!(existing_ret_type_closure); None } }, @@ -109,11 +108,11 @@ fn extract_tail(ctx: &AssistContext) -> Option<(FnType, ast::Expr, InsertOrRepla }; let frange = ctx.frange.range; if return_type_range.contains_range(frange) { - mark::hit!(cursor_in_ret_position); - mark::hit!(cursor_in_ret_position_closure); + cov_mark::hit!(cursor_in_ret_position); + cov_mark::hit!(cursor_in_ret_position_closure); } else if tail_expr.syntax().text_range().contains_range(frange) { - mark::hit!(cursor_on_tail); - mark::hit!(cursor_on_tail_closure); + cov_mark::hit!(cursor_on_tail); + cov_mark::hit!(cursor_on_tail_closure); } else { return None; } @@ -128,7 +127,7 @@ mod tests { #[test] fn infer_return_type_specified_inferred() { - mark::check!(existing_infer_ret_type); + cov_mark::check!(existing_infer_ret_type); check_assist( infer_function_return_type, r#"fn foo() -> $0_ { @@ -142,7 +141,7 @@ mod tests { #[test] fn infer_return_type_specified_inferred_closure() { - mark::check!(existing_infer_ret_type_closure); + cov_mark::check!(existing_infer_ret_type_closure); check_assist( infer_function_return_type, r#"fn foo() { @@ -156,7 +155,7 @@ mod tests { #[test] fn infer_return_type_cursor_at_return_type_pos() { - mark::check!(cursor_in_ret_position); + cov_mark::check!(cursor_in_ret_position); check_assist( infer_function_return_type, r#"fn foo() $0{ @@ -170,7 +169,7 @@ mod tests { #[test] fn infer_return_type_cursor_at_return_type_pos_closure() { - mark::check!(cursor_in_ret_position_closure); + cov_mark::check!(cursor_in_ret_position_closure); check_assist( infer_function_return_type, r#"fn foo() { @@ -184,7 +183,7 @@ mod tests { #[test] fn infer_return_type() { - mark::check!(cursor_on_tail); + cov_mark::check!(cursor_on_tail); check_assist( infer_function_return_type, r#"fn foo() { @@ -219,7 +218,7 @@ mod tests { #[test] fn not_applicable_ret_type_specified() { - mark::check!(existing_ret_type); + cov_mark::check!(existing_ret_type); check_assist_not_applicable( infer_function_return_type, r#"fn foo() -> i32 { @@ -251,7 +250,7 @@ mod tests { #[test] fn infer_return_type_closure_block() { - mark::check!(cursor_on_tail_closure); + cov_mark::check!(cursor_on_tail_closure); check_assist( infer_function_return_type, r#"fn foo() { @@ -282,7 +281,7 @@ mod tests { #[test] fn infer_return_type_closure_wrap() { - mark::check!(wrap_closure_non_block_expr); + cov_mark::check!(wrap_closure_non_block_expr); check_assist( infer_function_return_type, r#"fn foo() { @@ -321,7 +320,7 @@ mod tests { #[test] fn not_applicable_ret_type_specified_closure() { - mark::check!(existing_ret_type_closure); + cov_mark::check!(existing_ret_type_closure); check_assist_not_applicable( infer_function_return_type, r#"fn foo() { diff --git a/crates/ide_assists/src/handlers/inline_function.rs b/crates/ide_assists/src/handlers/inline_function.rs index 6ec99b09b..8e56029cb 100644 --- a/crates/ide_assists/src/handlers/inline_function.rs +++ b/crates/ide_assists/src/handlers/inline_function.rs @@ -4,7 +4,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, ArgListOwner}, AstNode, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -49,7 +48,7 @@ pub(crate) fn inline_function(acc: &mut Assists, ctx: &AssistContext) -> Option< if arguments.len() != parameters.len() { // Can't inline the function because they've passed the wrong number of // arguments to this function - mark::hit!(inline_function_incorrect_number_of_arguments); + cov_mark::hit!(inline_function_incorrect_number_of_arguments); return None; } @@ -155,7 +154,7 @@ fn main() { Foo.bar$0(); } #[test] fn not_applicable_when_incorrect_number_of_parameters_are_provided() { - mark::check!(inline_function_incorrect_number_of_arguments); + cov_mark::check!(inline_function_incorrect_number_of_arguments); check_assist_not_applicable( inline_function, r#" diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs index da5522670..ea1466dc8 100644 --- a/crates/ide_assists/src/handlers/inline_local_variable.rs +++ b/crates/ide_assists/src/handlers/inline_local_variable.rs @@ -4,7 +4,6 @@ use syntax::{ ast::{self, AstNode, AstToken}, TextRange, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -34,11 +33,11 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O _ => return None, }; if bind_pat.mut_token().is_some() { - mark::hit!(test_not_inline_mut_variable); + cov_mark::hit!(test_not_inline_mut_variable); return None; } if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) { - mark::hit!(not_applicable_outside_of_bind_pat); + cov_mark::hit!(not_applicable_outside_of_bind_pat); return None; } let initializer_expr = let_stmt.initializer()?; @@ -47,7 +46,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O let def = Definition::Local(def); let usages = def.usages(&ctx.sema).all(); if usages.is_empty() { - mark::hit!(test_not_applicable_if_variable_unused); + cov_mark::hit!(test_not_applicable_if_variable_unused); return None; }; @@ -130,7 +129,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O Some(name_ref) if ast::RecordExprField::for_field_name(name_ref).is_some() => { - mark::hit!(inline_field_shorthand); + cov_mark::hit!(inline_field_shorthand); builder.insert(reference.range.end(), format!(": {}", replacement)); } _ => builder.replace(reference.range, replacement), @@ -143,8 +142,6 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -351,7 +348,7 @@ fn foo() { #[test] fn test_not_inline_mut_variable() { - mark::check!(test_not_inline_mut_variable); + cov_mark::check!(test_not_inline_mut_variable); check_assist_not_applicable( inline_local_variable, r" @@ -684,7 +681,7 @@ fn foo() { #[test] fn inline_field_shorthand() { - mark::check!(inline_field_shorthand); + cov_mark::check!(inline_field_shorthand); check_assist( inline_local_variable, r" @@ -705,7 +702,7 @@ fn main() { #[test] fn test_not_applicable_if_variable_unused() { - mark::check!(test_not_applicable_if_variable_unused); + cov_mark::check!(test_not_applicable_if_variable_unused); check_assist_not_applicable( inline_local_variable, r" @@ -718,7 +715,7 @@ fn foo() { #[test] fn not_applicable_outside_of_bind_pat() { - mark::check!(not_applicable_outside_of_bind_pat); + cov_mark::check!(not_applicable_outside_of_bind_pat); check_assist_not_applicable( inline_local_variable, r" diff --git a/crates/ide_assists/src/handlers/move_module_to_file.rs b/crates/ide_assists/src/handlers/move_module_to_file.rs index 91c395c1b..6e685b4b2 100644 --- a/crates/ide_assists/src/handlers/move_module_to_file.rs +++ b/crates/ide_assists/src/handlers/move_module_to_file.rs @@ -5,7 +5,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, NameOwner}, AstNode, TextRange, }; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -28,7 +27,7 @@ pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext) -> Opt let l_curly_offset = module_items.syntax().text_range().start(); if l_curly_offset <= ctx.offset() { - mark::hit!(available_before_curly); + cov_mark::hit!(available_before_curly); return None; } let target = TextRange::new(module_ast.syntax().text_range().start(), l_curly_offset); @@ -182,7 +181,7 @@ pub(crate) mod tests; #[test] fn available_before_curly() { - mark::check!(available_before_curly); + cov_mark::check!(available_before_curly); check_assist_not_applicable(move_module_to_file, r#"mod m { $0 }"#); } } diff --git a/crates/ide_assists/src/handlers/pull_assignment_up.rs b/crates/ide_assists/src/handlers/pull_assignment_up.rs index 377ed4f2f..04bae4e58 100644 --- a/crates/ide_assists/src/handlers/pull_assignment_up.rs +++ b/crates/ide_assists/src/handlers/pull_assignment_up.rs @@ -2,7 +2,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, make}, AstNode, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -104,7 +103,7 @@ fn exprify_if( ast::ElseBranch::Block(exprify_block(block, sema, name)?) } ast::ElseBranch::IfExpr(expr) => { - mark::hit!(test_pull_assignment_up_chained_if); + cov_mark::hit!(test_pull_assignment_up_chained_if); ast::ElseBranch::IfExpr(ast::IfExpr::cast( exprify_if(&expr, sema, name)?.syntax().to_owned(), )?) @@ -144,7 +143,7 @@ fn is_equivalent( ) -> bool { match (expr0, expr1) { (ast::Expr::FieldExpr(field_expr0), ast::Expr::FieldExpr(field_expr1)) => { - mark::hit!(test_pull_assignment_up_field_assignment); + cov_mark::hit!(test_pull_assignment_up_field_assignment); sema.resolve_field(field_expr0) == sema.resolve_field(field_expr1) } (ast::Expr::PathExpr(path0), ast::Expr::PathExpr(path1)) => { @@ -160,7 +159,7 @@ fn is_equivalent( if prefix0.op_kind() == Some(ast::PrefixOp::Deref) && prefix1.op_kind() == Some(ast::PrefixOp::Deref) => { - mark::hit!(test_pull_assignment_up_deref); + cov_mark::hit!(test_pull_assignment_up_deref); if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) { is_equivalent(sema, &prefix0, &prefix1) } else { @@ -263,7 +262,7 @@ fn foo() { #[test] fn test_pull_assignment_up_chained_if() { - mark::check!(test_pull_assignment_up_chained_if); + cov_mark::check!(test_pull_assignment_up_chained_if); check_assist( pull_assignment_up, r#" @@ -379,7 +378,7 @@ fn foo() { #[test] fn test_pull_assignment_up_field_assignment() { - mark::check!(test_pull_assignment_up_field_assignment); + cov_mark::check!(test_pull_assignment_up_field_assignment); check_assist( pull_assignment_up, r#" @@ -411,7 +410,7 @@ fn foo() { #[test] fn test_pull_assignment_up_deref() { - mark::check!(test_pull_assignment_up_deref); + cov_mark::check!(test_pull_assignment_up_deref); check_assist( pull_assignment_up, r#" diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index d84ca0e55..d3e34e540 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -8,7 +8,6 @@ use syntax::{ ast::{make, ArgListOwner}, AstNode, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -47,25 +46,25 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let qualify_candidate = match candidate { ImportCandidate::Path(candidate) => { if candidate.qualifier.is_some() { - mark::hit!(qualify_path_qualifier_start); + cov_mark::hit!(qualify_path_qualifier_start); let path = ast::Path::cast(syntax_under_caret)?; let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); QualifyCandidate::QualifierStart(segment, prev_segment.generic_arg_list()) } else { - mark::hit!(qualify_path_unqualified_name); + cov_mark::hit!(qualify_path_unqualified_name); let path = ast::Path::cast(syntax_under_caret)?; let generics = path.segment()?.generic_arg_list(); QualifyCandidate::UnqualifiedName(generics) } } ImportCandidate::TraitAssocItem(_) => { - mark::hit!(qualify_path_trait_assoc_item); + cov_mark::hit!(qualify_path_trait_assoc_item); let path = ast::Path::cast(syntax_under_caret)?; let (qualifier, segment) = (path.qualifier()?, path.segment()?); QualifyCandidate::TraitAssocItem(qualifier, segment) } ImportCandidate::TraitMethod(_) => { - mark::hit!(qualify_path_trait_method); + cov_mark::hit!(qualify_path_trait_method); let mcall_expr = ast::MethodCallExpr::cast(syntax_under_caret)?; QualifyCandidate::TraitMethod(ctx.sema.db, mcall_expr) } @@ -212,7 +211,7 @@ mod tests { #[test] fn applicable_when_found_an_import_partial() { - mark::check!(qualify_path_unqualified_name); + cov_mark::check!(qualify_path_unqualified_name); check_assist( qualify_path, r" @@ -504,7 +503,7 @@ fn main() { #[test] fn associated_struct_const() { - mark::check!(qualify_path_qualifier_start); + cov_mark::check!(qualify_path_qualifier_start); check_assist( qualify_path, r" @@ -605,7 +604,7 @@ fn main() { #[test] fn associated_trait_const() { - mark::check!(qualify_path_trait_assoc_item); + cov_mark::check!(qualify_path_trait_assoc_item); check_assist( qualify_path, r" @@ -675,7 +674,7 @@ fn main() { #[test] fn trait_method() { - mark::check!(qualify_path_trait_method); + cov_mark::check!(qualify_path_trait_method); check_assist( qualify_path, r" diff --git a/crates/ide_assists/src/handlers/raw_string.rs b/crates/ide_assists/src/handlers/raw_string.rs index d95267607..d0f1613f3 100644 --- a/crates/ide_assists/src/handlers/raw_string.rs +++ b/crates/ide_assists/src/handlers/raw_string.rs @@ -1,7 +1,6 @@ use std::borrow::Cow; use syntax::{ast, AstToken, TextRange, TextSize}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -149,7 +148,7 @@ pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let internal_text = &text[token.text_range_between_quotes()? - text_range.start()]; if existing_hashes == required_hashes(internal_text) { - mark::hit!(cant_remove_required_hash); + cov_mark::hit!(cant_remove_required_hash); return None; } @@ -182,8 +181,6 @@ fn test_required_hashes() { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; use super::*; @@ -396,7 +393,7 @@ string"###; #[test] fn cant_remove_required_hash() { - mark::check!(cant_remove_required_hash); + cov_mark::check!(cant_remove_required_hash); check_assist_not_applicable( remove_hash, r##" diff --git a/crates/ide_assists/src/handlers/remove_unused_param.rs b/crates/ide_assists/src/handlers/remove_unused_param.rs index c961680e2..2699d2861 100644 --- a/crates/ide_assists/src/handlers/remove_unused_param.rs +++ b/crates/ide_assists/src/handlers/remove_unused_param.rs @@ -4,7 +4,7 @@ use syntax::{ ast::{self, ArgListOwner}, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, T, }; -use test_utils::mark; + use SyntaxKind::WHITESPACE; use crate::{ @@ -49,7 +49,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext) -> Opt Definition::Local(local) }; if param_def.usages(&ctx.sema).at_least_one() { - mark::hit!(keep_used); + cov_mark::hit!(keep_used); return None; } acc.add( @@ -243,7 +243,7 @@ fn b2() { foo(9) } #[test] fn keep_used() { - mark::check!(keep_used); + cov_mark::check!(keep_used); check_assist_not_applicable( remove_unused_param, r#" diff --git a/crates/ide_assists/src/handlers/reorder_fields.rs b/crates/ide_assists/src/handlers/reorder_fields.rs index fba7d6ddb..794c89323 100644 --- a/crates/ide_assists/src/handlers/reorder_fields.rs +++ b/crates/ide_assists/src/handlers/reorder_fields.rs @@ -4,7 +4,6 @@ use rustc_hash::FxHashMap; use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; use ide_db::RootDatabase; use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -39,7 +38,7 @@ fn reorder(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { }); if sorted_fields == fields { - mark::hit!(reorder_sorted_fields); + cov_mark::hit!(reorder_sorted_fields); return None; } @@ -109,15 +108,13 @@ fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option Option<()> // Don't edit already sorted methods: if methods == sorted { - mark::hit!(not_applicable_if_sorted); + cov_mark::hit!(not_applicable_if_sorted); return None; } @@ -121,15 +120,13 @@ fn get_methods(items: &ast::AssocItemList) -> Vec { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; #[test] fn not_applicable_if_sorted() { - mark::check!(not_applicable_if_sorted); + cov_mark::check!(not_applicable_if_sorted); check_assist_not_applicable( reorder_impl, r#" diff --git a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs index 27da28bc0..50b05ab0b 100644 --- a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs +++ b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs @@ -3,7 +3,6 @@ use hir::known; use ide_db::helpers::FamousDefs; use stdx::format_to; use syntax::{ast, AstNode}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -34,7 +33,7 @@ pub(crate) fn replace_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistCont let pat = for_loop.pat()?; let body = for_loop.loop_body()?; if body.syntax().text_range().start() < ctx.offset() { - mark::hit!(not_available_in_body); + cov_mark::hit!(not_available_in_body); return None; } @@ -187,7 +186,7 @@ fn main() { #[test] fn not_available_in_body() { - mark::check!(not_available_in_body); + cov_mark::check!(not_available_in_body); check_assist_not_applicable( replace_for_loop_with_for_each, r" diff --git a/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs index 55481af34..36d2e0331 100644 --- a/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs @@ -1,6 +1,5 @@ use ide_db::helpers::insert_use::{insert_use, ImportScope}; use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -27,7 +26,7 @@ pub(crate) fn replace_qualified_name_with_use( return None; } if path.qualifier().is_none() { - mark::hit!(dont_import_trivial_paths); + cov_mark::hit!(dont_import_trivial_paths); return None; } @@ -458,7 +457,7 @@ impl Debug for Foo { #[test] fn dont_import_trivial_paths() { - mark::check!(dont_import_trivial_paths); + cov_mark::check!(dont_import_trivial_paths); check_assist_not_applicable( replace_qualified_name_with_use, r" diff --git a/crates/ide_assists/src/handlers/unmerge_use.rs b/crates/ide_assists/src/handlers/unmerge_use.rs index 3dbef8e51..616af7c2e 100644 --- a/crates/ide_assists/src/handlers/unmerge_use.rs +++ b/crates/ide_assists/src/handlers/unmerge_use.rs @@ -3,7 +3,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, VisibilityOwner}, AstNode, SyntaxKind, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -27,7 +26,7 @@ pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let tree_list = tree.syntax().parent().and_then(ast::UseTreeList::cast)?; if tree_list.use_trees().count() < 2 { - mark::hit!(skip_single_use_item); + cov_mark::hit!(skip_single_use_item); return None; } @@ -89,7 +88,7 @@ mod tests { #[test] fn skip_single_use_item() { - mark::check!(skip_single_use_item); + cov_mark::check!(skip_single_use_item); check_assist_not_applicable( unmerge_use, r" diff --git a/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs b/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs index fec16fc49..e838630ea 100644 --- a/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs +++ b/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs @@ -4,7 +4,6 @@ use syntax::{ ast::{self, make, BlockExpr, Expr, LoopBodyOwner}, match_ast, AstNode, SyntaxNode, }; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -39,7 +38,7 @@ pub(crate) fn wrap_return_type_in_result(acc: &mut Assists, ctx: &AssistContext) let first_part_ret_type = ret_type_str.splitn(2, '<').next(); if let Some(ret_type_first_part) = first_part_ret_type { if ret_type_first_part.ends_with("Result") { - mark::hit!(wrap_return_type_in_result_simple_return_type_already_result); + cov_mark::hit!(wrap_return_type_in_result_simple_return_type_already_result); return None; } } @@ -367,7 +366,7 @@ fn foo() -> std::result::Result { #[test] fn wrap_return_type_in_result_simple_return_type_already_result() { - mark::check!(wrap_return_type_in_result_simple_return_type_already_result); + cov_mark::check!(wrap_return_type_in_result_simple_return_type_already_result); check_assist_not_applicable( wrap_return_type_in_result, r#" diff --git a/crates/ide_completion/Cargo.toml b/crates/ide_completion/Cargo.toml index c09101ccb..84aa40736 100644 --- a/crates/ide_completion/Cargo.toml +++ b/crates/ide_completion/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" itertools = "0.10.0" log = "0.4.8" rustc-hash = "1.1.0" diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs index 084d7721d..5ee9a9f07 100644 --- a/crates/ide_completion/src/completions/dot.rs +++ b/crates/ide_completion/src/completions/dot.rs @@ -2,7 +2,6 @@ use hir::{HasVisibility, Type}; use rustc_hash::FxHashSet; -use test_utils::mark; use crate::{context::CompletionContext, Completions}; @@ -19,7 +18,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { }; if ctx.is_call { - mark::hit!(test_no_struct_field_completion_for_method_call); + cov_mark::hit!(test_no_struct_field_completion_for_method_call); } else { complete_fields(acc, ctx, &receiver_ty); } @@ -62,7 +61,6 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{test_utils::completion_list, CompletionKind}; @@ -122,7 +120,7 @@ impl A { #[test] fn test_no_struct_field_completion_for_method_call() { - mark::check!(test_no_struct_field_completion_for_method_call); + cov_mark::check!(test_no_struct_field_completion_for_method_call); check( r#" struct A { the_field: u32 } diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index da8375af9..f34764b61 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -55,7 +55,6 @@ use ide_db::helpers::{ }; use rustc_hash::FxHashSet; use syntax::{AstNode, SyntaxNode, T}; -use test_utils::mark; use crate::{ context::CompletionContext, @@ -174,7 +173,7 @@ fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option usize { - mark::hit!(certain_fuzzy_order_test); + cov_mark::hit!(certain_fuzzy_order_test); let proposed_import_name = match proposed_mod_path.segments().last() { Some(name) => name.to_string().to_lowercase(), None => return usize::MAX, @@ -200,7 +199,6 @@ fn compute_fuzzy_completion_order_key( #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ item::CompletionKind, @@ -295,7 +293,7 @@ fn main() { #[test] fn short_paths_are_ignored() { - mark::check!(ignore_short_input_for_path); + cov_mark::check!(ignore_short_input_for_path); check( r#" @@ -319,7 +317,7 @@ fn main() { #[test] fn fuzzy_completions_come_in_specific_order() { - mark::check!(certain_fuzzy_order_test); + cov_mark::check!(certain_fuzzy_order_test); check( r#" //- /lib.rs crate:dep diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs index 03c6dd454..80aa9fb06 100644 --- a/crates/ide_completion/src/completions/keyword.rs +++ b/crates/ide_completion/src/completions/keyword.rs @@ -3,7 +3,6 @@ use std::iter; use syntax::SyntaxKind; -use test_utils::mark; use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions}; @@ -47,11 +46,11 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { if ctx.token.kind() == SyntaxKind::COMMENT { - mark::hit!(no_keyword_completion_in_comments); + cov_mark::hit!(no_keyword_completion_in_comments); return; } if ctx.record_lit_syntax.is_some() { - mark::hit!(no_keyword_completion_in_record_lit); + cov_mark::hit!(no_keyword_completion_in_record_lit); return; } @@ -172,7 +171,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet Some(cap) => { let tmp; let snippet = if snippet.ends_with('}') && ctx.incomplete_let { - mark::hit!(let_semi); + cov_mark::hit!(let_semi); tmp = format!("{};", snippet); &tmp } else { @@ -188,7 +187,6 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, completion_list}, @@ -494,7 +492,7 @@ fn quux() -> i32 { #[test] fn no_keyword_completion_in_comments() { - mark::check!(no_keyword_completion_in_comments); + cov_mark::check!(no_keyword_completion_in_comments); check( r#" fn test() { @@ -599,7 +597,7 @@ struct Foo { #[test] fn skip_struct_initializer() { - mark::check!(no_keyword_completion_in_record_lit); + cov_mark::check!(no_keyword_completion_in_record_lit); check( r#" struct Foo { @@ -643,7 +641,7 @@ fn foo() { #[test] fn let_semi() { - mark::check!(let_semi); + cov_mark::check!(let_semi); check_edit( "match", r#" diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 72fb757b1..df74b739e 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs @@ -3,7 +3,6 @@ use hir::{Adt, HasVisibility, PathResolution, ScopeDef}; use rustc_hash::FxHashSet; use syntax::AstNode; -use test_utils::mark; use crate::{CompletionContext, Completions}; @@ -39,7 +38,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon if let Some(name_ref) = ctx.name_ref_syntax.as_ref() { if name_ref.syntax().text() == name.to_string().as_str() { // for `use self::foo$0`, don't suggest `foo` as a completion - mark::hit!(dont_complete_current_use); + cov_mark::hit!(dont_complete_current_use); continue; } } @@ -155,7 +154,6 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, completion_list}, @@ -174,7 +172,7 @@ mod tests { #[test] fn dont_complete_current_use() { - mark::check!(dont_complete_current_use); + cov_mark::check!(dont_complete_current_use); check(r#"use self::foo$0;"#, expect![[""]]); } diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index e9d0ff665..044dfd160 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -2,7 +2,6 @@ use hir::ScopeDef; use syntax::AstNode; -use test_utils::mark; use crate::{CompletionContext, Completions}; @@ -30,13 +29,13 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC ctx.scope.process_all_names(&mut |name, res| { if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { - mark::hit!(skip_lifetime_completion); + cov_mark::hit!(skip_lifetime_completion); return; } if ctx.use_item_syntax.is_some() { if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { if name_ref.syntax().text() == name.to_string().as_str() { - mark::hit!(self_fulfilling_completion); + cov_mark::hit!(self_fulfilling_completion); return; } } @@ -48,7 +47,6 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, completion_list_with_config, TEST_CONFIG}, @@ -66,7 +64,7 @@ mod tests { #[test] fn self_fulfilling_completion() { - mark::check!(self_fulfilling_completion); + cov_mark::check!(self_fulfilling_completion); check( r#" use foo$0 @@ -185,7 +183,7 @@ fn quux() { #[test] fn completes_if_prefix_is_keyword() { - mark::check!(completes_if_prefix_is_keyword); + cov_mark::check!(completes_if_prefix_is_keyword); check_edit( "wherewolf", r#" @@ -223,7 +221,7 @@ fn main() { #[test] fn does_not_complete_lifetimes() { - mark::check!(skip_lifetime_completion); + cov_mark::check!(skip_lifetime_completion); check( r#"fn quux<'a>() { $0 }"#, expect![[r#" diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 3db357855..17d9a3adf 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -7,7 +7,7 @@ use syntax::{ algo::find_node_at_offset, ast, match_ast, AstNode, NodeOrToken, SyntaxKind::*, SyntaxNode, SyntaxToken, TextRange, TextSize, }; -use test_utils::mark; + use text_edit::Indel; use crate::{ @@ -240,7 +240,7 @@ impl<'a> CompletionContext<'a> { // check kind of macro-expanded token, but use range of original token let kind = self.token.kind(); if kind == IDENT || kind == UNDERSCORE || kind.is_keyword() { - mark::hit!(completes_if_prefix_is_keyword); + cov_mark::hit!(completes_if_prefix_is_keyword); self.original_token.text_range() } else { TextRange::empty(self.position.offset) diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index eddaaa6f3..dcfac23c5 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs @@ -15,7 +15,6 @@ use hir::{ }; use ide_db::{helpers::SnippetCap, RootDatabase, SymbolKind}; use syntax::TextRange; -use test_utils::mark; use crate::{ item::ImportEdit, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, @@ -115,11 +114,11 @@ impl<'a> RenderContext<'a> { fn active_name_and_type(&self) -> Option<(String, Type)> { if let Some(record_field) = &self.completion.record_field_syntax { - mark::hit!(record_field_type_match); + cov_mark::hit!(record_field_type_match); let (struct_field, _local) = self.completion.sema.resolve_record_field(record_field)?; Some((struct_field.name(self.db()).to_string(), struct_field.signature_ty(self.db()))) } else if let Some(active_parameter) = &self.completion.active_parameter { - mark::hit!(active_param_type_match); + cov_mark::hit!(active_param_type_match); Some((active_parameter.name.clone(), active_parameter.ty.clone())) } else { None @@ -269,7 +268,7 @@ impl<'a> Render<'a> { _ => false, }; if has_non_default_type_params { - mark::hit!(inserts_angle_brackets_for_generics); + cov_mark::hit!(inserts_angle_brackets_for_generics); item = item .lookup_by(local_name.clone()) .label(format!("{}<…>", local_name)) @@ -358,7 +357,6 @@ mod tests { use std::cmp::Reverse; use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, do_completion, get_all_items, TEST_CONFIG}, @@ -734,7 +732,7 @@ fn foo(s: S) { s.$0 } #[test] fn no_call_parens_if_fn_ptr_needed() { - mark::check!(no_call_parens_if_fn_ptr_needed); + cov_mark::check!(no_call_parens_if_fn_ptr_needed); check_edit( "foo", r#" @@ -758,7 +756,7 @@ fn main() -> ManualVtable { #[test] fn no_parens_in_use_item() { - mark::check!(no_parens_in_use_item); + cov_mark::check!(no_parens_in_use_item); check_edit( "foo", r#" @@ -802,7 +800,7 @@ fn f(foo: &Foo) { foo.foo(); } #[test] fn inserts_angle_brackets_for_generics() { - mark::check!(inserts_angle_brackets_for_generics); + cov_mark::check!(inserts_angle_brackets_for_generics); check_edit( "Vec", r#" @@ -851,7 +849,7 @@ fn foo(xs: Vec) #[test] fn active_param_score() { - mark::check!(active_param_type_match); + cov_mark::check!(active_param_type_match); check_scores( r#" struct S { foo: i64, bar: u32, baz: u32 } @@ -868,7 +866,7 @@ fn foo(s: S) { test(s.$0) } #[test] fn record_field_scores() { - mark::check!(record_field_type_match); + cov_mark::check!(record_field_type_match); check_scores( r#" struct A { foo: i64, bar: u32, baz: u32 } diff --git a/crates/ide_completion/src/render/builder_ext.rs b/crates/ide_completion/src/render/builder_ext.rs index d053a988b..95a7596c1 100644 --- a/crates/ide_completion/src/render/builder_ext.rs +++ b/crates/ide_completion/src/render/builder_ext.rs @@ -1,7 +1,6 @@ //! Extensions for `Builder` structure required for item rendering. use itertools::Itertools; -use test_utils::mark; use crate::{item::Builder, CompletionContext}; @@ -30,7 +29,7 @@ impl Builder { return false; } if ctx.use_item_syntax.is_some() { - mark::hit!(no_parens_in_use_item); + cov_mark::hit!(no_parens_in_use_item); return false; } if ctx.is_pattern_call { @@ -43,7 +42,7 @@ impl Builder { // Don't add parentheses if the expected type is some function reference. if let Some(ty) = &ctx.expected_type { if ty.is_fn() { - mark::hit!(no_call_parens_if_fn_ptr_needed); + cov_mark::hit!(no_call_parens_if_fn_ptr_needed); return false; } } @@ -67,7 +66,7 @@ impl Builder { None => return self, }; // If not an import, add parenthesis automatically. - mark::hit!(inserts_parens_for_function_calls); + cov_mark::hit!(inserts_parens_for_function_calls); let (snippet, label) = if params.is_empty() { (format!("{}()$0", name), format!("{}()", name)) @@ -82,7 +81,7 @@ impl Builder { format!("{}({})$0", name, function_params_snippet) } _ => { - mark::hit!(suppress_arg_snippets); + cov_mark::hit!(suppress_arg_snippets); format!("{}($0)", name) } }; diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs index 9214193b4..ed055c1fb 100644 --- a/crates/ide_completion/src/render/enum_variant.rs +++ b/crates/ide_completion/src/render/enum_variant.rs @@ -3,7 +3,6 @@ use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; use ide_db::SymbolKind; use itertools::Itertools; -use test_utils::mark; use crate::{ item::{CompletionItem, CompletionKind, ImportEdit}, @@ -68,7 +67,7 @@ impl<'a> EnumRender<'a> { .detail(self.detail()); if self.variant_kind == StructKind::Tuple { - mark::hit!(inserts_parens_for_tuple_enums); + cov_mark::hit!(inserts_parens_for_tuple_enums); let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len()); builder = builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params); @@ -103,13 +102,11 @@ impl<'a> EnumRender<'a> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::test_utils::check_edit; #[test] fn inserts_parens_for_tuple_enums() { - mark::check!(inserts_parens_for_tuple_enums); + cov_mark::check!(inserts_parens_for_tuple_enums); check_edit( "Some", r#" diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index e46e21d24..5931945a8 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs @@ -3,7 +3,6 @@ use hir::{HasSource, HirDisplay, Type}; use ide_db::SymbolKind; use syntax::ast::Fn; -use test_utils::mark; use crate::{ item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, @@ -82,7 +81,7 @@ impl<'a> FunctionRender<'a> { self.func.method_params(self.ctx.db()).unwrap_or_default() } else { if let Some(s) = ast_params.self_param() { - mark::hit!(parens_for_method_call_as_assoc_fn); + cov_mark::hit!(parens_for_method_call_as_assoc_fn); params_pats.push(Some(s.to_string())); } self.func.assoc_fn_params(self.ctx.db()) @@ -114,8 +113,6 @@ impl<'a> FunctionRender<'a> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::{ test_utils::{check_edit, check_edit_with_config, TEST_CONFIG}, CompletionConfig, @@ -123,7 +120,7 @@ mod tests { #[test] fn inserts_parens_for_function_calls() { - mark::check!(inserts_parens_for_function_calls); + cov_mark::check!(inserts_parens_for_function_calls); check_edit( "no_args", r#" @@ -191,7 +188,7 @@ fn bar(s: &S) { #[test] fn parens_for_method_call_as_assoc_fn() { - mark::check!(parens_for_method_call_as_assoc_fn); + cov_mark::check!(parens_for_method_call_as_assoc_fn); check_edit( "foo", r#" @@ -213,7 +210,7 @@ fn main() { S::foo(${1:&self})$0 } #[test] fn suppress_arg_snippets() { - mark::check!(suppress_arg_snippets); + cov_mark::check!(suppress_arg_snippets); check_edit_with_config( CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG }, "with_args", diff --git a/crates/ide_completion/src/render/macro_.rs b/crates/ide_completion/src/render/macro_.rs index a4535786f..a6cf3e479 100644 --- a/crates/ide_completion/src/render/macro_.rs +++ b/crates/ide_completion/src/render/macro_.rs @@ -3,7 +3,6 @@ use hir::{Documentation, HasSource}; use ide_db::SymbolKind; use syntax::display::macro_label; -use test_utils::mark; use crate::{ item::{CompletionItem, CompletionKind, ImportEdit}, @@ -57,7 +56,7 @@ impl<'a> MacroRender<'a> { } None if needs_bang => builder.insert_text(self.banged_name()), _ => { - mark::hit!(dont_insert_macro_call_parens_unncessary); + cov_mark::hit!(dont_insert_macro_call_parens_unncessary); builder.insert_text(&self.name) } }; @@ -125,13 +124,11 @@ fn guess_macro_braces(macro_name: &str, docs: &str) -> (&'static str, &'static s #[cfg(test)] mod tests { - use test_utils::mark; - use crate::test_utils::check_edit; #[test] fn dont_insert_macro_call_parens_unncessary() { - mark::check!(dont_insert_macro_call_parens_unncessary); + cov_mark::check!(dont_insert_macro_call_parens_unncessary); check_edit( "frobnicate!", r#" diff --git a/crates/ide_db/Cargo.toml b/crates/ide_db/Cargo.toml index d4612a75e..1f855c621 100644 --- a/crates/ide_db/Cargo.toml +++ b/crates/ide_db/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" log = "0.4.8" rayon = "1.5.0" fst = { version = "0.4", default-features = false } diff --git a/crates/ide_db/src/call_info.rs b/crates/ide_db/src/call_info.rs index 615fa7b0e..d8878aa91 100644 --- a/crates/ide_db/src/call_info.rs +++ b/crates/ide_db/src/call_info.rs @@ -7,7 +7,6 @@ use syntax::{ ast::{self, ArgListOwner}, match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize, }; -use test_utils::mark; use crate::RootDatabase; @@ -122,7 +121,7 @@ fn call_info_impl( let arg_list_range = arg_list.syntax().text_range(); if !arg_list_range.contains_inclusive(token.text_range().start()) { - mark::hit!(call_info_bad_offset); + cov_mark::hit!(call_info_bad_offset); return None; } let param = std::cmp::min( @@ -162,7 +161,7 @@ impl ActiveParameter { let idx = active_parameter?; let mut params = signature.params(sema.db); if !(idx < params.len()) { - mark::hit!(too_many_arguments); + cov_mark::hit!(too_many_arguments); return None; } let (pat, ty) = params.swap_remove(idx); diff --git a/crates/ide_db/src/call_info/tests.rs b/crates/ide_db/src/call_info/tests.rs index c714cf280..9f84c253c 100644 --- a/crates/ide_db/src/call_info/tests.rs +++ b/crates/ide_db/src/call_info/tests.rs @@ -1,7 +1,7 @@ use crate::RootDatabase; use base_db::{fixture::ChangeFixture, FilePosition}; use expect_test::{expect, Expect}; -use test_utils::{mark, RangeOrOffset}; +use test_utils::RangeOrOffset; /// Creates analysis from a multi-file fixture, returns positions marked with $0. pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { @@ -347,7 +347,7 @@ pub fn foo(mut r: WriteHandler<()>) { #[test] fn call_info_bad_offset() { - mark::check!(call_info_bad_offset); + cov_mark::check!(call_info_bad_offset); check( r#" fn foo(x: u32, y: u32) -> u32 {x + y} diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index f52aee344..df66d8ea0 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs @@ -13,7 +13,6 @@ use syntax::{ }, AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken, }; -use test_utils::mark; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct InsertUseConfig { @@ -138,7 +137,7 @@ pub fn insert_use<'a>( if add_blank.has_before() { if let Some(indent) = indent.clone() { - mark::hit!(insert_use_indent_before); + cov_mark::hit!(insert_use_indent_before); buf.push(indent); } } @@ -156,11 +155,11 @@ pub fn insert_use<'a>( // only add indentation *after* our stuff if there's another node directly after it if add_blank.has_after() && matches!(insert_position, InsertPosition::Before(_)) { if let Some(indent) = indent { - mark::hit!(insert_use_indent_after); + cov_mark::hit!(insert_use_indent_after); buf.push(indent); } } else if add_blank.has_after() && matches!(insert_position, InsertPosition::After(_)) { - mark::hit!(insert_use_no_indent_after); + cov_mark::hit!(insert_use_no_indent_after); } buf diff --git a/crates/ide_db/src/helpers/insert_use/tests.rs b/crates/ide_db/src/helpers/insert_use/tests.rs index 67d0d6fb6..3d151e629 100644 --- a/crates/ide_db/src/helpers/insert_use/tests.rs +++ b/crates/ide_db/src/helpers/insert_use/tests.rs @@ -51,7 +51,7 @@ use std::bar::G;", #[test] fn insert_start_indent() { - mark::check!(insert_use_indent_after); + cov_mark::check!(insert_use_indent_after); check_none( "std::bar::AA", r" @@ -120,7 +120,7 @@ use std::bar::ZZ;", #[test] fn insert_end_indent() { - mark::check!(insert_use_indent_before); + cov_mark::check!(insert_use_indent_before); check_none( "std::bar::ZZ", r" @@ -255,7 +255,7 @@ fn insert_empty_file() { #[test] fn insert_empty_module() { - mark::check!(insert_use_no_indent_after); + cov_mark::check!(insert_use_no_indent_after); check( "foo::bar", "mod x {}", diff --git a/crates/ide_ssr/Cargo.toml b/crates/ide_ssr/Cargo.toml index edbc1846b..315691f40 100644 --- a/crates/ide_ssr/Cargo.toml +++ b/crates/ide_ssr/Cargo.toml @@ -11,6 +11,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" rustc-hash = "1.1.0" itertools = "0.10.0" diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs index df013bae9..e1adb381e 100644 --- a/crates/ide_ssr/src/matching.rs +++ b/crates/ide_ssr/src/matching.rs @@ -15,7 +15,6 @@ use syntax::{ ast::{AstNode, AstToken}, SmolStr, }; -use test_utils::mark; // Creates a match error. If we're currently attempting to match some code that we thought we were // going to match, as indicated by the --debug-snippet flag, then populate the reason field. @@ -731,7 +730,7 @@ impl NodeKind { fn matches(&self, node: &SyntaxNode) -> Result<(), MatchFailed> { let ok = match self { Self::Literal => { - mark::hit!(literal_constraint); + cov_mark::hit!(literal_constraint); ast::Literal::can_cast(node.kind()) } }; diff --git a/crates/ide_ssr/src/parsing.rs b/crates/ide_ssr/src/parsing.rs index 3d5e4feb7..5ff25cb6d 100644 --- a/crates/ide_ssr/src/parsing.rs +++ b/crates/ide_ssr/src/parsing.rs @@ -10,7 +10,6 @@ use crate::{SsrError, SsrPattern, SsrRule}; use rustc_hash::{FxHashMap, FxHashSet}; use std::{fmt::Display, str::FromStr}; use syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; -use test_utils::mark; #[derive(Debug)] pub(crate) struct ParsedRule { @@ -131,7 +130,7 @@ impl RuleBuilder { let old_len = self.rules.len(); self.rules.retain(|rule| contains_path(&rule.pattern)); if self.rules.len() < old_len { - mark::hit!(pattern_is_a_single_segment_path); + cov_mark::hit!(pattern_is_a_single_segment_path); } } Ok(self.rules) diff --git a/crates/ide_ssr/src/replacing.rs b/crates/ide_ssr/src/replacing.rs index 06a94a46c..c9ccc1961 100644 --- a/crates/ide_ssr/src/replacing.rs +++ b/crates/ide_ssr/src/replacing.rs @@ -5,7 +5,7 @@ use itertools::Itertools; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::ast::{self, AstNode, AstToken}; use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; -use test_utils::mark; + use text_edit::TextEdit; /// Returns a text edit that will replace each match in `matches` with its corresponding replacement @@ -128,7 +128,7 @@ impl ReplacementRenderer<'_> { && (placeholder_value.autoderef_count > 0 || placeholder_value.autoref_kind != ast::SelfParamKind::Owned) { - mark::hit!(replace_autoref_autoderef_capture); + cov_mark::hit!(replace_autoref_autoderef_capture); let ref_kind = match placeholder_value.autoref_kind { ast::SelfParamKind::Owned => "", ast::SelfParamKind::Ref => "&", diff --git a/crates/ide_ssr/src/resolving.rs b/crates/ide_ssr/src/resolving.rs index 14e5a3b69..af94c7bb1 100644 --- a/crates/ide_ssr/src/resolving.rs +++ b/crates/ide_ssr/src/resolving.rs @@ -6,7 +6,6 @@ use ide_db::base_db::FilePosition; use parsing::Placeholder; use rustc_hash::FxHashMap; use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; -use test_utils::mark; pub(crate) struct ResolutionScope<'db> { scope: hir::SemanticsScope<'db>, @@ -170,13 +169,13 @@ impl Resolver<'_, '_> { // calls. e.g. `Foo::bar($s)` should match `x.bar()`. true } else { - mark::hit!(replace_associated_trait_default_function_call); + cov_mark::hit!(replace_associated_trait_default_function_call); false } } hir::PathResolution::AssocItem(_) => { // Not a function. Could be a constant or an associated type. - mark::hit!(replace_associated_trait_constant); + cov_mark::hit!(replace_associated_trait_constant); false } _ => true, @@ -267,7 +266,7 @@ fn pick_node_for_resolution(node: SyntaxNode) -> SyntaxNode { match node.kind() { SyntaxKind::EXPR_STMT => { if let Some(n) = node.first_child() { - mark::hit!(cursor_after_semicolon); + cov_mark::hit!(cursor_after_semicolon); return n; } } @@ -291,7 +290,7 @@ fn path_contains_type_arguments(path: Option) -> bool { if let Some(path) = path { if let Some(segment) = path.segment() { if segment.generic_arg_list().is_some() { - mark::hit!(type_arguments_within_path); + cov_mark::hit!(type_arguments_within_path); return true; } } diff --git a/crates/ide_ssr/src/search.rs b/crates/ide_ssr/src/search.rs index 836eb94b2..28cef742c 100644 --- a/crates/ide_ssr/src/search.rs +++ b/crates/ide_ssr/src/search.rs @@ -12,7 +12,6 @@ use ide_db::{ }; use rustc_hash::FxHashSet; use syntax::{ast, AstNode, SyntaxKind, SyntaxNode}; -use test_utils::mark; /// A cache for the results of find_usages. This is for when we have multiple patterns that have the /// same path. e.g. if the pattern was `foo::Bar` that can parse as a path, an expression, a type @@ -61,7 +60,7 @@ impl<'db> MatchFinder<'db> { for file_range in self.find_usages(usage_cache, definition).file_ranges() { if let Some(node_to_match) = self.find_node_to_match(resolved_path, file_range) { if !is_search_permitted_ancestors(&node_to_match) { - mark::hit!(use_declaration_with_braces); + cov_mark::hit!(use_declaration_with_braces); continue; } self.try_add_match(rule, &node_to_match, &None, matches_out); @@ -205,7 +204,7 @@ impl<'db> MatchFinder<'db> { matches_out: &mut Vec, ) { if !self.within_range_restrictions(code) { - mark::hit!(replace_nonpath_within_selection); + cov_mark::hit!(replace_nonpath_within_selection); return; } if let Ok(m) = matching::get_match(false, rule, code, restrict_range, &self.sema) { diff --git a/crates/ide_ssr/src/tests.rs b/crates/ide_ssr/src/tests.rs index a3ea44f23..1d8565dc0 100644 --- a/crates/ide_ssr/src/tests.rs +++ b/crates/ide_ssr/src/tests.rs @@ -3,7 +3,7 @@ use expect_test::{expect, Expect}; use ide_db::base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; use rustc_hash::FxHashSet; use std::sync::Arc; -use test_utils::{mark, RangeOrOffset}; +use test_utils::RangeOrOffset; fn parse_error_text(query: &str) -> String { format!("{}", query.parse::().unwrap_err()) @@ -492,7 +492,7 @@ fn match_resolved_type_name() { #[test] fn type_arguments_within_path() { - mark::check!(type_arguments_within_path); + cov_mark::check!(type_arguments_within_path); let code = r#" mod foo { pub struct Bar {t: T} @@ -508,7 +508,7 @@ fn type_arguments_within_path() { #[test] fn literal_constraint() { - mark::check!(literal_constraint); + cov_mark::check!(literal_constraint); let code = r#" enum Option { Some(T), None } use Option::Some; @@ -641,7 +641,7 @@ fn replace_associated_function_call() { #[test] fn replace_associated_trait_default_function_call() { - mark::check!(replace_associated_trait_default_function_call); + cov_mark::check!(replace_associated_trait_default_function_call); assert_ssr_transform( "Bar2::foo() ==>> Bar2::foo2()", r#" @@ -673,7 +673,7 @@ fn replace_associated_trait_default_function_call() { #[test] fn replace_associated_trait_constant() { - mark::check!(replace_associated_trait_constant); + cov_mark::check!(replace_associated_trait_constant); assert_ssr_transform( "Bar2::VALUE ==>> Bar2::VALUE_2222", r#" @@ -998,7 +998,7 @@ fn use_declaration_with_braces() { // It would be OK for a path rule to match and alter a use declaration. We shouldn't mess it up // though. In particular, we must not change `use foo::{baz, bar}` to `use foo::{baz, // foo2::bar2}`. - mark::check!(use_declaration_with_braces); + cov_mark::check!(use_declaration_with_braces); assert_ssr_transform( "foo::bar ==>> foo2::bar2", r#" @@ -1076,7 +1076,7 @@ fn ufcs_matches_method_call() { #[test] fn pattern_is_a_single_segment_path() { - mark::check!(pattern_is_a_single_segment_path); + cov_mark::check!(pattern_is_a_single_segment_path); // The first function should not be altered because the `foo` in scope at the cursor position is // a different `foo`. This case is special because "foo" can be parsed as a pattern (IDENT_PAT -> // NAME -> IDENT), which contains no path. If we're not careful we'll end up matching the `foo` @@ -1118,7 +1118,7 @@ fn replace_local_variable_reference() { // The pattern references a local variable `foo` in the block containing the cursor. We should // only replace references to this variable `foo`, not other variables that just happen to have // the same name. - mark::check!(cursor_after_semicolon); + cov_mark::check!(cursor_after_semicolon); assert_ssr_transform( "foo + $a ==>> $a - foo", r#" @@ -1179,7 +1179,7 @@ fn replace_path_within_selection() { #[test] fn replace_nonpath_within_selection() { - mark::check!(replace_nonpath_within_selection); + cov_mark::check!(replace_nonpath_within_selection); assert_ssr_transform( "$a + $b ==>> $b * $a", r#" @@ -1269,7 +1269,7 @@ fn replace_autoref_autoderef_capture() { // second, we already have a reference, so it isn't. When $a is used in a context where autoref // doesn't apply, we need to prefix it with `&`. Finally, we have some cases where autoderef // needs to be applied. - mark::check!(replace_autoref_autoderef_capture); + cov_mark::check!(replace_autoref_autoderef_capture); let code = r#" struct Foo {} impl Foo { diff --git a/crates/mbe/Cargo.toml b/crates/mbe/Cargo.toml index bb2656a80..c7d5e39fa 100644 --- a/crates/mbe/Cargo.toml +++ b/crates/mbe/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" rustc-hash = "1.1.0" smallvec = "1.2.0" log = "0.4.8" diff --git a/crates/mbe/src/lib.rs b/crates/mbe/src/lib.rs index f3d2da55a..33b85e23d 100644 --- a/crates/mbe/src/lib.rs +++ b/crates/mbe/src/lib.rs @@ -17,7 +17,6 @@ mod benchmark; use std::fmt; -use test_utils::mark; pub use tt::{Delimiter, DelimiterKind, Punct}; use crate::{ @@ -217,7 +216,7 @@ impl MacroDef { let mut rules = Vec::new(); if Some(tt::DelimiterKind::Brace) == tt.delimiter_kind() { - mark::hit!(parse_macro_def_rules); + cov_mark::hit!(parse_macro_def_rules); while src.len() > 0 { let rule = Rule::parse(&mut src, true)?; rules.push(rule); @@ -229,7 +228,7 @@ impl MacroDef { } } } else { - mark::hit!(parse_macro_def_simple); + cov_mark::hit!(parse_macro_def_simple); let rule = Rule::parse(&mut src, false)?; if src.len() != 0 { return Err(ParseError::Expected("remain tokens in macro def".to_string())); diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 08acd4ac2..3a168bb4b 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs @@ -6,7 +6,7 @@ use syntax::{ SyntaxKind::{ERROR, IDENT}, SyntaxNode, WalkEvent, T, }; -use test_utils::{assert_eq_text, mark}; +use test_utils::assert_eq_text; use super::*; @@ -687,7 +687,7 @@ fn test_match_literal() { #[test] fn test_parse_macro_def_simple() { - mark::check!(parse_macro_def_simple); + cov_mark::check!(parse_macro_def_simple); parse_macro2( r#" @@ -701,7 +701,7 @@ macro foo($id:ident) { #[test] fn test_parse_macro_def_rules() { - mark::check!(parse_macro_def_rules); + cov_mark::check!(parse_macro_def_rules); parse_macro2( r#" diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs b/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs index e4006a5ab..e67902682 100644 --- a/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs +++ b/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs @@ -268,7 +268,7 @@ trait Mark { fn mark(unmarked: Self::Unmarked) -> Self; } -/// Unwrap types wrapped by `Mark::mark` (see `Mark` for details). +/// Unwrap types wrapped by `cov_mark::mark` (see `Mark` for details). trait Unmark { type Unmarked; fn unmark(self) -> Self::Unmarked; diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 9ee3a8586..c39095def 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -11,6 +11,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" itertools = "0.10.0" rowan = "0.12.2" rustc_lexer = { version = "709.0.0", package = "rustc-ap-rustc_lexer" } diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 2ff92f9f6..b13252eec 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs @@ -10,7 +10,6 @@ use std::{ use indexmap::IndexMap; use itertools::Itertools; use rustc_hash::FxHashMap; -use test_utils::mark; use text_edit::TextEditBuilder; use crate::{ @@ -184,7 +183,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { let (lhs, rhs) = match lhs.as_node().zip(rhs.as_node()) { Some((lhs, rhs)) => (lhs, rhs), _ => { - mark::hit!(diff_node_token_replace); + cov_mark::hit!(diff_node_token_replace); diff.replacements.insert(lhs, rhs); return; } @@ -202,19 +201,19 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { (None, Some(element)) => { let insert_pos = match last_lhs.clone() { Some(prev) => { - mark::hit!(diff_insert); + cov_mark::hit!(diff_insert); TreeDiffInsertPos::After(prev) } // first iteration, insert into out parent as the first child None => { - mark::hit!(diff_insert_as_first_child); + cov_mark::hit!(diff_insert_as_first_child); TreeDiffInsertPos::AsFirstChild(lhs.clone().into()) } }; diff.insertions.entry(insert_pos).or_insert_with(Vec::new).push(element); } (Some(element), None) => { - mark::hit!(diff_delete); + cov_mark::hit!(diff_delete); diff.deletions.push(element); } (Some(ref lhs_ele), Some(ref rhs_ele)) if syntax_element_eq(lhs_ele, rhs_ele) => {} @@ -228,7 +227,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { let mut insert = false; while let Some(rhs_child) = rhs_children_clone.next() { if syntax_element_eq(&lhs_ele, &rhs_child) { - mark::hit!(diff_insertions); + cov_mark::hit!(diff_insertions); insert = true; break; } else { @@ -240,7 +239,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { let insert_pos = if let Some(prev) = last_lhs.clone().filter(|_| insert) { TreeDiffInsertPos::After(prev) } else { - mark::hit!(insert_first_child); + cov_mark::hit!(insert_first_child); TreeDiffInsertPos::AsFirstChild(lhs.clone().into()) }; @@ -635,14 +634,13 @@ mod tests { use expect_test::{expect, Expect}; use itertools::Itertools; use parser::SyntaxKind; - use test_utils::mark; use text_edit::TextEdit; use crate::{AstNode, SyntaxElement}; #[test] fn replace_node_token() { - mark::check!(diff_node_token_replace); + cov_mark::check!(diff_node_token_replace); check_diff( r#"use node;"#, r#"ident"#, @@ -666,7 +664,7 @@ mod tests { #[test] fn replace_parent() { - mark::check!(diff_insert_as_first_child); + cov_mark::check!(diff_insert_as_first_child); check_diff( r#""#, r#"use foo::bar;"#, @@ -689,7 +687,7 @@ mod tests { #[test] fn insert_last() { - mark::check!(diff_insert); + cov_mark::check!(diff_insert); check_diff( r#" use foo; @@ -774,7 +772,7 @@ use baz;"#, #[test] fn first_child_insertion() { - mark::check!(insert_first_child); + cov_mark::check!(insert_first_child); check_diff( r#"fn main() { stdi @@ -804,7 +802,7 @@ use baz;"#, #[test] fn delete_last() { - mark::check!(diff_delete); + cov_mark::check!(diff_delete); check_diff( r#"use foo; use bar;"#, @@ -828,7 +826,7 @@ use baz;"#, #[test] fn delete_middle() { - mark::check!(diff_insertions); + cov_mark::check!(diff_insertions); check_diff( r#" use expect_test::{expect, Expect}; diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 6041ab5e4..c5f859790 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -6,8 +6,6 @@ //! * Extracting markup (mainly, `$0` markers) out of fixture strings. //! * marks (see the eponymous module). -#[macro_use] -pub mod mark; pub mod bench_fixture; mod fixture; diff --git a/crates/test_utils/src/mark.rs b/crates/test_utils/src/mark.rs deleted file mode 100644 index 97f5a93ad..000000000 --- a/crates/test_utils/src/mark.rs +++ /dev/null @@ -1,78 +0,0 @@ -//! This module implements manually tracked test coverage, which is useful for -//! quickly finding a test responsible for testing a particular bit of code. -//! -//! See -//! for details, but the TL;DR is that you write your test as -//! -//! ``` -//! #[test] -//! fn test_foo() { -//! mark::check!(test_foo); -//! } -//! ``` -//! -//! and in the code under test you write -//! -//! ``` -//! # use test_utils::mark; -//! # fn some_condition() -> bool { true } -//! fn foo() { -//! if some_condition() { -//! mark::hit!(test_foo); -//! } -//! } -//! ``` -//! -//! This module then checks that executing the test indeed covers the specified -//! function. This is useful if you come back to the `foo` function ten years -//! later and wonder where the test are: now you can grep for `test_foo`. -use std::sync::atomic::{AtomicUsize, Ordering}; - -#[macro_export] -macro_rules! _hit { - ($ident:ident) => {{ - #[cfg(test)] - { - extern "C" { - #[no_mangle] - static $ident: std::sync::atomic::AtomicUsize; - } - unsafe { - $ident.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - } - } - }}; -} -pub use _hit as hit; - -#[macro_export] -macro_rules! _check { - ($ident:ident) => { - #[no_mangle] - static $ident: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); - let _checker = $crate::mark::MarkChecker::new(&$ident); - }; -} -pub use _check as check; - -pub struct MarkChecker { - mark: &'static AtomicUsize, - value_on_entry: usize, -} - -impl MarkChecker { - pub fn new(mark: &'static AtomicUsize) -> MarkChecker { - let value_on_entry = mark.load(Ordering::Relaxed); - MarkChecker { mark, value_on_entry } - } -} - -impl Drop for MarkChecker { - fn drop(&mut self) { - if std::thread::panicking() { - return; - } - let value_on_exit = self.mark.load(Ordering::Relaxed); - assert!(value_on_exit > self.value_on_entry, "mark was not hit") - } -} -- cgit v1.2.3