aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2021-03-08 20:19:44 +0000
committerLaurenČ›iu Nicola <[email protected]>2021-03-08 20:19:44 +0000
commitfc9eed4836dfc88fe2893c81b015ab440cea2ba6 (patch)
tree3905029a42c8bb6c5d363753b34cd6b5dd43f4d5 /crates
parentc5189a22ccf4c28e309e4189defbb88b83bb2aea (diff)
Use upstream cov-mark
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/Cargo.toml1
-rw-r--r--crates/hir_def/src/attr.rs3
-rw-r--r--crates/hir_def/src/body.rs3
-rw-r--r--crates/hir_def/src/body/lower.rs3
-rw-r--r--crates/hir_def/src/body/scope.rs4
-rw-r--r--crates/hir_def/src/body/tests.rs3
-rw-r--r--crates/hir_def/src/body/tests/block.rs10
-rw-r--r--crates/hir_def/src/find_path.rs22
-rw-r--r--crates/hir_def/src/import_map.rs6
-rw-r--r--crates/hir_def/src/item_scope.rs3
-rw-r--r--crates/hir_def/src/item_tree.rs1
-rw-r--r--crates/hir_def/src/item_tree/lower.rs2
-rw-r--r--crates/hir_def/src/nameres/collector.rs17
-rw-r--r--crates/hir_def/src/nameres/mod_resolution.rs3
-rw-r--r--crates/hir_def/src/nameres/path_resolution.rs11
-rw-r--r--crates/hir_def/src/nameres/tests.rs9
-rw-r--r--crates/hir_def/src/nameres/tests/diagnostics.rs5
-rw-r--r--crates/hir_def/src/nameres/tests/globs.rs8
-rw-r--r--crates/hir_def/src/nameres/tests/macros.rs10
-rw-r--r--crates/hir_def/src/nameres/tests/mod_resolution.rs4
-rw-r--r--crates/hir_def/src/path/lower/lower_use.rs3
-rw-r--r--crates/hir_ty/Cargo.toml1
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs11
-rw-r--r--crates/hir_ty/src/infer/coerce.rs5
-rw-r--r--crates/hir_ty/src/infer/expr.rs3
-rw-r--r--crates/hir_ty/src/infer/pat.rs3
-rw-r--r--crates/hir_ty/src/infer/unify.rs8
-rw-r--r--crates/hir_ty/src/lower.rs5
-rw-r--r--crates/hir_ty/src/method_resolution.rs2
-rw-r--r--crates/hir_ty/src/tests/coercion.rs5
-rw-r--r--crates/hir_ty/src/tests/method_resolution.rs2
-rw-r--r--crates/hir_ty/src/tests/patterns.rs3
-rw-r--r--crates/hir_ty/src/tests/regression.rs7
-rw-r--r--crates/hir_ty/src/tests/simple.rs3
-rw-r--r--crates/hir_ty/src/tests/traits.rs5
-rw-r--r--crates/ide/Cargo.toml1
-rw-r--r--crates/ide/src/hover.rs9
-rw-r--r--crates/ide/src/join_lines.rs8
-rw-r--r--crates/ide/src/matching_brace.rs5
-rw-r--r--crates/ide/src/parent_module.rs6
-rw-r--r--crates/ide/src/references/rename.rs58
-rw-r--r--crates/ide/src/runnables.rs8
-rw-r--r--crates/ide/src/typing/on_enter.rs8
-rw-r--r--crates/ide_assists/Cargo.toml1
-rw-r--r--crates/ide_assists/src/handlers/add_turbo_fish.rs22
-rw-r--r--crates/ide_assists/src/handlers/apply_demorgan.rs10
-rw-r--r--crates/ide_assists/src/handlers/change_visibility.rs7
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs21
-rw-r--r--crates/ide_assists/src/handlers/extract_variable.rs15
-rw-r--r--crates/ide_assists/src/handlers/fill_match_arms.rs6
-rw-r--r--crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs11
-rw-r--r--crates/ide_assists/src/handlers/generate_default_from_new.rs17
-rw-r--r--crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs7
-rw-r--r--crates/ide_assists/src/handlers/infer_function_return_type.rs37
-rw-r--r--crates/ide_assists/src/handlers/inline_function.rs5
-rw-r--r--crates/ide_assists/src/handlers/inline_local_variable.rs19
-rw-r--r--crates/ide_assists/src/handlers/move_module_to_file.rs5
-rw-r--r--crates/ide_assists/src/handlers/pull_assignment_up.rs13
-rw-r--r--crates/ide_assists/src/handlers/qualify_path.rs17
-rw-r--r--crates/ide_assists/src/handlers/raw_string.rs7
-rw-r--r--crates/ide_assists/src/handlers/remove_unused_param.rs6
-rw-r--r--crates/ide_assists/src/handlers/reorder_fields.rs7
-rw-r--r--crates/ide_assists/src/handlers/reorder_impl.rs7
-rw-r--r--crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs5
-rw-r--r--crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs5
-rw-r--r--crates/ide_assists/src/handlers/unmerge_use.rs5
-rw-r--r--crates/ide_assists/src/handlers/wrap_return_type_in_result.rs5
-rw-r--r--crates/ide_completion/Cargo.toml1
-rw-r--r--crates/ide_completion/src/completions/dot.rs6
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs10
-rw-r--r--crates/ide_completion/src/completions/keyword.rs14
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs6
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs12
-rw-r--r--crates/ide_completion/src/context.rs4
-rw-r--r--crates/ide_completion/src/render.rs18
-rw-r--r--crates/ide_completion/src/render/builder_ext.rs9
-rw-r--r--crates/ide_completion/src/render/enum_variant.rs7
-rw-r--r--crates/ide_completion/src/render/function.rs11
-rw-r--r--crates/ide_completion/src/render/macro_.rs7
-rw-r--r--crates/ide_db/Cargo.toml1
-rw-r--r--crates/ide_db/src/call_info.rs5
-rw-r--r--crates/ide_db/src/call_info/tests.rs4
-rw-r--r--crates/ide_db/src/helpers/insert_use.rs7
-rw-r--r--crates/ide_db/src/helpers/insert_use/tests.rs6
-rw-r--r--crates/ide_ssr/Cargo.toml1
-rw-r--r--crates/ide_ssr/src/matching.rs3
-rw-r--r--crates/ide_ssr/src/parsing.rs3
-rw-r--r--crates/ide_ssr/src/replacing.rs4
-rw-r--r--crates/ide_ssr/src/resolving.rs9
-rw-r--r--crates/ide_ssr/src/search.rs5
-rw-r--r--crates/ide_ssr/src/tests.rs20
-rw-r--r--crates/mbe/Cargo.toml1
-rw-r--r--crates/mbe/src/lib.rs5
-rw-r--r--crates/mbe/src/tests.rs6
-rw-r--r--crates/proc_macro_srv/src/proc_macro/bridge/mod.rs2
-rw-r--r--crates/syntax/Cargo.toml1
-rw-r--r--crates/syntax/src/algo.rs26
-rw-r--r--crates/test_utils/src/lib.rs2
-rw-r--r--crates/test_utils/src/mark.rs78
99 files changed, 338 insertions, 513 deletions
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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13log = "0.4.8" 14log = "0.4.8"
14once_cell = "1.3.1" 15once_cell = "1.3.1"
15rustc-hash = "1.1.0" 16rustc-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::{
13 ast::{self, AstNode, AttrsOwner}, 13 ast::{self, AstNode, AttrsOwner},
14 match_ast, AstToken, SmolStr, SyntaxNode, 14 match_ast, AstToken, SmolStr, SyntaxNode,
15}; 15};
16use test_utils::mark;
17use tt::Subtree; 16use tt::Subtree;
18 17
19use crate::{ 18use crate::{
@@ -177,7 +176,7 @@ impl RawAttrs {
177 if cfg_options.check(&cfg) == Some(false) { 176 if cfg_options.check(&cfg) == Some(false) {
178 None 177 None
179 } else { 178 } else {
180 mark::hit!(cfg_attr_active); 179 cov_mark::hit!(cfg_attr_active);
181 180
182 let attr = ast::Attr::parse(&format!("#[{}]", attr)).ok()?; 181 let attr = ast::Attr::parse(&format!("#[{}]", attr)).ok()?;
183 let hygiene = Hygiene::new_unhygienic(); // FIXME 182 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};
20use profile::Count; 20use profile::Count;
21use rustc_hash::FxHashMap; 21use rustc_hash::FxHashMap;
22use syntax::{ast, AstNode, AstPtr}; 22use syntax::{ast, AstNode, AstPtr};
23use test_utils::mark;
24 23
25pub(crate) use lower::LowerCtx; 24pub(crate) use lower::LowerCtx;
26 25
@@ -105,7 +104,7 @@ impl Expander {
105 macro_call: ast::MacroCall, 104 macro_call: ast::MacroCall,
106 ) -> ExpandResult<Option<(Mark, T)>> { 105 ) -> ExpandResult<Option<(Mark, T)>> {
107 if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { 106 if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT {
108 mark::hit!(your_stack_belongs_to_me); 107 cov_mark::hit!(your_stack_belongs_to_me);
109 return ExpandResult::str_err("reached recursion limit during macro expansion".into()); 108 return ExpandResult::str_err("reached recursion limit during macro expansion".into());
110 } 109 }
111 110
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::{
19 }, 19 },
20 AstNode, AstPtr, SyntaxNodePtr, 20 AstNode, AstPtr, SyntaxNodePtr,
21}; 21};
22use test_utils::mark;
23 22
24use crate::{ 23use crate::{
25 adt::StructKind, 24 adt::StructKind,
@@ -286,7 +285,7 @@ impl ExprCollector<'_> {
286 None => self.collect_expr_opt(condition.expr()), 285 None => self.collect_expr_opt(condition.expr()),
287 // if let -- desugar to match 286 // if let -- desugar to match
288 Some(pat) => { 287 Some(pat) => {
289 mark::hit!(infer_resolve_while_let); 288 cov_mark::hit!(infer_resolve_while_let);
290 let pat = self.collect_pat(pat); 289 let pat = self.collect_pat(pat);
291 let match_expr = self.collect_expr_opt(condition.expr()); 290 let match_expr = self.collect_expr_opt(condition.expr());
292 let placeholder_pat = self.missing_pat(); 291 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 {
186 use base_db::{fixture::WithFixture, FileId, SourceDatabase}; 186 use base_db::{fixture::WithFixture, FileId, SourceDatabase};
187 use hir_expand::{name::AsName, InFile}; 187 use hir_expand::{name::AsName, InFile};
188 use syntax::{algo::find_node_at_offset, ast, AstNode}; 188 use syntax::{algo::find_node_at_offset, ast, AstNode};
189 use test_utils::{assert_eq_text, extract_offset, mark}; 189 use test_utils::{assert_eq_text, extract_offset};
190 190
191 use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId}; 191 use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
192 192
@@ -454,7 +454,7 @@ fn foo() {
454 454
455 #[test] 455 #[test]
456 fn while_let_desugaring() { 456 fn while_let_desugaring() {
457 mark::check!(infer_resolve_while_let); 457 cov_mark::check!(infer_resolve_while_let);
458 do_check_local_name( 458 do_check_local_name(
459 r#" 459 r#"
460fn test() { 460fn 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;
2 2
3use base_db::{fixture::WithFixture, SourceDatabase}; 3use base_db::{fixture::WithFixture, SourceDatabase};
4use expect_test::Expect; 4use expect_test::Expect;
5use test_utils::mark;
6 5
7use crate::{test_db::TestDB, ModuleDefId}; 6use crate::{test_db::TestDB, ModuleDefId};
8 7
@@ -48,7 +47,7 @@ fn check_at(ra_fixture: &str, expect: Expect) {
48 47
49#[test] 48#[test]
50fn your_stack_belongs_to_me() { 49fn your_stack_belongs_to_me() {
51 mark::check!(your_stack_belongs_to_me); 50 cov_mark::check!(your_stack_belongs_to_me);
52 lower( 51 lower(
53 " 52 "
54macro_rules! n_nuple { 53macro_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() {
165 check_at( 165 check_at(
166 r#" 166 r#"
167//- /lib.rs crate:lib deps:core 167//- /lib.rs crate:lib deps:core
168use core::mark; 168use core::cov_mark;
169 169
170fn f() { 170fn f() {
171 fn nested() { 171 fn nested() {
172 mark::hit!(Hit); 172 cov_mark::hit!(Hit);
173 $0 173 $0
174 } 174 }
175} 175}
176//- /core.rs crate:core 176//- /core.rs crate:core
177pub mod mark { 177pub mod cov_mark {
178 #[macro_export] 178 #[macro_export]
179 macro_rules! _hit { 179 macro_rules! _hit {
180 ($name:ident) => { 180 ($name:ident) => {
@@ -193,8 +193,8 @@ pub mod mark {
193 nested: v 193 nested: v
194 194
195 crate 195 crate
196 cov_mark: t
196 f: v 197 f: v
197 mark: t
198 "#]], 198 "#]],
199 ); 199 );
200} 200}
@@ -264,7 +264,7 @@ fn main() {
264fn underscore_import() { 264fn underscore_import() {
265 // This used to panic, because the default (private) visibility inside block expressions would 265 // This used to panic, because the default (private) visibility inside block expressions would
266 // point into the containing `DefMap`, which visibilities should never be able to do. 266 // point into the containing `DefMap`, which visibilities should never be able to do.
267 mark::check!(adjust_vis_in_block_def_map); 267 cov_mark::check!(adjust_vis_in_block_def_map);
268 check_at( 268 check_at(
269 r#" 269 r#"
270mod m { 270mod 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;
4 4
5use hir_expand::name::{known, AsName, Name}; 5use hir_expand::name::{known, AsName, Name};
6use rustc_hash::FxHashSet; 6use rustc_hash::FxHashSet;
7use test_utils::mark;
8 7
9use crate::nameres::DefMap; 8use crate::nameres::DefMap;
10use crate::{ 9use crate::{
@@ -215,7 +214,7 @@ fn find_path_inner(
215 best_path_len - 1, 214 best_path_len - 1,
216 prefixed, 215 prefixed,
217 )?; 216 )?;
218 mark::hit!(partially_imported); 217 cov_mark::hit!(partially_imported);
219 path.push_segment(info.path.segments.last().unwrap().clone()); 218 path.push_segment(info.path.segments.last().unwrap().clone());
220 Some(path) 219 Some(path)
221 }) 220 })
@@ -235,7 +234,7 @@ fn find_path_inner(
235 // that correctly (FIXME). 234 // that correctly (FIXME).
236 if let Some(item_module) = item.as_module_def_id().and_then(|did| did.module(db)) { 235 if let Some(item_module) = item.as_module_def_id().and_then(|did| did.module(db)) {
237 if item_module.def_map(db).block_id().is_some() && prefixed.is_some() { 236 if item_module.def_map(db).block_id().is_some() && prefixed.is_some() {
238 mark::hit!(prefixed_in_block_expression); 237 cov_mark::hit!(prefixed_in_block_expression);
239 prefixed = Some(PrefixKind::Plain); 238 prefixed = Some(PrefixKind::Plain);
240 } 239 }
241 } 240 }
@@ -252,18 +251,18 @@ fn find_path_inner(
252fn select_best_path(old_path: ModPath, new_path: ModPath, prefer_no_std: bool) -> ModPath { 251fn select_best_path(old_path: ModPath, new_path: ModPath, prefer_no_std: bool) -> ModPath {
253 if old_path.starts_with_std() && new_path.can_start_with_std() { 252 if old_path.starts_with_std() && new_path.can_start_with_std() {
254 if prefer_no_std { 253 if prefer_no_std {
255 mark::hit!(prefer_no_std_paths); 254 cov_mark::hit!(prefer_no_std_paths);
256 new_path 255 new_path
257 } else { 256 } else {
258 mark::hit!(prefer_std_paths); 257 cov_mark::hit!(prefer_std_paths);
259 old_path 258 old_path
260 } 259 }
261 } else if new_path.starts_with_std() && old_path.can_start_with_std() { 260 } else if new_path.starts_with_std() && old_path.can_start_with_std() {
262 if prefer_no_std { 261 if prefer_no_std {
263 mark::hit!(prefer_no_std_paths); 262 cov_mark::hit!(prefer_no_std_paths);
264 old_path 263 old_path
265 } else { 264 } else {
266 mark::hit!(prefer_std_paths); 265 cov_mark::hit!(prefer_std_paths);
267 new_path 266 new_path
268 } 267 }
269 } else if new_path.len() < old_path.len() { 268 } else if new_path.len() < old_path.len() {
@@ -364,7 +363,6 @@ mod tests {
364 use base_db::fixture::WithFixture; 363 use base_db::fixture::WithFixture;
365 use hir_expand::hygiene::Hygiene; 364 use hir_expand::hygiene::Hygiene;
366 use syntax::ast::AstNode; 365 use syntax::ast::AstNode;
367 use test_utils::mark;
368 366
369 use crate::test_db::TestDB; 367 use crate::test_db::TestDB;
370 368
@@ -522,7 +520,7 @@ mod tests {
522 520
523 #[test] 521 #[test]
524 fn partially_imported() { 522 fn partially_imported() {
525 mark::check!(partially_imported); 523 cov_mark::check!(partially_imported);
526 // Tests that short paths are used even for external items, when parts of the path are 524 // Tests that short paths are used even for external items, when parts of the path are
527 // already in scope. 525 // already in scope.
528 let code = r#" 526 let code = r#"
@@ -686,7 +684,7 @@ mod tests {
686 684
687 #[test] 685 #[test]
688 fn prefer_std_paths_over_alloc() { 686 fn prefer_std_paths_over_alloc() {
689 mark::check!(prefer_std_paths); 687 cov_mark::check!(prefer_std_paths);
690 let code = r#" 688 let code = r#"
691 //- /main.rs crate:main deps:alloc,std 689 //- /main.rs crate:main deps:alloc,std
692 $0 690 $0
@@ -712,7 +710,7 @@ mod tests {
712 710
713 #[test] 711 #[test]
714 fn prefer_core_paths_over_std() { 712 fn prefer_core_paths_over_std() {
715 mark::check!(prefer_no_std_paths); 713 cov_mark::check!(prefer_no_std_paths);
716 let code = r#" 714 let code = r#"
717 //- /main.rs crate:main deps:core,std 715 //- /main.rs crate:main deps:core,std
718 #![no_std] 716 #![no_std]
@@ -842,7 +840,7 @@ mod tests {
842 840
843 #[test] 841 #[test]
844 fn inner_items_from_inner_module() { 842 fn inner_items_from_inner_module() {
845 mark::check!(prefixed_in_block_expression); 843 cov_mark::check!(prefixed_in_block_expression);
846 check_found_path( 844 check_found_path(
847 r#" 845 r#"
848 fn main() { 846 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;
8use indexmap::{map::Entry, IndexMap}; 8use indexmap::{map::Entry, IndexMap};
9use itertools::Itertools; 9use itertools::Itertools;
10use rustc_hash::{FxHashSet, FxHasher}; 10use rustc_hash::{FxHashSet, FxHasher};
11use test_utils::mark;
12 11
13use crate::{ 12use crate::{
14 db::DefDatabase, item_scope::ItemInNs, visibility::Visibility, AssocItemId, ModuleDefId, 13 db::DefDatabase, item_scope::ItemInNs, visibility::Visibility, AssocItemId, ModuleDefId,
@@ -193,7 +192,7 @@ impl ImportMap {
193 // cannot use associated type aliases directly: need a `<Struct as Trait>::TypeAlias` 192 // cannot use associated type aliases directly: need a `<Struct as Trait>::TypeAlias`
194 // qualifier, ergo no need to store it for imports in import_map 193 // qualifier, ergo no need to store it for imports in import_map
195 AssocItemId::TypeAliasId(_) => { 194 AssocItemId::TypeAliasId(_) => {
196 mark::hit!(type_aliases_ignored); 195 cov_mark::hit!(type_aliases_ignored);
197 continue; 196 continue;
198 } 197 }
199 }; 198 };
@@ -463,7 +462,6 @@ fn item_import_kind(item: ItemInNs) -> Option<ImportKind> {
463mod tests { 462mod tests {
464 use base_db::{fixture::WithFixture, SourceDatabase, Upcast}; 463 use base_db::{fixture::WithFixture, SourceDatabase, Upcast};
465 use expect_test::{expect, Expect}; 464 use expect_test::{expect, Expect};
466 use test_utils::mark;
467 465
468 use crate::{test_db::TestDB, AssocContainerId, Lookup}; 466 use crate::{test_db::TestDB, AssocContainerId, Lookup};
469 467
@@ -801,7 +799,7 @@ mod tests {
801 799
802 #[test] 800 #[test]
803 fn fuzzy_import_trait_and_assoc_items() { 801 fn fuzzy_import_trait_and_assoc_items() {
804 mark::check!(type_aliases_ignored); 802 cov_mark::check!(type_aliases_ignored);
805 let ra_fixture = r#" 803 let ra_fixture = r#"
806 //- /main.rs crate:main deps:dep 804 //- /main.rs crate:main deps:dep
807 //- /dep.rs crate:dep 805 //- /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;
9use once_cell::sync::Lazy; 9use once_cell::sync::Lazy;
10use rustc_hash::{FxHashMap, FxHashSet}; 10use rustc_hash::{FxHashMap, FxHashSet};
11use stdx::format_to; 11use stdx::format_to;
12use test_utils::mark;
13 12
14use crate::{ 13use crate::{
15 db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, ImplId, 14 db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, ImplId,
@@ -237,7 +236,7 @@ impl ItemScope {
237 if $glob_imports.$field.contains(&$lookup) 236 if $glob_imports.$field.contains(&$lookup)
238 && matches!($def_import_type, ImportType::Named) => 237 && matches!($def_import_type, ImportType::Named) =>
239 { 238 {
240 mark::hit!(import_shadowed); 239 cov_mark::hit!(import_shadowed);
241 $glob_imports.$field.remove(&$lookup); 240 $glob_imports.$field.remove(&$lookup);
242 if let Some(fld) = $def.$field { 241 if let Some(fld) = $def.$field {
243 entry.insert(fld); 242 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;
25use rustc_hash::FxHashMap; 25use rustc_hash::FxHashMap;
26use smallvec::SmallVec; 26use smallvec::SmallVec;
27use syntax::{ast, match_ast, SyntaxKind}; 27use syntax::{ast, match_ast, SyntaxKind};
28use test_utils::mark;
29 28
30use crate::{ 29use crate::{
31 attr::{Attrs, RawAttrs}, 30 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 {
466 .collect() 466 .collect()
467 }) 467 })
468 .unwrap_or_else(|| { 468 .unwrap_or_else(|| {
469 mark::hit!(name_res_works_for_broken_modules); 469 cov_mark::hit!(name_res_works_for_broken_modules);
470 Box::new([]) as Box<[_]> 470 Box::new([]) as Box<[_]>
471 }), 471 }),
472 } 472 }
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::{
18use hir_expand::{InFile, MacroCallLoc}; 18use hir_expand::{InFile, MacroCallLoc};
19use rustc_hash::{FxHashMap, FxHashSet}; 19use rustc_hash::{FxHashMap, FxHashSet};
20use syntax::ast; 20use syntax::ast;
21use test_utils::mark;
22use tt::{Leaf, TokenTree}; 21use tt::{Leaf, TokenTree};
23 22
24use crate::{ 23use crate::{
@@ -462,7 +461,7 @@ impl DefCollector<'_> {
462 let res = self.def_map.resolve_name_in_extern_prelude(&extern_crate.name); 461 let res = self.def_map.resolve_name_in_extern_prelude(&extern_crate.name);
463 462
464 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() { 463 if let Some(ModuleDefId::ModuleId(m)) = res.take_types() {
465 mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use); 464 cov_mark::hit!(macro_rules_from_other_crates_are_visible_with_macro_use);
466 self.import_all_macros_exported(current_module_id, m.krate); 465 self.import_all_macros_exported(current_module_id, m.krate);
467 } 466 }
468 } 467 }
@@ -571,10 +570,10 @@ impl DefCollector<'_> {
571 match def.take_types() { 570 match def.take_types() {
572 Some(ModuleDefId::ModuleId(m)) => { 571 Some(ModuleDefId::ModuleId(m)) => {
573 if import.is_prelude { 572 if import.is_prelude {
574 mark::hit!(std_prelude); 573 cov_mark::hit!(std_prelude);
575 self.def_map.prelude = Some(m); 574 self.def_map.prelude = Some(m);
576 } else if m.krate != self.def_map.krate { 575 } else if m.krate != self.def_map.krate {
577 mark::hit!(glob_across_crates); 576 cov_mark::hit!(glob_across_crates);
578 // glob import from other crate => we can just import everything once 577 // glob import from other crate => we can just import everything once
579 let item_map = m.def_map(self.db); 578 let item_map = m.def_map(self.db);
580 let scope = &item_map[m.local_id].scope; 579 let scope = &item_map[m.local_id].scope;
@@ -626,7 +625,7 @@ impl DefCollector<'_> {
626 } 625 }
627 } 626 }
628 Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => { 627 Some(ModuleDefId::AdtId(AdtId::EnumId(e))) => {
629 mark::hit!(glob_enum); 628 cov_mark::hit!(glob_enum);
630 // glob import from enum => just import all the variants 629 // glob import from enum => just import all the variants
631 630
632 // XXX: urgh, so this works by accident! Here, we look at 631 // XXX: urgh, so this works by accident! Here, we look at
@@ -675,7 +674,7 @@ impl DefCollector<'_> {
675 674
676 self.update(module_id, &[(name, def)], vis, ImportType::Named); 675 self.update(module_id, &[(name, def)], vis, ImportType::Named);
677 } 676 }
678 None => mark::hit!(bogus_paths), 677 None => cov_mark::hit!(bogus_paths),
679 } 678 }
680 } 679 }
681 } 680 }
@@ -738,7 +737,7 @@ impl DefCollector<'_> {
738 if max_vis == old_vis { 737 if max_vis == old_vis {
739 false 738 false
740 } else { 739 } else {
741 mark::hit!(upgrade_underscore_visibility); 740 cov_mark::hit!(upgrade_underscore_visibility);
742 true 741 true
743 } 742 }
744 } 743 }
@@ -866,7 +865,7 @@ impl DefCollector<'_> {
866 depth: usize, 865 depth: usize,
867 ) { 866 ) {
868 if depth > EXPANSION_DEPTH_LIMIT { 867 if depth > EXPANSION_DEPTH_LIMIT {
869 mark::hit!(macro_expansion_overflow); 868 cov_mark::hit!(macro_expansion_overflow);
870 log::warn!("macro expansion is too deep"); 869 log::warn!("macro expansion is too deep");
871 return; 870 return;
872 } 871 }
@@ -1009,7 +1008,7 @@ impl ModCollector<'_, '_> {
1009 // Prelude module is always considered to be `#[macro_use]`. 1008 // Prelude module is always considered to be `#[macro_use]`.
1010 if let Some(prelude_module) = self.def_collector.def_map.prelude { 1009 if let Some(prelude_module) = self.def_collector.def_map.prelude {
1011 if prelude_module.krate != self.def_collector.def_map.krate { 1010 if prelude_module.krate != self.def_collector.def_map.krate {
1012 mark::hit!(prelude_is_macro_use); 1011 cov_mark::hit!(prelude_is_macro_use);
1013 self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate); 1012 self.def_collector.import_all_macros_exported(self.module_id, prelude_module.krate);
1014 } 1013 }
1015 } 1014 }
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 @@
2use base_db::{AnchoredPath, FileId}; 2use base_db::{AnchoredPath, FileId};
3use hir_expand::name::Name; 3use hir_expand::name::Name;
4use syntax::SmolStr; 4use syntax::SmolStr;
5use test_utils::mark;
6 5
7use crate::{db::DefDatabase, HirFileId}; 6use crate::{db::DefDatabase, HirFileId};
8 7
@@ -28,7 +27,7 @@ impl ModDir {
28 let depth = self.depth + 1; 27 let depth = self.depth + 1;
29 if depth > MOD_DEPTH_LIMIT { 28 if depth > MOD_DEPTH_LIMIT {
30 log::error!("MOD_DEPTH_LIMIT exceeded"); 29 log::error!("MOD_DEPTH_LIMIT exceeded");
31 mark::hit!(circular_mods); 30 cov_mark::hit!(circular_mods);
32 return None; 31 return None;
33 } 32 }
34 Some(ModDir { dir_path, root_non_dir_owner, depth }) 33 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 @@
13use base_db::Edition; 13use base_db::Edition;
14use hir_expand::name; 14use hir_expand::name;
15use hir_expand::name::Name; 15use hir_expand::name::Name;
16use test_utils::mark;
17 16
18use crate::{ 17use crate::{
19 db::DefDatabase, 18 db::DefDatabase,
@@ -63,7 +62,7 @@ impl ResolvePathResult {
63impl DefMap { 62impl DefMap {
64 pub(super) fn resolve_name_in_extern_prelude(&self, name: &Name) -> PerNs { 63 pub(super) fn resolve_name_in_extern_prelude(&self, name: &Name) -> PerNs {
65 if name == &name!(self) { 64 if name == &name!(self) {
66 mark::hit!(extern_crate_self_as); 65 cov_mark::hit!(extern_crate_self_as);
67 return PerNs::types(self.module_id(self.root).into(), Visibility::Public); 66 return PerNs::types(self.module_id(self.root).into(), Visibility::Public);
68 } 67 }
69 self.extern_prelude 68 self.extern_prelude
@@ -101,7 +100,7 @@ impl DefMap {
101 // DefMap they're written in, so we restrict them when that happens. 100 // DefMap they're written in, so we restrict them when that happens.
102 if let Visibility::Module(m) = vis { 101 if let Visibility::Module(m) = vis {
103 if self.block_id() != m.block { 102 if self.block_id() != m.block {
104 mark::hit!(adjust_vis_in_block_def_map); 103 cov_mark::hit!(adjust_vis_in_block_def_map);
105 vis = Visibility::Module(self.module_id(self.root())); 104 vis = Visibility::Module(self.module_id(self.root()));
106 log::debug!("visibility {:?} points outside DefMap, adjusting to {:?}", m, vis); 105 log::debug!("visibility {:?} points outside DefMap, adjusting to {:?}", m, vis);
107 } 106 }
@@ -169,12 +168,12 @@ impl DefMap {
169 let mut curr_per_ns: PerNs = match path.kind { 168 let mut curr_per_ns: PerNs = match path.kind {
170 PathKind::DollarCrate(krate) => { 169 PathKind::DollarCrate(krate) => {
171 if krate == self.krate { 170 if krate == self.krate {
172 mark::hit!(macro_dollar_crate_self); 171 cov_mark::hit!(macro_dollar_crate_self);
173 PerNs::types(self.crate_root(db).into(), Visibility::Public) 172 PerNs::types(self.crate_root(db).into(), Visibility::Public)
174 } else { 173 } else {
175 let def_map = db.crate_def_map(krate); 174 let def_map = db.crate_def_map(krate);
176 let module = def_map.module_id(def_map.root); 175 let module = def_map.module_id(def_map.root);
177 mark::hit!(macro_dollar_crate_other); 176 cov_mark::hit!(macro_dollar_crate_other);
178 PerNs::types(module.into(), Visibility::Public) 177 PerNs::types(module.into(), Visibility::Public)
179 } 178 }
180 } 179 }
@@ -310,7 +309,7 @@ impl DefMap {
310 } 309 }
311 ModuleDefId::AdtId(AdtId::EnumId(e)) => { 310 ModuleDefId::AdtId(AdtId::EnumId(e)) => {
312 // enum variant 311 // enum variant
313 mark::hit!(can_import_enum_variant); 312 cov_mark::hit!(can_import_enum_variant);
314 let enum_data = db.enum_data(e); 313 let enum_data = db.enum_data(e);
315 match enum_data.variant(&segment) { 314 match enum_data.variant(&segment) {
316 Some(local_id) => { 315 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;
9 9
10use base_db::{fixture::WithFixture, SourceDatabase}; 10use base_db::{fixture::WithFixture, SourceDatabase};
11use expect_test::{expect, Expect}; 11use expect_test::{expect, Expect};
12use test_utils::mark;
13 12
14use crate::{db::DefDatabase, test_db::TestDB}; 13use crate::{db::DefDatabase, test_db::TestDB};
15 14
@@ -136,7 +135,7 @@ mod m {
136 135
137#[test] 136#[test]
138fn bogus_paths() { 137fn bogus_paths() {
139 mark::check!(bogus_paths); 138 cov_mark::check!(bogus_paths);
140 check( 139 check(
141 r#" 140 r#"
142//- /lib.rs 141//- /lib.rs
@@ -243,7 +242,7 @@ pub struct Baz;
243 242
244#[test] 243#[test]
245fn std_prelude() { 244fn std_prelude() {
246 mark::check!(std_prelude); 245 cov_mark::check!(std_prelude);
247 check( 246 check(
248 r#" 247 r#"
249//- /main.rs crate:main deps:test_crate 248//- /main.rs crate:main deps:test_crate
@@ -267,7 +266,7 @@ pub enum Foo { Bar, Baz };
267 266
268#[test] 267#[test]
269fn can_import_enum_variant() { 268fn can_import_enum_variant() {
270 mark::check!(can_import_enum_variant); 269 cov_mark::check!(can_import_enum_variant);
271 check( 270 check(
272 r#" 271 r#"
273enum E { V } 272enum E { V }
@@ -628,7 +627,7 @@ use crate::reex::*;
628 627
629#[test] 628#[test]
630fn underscore_pub_crate_reexport() { 629fn underscore_pub_crate_reexport() {
631 mark::check!(upgrade_underscore_visibility); 630 cov_mark::check!(upgrade_underscore_visibility);
632 check( 631 check(
633 r#" 632 r#"
634//- /main.rs crate:main deps:lib 633//- /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 @@
1use base_db::fixture::WithFixture; 1use base_db::fixture::WithFixture;
2use test_utils::mark;
3 2
4use crate::test_db::TestDB; 3use crate::test_db::TestDB;
5 4
@@ -63,7 +62,7 @@ fn unresolved_extern_crate() {
63 62
64#[test] 63#[test]
65fn extern_crate_self_as() { 64fn extern_crate_self_as() {
66 mark::check!(extern_crate_self_as); 65 cov_mark::check!(extern_crate_self_as);
67 check_diagnostics( 66 check_diagnostics(
68 r" 67 r"
69 //- /lib.rs 68 //- /lib.rs
@@ -140,7 +139,7 @@ fn inactive_item() {
140/// Tests that `cfg` attributes behind `cfg_attr` is handled properly. 139/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
141#[test] 140#[test]
142fn inactive_via_cfg_attr() { 141fn inactive_via_cfg_attr() {
143 mark::check!(cfg_attr_active); 142 cov_mark::check!(cfg_attr_active);
144 check_diagnostics( 143 check_diagnostics(
145 r#" 144 r#"
146 //- /lib.rs 145 //- /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;
148 148
149#[test] 149#[test]
150fn glob_across_crates() { 150fn glob_across_crates() {
151 mark::check!(glob_across_crates); 151 cov_mark::check!(glob_across_crates);
152 check( 152 check(
153 r#" 153 r#"
154//- /main.rs crate:main deps:test_crate 154//- /main.rs crate:main deps:test_crate
@@ -184,7 +184,7 @@ struct Foo;
184 184
185#[test] 185#[test]
186fn glob_enum() { 186fn glob_enum() {
187 mark::check!(glob_enum); 187 cov_mark::check!(glob_enum);
188 check( 188 check(
189 r#" 189 r#"
190enum Foo { Bar, Baz } 190enum Foo { Bar, Baz }
@@ -201,7 +201,7 @@ use self::Foo::*;
201 201
202#[test] 202#[test]
203fn glob_enum_group() { 203fn glob_enum_group() {
204 mark::check!(glob_enum_group); 204 cov_mark::check!(glob_enum_group);
205 check( 205 check(
206 r#" 206 r#"
207enum Foo { Bar, Baz } 207enum Foo { Bar, Baz }
@@ -218,7 +218,7 @@ use self::Foo::{*};
218 218
219#[test] 219#[test]
220fn glob_shadowed_def() { 220fn glob_shadowed_def() {
221 mark::check!(import_shadowed); 221 cov_mark::check!(import_shadowed);
222 check( 222 check(
223 r#" 223 r#"
224//- /lib.rs 224//- /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 {
210 210
211#[test] 211#[test]
212fn macro_rules_from_other_crates_are_visible_with_macro_use() { 212fn macro_rules_from_other_crates_are_visible_with_macro_use() {
213 mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use); 213 cov_mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use);
214 check( 214 check(
215 r#" 215 r#"
216//- /main.rs crate:main deps:foo 216//- /main.rs crate:main deps:foo
@@ -260,7 +260,7 @@ mod priv_mod {
260 260
261#[test] 261#[test]
262fn prelude_is_macro_use() { 262fn prelude_is_macro_use() {
263 mark::check!(prelude_is_macro_use); 263 cov_mark::check!(prelude_is_macro_use);
264 check( 264 check(
265 r#" 265 r#"
266//- /main.rs crate:main deps:foo 266//- /main.rs crate:main deps:foo
@@ -550,7 +550,7 @@ mod m {
550 550
551#[test] 551#[test]
552fn macro_dollar_crate_is_correct_in_item() { 552fn macro_dollar_crate_is_correct_in_item() {
553 mark::check!(macro_dollar_crate_self); 553 cov_mark::check!(macro_dollar_crate_self);
554 check( 554 check(
555 r#" 555 r#"
556//- /main.rs crate:main deps:foo 556//- /main.rs crate:main deps:foo
@@ -608,7 +608,7 @@ struct Baz;
608 608
609#[test] 609#[test]
610fn macro_dollar_crate_is_correct_in_indirect_deps() { 610fn macro_dollar_crate_is_correct_in_indirect_deps() {
611 mark::check!(macro_dollar_crate_other); 611 cov_mark::check!(macro_dollar_crate_other);
612 // From std 612 // From std
613 check( 613 check(
614 r#" 614 r#"
@@ -686,7 +686,7 @@ pub trait Clone {}
686 686
687#[test] 687#[test]
688fn macro_expansion_overflow() { 688fn macro_expansion_overflow() {
689 mark::check!(macro_expansion_overflow); 689 cov_mark::check!(macro_expansion_overflow);
690 check( 690 check(
691 r#" 691 r#"
692macro_rules! a { 692macro_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::*;
2 2
3#[test] 3#[test]
4fn name_res_works_for_broken_modules() { 4fn name_res_works_for_broken_modules() {
5 mark::check!(name_res_works_for_broken_modules); 5 cov_mark::check!(name_res_works_for_broken_modules);
6 check( 6 check(
7 r" 7 r"
8//- /lib.rs 8//- /lib.rs
@@ -774,7 +774,7 @@ struct X;
774 774
775#[test] 775#[test]
776fn circular_mods() { 776fn circular_mods() {
777 mark::check!(circular_mods); 777 cov_mark::check!(circular_mods);
778 compute_crate_def_map( 778 compute_crate_def_map(
779 r#" 779 r#"
780//- /lib.rs 780//- /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;
6use either::Either; 6use either::Either;
7use hir_expand::{hygiene::Hygiene, name::AsName}; 7use hir_expand::{hygiene::Hygiene, name::AsName};
8use syntax::ast::{self, NameOwner}; 8use syntax::ast::{self, NameOwner};
9use test_utils::mark;
10 9
11use crate::path::{ImportAlias, ModPath, PathKind}; 10use crate::path::{ImportAlias, ModPath, PathKind};
12 11
@@ -54,7 +53,7 @@ pub(crate) fn lower_use_tree(
54 // FIXME: report errors somewhere 53 // FIXME: report errors somewhere
55 // We get here if we do 54 // We get here if we do
56 } else if is_glob { 55 } else if is_glob {
57 mark::hit!(glob_enum_group); 56 cov_mark::hit!(glob_enum_group);
58 if let Some(prefix) = prefix { 57 if let Some(prefix) = prefix {
59 cb(prefix, &tree, is_glob, None) 58 cb(prefix, &tree, is_glob, None)
60 } 59 }
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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13itertools = "0.10.0" 14itertools = "0.10.0"
14arrayvec = "0.5.1" 15arrayvec = "0.5.1"
15smallvec = "1.2.0" 16smallvec = "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::{
28 ast::{self, NameOwner}, 28 ast::{self, NameOwner},
29 AstNode, AstPtr, 29 AstNode, AstPtr,
30}; 30};
31use test_utils::mark;
32 31
33use crate::{ 32use crate::{
34 db::HirDatabase, 33 db::HirDatabase,
@@ -93,7 +92,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
93 fn validate_func(&mut self, func: FunctionId) { 92 fn validate_func(&mut self, func: FunctionId) {
94 let data = self.db.function_data(func); 93 let data = self.db.function_data(func);
95 if data.is_extern { 94 if data.is_extern {
96 mark::hit!(extern_func_incorrect_case_ignored); 95 cov_mark::hit!(extern_func_incorrect_case_ignored);
97 return; 96 return;
98 } 97 }
99 98
@@ -625,7 +624,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
625 fn validate_static(&mut self, static_id: StaticId) { 624 fn validate_static(&mut self, static_id: StaticId) {
626 let data = self.db.static_data(static_id); 625 let data = self.db.static_data(static_id);
627 if data.is_extern { 626 if data.is_extern {
628 mark::hit!(extern_static_incorrect_case_ignored); 627 cov_mark::hit!(extern_static_incorrect_case_ignored);
629 return; 628 return;
630 } 629 }
631 630
@@ -673,8 +672,6 @@ impl<'a, 'b> DeclValidator<'a, 'b> {
673 672
674#[cfg(test)] 673#[cfg(test)]
675mod tests { 674mod tests {
676 use test_utils::mark;
677
678 use crate::diagnostics::tests::check_diagnostics; 675 use crate::diagnostics::tests::check_diagnostics;
679 676
680 #[test] 677 #[test]
@@ -889,8 +886,8 @@ fn main() {
889 886
890 #[test] 887 #[test]
891 fn ignores_extern_items() { 888 fn ignores_extern_items() {
892 mark::check!(extern_func_incorrect_case_ignored); 889 cov_mark::check!(extern_func_incorrect_case_ignored);
893 mark::check!(extern_static_incorrect_case_ignored); 890 cov_mark::check!(extern_static_incorrect_case_ignored);
894 check_diagnostics( 891 check_diagnostics(
895 r#" 892 r#"
896extern { 893extern {
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 @@
6 6
7use chalk_ir::{Mutability, TyVariableKind}; 7use chalk_ir::{Mutability, TyVariableKind};
8use hir_def::lang_item::LangItemTarget; 8use hir_def::lang_item::LangItemTarget;
9use test_utils::mark;
10 9
11use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty}; 10use crate::{autoderef, traits::Solution, Obligation, Substs, TraitRef, Ty};
12 11
@@ -35,7 +34,7 @@ impl<'a> InferenceContext<'a> {
35 ty1.clone() 34 ty1.clone()
36 } else { 35 } else {
37 if let (Ty::FnDef(..), Ty::FnDef(..)) = (ty1, ty2) { 36 if let (Ty::FnDef(..), Ty::FnDef(..)) = (ty1, ty2) {
38 mark::hit!(coerce_fn_reification); 37 cov_mark::hit!(coerce_fn_reification);
39 // Special case: two function types. Try to coerce both to 38 // Special case: two function types. Try to coerce both to
40 // pointers to have a chance at getting a match. See 39 // pointers to have a chance at getting a match. See
41 // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 40 // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916
@@ -45,7 +44,7 @@ impl<'a> InferenceContext<'a> {
45 let ptr_ty2 = Ty::fn_ptr(sig2); 44 let ptr_ty2 = Ty::fn_ptr(sig2);
46 self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) 45 self.coerce_merge_branch(&ptr_ty1, &ptr_ty2)
47 } else { 46 } else {
48 mark::hit!(coerce_merge_fail_fallback); 47 cov_mark::hit!(coerce_merge_fail_fallback);
49 ty1.clone() 48 ty1.clone()
50 } 49 }
51 } 50 }
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::{
12}; 12};
13use hir_expand::name::{name, Name}; 13use hir_expand::name::{name, Name};
14use syntax::ast::RangeOp; 14use syntax::ast::RangeOp;
15use test_utils::mark;
16 15
17use crate::{ 16use crate::{
18 autoderef, 17 autoderef,
@@ -565,7 +564,7 @@ impl<'a> InferenceContext<'a> {
565 let ret = op::binary_op_return_ty(*op, lhs_ty.clone(), rhs_ty.clone()); 564 let ret = op::binary_op_return_ty(*op, lhs_ty.clone(), rhs_ty.clone());
566 565
567 if ret == Ty::Unknown { 566 if ret == Ty::Unknown {
568 mark::hit!(infer_expr_inner_binary_operator_overload); 567 cov_mark::hit!(infer_expr_inner_binary_operator_overload);
569 568
570 self.resolve_associated_type_with_params( 569 self.resolve_associated_type_with_params(
571 lhs_ty, 570 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::{
10 FieldId, 10 FieldId,
11}; 11};
12use hir_expand::name::Name; 12use hir_expand::name::Name;
13use test_utils::mark;
14 13
15use super::{BindingMode, Expectation, InferenceContext}; 14use super::{BindingMode, Expectation, InferenceContext};
16use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Substs, Ty}; 15use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Substs, Ty};
@@ -108,7 +107,7 @@ impl<'a> InferenceContext<'a> {
108 } 107 }
109 } 108 }
110 } else if let Pat::Ref { .. } = &body[pat] { 109 } else if let Pat::Ref { .. } = &body[pat] {
111 mark::hit!(match_ergonomics_ref); 110 cov_mark::hit!(match_ergonomics_ref);
112 // When you encounter a `&pat` pattern, reset to Move. 111 // When you encounter a `&pat` pattern, reset to Move.
113 // This is so that `w` is by value: `let (_, &w) = &(1, &2);` 112 // This is so that `w` is by value: `let (_, &w) = &(1, &2);`
114 default_bm = BindingMode::Move; 113 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;
5use chalk_ir::{FloatTy, IntTy, TyVariableKind}; 5use chalk_ir::{FloatTy, IntTy, TyVariableKind};
6use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; 6use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
7 7
8use test_utils::mark;
9
10use super::{InferenceContext, Obligation}; 8use super::{InferenceContext, Obligation};
11use crate::{ 9use crate::{
12 BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferenceVar, Scalar, 10 BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferenceVar, Scalar,
@@ -387,7 +385,7 @@ impl InferenceTable {
387 // more than once 385 // more than once
388 for i in 0..3 { 386 for i in 0..3 {
389 if i > 0 { 387 if i > 0 {
390 mark::hit!(type_var_resolves_to_int_var); 388 cov_mark::hit!(type_var_resolves_to_int_var);
391 } 389 }
392 match &*ty { 390 match &*ty {
393 Ty::InferenceVar(tv, _) => { 391 Ty::InferenceVar(tv, _) => {
@@ -416,7 +414,7 @@ impl InferenceTable {
416 Ty::InferenceVar(tv, kind) => { 414 Ty::InferenceVar(tv, kind) => {
417 let inner = tv.to_inner(); 415 let inner = tv.to_inner();
418 if tv_stack.contains(&inner) { 416 if tv_stack.contains(&inner) {
419 mark::hit!(type_var_cycles_resolve_as_possible); 417 cov_mark::hit!(type_var_cycles_resolve_as_possible);
420 // recursive type 418 // recursive type
421 return self.type_variable_table.fallback_value(tv, kind); 419 return self.type_variable_table.fallback_value(tv, kind);
422 } 420 }
@@ -443,7 +441,7 @@ impl InferenceTable {
443 Ty::InferenceVar(tv, kind) => { 441 Ty::InferenceVar(tv, kind) => {
444 let inner = tv.to_inner(); 442 let inner = tv.to_inner();
445 if tv_stack.contains(&inner) { 443 if tv_stack.contains(&inner) {
446 mark::hit!(type_var_cycles_resolve_completely); 444 cov_mark::hit!(type_var_cycles_resolve_completely);
447 // recursive type 445 // recursive type
448 return self.type_variable_table.fallback_value(tv, kind); 446 return self.type_variable_table.fallback_value(tv, kind);
449 } 447 }
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;
24use la_arena::ArenaMap; 24use la_arena::ArenaMap;
25use smallvec::SmallVec; 25use smallvec::SmallVec;
26use stdx::impl_from; 26use stdx::impl_from;
27use test_utils::mark;
28 27
29use crate::{ 28use crate::{
30 db::HirDatabase, 29 db::HirDatabase,
@@ -760,7 +759,7 @@ fn assoc_type_bindings_from_type_bound<'a>(
760 759
761impl ReturnTypeImplTrait { 760impl ReturnTypeImplTrait {
762 fn from_hir(ctx: &TyLoweringContext, bounds: &[TypeBound]) -> Self { 761 fn from_hir(ctx: &TyLoweringContext, bounds: &[TypeBound]) -> Self {
763 mark::hit!(lower_rpit); 762 cov_mark::hit!(lower_rpit);
764 let self_ty = Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)); 763 let self_ty = Ty::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0));
765 let predicates = ctx.with_shifted_in(DebruijnIndex::ONE, |ctx| { 764 let predicates = ctx.with_shifted_in(DebruijnIndex::ONE, |ctx| {
766 bounds 765 bounds
@@ -935,7 +934,7 @@ impl TraitEnvironment {
935 // add `Self: Trait<T1, T2, ...>` to the environment in trait 934 // add `Self: Trait<T1, T2, ...>` to the environment in trait
936 // function default implementations (and hypothetical code 935 // function default implementations (and hypothetical code
937 // inside consts or type aliases) 936 // inside consts or type aliases)
938 test_utils::mark::hit!(trait_self_implements_self); 937 cov_mark::hit!(trait_self_implements_self);
939 let substs = Substs::type_params(db, trait_id); 938 let substs = Substs::type_params(db, trait_id);
940 let trait_ref = TraitRef { trait_: trait_id, substs }; 939 let trait_ref = TraitRef { trait_: trait_id, substs };
941 let pred = GenericPredicate::Implemented(trait_ref); 940 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(
588 // already happens in `is_valid_candidate` above; if not, we 588 // already happens in `is_valid_candidate` above; if not, we
589 // check it here 589 // check it here
590 if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() { 590 if receiver_ty.is_none() && inherent_impl_substs(db, impl_def, self_ty).is_none() {
591 test_utils::mark::hit!(impl_self_type_match_without_receiver); 591 cov_mark::hit!(impl_self_type_match_without_receiver);
592 continue; 592 continue;
593 } 593 }
594 if callback(&self_ty.value, item) { 594 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 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark;
3 2
4use super::{check_infer, check_infer_with_mismatches}; 3use super::{check_infer, check_infer_with_mismatches};
5 4
@@ -381,7 +380,7 @@ fn infer_match_second_coerce() {
381 380
382#[test] 381#[test]
383fn coerce_merge_one_by_one1() { 382fn coerce_merge_one_by_one1() {
384 mark::check!(coerce_merge_fail_fallback); 383 cov_mark::check!(coerce_merge_fail_fallback);
385 384
386 check_infer( 385 check_infer(
387 r" 386 r"
@@ -589,7 +588,7 @@ fn coerce_fn_item_to_fn_ptr() {
589 588
590#[test] 589#[test]
591fn coerce_fn_items_in_match_arms() { 590fn coerce_fn_items_in_match_arms() {
592 mark::check!(coerce_fn_reification); 591 cov_mark::check!(coerce_fn_reification);
593 592
594 check_infer_with_mismatches( 593 check_infer_with_mismatches(
595 r" 594 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(); }
913 913
914#[test] 914#[test]
915fn method_resolution_overloaded_method() { 915fn method_resolution_overloaded_method() {
916 test_utils::mark::check!(impl_self_type_match_without_receiver); 916 cov_mark::check!(impl_self_type_match_without_receiver);
917 check_types( 917 check_types(
918 r#" 918 r#"
919struct Wrapper<T>(T); 919struct Wrapper<T>(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 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark;
3 2
4use super::{check_infer, check_infer_with_mismatches}; 3use super::{check_infer, check_infer_with_mismatches};
5 4
@@ -197,7 +196,7 @@ fn infer_pattern_match_ergonomics() {
197 196
198#[test] 197#[test]
199fn infer_pattern_match_ergonomics_ref() { 198fn infer_pattern_match_ergonomics_ref() {
200 mark::check!(match_ergonomics_ref); 199 cov_mark::check!(match_ergonomics_ref);
201 check_infer( 200 check_infer(
202 r#" 201 r#"
203 fn test() { 202 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 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark;
3 2
4use super::{check_infer, check_types}; 3use super::{check_infer, check_types};
5 4
@@ -87,8 +86,8 @@ fn bug_651() {
87 86
88#[test] 87#[test]
89fn recursive_vars() { 88fn recursive_vars() {
90 mark::check!(type_var_cycles_resolve_completely); 89 cov_mark::check!(type_var_cycles_resolve_completely);
91 mark::check!(type_var_cycles_resolve_as_possible); 90 cov_mark::check!(type_var_cycles_resolve_as_possible);
92 check_infer( 91 check_infer(
93 r#" 92 r#"
94 fn test() { 93 fn test() {
@@ -166,7 +165,7 @@ fn infer_std_crash_1() {
166 165
167#[test] 166#[test]
168fn infer_std_crash_2() { 167fn infer_std_crash_2() {
169 mark::check!(type_var_resolves_to_int_var); 168 cov_mark::check!(type_var_resolves_to_int_var);
170 // caused "equating two type variables, ...", taken from std 169 // caused "equating two type variables, ...", taken from std
171 check_infer( 170 check_infer(
172 r#" 171 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 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark;
3 2
4use super::{check_infer, check_types}; 3use super::{check_infer, check_types};
5 4
@@ -2314,7 +2313,7 @@ fn generic_default_depending_on_other_type_arg_forward() {
2314 2313
2315#[test] 2314#[test]
2316fn infer_operator_overload() { 2315fn infer_operator_overload() {
2317 mark::check!(infer_expr_inner_binary_operator_overload); 2316 cov_mark::check!(infer_expr_inner_binary_operator_overload);
2318 2317
2319 check_infer( 2318 check_infer(
2320 r#" 2319 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 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark;
3 2
4use super::{check_infer, check_infer_with_mismatches, check_types}; 3use super::{check_infer, check_infer_with_mismatches, check_types};
5 4
@@ -319,7 +318,7 @@ fn infer_from_bound_2() {
319 318
320#[test] 319#[test]
321fn trait_default_method_self_bound_implements_trait() { 320fn trait_default_method_self_bound_implements_trait() {
322 mark::check!(trait_self_implements_self); 321 cov_mark::check!(trait_self_implements_self);
323 check_infer( 322 check_infer(
324 r#" 323 r#"
325 trait Trait { 324 trait Trait {
@@ -1189,7 +1188,7 @@ fn impl_trait() {
1189 1188
1190#[test] 1189#[test]
1191fn simple_return_pos_impl_trait() { 1190fn simple_return_pos_impl_trait() {
1192 mark::check!(lower_rpit); 1191 cov_mark::check!(lower_rpit);
1193 check_infer( 1192 check_infer(
1194 r#" 1193 r#"
1195 trait Trait<T> { 1194 trait Trait<T> {
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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13either = "1.5.3" 14either = "1.5.3"
14indexmap = "1.4.0" 15indexmap = "1.4.0"
15itertools = "0.10.0" 16itertools = "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::{
11use itertools::Itertools; 11use itertools::Itertools;
12use stdx::format_to; 12use stdx::format_to;
13use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; 13use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T};
14use test_utils::mark;
15 14
16use crate::{ 15use crate::{
17 display::{macro_label, ShortLabel, TryToNav}, 16 display::{macro_label, ShortLabel, TryToNav},
@@ -193,8 +192,8 @@ fn runnable_action(
193 ModuleDef::Function(func) => { 192 ModuleDef::Function(func) => {
194 let src = func.source(sema.db)?; 193 let src = func.source(sema.db)?;
195 if src.file_id != file_id.into() { 194 if src.file_id != file_id.into() {
196 mark::hit!(hover_macro_generated_struct_fn_doc_comment); 195 cov_mark::hit!(hover_macro_generated_struct_fn_doc_comment);
197 mark::hit!(hover_macro_generated_struct_fn_doc_attr); 196 cov_mark::hit!(hover_macro_generated_struct_fn_doc_attr);
198 return None; 197 return None;
199 } 198 }
200 199
@@ -2101,7 +2100,7 @@ pub fn fo$0o() {}
2101 2100
2102 #[test] 2101 #[test]
2103 fn test_hover_macro_generated_struct_fn_doc_comment() { 2102 fn test_hover_macro_generated_struct_fn_doc_comment() {
2104 mark::check!(hover_macro_generated_struct_fn_doc_comment); 2103 cov_mark::check!(hover_macro_generated_struct_fn_doc_comment);
2105 2104
2106 check( 2105 check(
2107 r#" 2106 r#"
@@ -2139,7 +2138,7 @@ fn foo() { let bar = Bar; bar.fo$0o(); }
2139 2138
2140 #[test] 2139 #[test]
2141 fn test_hover_macro_generated_struct_fn_doc_attr() { 2140 fn test_hover_macro_generated_struct_fn_doc_attr() {
2142 mark::check!(hover_macro_generated_struct_fn_doc_attr); 2141 cov_mark::check!(hover_macro_generated_struct_fn_doc_attr);
2143 2142
2144 check( 2143 check(
2145 r#" 2144 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::{
7 SyntaxKind::{self, USE_TREE, WHITESPACE}, 7 SyntaxKind::{self, USE_TREE, WHITESPACE},
8 SyntaxNode, SyntaxToken, TextRange, TextSize, T, 8 SyntaxNode, SyntaxToken, TextRange, TextSize, T,
9}; 9};
10use test_utils::mark; 10
11use text_edit::{TextEdit, TextEditBuilder}; 11use text_edit::{TextEdit, TextEditBuilder};
12 12
13// Feature: Join Lines 13// Feature: Join Lines
@@ -60,7 +60,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS
60 let mut string_open_quote = false; 60 let mut string_open_quote = false;
61 if let Some(string) = ast::String::cast(token.clone()) { 61 if let Some(string) = ast::String::cast(token.clone()) {
62 if let Some(range) = string.open_quote_text_range() { 62 if let Some(range) = string.open_quote_text_range() {
63 mark::hit!(join_string_literal); 63 cov_mark::hit!(join_string_literal);
64 string_open_quote = range.end() == offset; 64 string_open_quote = range.end() == offset;
65 } 65 }
66 } 66 }
@@ -206,7 +206,7 @@ fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str {
206#[cfg(test)] 206#[cfg(test)]
207mod tests { 207mod tests {
208 use syntax::SourceFile; 208 use syntax::SourceFile;
209 use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range, mark}; 209 use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range};
210 210
211 use super::*; 211 use super::*;
212 212
@@ -786,7 +786,7 @@ fn foo() {
786 786
787 #[test] 787 #[test]
788 fn join_string_literal() { 788 fn join_string_literal() {
789 mark::check!(join_string_literal); 789 cov_mark::check!(join_string_literal);
790 check_join_lines( 790 check_join_lines(
791 r#" 791 r#"
792fn main() { 792fn 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::{
2 ast::{self, AstNode}, 2 ast::{self, AstNode},
3 SourceFile, SyntaxKind, TextSize, T, 3 SourceFile, SyntaxKind, TextSize, T,
4}; 4};
5use test_utils::mark;
6 5
7// Feature: Matching Brace 6// Feature: Matching Brace
8// 7//
@@ -28,7 +27,7 @@ pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<Text
28 .next()?; 27 .next()?;
29 let parent = brace_token.parent(); 28 let parent = brace_token.parent();
30 if brace_token.kind() == T![|] && !ast::ParamList::can_cast(parent.kind()) { 29 if brace_token.kind() == T![|] && !ast::ParamList::can_cast(parent.kind()) {
31 mark::hit!(pipes_not_braces); 30 cov_mark::hit!(pipes_not_braces);
32 return None; 31 return None;
33 } 32 }
34 let matching_kind = BRACES[brace_idx ^ 1]; 33 let matching_kind = BRACES[brace_idx ^ 1];
@@ -63,7 +62,7 @@ mod tests {
63 do_check("fn main() { $0|x: i32| x * 2;}", "fn main() { |x: i32$0| x * 2;}"); 62 do_check("fn main() { $0|x: i32| x * 2;}", "fn main() { |x: i32$0| x * 2;}");
64 63
65 { 64 {
66 mark::check!(pipes_not_braces); 65 cov_mark::check!(pipes_not_braces);
67 do_check( 66 do_check(
68 "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }", 67 "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }",
69 "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }", 68 "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::{
5 algo::find_node_at_offset, 5 algo::find_node_at_offset,
6 ast::{self, AstNode}, 6 ast::{self, AstNode},
7}; 7};
8use test_utils::mark;
9 8
10use crate::NavigationTarget; 9use crate::NavigationTarget;
11 10
@@ -33,7 +32,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
33 .item_list() 32 .item_list()
34 .map_or(false, |it| it.syntax().text_range().contains_inclusive(position.offset)) 33 .map_or(false, |it| it.syntax().text_range().contains_inclusive(position.offset))
35 { 34 {
36 mark::hit!(test_resolve_parent_module_on_module_decl); 35 cov_mark::hit!(test_resolve_parent_module_on_module_decl);
37 module = m.syntax().ancestors().skip(1).find_map(ast::Module::cast); 36 module = m.syntax().ancestors().skip(1).find_map(ast::Module::cast);
38 } 37 }
39 } 38 }
@@ -64,7 +63,6 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
64#[cfg(test)] 63#[cfg(test)]
65mod tests { 64mod tests {
66 use ide_db::base_db::FileRange; 65 use ide_db::base_db::FileRange;
67 use test_utils::mark;
68 66
69 use crate::fixture; 67 use crate::fixture;
70 68
@@ -92,7 +90,7 @@ $0// empty
92 90
93 #[test] 91 #[test]
94 fn test_resolve_parent_module_on_module_decl() { 92 fn test_resolve_parent_module_on_module_decl() {
95 mark::check!(test_resolve_parent_module_on_module_decl); 93 cov_mark::check!(test_resolve_parent_module_on_module_decl);
96 check( 94 check(
97 r#" 95 r#"
98//- /lib.rs 96//- /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::{
14 ast::{self, NameOwner}, 14 ast::{self, NameOwner},
15 lex_single_syntax_kind, AstNode, SyntaxKind, SyntaxNode, T, 15 lex_single_syntax_kind, AstNode, SyntaxKind, SyntaxNode, T,
16}; 16};
17use test_utils::mark; 17
18use text_edit::TextEdit; 18use text_edit::TextEdit;
19 19
20use crate::{display::TryToNav, FilePosition, FileSystemEdit, RangeInfo, SourceChange, TextRange}; 20use crate::{display::TryToNav, FilePosition, FileSystemEdit, RangeInfo, SourceChange, TextRange};
@@ -226,34 +226,36 @@ fn rename_reference(
226 | (IdentifierKind::Ident, _) 226 | (IdentifierKind::Ident, _)
227 if def_is_lbl_or_lt => 227 if def_is_lbl_or_lt =>
228 { 228 {
229 mark::hit!(rename_not_a_lifetime_ident_ref); 229 cov_mark::hit!(rename_not_a_lifetime_ident_ref);
230 bail!("Invalid name `{}`: not a lifetime identifier", new_name) 230 bail!("Invalid name `{}`: not a lifetime identifier", new_name)
231 } 231 }
232 (IdentifierKind::Lifetime, _) if def_is_lbl_or_lt => mark::hit!(rename_lifetime), 232 (IdentifierKind::Lifetime, _) if def_is_lbl_or_lt => cov_mark::hit!(rename_lifetime),
233 (IdentifierKind::Lifetime, _) => { 233 (IdentifierKind::Lifetime, _) => {
234 mark::hit!(rename_not_an_ident_ref); 234 cov_mark::hit!(rename_not_an_ident_ref);
235 bail!("Invalid name `{}`: not an identifier", new_name) 235 bail!("Invalid name `{}`: not an identifier", new_name)
236 } 236 }
237 (IdentifierKind::ToSelf, Definition::Local(local)) if local.is_self(sema.db) => { 237 (IdentifierKind::ToSelf, Definition::Local(local)) if local.is_self(sema.db) => {
238 // no-op 238 // no-op
239 mark::hit!(rename_self_to_self); 239 cov_mark::hit!(rename_self_to_self);
240 return Ok(SourceChange::default()); 240 return Ok(SourceChange::default());
241 } 241 }
242 (ident_kind, Definition::Local(local)) if local.is_self(sema.db) => { 242 (ident_kind, Definition::Local(local)) if local.is_self(sema.db) => {
243 mark::hit!(rename_self_to_param); 243 cov_mark::hit!(rename_self_to_param);
244 return rename_self_to_param(sema, local, new_name, ident_kind); 244 return rename_self_to_param(sema, local, new_name, ident_kind);
245 } 245 }
246 (IdentifierKind::ToSelf, Definition::Local(local)) => { 246 (IdentifierKind::ToSelf, Definition::Local(local)) => {
247 mark::hit!(rename_to_self); 247 cov_mark::hit!(rename_to_self);
248 return rename_to_self(sema, local); 248 return rename_to_self(sema, local);
249 } 249 }
250 (IdentifierKind::ToSelf, _) => bail!("Invalid name `{}`: not an identifier", new_name), 250 (IdentifierKind::ToSelf, _) => bail!("Invalid name `{}`: not an identifier", new_name),
251 (IdentifierKind::Ident, _) | (IdentifierKind::Underscore, _) => mark::hit!(rename_ident), 251 (IdentifierKind::Ident, _) | (IdentifierKind::Underscore, _) => {
252 cov_mark::hit!(rename_ident)
253 }
252 } 254 }
253 255
254 let usages = def.usages(sema).all(); 256 let usages = def.usages(sema).all();
255 if !usages.is_empty() && ident_kind == IdentifierKind::Underscore { 257 if !usages.is_empty() && ident_kind == IdentifierKind::Underscore {
256 mark::hit!(rename_underscore_multiple); 258 cov_mark::hit!(rename_underscore_multiple);
257 bail!("Cannot rename reference to `_` as it is being referenced multiple times"); 259 bail!("Cannot rename reference to `_` as it is being referenced multiple times");
258 } 260 }
259 let mut source_change = SourceChange::default(); 261 let mut source_change = SourceChange::default();
@@ -444,7 +446,7 @@ fn source_edit_from_name_ref(
444 (Some(field_name), Some(init)) => { 446 (Some(field_name), Some(init)) => {
445 if field_name == *name_ref { 447 if field_name == *name_ref {
446 if init.text() == new_name { 448 if init.text() == new_name {
447 mark::hit!(test_rename_field_put_init_shorthand); 449 cov_mark::hit!(test_rename_field_put_init_shorthand);
448 // same names, we can use a shorthand here instead. 450 // same names, we can use a shorthand here instead.
449 // we do not want to erase attributes hence this range start 451 // we do not want to erase attributes hence this range start
450 let s = field_name.syntax().text_range().start(); 452 let s = field_name.syntax().text_range().start();
@@ -453,7 +455,7 @@ fn source_edit_from_name_ref(
453 } 455 }
454 } else if init == *name_ref { 456 } else if init == *name_ref {
455 if field_name.text() == new_name { 457 if field_name.text() == new_name {
456 mark::hit!(test_rename_local_put_init_shorthand); 458 cov_mark::hit!(test_rename_local_put_init_shorthand);
457 // same names, we can use a shorthand here instead. 459 // same names, we can use a shorthand here instead.
458 // we do not want to erase attributes hence this range start 460 // we do not want to erase attributes hence this range start
459 let s = field_name.syntax().text_range().start(); 461 let s = field_name.syntax().text_range().start();
@@ -467,12 +469,12 @@ fn source_edit_from_name_ref(
467 // FIXME: instead of splitting the shorthand, recursively trigger a rename of the 469 // FIXME: instead of splitting the shorthand, recursively trigger a rename of the
468 // other name https://github.com/rust-analyzer/rust-analyzer/issues/6547 470 // other name https://github.com/rust-analyzer/rust-analyzer/issues/6547
469 (None, Some(_)) if matches!(def, Definition::Field(_)) => { 471 (None, Some(_)) if matches!(def, Definition::Field(_)) => {
470 mark::hit!(test_rename_field_in_field_shorthand); 472 cov_mark::hit!(test_rename_field_in_field_shorthand);
471 let s = name_ref.syntax().text_range().start(); 473 let s = name_ref.syntax().text_range().start();
472 Some((TextRange::empty(s), format!("{}: ", new_name))) 474 Some((TextRange::empty(s), format!("{}: ", new_name)))
473 } 475 }
474 (None, Some(_)) if matches!(def, Definition::Local(_)) => { 476 (None, Some(_)) if matches!(def, Definition::Local(_)) => {
475 mark::hit!(test_rename_local_in_field_shorthand); 477 cov_mark::hit!(test_rename_local_in_field_shorthand);
476 let s = name_ref.syntax().text_range().end(); 478 let s = name_ref.syntax().text_range().end();
477 Some((TextRange::empty(s), format!(": {}", new_name))) 479 Some((TextRange::empty(s), format!(": {}", new_name)))
478 } 480 }
@@ -486,7 +488,7 @@ fn source_edit_from_name_ref(
486 (Some(field_name), Some(ast::Pat::IdentPat(pat))) if field_name == *name_ref => { 488 (Some(field_name), Some(ast::Pat::IdentPat(pat))) if field_name == *name_ref => {
487 // field name is being renamed 489 // field name is being renamed
488 if pat.name().map_or(false, |it| it.text() == new_name) { 490 if pat.name().map_or(false, |it| it.text() == new_name) {
489 mark::hit!(test_rename_field_put_init_shorthand_pat); 491 cov_mark::hit!(test_rename_field_put_init_shorthand_pat);
490 // same names, we can use a shorthand here instead/ 492 // same names, we can use a shorthand here instead/
491 // we do not want to erase attributes hence this range start 493 // we do not want to erase attributes hence this range start
492 let s = field_name.syntax().text_range().start(); 494 let s = field_name.syntax().text_range().start();
@@ -538,7 +540,7 @@ fn source_edit_from_def(
538mod tests { 540mod tests {
539 use expect_test::{expect, Expect}; 541 use expect_test::{expect, Expect};
540 use stdx::trim_indent; 542 use stdx::trim_indent;
541 use test_utils::{assert_eq_text, mark}; 543 use test_utils::assert_eq_text;
542 use text_edit::TextEdit; 544 use text_edit::TextEdit;
543 545
544 use crate::{fixture, FileId}; 546 use crate::{fixture, FileId};
@@ -627,7 +629,7 @@ mod tests {
627 629
628 #[test] 630 #[test]
629 fn test_rename_to_invalid_identifier_lifetime() { 631 fn test_rename_to_invalid_identifier_lifetime() {
630 mark::check!(rename_not_an_ident_ref); 632 cov_mark::check!(rename_not_an_ident_ref);
631 check( 633 check(
632 "'foo", 634 "'foo",
633 r#"fn main() { let i$0 = 1; }"#, 635 r#"fn main() { let i$0 = 1; }"#,
@@ -637,7 +639,7 @@ mod tests {
637 639
638 #[test] 640 #[test]
639 fn test_rename_to_invalid_identifier_lifetime2() { 641 fn test_rename_to_invalid_identifier_lifetime2() {
640 mark::check!(rename_not_a_lifetime_ident_ref); 642 cov_mark::check!(rename_not_a_lifetime_ident_ref);
641 check( 643 check(
642 "foo", 644 "foo",
643 r#"fn main<'a>(_: &'a$0 ()) {}"#, 645 r#"fn main<'a>(_: &'a$0 ()) {}"#,
@@ -647,7 +649,7 @@ mod tests {
647 649
648 #[test] 650 #[test]
649 fn test_rename_to_underscore_invalid() { 651 fn test_rename_to_underscore_invalid() {
650 mark::check!(rename_underscore_multiple); 652 cov_mark::check!(rename_underscore_multiple);
651 check( 653 check(
652 "_", 654 "_",
653 r#"fn main(foo$0: ()) {foo;}"#, 655 r#"fn main(foo$0: ()) {foo;}"#,
@@ -666,7 +668,7 @@ mod tests {
666 668
667 #[test] 669 #[test]
668 fn test_rename_for_local() { 670 fn test_rename_for_local() {
669 mark::check!(rename_ident); 671 cov_mark::check!(rename_ident);
670 check( 672 check(
671 "k", 673 "k",
672 r#" 674 r#"
@@ -829,7 +831,7 @@ impl Foo {
829 831
830 #[test] 832 #[test]
831 fn test_rename_field_in_field_shorthand() { 833 fn test_rename_field_in_field_shorthand() {
832 mark::check!(test_rename_field_in_field_shorthand); 834 cov_mark::check!(test_rename_field_in_field_shorthand);
833 check( 835 check(
834 "j", 836 "j",
835 r#" 837 r#"
@@ -855,7 +857,7 @@ impl Foo {
855 857
856 #[test] 858 #[test]
857 fn test_rename_local_in_field_shorthand() { 859 fn test_rename_local_in_field_shorthand() {
858 mark::check!(test_rename_local_in_field_shorthand); 860 cov_mark::check!(test_rename_local_in_field_shorthand);
859 check( 861 check(
860 "j", 862 "j",
861 r#" 863 r#"
@@ -1261,7 +1263,7 @@ fn foo(f: foo::Foo) {
1261 1263
1262 #[test] 1264 #[test]
1263 fn test_parameter_to_self() { 1265 fn test_parameter_to_self() {
1264 mark::check!(rename_to_self); 1266 cov_mark::check!(rename_to_self);
1265 check( 1267 check(
1266 "self", 1268 "self",
1267 r#" 1269 r#"
@@ -1401,7 +1403,7 @@ impl Foo {
1401 1403
1402 #[test] 1404 #[test]
1403 fn test_owned_self_to_parameter() { 1405 fn test_owned_self_to_parameter() {
1404 mark::check!(rename_self_to_param); 1406 cov_mark::check!(rename_self_to_param);
1405 check( 1407 check(
1406 "foo", 1408 "foo",
1407 r#" 1409 r#"
@@ -1454,7 +1456,7 @@ impl Foo {
1454 1456
1455 #[test] 1457 #[test]
1456 fn test_rename_field_put_init_shorthand() { 1458 fn test_rename_field_put_init_shorthand() {
1457 mark::check!(test_rename_field_put_init_shorthand); 1459 cov_mark::check!(test_rename_field_put_init_shorthand);
1458 check( 1460 check(
1459 "bar", 1461 "bar",
1460 r#" 1462 r#"
@@ -1476,7 +1478,7 @@ fn foo(bar: i32) -> Foo {
1476 1478
1477 #[test] 1479 #[test]
1478 fn test_rename_local_put_init_shorthand() { 1480 fn test_rename_local_put_init_shorthand() {
1479 mark::check!(test_rename_local_put_init_shorthand); 1481 cov_mark::check!(test_rename_local_put_init_shorthand);
1480 check( 1482 check(
1481 "i", 1483 "i",
1482 r#" 1484 r#"
@@ -1498,7 +1500,7 @@ fn foo(i: i32) -> Foo {
1498 1500
1499 #[test] 1501 #[test]
1500 fn test_struct_field_pat_into_shorthand() { 1502 fn test_struct_field_pat_into_shorthand() {
1501 mark::check!(test_rename_field_put_init_shorthand_pat); 1503 cov_mark::check!(test_rename_field_put_init_shorthand_pat);
1502 check( 1504 check(
1503 "baz", 1505 "baz",
1504 r#" 1506 r#"
@@ -1610,7 +1612,7 @@ fn foo(foo: Foo) {
1610 1612
1611 #[test] 1613 #[test]
1612 fn test_rename_lifetimes() { 1614 fn test_rename_lifetimes() {
1613 mark::check!(rename_lifetime); 1615 cov_mark::check!(rename_lifetime);
1614 check( 1616 check(
1615 "'yeeee", 1617 "'yeeee",
1616 r#" 1618 r#"
@@ -1698,7 +1700,7 @@ fn foo<'a>() -> &'a () {
1698 1700
1699 #[test] 1701 #[test]
1700 fn test_self_to_self() { 1702 fn test_self_to_self() {
1701 mark::check!(rename_self_to_self); 1703 cov_mark::check!(rename_self_to_self);
1702 check( 1704 check(
1703 "self", 1705 "self",
1704 r#" 1706 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::{
9 ast::{self, AstNode, AttrsOwner}, 9 ast::{self, AstNode, AttrsOwner},
10 match_ast, SyntaxNode, 10 match_ast, SyntaxNode,
11}; 11};
12use test_utils::mark;
13 12
14use crate::{ 13use crate::{
15 display::{ToNav, TryToNav}, 14 display::{ToNav, TryToNav},
@@ -130,7 +129,9 @@ fn runnables_mod(sema: &Semantics<RootDatabase>, acc: &mut Vec<Runnable>, module
130 if let hir::ModuleDef::Module(submodule) = def { 129 if let hir::ModuleDef::Module(submodule) = def {
131 match submodule.definition_source(sema.db).value { 130 match submodule.definition_source(sema.db).value {
132 hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule), 131 hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule),
133 hir::ModuleSource::SourceFile(_) => mark::hit!(dont_recurse_in_outline_submodules), 132 hir::ModuleSource::SourceFile(_) => {
133 cov_mark::hit!(dont_recurse_in_outline_submodules)
134 }
134 hir::ModuleSource::BlockExpr(_) => {} // inner items aren't runnable 135 hir::ModuleSource::BlockExpr(_) => {} // inner items aren't runnable
135 } 136 }
136 } 137 }
@@ -328,7 +329,6 @@ fn has_test_function_or_multiple_test_submodules(
328#[cfg(test)] 329#[cfg(test)]
329mod tests { 330mod tests {
330 use expect_test::{expect, Expect}; 331 use expect_test::{expect, Expect};
331 use test_utils::mark;
332 332
333 use crate::fixture; 333 use crate::fixture;
334 334
@@ -1056,7 +1056,7 @@ mod tests {
1056 1056
1057 #[test] 1057 #[test]
1058 fn dont_recurse_in_outline_submodules() { 1058 fn dont_recurse_in_outline_submodules() {
1059 mark::check!(dont_recurse_in_outline_submodules); 1059 cov_mark::check!(dont_recurse_in_outline_submodules);
1060 check( 1060 check(
1061 r#" 1061 r#"
1062//- /lib.rs 1062//- /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::{
9 SyntaxKind::*, 9 SyntaxKind::*,
10 SyntaxToken, TextRange, TextSize, TokenAtOffset, 10 SyntaxToken, TextRange, TextSize, TokenAtOffset,
11}; 11};
12use test_utils::mark; 12
13use text_edit::TextEdit; 13use text_edit::TextEdit;
14 14
15// Feature: On Enter 15// Feature: On Enter
@@ -55,7 +55,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Text
55 // Continuing single-line non-doc comments (like this one :) ) is annoying 55 // Continuing single-line non-doc comments (like this one :) ) is annoying
56 if prefix == "//" && comment_range.end() == position.offset { 56 if prefix == "//" && comment_range.end() == position.offset {
57 if comment.text().ends_with(' ') { 57 if comment.text().ends_with(' ') {
58 mark::hit!(continues_end_of_line_comment_with_space); 58 cov_mark::hit!(continues_end_of_line_comment_with_space);
59 remove_trailing_whitespace = true; 59 remove_trailing_whitespace = true;
60 } else if !followed_by_comment(&comment) { 60 } else if !followed_by_comment(&comment) {
61 return None; 61 return None;
@@ -109,7 +109,7 @@ fn node_indent(file: &SourceFile, token: &SyntaxToken) -> Option<SmolStr> {
109#[cfg(test)] 109#[cfg(test)]
110mod tests { 110mod tests {
111 use stdx::trim_indent; 111 use stdx::trim_indent;
112 use test_utils::{assert_eq_text, mark}; 112 use test_utils::assert_eq_text;
113 113
114 use crate::fixture; 114 use crate::fixture;
115 115
@@ -238,7 +238,7 @@ fn main() {
238 238
239 #[test] 239 #[test]
240 fn continues_end_of_line_comment_with_space() { 240 fn continues_end_of_line_comment_with_space() {
241 mark::check!(continues_end_of_line_comment_with_space); 241 cov_mark::check!(continues_end_of_line_comment_with_space);
242 do_check( 242 do_check(
243 r#" 243 r#"
244fn main() { 244fn 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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13rustc-hash = "1.1.0" 14rustc-hash = "1.1.0"
14itertools = "0.10.0" 15itertools = "0.10.0"
15either = "1.6.1" 16either = "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 @@
1use ide_db::defs::{Definition, NameRefClass}; 1use ide_db::defs::{Definition, NameRefClass};
2use syntax::{ast, AstNode, SyntaxKind, T}; 2use syntax::{ast, AstNode, SyntaxKind, T};
3use test_utils::mark;
4 3
5use crate::{ 4use crate::{
6 assist_context::{AssistContext, Assists}, 5 assist_context::{AssistContext, Assists},
@@ -30,13 +29,13 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
30 if arg_list.args().count() > 0 { 29 if arg_list.args().count() > 0 {
31 return None; 30 return None;
32 } 31 }
33 mark::hit!(add_turbo_fish_after_call); 32 cov_mark::hit!(add_turbo_fish_after_call);
34 mark::hit!(add_type_ascription_after_call); 33 cov_mark::hit!(add_type_ascription_after_call);
35 arg_list.l_paren_token()?.prev_token().filter(|it| it.kind() == SyntaxKind::IDENT) 34 arg_list.l_paren_token()?.prev_token().filter(|it| it.kind() == SyntaxKind::IDENT)
36 })?; 35 })?;
37 let next_token = ident.next_token()?; 36 let next_token = ident.next_token()?;
38 if next_token.kind() == T![::] { 37 if next_token.kind() == T![::] {
39 mark::hit!(add_turbo_fish_one_fish_is_enough); 38 cov_mark::hit!(add_turbo_fish_one_fish_is_enough);
40 return None; 39 return None;
41 } 40 }
42 let name_ref = ast::NameRef::cast(ident.parent())?; 41 let name_ref = ast::NameRef::cast(ident.parent())?;
@@ -50,7 +49,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
50 }; 49 };
51 let generics = hir::GenericDef::Function(fun).params(ctx.sema.db); 50 let generics = hir::GenericDef::Function(fun).params(ctx.sema.db);
52 if generics.is_empty() { 51 if generics.is_empty() {
53 mark::hit!(add_turbo_fish_non_generic); 52 cov_mark::hit!(add_turbo_fish_non_generic);
54 return None; 53 return None;
55 } 54 }
56 55
@@ -67,7 +66,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
67 }, 66 },
68 )? 67 )?
69 } else { 68 } else {
70 mark::hit!(add_type_ascription_already_typed); 69 cov_mark::hit!(add_type_ascription_already_typed);
71 } 70 }
72 } 71 }
73 72
@@ -87,7 +86,6 @@ mod tests {
87 use crate::tests::{check_assist, check_assist_by_label, check_assist_not_applicable}; 86 use crate::tests::{check_assist, check_assist_by_label, check_assist_not_applicable};
88 87
89 use super::*; 88 use super::*;
90 use test_utils::mark;
91 89
92 #[test] 90 #[test]
93 fn add_turbo_fish_function() { 91 fn add_turbo_fish_function() {
@@ -110,7 +108,7 @@ fn main() {
110 108
111 #[test] 109 #[test]
112 fn add_turbo_fish_after_call() { 110 fn add_turbo_fish_after_call() {
113 mark::check!(add_turbo_fish_after_call); 111 cov_mark::check!(add_turbo_fish_after_call);
114 check_assist( 112 check_assist(
115 add_turbo_fish, 113 add_turbo_fish,
116 r#" 114 r#"
@@ -155,7 +153,7 @@ fn main() {
155 153
156 #[test] 154 #[test]
157 fn add_turbo_fish_one_fish_is_enough() { 155 fn add_turbo_fish_one_fish_is_enough() {
158 mark::check!(add_turbo_fish_one_fish_is_enough); 156 cov_mark::check!(add_turbo_fish_one_fish_is_enough);
159 check_assist_not_applicable( 157 check_assist_not_applicable(
160 add_turbo_fish, 158 add_turbo_fish,
161 r#" 159 r#"
@@ -169,7 +167,7 @@ fn main() {
169 167
170 #[test] 168 #[test]
171 fn add_turbo_fish_non_generic() { 169 fn add_turbo_fish_non_generic() {
172 mark::check!(add_turbo_fish_non_generic); 170 cov_mark::check!(add_turbo_fish_non_generic);
173 check_assist_not_applicable( 171 check_assist_not_applicable(
174 add_turbo_fish, 172 add_turbo_fish,
175 r#" 173 r#"
@@ -203,7 +201,7 @@ fn main() {
203 201
204 #[test] 202 #[test]
205 fn add_type_ascription_after_call() { 203 fn add_type_ascription_after_call() {
206 mark::check!(add_type_ascription_after_call); 204 cov_mark::check!(add_type_ascription_after_call);
207 check_assist_by_label( 205 check_assist_by_label(
208 add_turbo_fish, 206 add_turbo_fish,
209 r#" 207 r#"
@@ -250,7 +248,7 @@ fn main() {
250 248
251 #[test] 249 #[test]
252 fn add_type_ascription_already_typed() { 250 fn add_type_ascription_already_typed() {
253 mark::check!(add_type_ascription_already_typed); 251 cov_mark::check!(add_type_ascription_already_typed);
254 check_assist( 252 check_assist(
255 add_turbo_fish, 253 add_turbo_fish,
256 r#" 254 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 @@
1use syntax::ast::{self, AstNode}; 1use syntax::ast::{self, AstNode};
2use test_utils::mark;
3 2
4use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists}; 3use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists};
5 4
@@ -64,10 +63,10 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<(
64 edit.replace(lhs_range, not_lhs.syntax().text()); 63 edit.replace(lhs_range, not_lhs.syntax().text());
65 edit.replace(rhs_range, not_rhs.syntax().text()); 64 edit.replace(rhs_range, not_rhs.syntax().text());
66 if let Some(neg_expr) = neg_expr { 65 if let Some(neg_expr) = neg_expr {
67 mark::hit!(demorgan_double_negation); 66 cov_mark::hit!(demorgan_double_negation);
68 edit.replace(neg_expr.op_token().unwrap().text_range(), ""); 67 edit.replace(neg_expr.op_token().unwrap().text_range(), "");
69 } else { 68 } else {
70 mark::hit!(demorgan_double_parens); 69 cov_mark::hit!(demorgan_double_parens);
71 edit.replace(paren_expr.l_paren_token().unwrap().text_range(), "!("); 70 edit.replace(paren_expr.l_paren_token().unwrap().text_range(), "!(");
72 } 71 }
73 } else { 72 } else {
@@ -90,7 +89,6 @@ fn opposite_logic_op(kind: ast::BinOp) -> Option<&'static str> {
90#[cfg(test)] 89#[cfg(test)]
91mod tests { 90mod tests {
92 use ide_db::helpers::FamousDefs; 91 use ide_db::helpers::FamousDefs;
93 use test_utils::mark;
94 92
95 use super::*; 93 use super::*;
96 94
@@ -188,13 +186,13 @@ fn f() {
188 186
189 #[test] 187 #[test]
190 fn demorgan_doesnt_double_negation() { 188 fn demorgan_doesnt_double_negation() {
191 mark::check!(demorgan_double_negation); 189 cov_mark::check!(demorgan_double_negation);
192 check_assist(apply_demorgan, "fn f() { !(x ||$0 x) }", "fn f() { (!x && !x) }") 190 check_assist(apply_demorgan, "fn f() { !(x ||$0 x) }", "fn f() { (!x && !x) }")
193 } 191 }
194 192
195 #[test] 193 #[test]
196 fn demorgan_doesnt_double_parens() { 194 fn demorgan_doesnt_double_parens() {
197 mark::check!(demorgan_double_parens); 195 cov_mark::check!(demorgan_double_parens);
198 check_assist(apply_demorgan, "fn f() { (x ||$0 x) }", "fn f() { !(!x && !x) }") 196 check_assist(apply_demorgan, "fn f() { (x ||$0 x) }", "fn f() { !(!x && !x) }")
199 } 197 }
200} 198}
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::{
4 SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, VISIBILITY}, 4 SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, VISIBILITY},
5 T, 5 T,
6}; 6};
7use test_utils::mark;
8 7
9use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; 8use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists};
10 9
@@ -56,7 +55,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
56 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { 55 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() {
57 let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?; 56 let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?;
58 if field.name()? != field_name { 57 if field.name()? != field_name {
59 mark::hit!(change_visibility_field_false_positive); 58 cov_mark::hit!(change_visibility_field_false_positive);
60 return None; 59 return None;
61 } 60 }
62 if field.visibility().is_some() { 61 if field.visibility().is_some() {
@@ -110,8 +109,6 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> {
110 109
111#[cfg(test)] 110#[cfg(test)]
112mod tests { 111mod tests {
113 use test_utils::mark;
114
115 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 112 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
116 113
117 use super::*; 114 use super::*;
@@ -139,7 +136,7 @@ mod tests {
139 136
140 #[test] 137 #[test]
141 fn change_visibility_field_false_positive() { 138 fn change_visibility_field_false_positive() {
142 mark::check!(change_visibility_field_false_positive); 139 cov_mark::check!(change_visibility_field_false_positive);
143 check_assist_not_applicable( 140 check_assist_not_applicable(
144 change_visibility, 141 change_visibility,
145 r"struct S { field: [(); { let $0x = ();}] }", 142 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::{
20 SyntaxKind::{self, BLOCK_EXPR, BREAK_EXPR, COMMENT, PATH_EXPR, RETURN_EXPR}, 20 SyntaxKind::{self, BLOCK_EXPR, BREAK_EXPR, COMMENT, PATH_EXPR, RETURN_EXPR},
21 SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, WalkEvent, T, 21 SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, WalkEvent, T,
22}; 22};
23use test_utils::mark;
24 23
25use crate::{ 24use crate::{
26 assist_context::{AssistContext, Assists}, 25 assist_context::{AssistContext, Assists},
@@ -59,7 +58,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option
59 58
60 let node = ctx.covering_element(); 59 let node = ctx.covering_element();
61 if node.kind() == COMMENT { 60 if node.kind() == COMMENT {
62 mark::hit!(extract_function_in_comment_is_not_applicable); 61 cov_mark::hit!(extract_function_in_comment_is_not_applicable);
63 return None; 62 return None;
64 } 63 }
65 64
@@ -197,14 +196,14 @@ fn external_control_flow(ctx: &AssistContext, body: &FunctionBody) -> Option<Con
197 if let Some(kind) = expr_err_kind(&expr, ctx) { 196 if let Some(kind) = expr_err_kind(&expr, ctx) {
198 Some(FlowKind::TryReturn { expr, kind }) 197 Some(FlowKind::TryReturn { expr, kind })
199 } else { 198 } else {
200 mark::hit!(external_control_flow_try_and_return_non_err); 199 cov_mark::hit!(external_control_flow_try_and_return_non_err);
201 return None; 200 return None;
202 } 201 }
203 } 202 }
204 None => return None, 203 None => return None,
205 }, 204 },
206 (Some(_), _, _, _) => { 205 (Some(_), _, _, _) => {
207 mark::hit!(external_control_flow_try_and_bc); 206 cov_mark::hit!(external_control_flow_try_and_bc);
208 return None; 207 return None;
209 } 208 }
210 (None, Some(r), None, None) => match r.expr() { 209 (None, Some(r), None, None) => match r.expr() {
@@ -212,11 +211,11 @@ fn external_control_flow(ctx: &AssistContext, body: &FunctionBody) -> Option<Con
212 None => Some(FlowKind::Return), 211 None => Some(FlowKind::Return),
213 }, 212 },
214 (None, Some(_), _, _) => { 213 (None, Some(_), _, _) => {
215 mark::hit!(external_control_flow_return_and_bc); 214 cov_mark::hit!(external_control_flow_return_and_bc);
216 return None; 215 return None;
217 } 216 }
218 (None, None, Some(_), Some(_)) => { 217 (None, None, Some(_), Some(_)) => {
219 mark::hit!(external_control_flow_break_and_continue); 218 cov_mark::hit!(external_control_flow_break_and_continue);
220 return None; 219 return None;
221 } 220 }
222 (None, None, Some(b), None) => match b.expr() { 221 (None, None, Some(b), None) => match b.expr() {
@@ -1837,7 +1836,7 @@ fn $0fun_name(n: u32) -> u32 {
1837 1836
1838 #[test] 1837 #[test]
1839 fn in_comment_is_not_applicable() { 1838 fn in_comment_is_not_applicable() {
1840 mark::check!(extract_function_in_comment_is_not_applicable); 1839 cov_mark::check!(extract_function_in_comment_is_not_applicable);
1841 check_assist_not_applicable(extract_function, r"fn main() { 1 + /* $0comment$0 */ 1; }"); 1840 check_assist_not_applicable(extract_function, r"fn main() { 1 + /* $0comment$0 */ 1; }");
1842 } 1841 }
1843 1842
@@ -2822,7 +2821,7 @@ fn $0fun_name(n: i32) -> Result<i32, i64> {
2822 2821
2823 #[test] 2822 #[test]
2824 fn break_and_continue() { 2823 fn break_and_continue() {
2825 mark::check!(external_control_flow_break_and_continue); 2824 cov_mark::check!(external_control_flow_break_and_continue);
2826 check_assist_not_applicable( 2825 check_assist_not_applicable(
2827 extract_function, 2826 extract_function,
2828 r##" 2827 r##"
@@ -2842,7 +2841,7 @@ fn foo() {
2842 2841
2843 #[test] 2842 #[test]
2844 fn return_and_break() { 2843 fn return_and_break() {
2845 mark::check!(external_control_flow_return_and_bc); 2844 cov_mark::check!(external_control_flow_return_and_bc);
2846 check_assist_not_applicable( 2845 check_assist_not_applicable(
2847 extract_function, 2846 extract_function,
2848 r##" 2847 r##"
@@ -3341,7 +3340,7 @@ fn $0fun_name() -> Result<i32, i64> {
3341 3340
3342 #[test] 3341 #[test]
3343 fn try_and_break() { 3342 fn try_and_break() {
3344 mark::check!(external_control_flow_try_and_bc); 3343 cov_mark::check!(external_control_flow_try_and_bc);
3345 check_assist_not_applicable( 3344 check_assist_not_applicable(
3346 extract_function, 3345 extract_function,
3347 r##" 3346 r##"
@@ -3363,7 +3362,7 @@ fn foo() -> Option<()> {
3363 3362
3364 #[test] 3363 #[test]
3365 fn try_and_return_ok() { 3364 fn try_and_return_ok() {
3366 mark::check!(external_control_flow_try_and_return_non_err); 3365 cov_mark::check!(external_control_flow_try_and_return_non_err);
3367 check_assist_not_applicable( 3366 check_assist_not_applicable(
3368 extract_function, 3367 extract_function,
3369 r##" 3368 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::{
6 }, 6 },
7 SyntaxNode, 7 SyntaxNode,
8}; 8};
9use test_utils::mark;
10 9
11use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists}; 10use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists};
12 11
@@ -32,7 +31,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
32 } 31 }
33 let node = ctx.covering_element(); 32 let node = ctx.covering_element();
34 if node.kind() == COMMENT { 33 if node.kind() == COMMENT {
35 mark::hit!(extract_var_in_comment_is_not_applicable); 34 cov_mark::hit!(extract_var_in_comment_is_not_applicable);
36 return None; 35 return None;
37 } 36 }
38 let to_extract = node.ancestors().find_map(valid_target_expr)?; 37 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
69 format_to!(buf, "{}", to_extract.syntax()); 68 format_to!(buf, "{}", to_extract.syntax());
70 69
71 if let Anchor::Replace(stmt) = anchor { 70 if let Anchor::Replace(stmt) = anchor {
72 mark::hit!(test_extract_var_expr_stmt); 71 cov_mark::hit!(test_extract_var_expr_stmt);
73 if stmt.semicolon_token().is_none() { 72 if stmt.semicolon_token().is_none() {
74 buf.push_str(";"); 73 buf.push_str(";");
75 } 74 }
@@ -142,7 +141,7 @@ impl Anchor {
142 node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.tail_expr()) 141 node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.tail_expr())
143 { 142 {
144 if expr.syntax() == &node { 143 if expr.syntax() == &node {
145 mark::hit!(test_extract_var_last_expr); 144 cov_mark::hit!(test_extract_var_last_expr);
146 return Some(Anchor::Before(node)); 145 return Some(Anchor::Before(node));
147 } 146 }
148 } 147 }
@@ -175,8 +174,6 @@ impl Anchor {
175 174
176#[cfg(test)] 175#[cfg(test)]
177mod tests { 176mod tests {
178 use test_utils::mark;
179
180 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 177 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
181 178
182 use super::*; 179 use super::*;
@@ -199,13 +196,13 @@ fn foo() {
199 196
200 #[test] 197 #[test]
201 fn extract_var_in_comment_is_not_applicable() { 198 fn extract_var_in_comment_is_not_applicable() {
202 mark::check!(extract_var_in_comment_is_not_applicable); 199 cov_mark::check!(extract_var_in_comment_is_not_applicable);
203 check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }"); 200 check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }");
204 } 201 }
205 202
206 #[test] 203 #[test]
207 fn test_extract_var_expr_stmt() { 204 fn test_extract_var_expr_stmt() {
208 mark::check!(test_extract_var_expr_stmt); 205 cov_mark::check!(test_extract_var_expr_stmt);
209 check_assist( 206 check_assist(
210 extract_variable, 207 extract_variable,
211 r#" 208 r#"
@@ -250,7 +247,7 @@ fn foo() {
250 247
251 #[test] 248 #[test]
252 fn test_extract_var_last_expr() { 249 fn test_extract_var_last_expr() {
253 mark::check!(test_extract_var_last_expr); 250 cov_mark::check!(test_extract_var_last_expr);
254 check_assist( 251 check_assist(
255 extract_variable, 252 extract_variable,
256 r#" 253 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};
5use ide_db::RootDatabase; 5use ide_db::RootDatabase;
6use itertools::Itertools; 6use itertools::Itertools;
7use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; 7use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
8use test_utils::mark;
9 8
10use crate::{ 9use crate::{
11 utils::{does_pat_match_variant, render_snippet, Cursor}, 10 utils::{does_pat_match_variant, render_snippet, Cursor},
@@ -62,7 +61,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
62 .collect::<Vec<_>>(); 61 .collect::<Vec<_>>();
63 if Some(enum_def) == FamousDefs(&ctx.sema, Some(module.krate())).core_option_Option() { 62 if Some(enum_def) == FamousDefs(&ctx.sema, Some(module.krate())).core_option_Option() {
64 // Match `Some` variant first. 63 // Match `Some` variant first.
65 mark::hit!(option_order); 64 cov_mark::hit!(option_order);
66 variants.reverse() 65 variants.reverse()
67 } 66 }
68 variants 67 variants
@@ -195,7 +194,6 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::Variant) -> Optio
195#[cfg(test)] 194#[cfg(test)]
196mod tests { 195mod tests {
197 use ide_db::helpers::FamousDefs; 196 use ide_db::helpers::FamousDefs;
198 use test_utils::mark;
199 197
200 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 198 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
201 199
@@ -730,7 +728,7 @@ fn main() {
730 728
731 #[test] 729 #[test]
732 fn option_order() { 730 fn option_order() {
733 mark::check!(option_order); 731 cov_mark::check!(option_order);
734 let before = r#" 732 let before = r#"
735fn foo(opt: Option<i32>) { 733fn foo(opt: Option<i32>) {
736 match opt$0 { 734 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 @@
1use ide_db::helpers::FamousDefs; 1use ide_db::helpers::FamousDefs;
2use ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use syntax::ast::{self, AstNode, NameOwner}; 3use syntax::ast::{self, AstNode, NameOwner};
4use test_utils::mark;
5 4
6use crate::{AssistContext, AssistId, AssistKind, Assists}; 5use crate::{AssistContext, AssistId, AssistKind, Assists};
7 6
@@ -38,12 +37,12 @@ pub(crate) fn generate_default_from_enum_variant(
38 let variant_name = variant.name()?; 37 let variant_name = variant.name()?;
39 let enum_name = variant.parent_enum().name()?; 38 let enum_name = variant.parent_enum().name()?;
40 if !matches!(variant.kind(), ast::StructKind::Unit) { 39 if !matches!(variant.kind(), ast::StructKind::Unit) {
41 mark::hit!(test_gen_default_on_non_unit_variant_not_implemented); 40 cov_mark::hit!(test_gen_default_on_non_unit_variant_not_implemented);
42 return None; 41 return None;
43 } 42 }
44 43
45 if existing_default_impl(&ctx.sema, &variant).is_some() { 44 if existing_default_impl(&ctx.sema, &variant).is_some() {
46 mark::hit!(test_gen_default_impl_already_exists); 45 cov_mark::hit!(test_gen_default_impl_already_exists);
47 return None; 46 return None;
48 } 47 }
49 48
@@ -89,8 +88,6 @@ fn existing_default_impl(
89 88
90#[cfg(test)] 89#[cfg(test)]
91mod tests { 90mod tests {
92 use test_utils::mark;
93
94 use crate::tests::{check_assist, check_assist_not_applicable}; 91 use crate::tests::{check_assist, check_assist_not_applicable};
95 92
96 use super::*; 93 use super::*;
@@ -127,7 +124,7 @@ impl Default for Variant {
127 124
128 #[test] 125 #[test]
129 fn test_generate_default_already_implemented() { 126 fn test_generate_default_already_implemented() {
130 mark::check!(test_gen_default_impl_already_exists); 127 cov_mark::check!(test_gen_default_impl_already_exists);
131 check_not_applicable( 128 check_not_applicable(
132 r#" 129 r#"
133enum Variant { 130enum Variant {
@@ -146,7 +143,7 @@ impl Default for Variant {
146 143
147 #[test] 144 #[test]
148 fn test_add_from_impl_no_element() { 145 fn test_add_from_impl_no_element() {
149 mark::check!(test_gen_default_on_non_unit_variant_not_implemented); 146 cov_mark::check!(test_gen_default_on_non_unit_variant_not_implemented);
150 check_not_applicable( 147 check_not_applicable(
151 r#" 148 r#"
152enum Variant { 149enum 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::{
7 ast::{self, Impl, NameOwner}, 7 ast::{self, Impl, NameOwner},
8 AstNode, 8 AstNode,
9}; 9};
10use test_utils::mark;
11 10
12// Assist: generate_default_from_new 11// Assist: generate_default_from_new
13// 12//
@@ -43,19 +42,19 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext)
43 let fn_name = fn_node.name()?; 42 let fn_name = fn_node.name()?;
44 43
45 if fn_name.text() != "new" { 44 if fn_name.text() != "new" {
46 mark::hit!(other_function_than_new); 45 cov_mark::hit!(other_function_than_new);
47 return None; 46 return None;
48 } 47 }
49 48
50 if fn_node.param_list()?.params().next().is_some() { 49 if fn_node.param_list()?.params().next().is_some() {
51 mark::hit!(new_function_with_parameters); 50 cov_mark::hit!(new_function_with_parameters);
52 return None; 51 return None;
53 } 52 }
54 53
55 let impl_ = fn_node.syntax().ancestors().into_iter().find_map(ast::Impl::cast)?; 54 let impl_ = fn_node.syntax().ancestors().into_iter().find_map(ast::Impl::cast)?;
56 if is_default_implemented(ctx, &impl_) { 55 if is_default_implemented(ctx, &impl_) {
57 mark::hit!(default_block_is_already_present); 56 cov_mark::hit!(default_block_is_already_present);
58 mark::hit!(struct_in_module_with_default); 57 cov_mark::hit!(struct_in_module_with_default);
59 return None; 58 return None;
60 } 59 }
61 60
@@ -178,7 +177,7 @@ impl Default for Test {
178 177
179 #[test] 178 #[test]
180 fn new_function_with_parameters() { 179 fn new_function_with_parameters() {
181 mark::check!(new_function_with_parameters); 180 cov_mark::check!(new_function_with_parameters);
182 check_not_applicable( 181 check_not_applicable(
183 r#" 182 r#"
184struct Example { _inner: () } 183struct Example { _inner: () }
@@ -194,7 +193,7 @@ impl Example {
194 193
195 #[test] 194 #[test]
196 fn other_function_than_new() { 195 fn other_function_than_new() {
197 mark::check!(other_function_than_new); 196 cov_mark::check!(other_function_than_new);
198 check_not_applicable( 197 check_not_applicable(
199 r#" 198 r#"
200struct Example { _inner: () } 199struct Example { _inner: () }
@@ -211,7 +210,7 @@ impl Example {
211 210
212 #[test] 211 #[test]
213 fn default_block_is_already_present() { 212 fn default_block_is_already_present() {
214 mark::check!(default_block_is_already_present); 213 cov_mark::check!(default_block_is_already_present);
215 check_not_applicable( 214 check_not_applicable(
216 r#" 215 r#"
217struct Example { _inner: () } 216struct Example { _inner: () }
@@ -340,7 +339,7 @@ impl Default for Example {
340 339
341 #[test] 340 #[test]
342 fn struct_in_module_with_default() { 341 fn struct_in_module_with_default() {
343 mark::check!(struct_in_module_with_default); 342 cov_mark::check!(struct_in_module_with_default);
344 check_not_applicable( 343 check_not_applicable(
345 r#" 344 r#"
346mod test { 345mod 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 @@
1use ide_db::helpers::FamousDefs; 1use ide_db::helpers::FamousDefs;
2use ide_db::RootDatabase; 2use ide_db::RootDatabase;
3use syntax::ast::{self, AstNode, NameOwner}; 3use syntax::ast::{self, AstNode, NameOwner};
4use test_utils::mark;
5 4
6use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists}; 5use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists};
7 6
@@ -44,7 +43,7 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext
44 }; 43 };
45 44
46 if existing_from_impl(&ctx.sema, &variant).is_some() { 45 if existing_from_impl(&ctx.sema, &variant).is_some() {
47 mark::hit!(test_add_from_impl_already_exists); 46 cov_mark::hit!(test_add_from_impl_already_exists);
48 return None; 47 return None;
49 } 48 }
50 49
@@ -103,8 +102,6 @@ fn existing_from_impl(
103 102
104#[cfg(test)] 103#[cfg(test)]
105mod tests { 104mod tests {
106 use test_utils::mark;
107
108 use crate::tests::{check_assist, check_assist_not_applicable}; 105 use crate::tests::{check_assist, check_assist_not_applicable};
109 106
110 use super::*; 107 use super::*;
@@ -172,7 +169,7 @@ impl From<u32> for A {
172 169
173 #[test] 170 #[test]
174 fn test_add_from_impl_already_exists() { 171 fn test_add_from_impl_already_exists() {
175 mark::check!(test_add_from_impl_already_exists); 172 cov_mark::check!(test_add_from_impl_already_exists);
176 check_not_applicable( 173 check_not_applicable(
177 r#" 174 r#"
178enum A { $0One(u32), } 175enum 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 @@
1use hir::HirDisplay; 1use hir::HirDisplay;
2use syntax::{ast, AstNode, TextRange, TextSize}; 2use syntax::{ast, AstNode, TextRange, TextSize};
3use test_utils::mark;
4 3
5use crate::{AssistContext, AssistId, AssistKind, Assists}; 4use crate::{AssistContext, AssistId, AssistKind, Assists};
6 5
@@ -42,7 +41,7 @@ pub(crate) fn infer_function_return_type(acc: &mut Assists, ctx: &AssistContext)
42 } 41 }
43 } 42 }
44 if let FnType::Closure { wrap_expr: true } = fn_type { 43 if let FnType::Closure { wrap_expr: true } = fn_type {
45 mark::hit!(wrap_closure_non_block_expr); 44 cov_mark::hit!(wrap_closure_non_block_expr);
46 // `|x| x` becomes `|x| -> T x` which is invalid, so wrap it in a block 45 // `|x| x` becomes `|x| -> T x` which is invalid, so wrap it in a block
47 builder.replace(tail_expr.syntax().text_range(), &format!("{{{}}}", tail_expr)); 46 builder.replace(tail_expr.syntax().text_range(), &format!("{{{}}}", tail_expr));
48 } 47 }
@@ -61,13 +60,13 @@ fn ret_ty_to_action(ret_ty: Option<ast::RetType>, insert_pos: TextSize) -> Optio
61 match ret_ty { 60 match ret_ty {
62 Some(ret_ty) => match ret_ty.ty() { 61 Some(ret_ty) => match ret_ty.ty() {
63 Some(ast::Type::InferType(_)) | None => { 62 Some(ast::Type::InferType(_)) | None => {
64 mark::hit!(existing_infer_ret_type); 63 cov_mark::hit!(existing_infer_ret_type);
65 mark::hit!(existing_infer_ret_type_closure); 64 cov_mark::hit!(existing_infer_ret_type_closure);
66 Some(InsertOrReplace::Replace(ret_ty.syntax().text_range())) 65 Some(InsertOrReplace::Replace(ret_ty.syntax().text_range()))
67 } 66 }
68 _ => { 67 _ => {
69 mark::hit!(existing_ret_type); 68 cov_mark::hit!(existing_ret_type);
70 mark::hit!(existing_ret_type_closure); 69 cov_mark::hit!(existing_ret_type_closure);
71 None 70 None
72 } 71 }
73 }, 72 },
@@ -109,11 +108,11 @@ fn extract_tail(ctx: &AssistContext) -> Option<(FnType, ast::Expr, InsertOrRepla
109 }; 108 };
110 let frange = ctx.frange.range; 109 let frange = ctx.frange.range;
111 if return_type_range.contains_range(frange) { 110 if return_type_range.contains_range(frange) {
112 mark::hit!(cursor_in_ret_position); 111 cov_mark::hit!(cursor_in_ret_position);
113 mark::hit!(cursor_in_ret_position_closure); 112 cov_mark::hit!(cursor_in_ret_position_closure);
114 } else if tail_expr.syntax().text_range().contains_range(frange) { 113 } else if tail_expr.syntax().text_range().contains_range(frange) {
115 mark::hit!(cursor_on_tail); 114 cov_mark::hit!(cursor_on_tail);
116 mark::hit!(cursor_on_tail_closure); 115 cov_mark::hit!(cursor_on_tail_closure);
117 } else { 116 } else {
118 return None; 117 return None;
119 } 118 }
@@ -128,7 +127,7 @@ mod tests {
128 127
129 #[test] 128 #[test]
130 fn infer_return_type_specified_inferred() { 129 fn infer_return_type_specified_inferred() {
131 mark::check!(existing_infer_ret_type); 130 cov_mark::check!(existing_infer_ret_type);
132 check_assist( 131 check_assist(
133 infer_function_return_type, 132 infer_function_return_type,
134 r#"fn foo() -> $0_ { 133 r#"fn foo() -> $0_ {
@@ -142,7 +141,7 @@ mod tests {
142 141
143 #[test] 142 #[test]
144 fn infer_return_type_specified_inferred_closure() { 143 fn infer_return_type_specified_inferred_closure() {
145 mark::check!(existing_infer_ret_type_closure); 144 cov_mark::check!(existing_infer_ret_type_closure);
146 check_assist( 145 check_assist(
147 infer_function_return_type, 146 infer_function_return_type,
148 r#"fn foo() { 147 r#"fn foo() {
@@ -156,7 +155,7 @@ mod tests {
156 155
157 #[test] 156 #[test]
158 fn infer_return_type_cursor_at_return_type_pos() { 157 fn infer_return_type_cursor_at_return_type_pos() {
159 mark::check!(cursor_in_ret_position); 158 cov_mark::check!(cursor_in_ret_position);
160 check_assist( 159 check_assist(
161 infer_function_return_type, 160 infer_function_return_type,
162 r#"fn foo() $0{ 161 r#"fn foo() $0{
@@ -170,7 +169,7 @@ mod tests {
170 169
171 #[test] 170 #[test]
172 fn infer_return_type_cursor_at_return_type_pos_closure() { 171 fn infer_return_type_cursor_at_return_type_pos_closure() {
173 mark::check!(cursor_in_ret_position_closure); 172 cov_mark::check!(cursor_in_ret_position_closure);
174 check_assist( 173 check_assist(
175 infer_function_return_type, 174 infer_function_return_type,
176 r#"fn foo() { 175 r#"fn foo() {
@@ -184,7 +183,7 @@ mod tests {
184 183
185 #[test] 184 #[test]
186 fn infer_return_type() { 185 fn infer_return_type() {
187 mark::check!(cursor_on_tail); 186 cov_mark::check!(cursor_on_tail);
188 check_assist( 187 check_assist(
189 infer_function_return_type, 188 infer_function_return_type,
190 r#"fn foo() { 189 r#"fn foo() {
@@ -219,7 +218,7 @@ mod tests {
219 218
220 #[test] 219 #[test]
221 fn not_applicable_ret_type_specified() { 220 fn not_applicable_ret_type_specified() {
222 mark::check!(existing_ret_type); 221 cov_mark::check!(existing_ret_type);
223 check_assist_not_applicable( 222 check_assist_not_applicable(
224 infer_function_return_type, 223 infer_function_return_type,
225 r#"fn foo() -> i32 { 224 r#"fn foo() -> i32 {
@@ -251,7 +250,7 @@ mod tests {
251 250
252 #[test] 251 #[test]
253 fn infer_return_type_closure_block() { 252 fn infer_return_type_closure_block() {
254 mark::check!(cursor_on_tail_closure); 253 cov_mark::check!(cursor_on_tail_closure);
255 check_assist( 254 check_assist(
256 infer_function_return_type, 255 infer_function_return_type,
257 r#"fn foo() { 256 r#"fn foo() {
@@ -282,7 +281,7 @@ mod tests {
282 281
283 #[test] 282 #[test]
284 fn infer_return_type_closure_wrap() { 283 fn infer_return_type_closure_wrap() {
285 mark::check!(wrap_closure_non_block_expr); 284 cov_mark::check!(wrap_closure_non_block_expr);
286 check_assist( 285 check_assist(
287 infer_function_return_type, 286 infer_function_return_type,
288 r#"fn foo() { 287 r#"fn foo() {
@@ -321,7 +320,7 @@ mod tests {
321 320
322 #[test] 321 #[test]
323 fn not_applicable_ret_type_specified_closure() { 322 fn not_applicable_ret_type_specified_closure() {
324 mark::check!(existing_ret_type_closure); 323 cov_mark::check!(existing_ret_type_closure);
325 check_assist_not_applicable( 324 check_assist_not_applicable(
326 infer_function_return_type, 325 infer_function_return_type,
327 r#"fn foo() { 326 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::{
4 ast::{self, edit::AstNodeEdit, ArgListOwner}, 4 ast::{self, edit::AstNodeEdit, ArgListOwner},
5 AstNode, 5 AstNode,
6}; 6};
7use test_utils::mark;
8 7
9use crate::{ 8use crate::{
10 assist_context::{AssistContext, Assists}, 9 assist_context::{AssistContext, Assists},
@@ -49,7 +48,7 @@ pub(crate) fn inline_function(acc: &mut Assists, ctx: &AssistContext) -> Option<
49 if arguments.len() != parameters.len() { 48 if arguments.len() != parameters.len() {
50 // Can't inline the function because they've passed the wrong number of 49 // Can't inline the function because they've passed the wrong number of
51 // arguments to this function 50 // arguments to this function
52 mark::hit!(inline_function_incorrect_number_of_arguments); 51 cov_mark::hit!(inline_function_incorrect_number_of_arguments);
53 return None; 52 return None;
54 } 53 }
55 54
@@ -155,7 +154,7 @@ fn main() { Foo.bar$0(); }
155 154
156 #[test] 155 #[test]
157 fn not_applicable_when_incorrect_number_of_parameters_are_provided() { 156 fn not_applicable_when_incorrect_number_of_parameters_are_provided() {
158 mark::check!(inline_function_incorrect_number_of_arguments); 157 cov_mark::check!(inline_function_incorrect_number_of_arguments);
159 check_assist_not_applicable( 158 check_assist_not_applicable(
160 inline_function, 159 inline_function,
161 r#" 160 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::{
4 ast::{self, AstNode, AstToken}, 4 ast::{self, AstNode, AstToken},
5 TextRange, 5 TextRange,
6}; 6};
7use test_utils::mark;
8 7
9use crate::{ 8use crate::{
10 assist_context::{AssistContext, Assists}, 9 assist_context::{AssistContext, Assists},
@@ -34,11 +33,11 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
34 _ => return None, 33 _ => return None,
35 }; 34 };
36 if bind_pat.mut_token().is_some() { 35 if bind_pat.mut_token().is_some() {
37 mark::hit!(test_not_inline_mut_variable); 36 cov_mark::hit!(test_not_inline_mut_variable);
38 return None; 37 return None;
39 } 38 }
40 if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) { 39 if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) {
41 mark::hit!(not_applicable_outside_of_bind_pat); 40 cov_mark::hit!(not_applicable_outside_of_bind_pat);
42 return None; 41 return None;
43 } 42 }
44 let initializer_expr = let_stmt.initializer()?; 43 let initializer_expr = let_stmt.initializer()?;
@@ -47,7 +46,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
47 let def = Definition::Local(def); 46 let def = Definition::Local(def);
48 let usages = def.usages(&ctx.sema).all(); 47 let usages = def.usages(&ctx.sema).all();
49 if usages.is_empty() { 48 if usages.is_empty() {
50 mark::hit!(test_not_applicable_if_variable_unused); 49 cov_mark::hit!(test_not_applicable_if_variable_unused);
51 return None; 50 return None;
52 }; 51 };
53 52
@@ -130,7 +129,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
130 Some(name_ref) 129 Some(name_ref)
131 if ast::RecordExprField::for_field_name(name_ref).is_some() => 130 if ast::RecordExprField::for_field_name(name_ref).is_some() =>
132 { 131 {
133 mark::hit!(inline_field_shorthand); 132 cov_mark::hit!(inline_field_shorthand);
134 builder.insert(reference.range.end(), format!(": {}", replacement)); 133 builder.insert(reference.range.end(), format!(": {}", replacement));
135 } 134 }
136 _ => builder.replace(reference.range, replacement), 135 _ => builder.replace(reference.range, replacement),
@@ -143,8 +142,6 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
143 142
144#[cfg(test)] 143#[cfg(test)]
145mod tests { 144mod tests {
146 use test_utils::mark;
147
148 use crate::tests::{check_assist, check_assist_not_applicable}; 145 use crate::tests::{check_assist, check_assist_not_applicable};
149 146
150 use super::*; 147 use super::*;
@@ -351,7 +348,7 @@ fn foo() {
351 348
352 #[test] 349 #[test]
353 fn test_not_inline_mut_variable() { 350 fn test_not_inline_mut_variable() {
354 mark::check!(test_not_inline_mut_variable); 351 cov_mark::check!(test_not_inline_mut_variable);
355 check_assist_not_applicable( 352 check_assist_not_applicable(
356 inline_local_variable, 353 inline_local_variable,
357 r" 354 r"
@@ -684,7 +681,7 @@ fn foo() {
684 681
685 #[test] 682 #[test]
686 fn inline_field_shorthand() { 683 fn inline_field_shorthand() {
687 mark::check!(inline_field_shorthand); 684 cov_mark::check!(inline_field_shorthand);
688 check_assist( 685 check_assist(
689 inline_local_variable, 686 inline_local_variable,
690 r" 687 r"
@@ -705,7 +702,7 @@ fn main() {
705 702
706 #[test] 703 #[test]
707 fn test_not_applicable_if_variable_unused() { 704 fn test_not_applicable_if_variable_unused() {
708 mark::check!(test_not_applicable_if_variable_unused); 705 cov_mark::check!(test_not_applicable_if_variable_unused);
709 check_assist_not_applicable( 706 check_assist_not_applicable(
710 inline_local_variable, 707 inline_local_variable,
711 r" 708 r"
@@ -718,7 +715,7 @@ fn foo() {
718 715
719 #[test] 716 #[test]
720 fn not_applicable_outside_of_bind_pat() { 717 fn not_applicable_outside_of_bind_pat() {
721 mark::check!(not_applicable_outside_of_bind_pat); 718 cov_mark::check!(not_applicable_outside_of_bind_pat);
722 check_assist_not_applicable( 719 check_assist_not_applicable(
723 inline_local_variable, 720 inline_local_variable,
724 r" 721 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::{
5 ast::{self, edit::AstNodeEdit, NameOwner}, 5 ast::{self, edit::AstNodeEdit, NameOwner},
6 AstNode, TextRange, 6 AstNode, TextRange,
7}; 7};
8use test_utils::mark;
9 8
10use crate::{AssistContext, AssistId, AssistKind, Assists}; 9use crate::{AssistContext, AssistId, AssistKind, Assists};
11 10
@@ -28,7 +27,7 @@ pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext) -> Opt
28 27
29 let l_curly_offset = module_items.syntax().text_range().start(); 28 let l_curly_offset = module_items.syntax().text_range().start();
30 if l_curly_offset <= ctx.offset() { 29 if l_curly_offset <= ctx.offset() {
31 mark::hit!(available_before_curly); 30 cov_mark::hit!(available_before_curly);
32 return None; 31 return None;
33 } 32 }
34 let target = TextRange::new(module_ast.syntax().text_range().start(), l_curly_offset); 33 let target = TextRange::new(module_ast.syntax().text_range().start(), l_curly_offset);
@@ -182,7 +181,7 @@ pub(crate) mod tests;
182 181
183 #[test] 182 #[test]
184 fn available_before_curly() { 183 fn available_before_curly() {
185 mark::check!(available_before_curly); 184 cov_mark::check!(available_before_curly);
186 check_assist_not_applicable(move_module_to_file, r#"mod m { $0 }"#); 185 check_assist_not_applicable(move_module_to_file, r#"mod m { $0 }"#);
187 } 186 }
188} 187}
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::{
2 ast::{self, edit::AstNodeEdit, make}, 2 ast::{self, edit::AstNodeEdit, make},
3 AstNode, 3 AstNode,
4}; 4};
5use test_utils::mark;
6 5
7use crate::{ 6use crate::{
8 assist_context::{AssistContext, Assists}, 7 assist_context::{AssistContext, Assists},
@@ -104,7 +103,7 @@ fn exprify_if(
104 ast::ElseBranch::Block(exprify_block(block, sema, name)?) 103 ast::ElseBranch::Block(exprify_block(block, sema, name)?)
105 } 104 }
106 ast::ElseBranch::IfExpr(expr) => { 105 ast::ElseBranch::IfExpr(expr) => {
107 mark::hit!(test_pull_assignment_up_chained_if); 106 cov_mark::hit!(test_pull_assignment_up_chained_if);
108 ast::ElseBranch::IfExpr(ast::IfExpr::cast( 107 ast::ElseBranch::IfExpr(ast::IfExpr::cast(
109 exprify_if(&expr, sema, name)?.syntax().to_owned(), 108 exprify_if(&expr, sema, name)?.syntax().to_owned(),
110 )?) 109 )?)
@@ -144,7 +143,7 @@ fn is_equivalent(
144) -> bool { 143) -> bool {
145 match (expr0, expr1) { 144 match (expr0, expr1) {
146 (ast::Expr::FieldExpr(field_expr0), ast::Expr::FieldExpr(field_expr1)) => { 145 (ast::Expr::FieldExpr(field_expr0), ast::Expr::FieldExpr(field_expr1)) => {
147 mark::hit!(test_pull_assignment_up_field_assignment); 146 cov_mark::hit!(test_pull_assignment_up_field_assignment);
148 sema.resolve_field(field_expr0) == sema.resolve_field(field_expr1) 147 sema.resolve_field(field_expr0) == sema.resolve_field(field_expr1)
149 } 148 }
150 (ast::Expr::PathExpr(path0), ast::Expr::PathExpr(path1)) => { 149 (ast::Expr::PathExpr(path0), ast::Expr::PathExpr(path1)) => {
@@ -160,7 +159,7 @@ fn is_equivalent(
160 if prefix0.op_kind() == Some(ast::PrefixOp::Deref) 159 if prefix0.op_kind() == Some(ast::PrefixOp::Deref)
161 && prefix1.op_kind() == Some(ast::PrefixOp::Deref) => 160 && prefix1.op_kind() == Some(ast::PrefixOp::Deref) =>
162 { 161 {
163 mark::hit!(test_pull_assignment_up_deref); 162 cov_mark::hit!(test_pull_assignment_up_deref);
164 if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) { 163 if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) {
165 is_equivalent(sema, &prefix0, &prefix1) 164 is_equivalent(sema, &prefix0, &prefix1)
166 } else { 165 } else {
@@ -263,7 +262,7 @@ fn foo() {
263 262
264 #[test] 263 #[test]
265 fn test_pull_assignment_up_chained_if() { 264 fn test_pull_assignment_up_chained_if() {
266 mark::check!(test_pull_assignment_up_chained_if); 265 cov_mark::check!(test_pull_assignment_up_chained_if);
267 check_assist( 266 check_assist(
268 pull_assignment_up, 267 pull_assignment_up,
269 r#" 268 r#"
@@ -379,7 +378,7 @@ fn foo() {
379 378
380 #[test] 379 #[test]
381 fn test_pull_assignment_up_field_assignment() { 380 fn test_pull_assignment_up_field_assignment() {
382 mark::check!(test_pull_assignment_up_field_assignment); 381 cov_mark::check!(test_pull_assignment_up_field_assignment);
383 check_assist( 382 check_assist(
384 pull_assignment_up, 383 pull_assignment_up,
385 r#" 384 r#"
@@ -411,7 +410,7 @@ fn foo() {
411 410
412 #[test] 411 #[test]
413 fn test_pull_assignment_up_deref() { 412 fn test_pull_assignment_up_deref() {
414 mark::check!(test_pull_assignment_up_deref); 413 cov_mark::check!(test_pull_assignment_up_deref);
415 check_assist( 414 check_assist(
416 pull_assignment_up, 415 pull_assignment_up,
417 r#" 416 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::{
8 ast::{make, ArgListOwner}, 8 ast::{make, ArgListOwner},
9 AstNode, 9 AstNode,
10}; 10};
11use test_utils::mark;
12 11
13use crate::{ 12use crate::{
14 assist_context::{AssistContext, Assists}, 13 assist_context::{AssistContext, Assists},
@@ -47,25 +46,25 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
47 let qualify_candidate = match candidate { 46 let qualify_candidate = match candidate {
48 ImportCandidate::Path(candidate) => { 47 ImportCandidate::Path(candidate) => {
49 if candidate.qualifier.is_some() { 48 if candidate.qualifier.is_some() {
50 mark::hit!(qualify_path_qualifier_start); 49 cov_mark::hit!(qualify_path_qualifier_start);
51 let path = ast::Path::cast(syntax_under_caret)?; 50 let path = ast::Path::cast(syntax_under_caret)?;
52 let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); 51 let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?);
53 QualifyCandidate::QualifierStart(segment, prev_segment.generic_arg_list()) 52 QualifyCandidate::QualifierStart(segment, prev_segment.generic_arg_list())
54 } else { 53 } else {
55 mark::hit!(qualify_path_unqualified_name); 54 cov_mark::hit!(qualify_path_unqualified_name);
56 let path = ast::Path::cast(syntax_under_caret)?; 55 let path = ast::Path::cast(syntax_under_caret)?;
57 let generics = path.segment()?.generic_arg_list(); 56 let generics = path.segment()?.generic_arg_list();
58 QualifyCandidate::UnqualifiedName(generics) 57 QualifyCandidate::UnqualifiedName(generics)
59 } 58 }
60 } 59 }
61 ImportCandidate::TraitAssocItem(_) => { 60 ImportCandidate::TraitAssocItem(_) => {
62 mark::hit!(qualify_path_trait_assoc_item); 61 cov_mark::hit!(qualify_path_trait_assoc_item);
63 let path = ast::Path::cast(syntax_under_caret)?; 62 let path = ast::Path::cast(syntax_under_caret)?;
64 let (qualifier, segment) = (path.qualifier()?, path.segment()?); 63 let (qualifier, segment) = (path.qualifier()?, path.segment()?);
65 QualifyCandidate::TraitAssocItem(qualifier, segment) 64 QualifyCandidate::TraitAssocItem(qualifier, segment)
66 } 65 }
67 ImportCandidate::TraitMethod(_) => { 66 ImportCandidate::TraitMethod(_) => {
68 mark::hit!(qualify_path_trait_method); 67 cov_mark::hit!(qualify_path_trait_method);
69 let mcall_expr = ast::MethodCallExpr::cast(syntax_under_caret)?; 68 let mcall_expr = ast::MethodCallExpr::cast(syntax_under_caret)?;
70 QualifyCandidate::TraitMethod(ctx.sema.db, mcall_expr) 69 QualifyCandidate::TraitMethod(ctx.sema.db, mcall_expr)
71 } 70 }
@@ -212,7 +211,7 @@ mod tests {
212 211
213 #[test] 212 #[test]
214 fn applicable_when_found_an_import_partial() { 213 fn applicable_when_found_an_import_partial() {
215 mark::check!(qualify_path_unqualified_name); 214 cov_mark::check!(qualify_path_unqualified_name);
216 check_assist( 215 check_assist(
217 qualify_path, 216 qualify_path,
218 r" 217 r"
@@ -504,7 +503,7 @@ fn main() {
504 503
505 #[test] 504 #[test]
506 fn associated_struct_const() { 505 fn associated_struct_const() {
507 mark::check!(qualify_path_qualifier_start); 506 cov_mark::check!(qualify_path_qualifier_start);
508 check_assist( 507 check_assist(
509 qualify_path, 508 qualify_path,
510 r" 509 r"
@@ -605,7 +604,7 @@ fn main() {
605 604
606 #[test] 605 #[test]
607 fn associated_trait_const() { 606 fn associated_trait_const() {
608 mark::check!(qualify_path_trait_assoc_item); 607 cov_mark::check!(qualify_path_trait_assoc_item);
609 check_assist( 608 check_assist(
610 qualify_path, 609 qualify_path,
611 r" 610 r"
@@ -675,7 +674,7 @@ fn main() {
675 674
676 #[test] 675 #[test]
677 fn trait_method() { 676 fn trait_method() {
678 mark::check!(qualify_path_trait_method); 677 cov_mark::check!(qualify_path_trait_method);
679 check_assist( 678 check_assist(
680 qualify_path, 679 qualify_path,
681 r" 680 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 @@
1use std::borrow::Cow; 1use std::borrow::Cow;
2 2
3use syntax::{ast, AstToken, TextRange, TextSize}; 3use syntax::{ast, AstToken, TextRange, TextSize};
4use test_utils::mark;
5 4
6use crate::{AssistContext, AssistId, AssistKind, Assists}; 5use crate::{AssistContext, AssistId, AssistKind, Assists};
7 6
@@ -149,7 +148,7 @@ pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
149 let internal_text = &text[token.text_range_between_quotes()? - text_range.start()]; 148 let internal_text = &text[token.text_range_between_quotes()? - text_range.start()];
150 149
151 if existing_hashes == required_hashes(internal_text) { 150 if existing_hashes == required_hashes(internal_text) {
152 mark::hit!(cant_remove_required_hash); 151 cov_mark::hit!(cant_remove_required_hash);
153 return None; 152 return None;
154 } 153 }
155 154
@@ -182,8 +181,6 @@ fn test_required_hashes() {
182 181
183#[cfg(test)] 182#[cfg(test)]
184mod tests { 183mod tests {
185 use test_utils::mark;
186
187 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 184 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
188 185
189 use super::*; 186 use super::*;
@@ -396,7 +393,7 @@ string"###;
396 393
397 #[test] 394 #[test]
398 fn cant_remove_required_hash() { 395 fn cant_remove_required_hash() {
399 mark::check!(cant_remove_required_hash); 396 cov_mark::check!(cant_remove_required_hash);
400 check_assist_not_applicable( 397 check_assist_not_applicable(
401 remove_hash, 398 remove_hash,
402 r##" 399 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::{
4 ast::{self, ArgListOwner}, 4 ast::{self, ArgListOwner},
5 AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, T, 5 AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, T,
6}; 6};
7use test_utils::mark; 7
8use SyntaxKind::WHITESPACE; 8use SyntaxKind::WHITESPACE;
9 9
10use crate::{ 10use crate::{
@@ -49,7 +49,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext) -> Opt
49 Definition::Local(local) 49 Definition::Local(local)
50 }; 50 };
51 if param_def.usages(&ctx.sema).at_least_one() { 51 if param_def.usages(&ctx.sema).at_least_one() {
52 mark::hit!(keep_used); 52 cov_mark::hit!(keep_used);
53 return None; 53 return None;
54 } 54 }
55 acc.add( 55 acc.add(
@@ -243,7 +243,7 @@ fn b2() { foo(9) }
243 243
244 #[test] 244 #[test]
245 fn keep_used() { 245 fn keep_used() {
246 mark::check!(keep_used); 246 cov_mark::check!(keep_used);
247 check_assist_not_applicable( 247 check_assist_not_applicable(
248 remove_unused_param, 248 remove_unused_param,
249 r#" 249 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;
4use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; 4use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct};
5use ide_db::RootDatabase; 5use ide_db::RootDatabase;
6use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; 6use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode};
7use test_utils::mark;
8 7
9use crate::{AssistContext, AssistId, AssistKind, Assists}; 8use crate::{AssistContext, AssistId, AssistKind, Assists};
10 9
@@ -39,7 +38,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
39 }); 38 });
40 39
41 if sorted_fields == fields { 40 if sorted_fields == fields {
42 mark::hit!(reorder_sorted_fields); 41 cov_mark::hit!(reorder_sorted_fields);
43 return None; 42 return None;
44 } 43 }
45 44
@@ -109,15 +108,13 @@ fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashM
109 108
110#[cfg(test)] 109#[cfg(test)]
111mod tests { 110mod tests {
112 use test_utils::mark;
113
114 use crate::tests::{check_assist, check_assist_not_applicable}; 111 use crate::tests::{check_assist, check_assist_not_applicable};
115 112
116 use super::*; 113 use super::*;
117 114
118 #[test] 115 #[test]
119 fn reorder_sorted_fields() { 116 fn reorder_sorted_fields() {
120 mark::check!(reorder_sorted_fields); 117 cov_mark::check!(reorder_sorted_fields);
121 check_assist_not_applicable( 118 check_assist_not_applicable(
122 reorder_fields, 119 reorder_fields,
123 r#" 120 r#"
diff --git a/crates/ide_assists/src/handlers/reorder_impl.rs b/crates/ide_assists/src/handlers/reorder_impl.rs
index 309f291c8..edf4b0bfe 100644
--- a/crates/ide_assists/src/handlers/reorder_impl.rs
+++ b/crates/ide_assists/src/handlers/reorder_impl.rs
@@ -8,7 +8,6 @@ use syntax::{
8 ast::{self, NameOwner}, 8 ast::{self, NameOwner},
9 AstNode, 9 AstNode,
10}; 10};
11use test_utils::mark;
12 11
13use crate::{AssistContext, AssistId, AssistKind, Assists}; 12use crate::{AssistContext, AssistId, AssistKind, Assists};
14 13
@@ -71,7 +70,7 @@ pub(crate) fn reorder_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
71 70
72 // Don't edit already sorted methods: 71 // Don't edit already sorted methods:
73 if methods == sorted { 72 if methods == sorted {
74 mark::hit!(not_applicable_if_sorted); 73 cov_mark::hit!(not_applicable_if_sorted);
75 return None; 74 return None;
76 } 75 }
77 76
@@ -121,15 +120,13 @@ fn get_methods(items: &ast::AssocItemList) -> Vec<ast::Fn> {
121 120
122#[cfg(test)] 121#[cfg(test)]
123mod tests { 122mod tests {
124 use test_utils::mark;
125
126 use crate::tests::{check_assist, check_assist_not_applicable}; 123 use crate::tests::{check_assist, check_assist_not_applicable};
127 124
128 use super::*; 125 use super::*;
129 126
130 #[test] 127 #[test]
131 fn not_applicable_if_sorted() { 128 fn not_applicable_if_sorted() {
132 mark::check!(not_applicable_if_sorted); 129 cov_mark::check!(not_applicable_if_sorted);
133 check_assist_not_applicable( 130 check_assist_not_applicable(
134 reorder_impl, 131 reorder_impl,
135 r#" 132 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;
3use ide_db::helpers::FamousDefs; 3use ide_db::helpers::FamousDefs;
4use stdx::format_to; 4use stdx::format_to;
5use syntax::{ast, AstNode}; 5use syntax::{ast, AstNode};
6use test_utils::mark;
7 6
8use crate::{AssistContext, AssistId, AssistKind, Assists}; 7use crate::{AssistContext, AssistId, AssistKind, Assists};
9 8
@@ -34,7 +33,7 @@ pub(crate) fn replace_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistCont
34 let pat = for_loop.pat()?; 33 let pat = for_loop.pat()?;
35 let body = for_loop.loop_body()?; 34 let body = for_loop.loop_body()?;
36 if body.syntax().text_range().start() < ctx.offset() { 35 if body.syntax().text_range().start() < ctx.offset() {
37 mark::hit!(not_available_in_body); 36 cov_mark::hit!(not_available_in_body);
38 return None; 37 return None;
39 } 38 }
40 39
@@ -187,7 +186,7 @@ fn main() {
187 186
188 #[test] 187 #[test]
189 fn not_available_in_body() { 188 fn not_available_in_body() {
190 mark::check!(not_available_in_body); 189 cov_mark::check!(not_available_in_body);
191 check_assist_not_applicable( 190 check_assist_not_applicable(
192 replace_for_loop_with_for_each, 191 replace_for_loop_with_for_each,
193 r" 192 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 @@
1use ide_db::helpers::insert_use::{insert_use, ImportScope}; 1use ide_db::helpers::insert_use::{insert_use, ImportScope};
2use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode}; 2use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode};
3use test_utils::mark;
4 3
5use crate::{AssistContext, AssistId, AssistKind, Assists}; 4use crate::{AssistContext, AssistId, AssistKind, Assists};
6 5
@@ -27,7 +26,7 @@ pub(crate) fn replace_qualified_name_with_use(
27 return None; 26 return None;
28 } 27 }
29 if path.qualifier().is_none() { 28 if path.qualifier().is_none() {
30 mark::hit!(dont_import_trivial_paths); 29 cov_mark::hit!(dont_import_trivial_paths);
31 return None; 30 return None;
32 } 31 }
33 32
@@ -458,7 +457,7 @@ impl Debug for Foo {
458 457
459 #[test] 458 #[test]
460 fn dont_import_trivial_paths() { 459 fn dont_import_trivial_paths() {
461 mark::check!(dont_import_trivial_paths); 460 cov_mark::check!(dont_import_trivial_paths);
462 check_assist_not_applicable( 461 check_assist_not_applicable(
463 replace_qualified_name_with_use, 462 replace_qualified_name_with_use,
464 r" 463 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::{
3 ast::{self, edit::AstNodeEdit, VisibilityOwner}, 3 ast::{self, edit::AstNodeEdit, VisibilityOwner},
4 AstNode, SyntaxKind, 4 AstNode, SyntaxKind,
5}; 5};
6use test_utils::mark;
7 6
8use crate::{ 7use crate::{
9 assist_context::{AssistContext, Assists}, 8 assist_context::{AssistContext, Assists},
@@ -27,7 +26,7 @@ pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
27 26
28 let tree_list = tree.syntax().parent().and_then(ast::UseTreeList::cast)?; 27 let tree_list = tree.syntax().parent().and_then(ast::UseTreeList::cast)?;
29 if tree_list.use_trees().count() < 2 { 28 if tree_list.use_trees().count() < 2 {
30 mark::hit!(skip_single_use_item); 29 cov_mark::hit!(skip_single_use_item);
31 return None; 30 return None;
32 } 31 }
33 32
@@ -89,7 +88,7 @@ mod tests {
89 88
90 #[test] 89 #[test]
91 fn skip_single_use_item() { 90 fn skip_single_use_item() {
92 mark::check!(skip_single_use_item); 91 cov_mark::check!(skip_single_use_item);
93 check_assist_not_applicable( 92 check_assist_not_applicable(
94 unmerge_use, 93 unmerge_use,
95 r" 94 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::{
4 ast::{self, make, BlockExpr, Expr, LoopBodyOwner}, 4 ast::{self, make, BlockExpr, Expr, LoopBodyOwner},
5 match_ast, AstNode, SyntaxNode, 5 match_ast, AstNode, SyntaxNode,
6}; 6};
7use test_utils::mark;
8 7
9use crate::{AssistContext, AssistId, AssistKind, Assists}; 8use crate::{AssistContext, AssistId, AssistKind, Assists};
10 9
@@ -39,7 +38,7 @@ pub(crate) fn wrap_return_type_in_result(acc: &mut Assists, ctx: &AssistContext)
39 let first_part_ret_type = ret_type_str.splitn(2, '<').next(); 38 let first_part_ret_type = ret_type_str.splitn(2, '<').next();
40 if let Some(ret_type_first_part) = first_part_ret_type { 39 if let Some(ret_type_first_part) = first_part_ret_type {
41 if ret_type_first_part.ends_with("Result") { 40 if ret_type_first_part.ends_with("Result") {
42 mark::hit!(wrap_return_type_in_result_simple_return_type_already_result); 41 cov_mark::hit!(wrap_return_type_in_result_simple_return_type_already_result);
43 return None; 42 return None;
44 } 43 }
45 } 44 }
@@ -367,7 +366,7 @@ fn foo() -> std::result::Result<i32$0, String> {
367 366
368 #[test] 367 #[test]
369 fn wrap_return_type_in_result_simple_return_type_already_result() { 368 fn wrap_return_type_in_result_simple_return_type_already_result() {
370 mark::check!(wrap_return_type_in_result_simple_return_type_already_result); 369 cov_mark::check!(wrap_return_type_in_result_simple_return_type_already_result);
371 check_assist_not_applicable( 370 check_assist_not_applicable(
372 wrap_return_type_in_result, 371 wrap_return_type_in_result,
373 r#" 372 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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13itertools = "0.10.0" 14itertools = "0.10.0"
14log = "0.4.8" 15log = "0.4.8"
15rustc-hash = "1.1.0" 16rustc-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 @@
2 2
3use hir::{HasVisibility, Type}; 3use hir::{HasVisibility, Type};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use test_utils::mark;
6 5
7use crate::{context::CompletionContext, Completions}; 6use crate::{context::CompletionContext, Completions};
8 7
@@ -19,7 +18,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
19 }; 18 };
20 19
21 if ctx.is_call { 20 if ctx.is_call {
22 mark::hit!(test_no_struct_field_completion_for_method_call); 21 cov_mark::hit!(test_no_struct_field_completion_for_method_call);
23 } else { 22 } else {
24 complete_fields(acc, ctx, &receiver_ty); 23 complete_fields(acc, ctx, &receiver_ty);
25 } 24 }
@@ -62,7 +61,6 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T
62#[cfg(test)] 61#[cfg(test)]
63mod tests { 62mod tests {
64 use expect_test::{expect, Expect}; 63 use expect_test::{expect, Expect};
65 use test_utils::mark;
66 64
67 use crate::{test_utils::completion_list, CompletionKind}; 65 use crate::{test_utils::completion_list, CompletionKind};
68 66
@@ -122,7 +120,7 @@ impl A {
122 120
123 #[test] 121 #[test]
124 fn test_no_struct_field_completion_for_method_call() { 122 fn test_no_struct_field_completion_for_method_call() {
125 mark::check!(test_no_struct_field_completion_for_method_call); 123 cov_mark::check!(test_no_struct_field_completion_for_method_call);
126 check( 124 check(
127 r#" 125 r#"
128struct A { the_field: u32 } 126struct 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::{
55}; 55};
56use rustc_hash::FxHashSet; 56use rustc_hash::FxHashSet;
57use syntax::{AstNode, SyntaxNode, T}; 57use syntax::{AstNode, SyntaxNode, T};
58use test_utils::mark;
59 58
60use crate::{ 59use crate::{
61 context::CompletionContext, 60 context::CompletionContext,
@@ -174,7 +173,7 @@ fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option<ImportAs
174 if matches!(assets_for_path.as_ref()?.import_candidate(), ImportCandidate::Path(_)) 173 if matches!(assets_for_path.as_ref()?.import_candidate(), ImportCandidate::Path(_))
175 && fuzzy_name_length < 2 174 && fuzzy_name_length < 2
176 { 175 {
177 mark::hit!(ignore_short_input_for_path); 176 cov_mark::hit!(ignore_short_input_for_path);
178 None 177 None
179 } else { 178 } else {
180 assets_for_path 179 assets_for_path
@@ -186,7 +185,7 @@ fn compute_fuzzy_completion_order_key(
186 proposed_mod_path: &ModPath, 185 proposed_mod_path: &ModPath,
187 user_input_lowercased: &str, 186 user_input_lowercased: &str,
188) -> usize { 187) -> usize {
189 mark::hit!(certain_fuzzy_order_test); 188 cov_mark::hit!(certain_fuzzy_order_test);
190 let proposed_import_name = match proposed_mod_path.segments().last() { 189 let proposed_import_name = match proposed_mod_path.segments().last() {
191 Some(name) => name.to_string().to_lowercase(), 190 Some(name) => name.to_string().to_lowercase(),
192 None => return usize::MAX, 191 None => return usize::MAX,
@@ -200,7 +199,6 @@ fn compute_fuzzy_completion_order_key(
200#[cfg(test)] 199#[cfg(test)]
201mod tests { 200mod tests {
202 use expect_test::{expect, Expect}; 201 use expect_test::{expect, Expect};
203 use test_utils::mark;
204 202
205 use crate::{ 203 use crate::{
206 item::CompletionKind, 204 item::CompletionKind,
@@ -295,7 +293,7 @@ fn main() {
295 293
296 #[test] 294 #[test]
297 fn short_paths_are_ignored() { 295 fn short_paths_are_ignored() {
298 mark::check!(ignore_short_input_for_path); 296 cov_mark::check!(ignore_short_input_for_path);
299 297
300 check( 298 check(
301 r#" 299 r#"
@@ -319,7 +317,7 @@ fn main() {
319 317
320 #[test] 318 #[test]
321 fn fuzzy_completions_come_in_specific_order() { 319 fn fuzzy_completions_come_in_specific_order() {
322 mark::check!(certain_fuzzy_order_test); 320 cov_mark::check!(certain_fuzzy_order_test);
323 check( 321 check(
324 r#" 322 r#"
325//- /lib.rs crate:dep 323//- /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 @@
3use std::iter; 3use std::iter;
4 4
5use syntax::SyntaxKind; 5use syntax::SyntaxKind;
6use test_utils::mark;
7 6
8use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions}; 7use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions};
9 8
@@ -47,11 +46,11 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
47 46
48pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { 47pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) {
49 if ctx.token.kind() == SyntaxKind::COMMENT { 48 if ctx.token.kind() == SyntaxKind::COMMENT {
50 mark::hit!(no_keyword_completion_in_comments); 49 cov_mark::hit!(no_keyword_completion_in_comments);
51 return; 50 return;
52 } 51 }
53 if ctx.record_lit_syntax.is_some() { 52 if ctx.record_lit_syntax.is_some() {
54 mark::hit!(no_keyword_completion_in_record_lit); 53 cov_mark::hit!(no_keyword_completion_in_record_lit);
55 return; 54 return;
56 } 55 }
57 56
@@ -172,7 +171,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet
172 Some(cap) => { 171 Some(cap) => {
173 let tmp; 172 let tmp;
174 let snippet = if snippet.ends_with('}') && ctx.incomplete_let { 173 let snippet = if snippet.ends_with('}') && ctx.incomplete_let {
175 mark::hit!(let_semi); 174 cov_mark::hit!(let_semi);
176 tmp = format!("{};", snippet); 175 tmp = format!("{};", snippet);
177 &tmp 176 &tmp
178 } else { 177 } else {
@@ -188,7 +187,6 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet
188#[cfg(test)] 187#[cfg(test)]
189mod tests { 188mod tests {
190 use expect_test::{expect, Expect}; 189 use expect_test::{expect, Expect};
191 use test_utils::mark;
192 190
193 use crate::{ 191 use crate::{
194 test_utils::{check_edit, completion_list}, 192 test_utils::{check_edit, completion_list},
@@ -494,7 +492,7 @@ fn quux() -> i32 {
494 492
495 #[test] 493 #[test]
496 fn no_keyword_completion_in_comments() { 494 fn no_keyword_completion_in_comments() {
497 mark::check!(no_keyword_completion_in_comments); 495 cov_mark::check!(no_keyword_completion_in_comments);
498 check( 496 check(
499 r#" 497 r#"
500fn test() { 498fn test() {
@@ -599,7 +597,7 @@ struct Foo {
599 597
600 #[test] 598 #[test]
601 fn skip_struct_initializer() { 599 fn skip_struct_initializer() {
602 mark::check!(no_keyword_completion_in_record_lit); 600 cov_mark::check!(no_keyword_completion_in_record_lit);
603 check( 601 check(
604 r#" 602 r#"
605struct Foo { 603struct Foo {
@@ -643,7 +641,7 @@ fn foo() {
643 641
644 #[test] 642 #[test]
645 fn let_semi() { 643 fn let_semi() {
646 mark::check!(let_semi); 644 cov_mark::check!(let_semi);
647 check_edit( 645 check_edit(
648 "match", 646 "match",
649 r#" 647 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 @@
3use hir::{Adt, HasVisibility, PathResolution, ScopeDef}; 3use hir::{Adt, HasVisibility, PathResolution, ScopeDef};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use syntax::AstNode; 5use syntax::AstNode;
6use test_utils::mark;
7 6
8use crate::{CompletionContext, Completions}; 7use crate::{CompletionContext, Completions};
9 8
@@ -39,7 +38,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
39 if let Some(name_ref) = ctx.name_ref_syntax.as_ref() { 38 if let Some(name_ref) = ctx.name_ref_syntax.as_ref() {
40 if name_ref.syntax().text() == name.to_string().as_str() { 39 if name_ref.syntax().text() == name.to_string().as_str() {
41 // for `use self::foo$0`, don't suggest `foo` as a completion 40 // for `use self::foo$0`, don't suggest `foo` as a completion
42 mark::hit!(dont_complete_current_use); 41 cov_mark::hit!(dont_complete_current_use);
43 continue; 42 continue;
44 } 43 }
45 } 44 }
@@ -155,7 +154,6 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
155#[cfg(test)] 154#[cfg(test)]
156mod tests { 155mod tests {
157 use expect_test::{expect, Expect}; 156 use expect_test::{expect, Expect};
158 use test_utils::mark;
159 157
160 use crate::{ 158 use crate::{
161 test_utils::{check_edit, completion_list}, 159 test_utils::{check_edit, completion_list},
@@ -174,7 +172,7 @@ mod tests {
174 172
175 #[test] 173 #[test]
176 fn dont_complete_current_use() { 174 fn dont_complete_current_use() {
177 mark::check!(dont_complete_current_use); 175 cov_mark::check!(dont_complete_current_use);
178 check(r#"use self::foo$0;"#, expect![[""]]); 176 check(r#"use self::foo$0;"#, expect![[""]]);
179 } 177 }
180 178
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 @@
2 2
3use hir::ScopeDef; 3use hir::ScopeDef;
4use syntax::AstNode; 4use syntax::AstNode;
5use test_utils::mark;
6 5
7use crate::{CompletionContext, Completions}; 6use crate::{CompletionContext, Completions};
8 7
@@ -30,13 +29,13 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
30 29
31 ctx.scope.process_all_names(&mut |name, res| { 30 ctx.scope.process_all_names(&mut |name, res| {
32 if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { 31 if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res {
33 mark::hit!(skip_lifetime_completion); 32 cov_mark::hit!(skip_lifetime_completion);
34 return; 33 return;
35 } 34 }
36 if ctx.use_item_syntax.is_some() { 35 if ctx.use_item_syntax.is_some() {
37 if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { 36 if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) {
38 if name_ref.syntax().text() == name.to_string().as_str() { 37 if name_ref.syntax().text() == name.to_string().as_str() {
39 mark::hit!(self_fulfilling_completion); 38 cov_mark::hit!(self_fulfilling_completion);
40 return; 39 return;
41 } 40 }
42 } 41 }
@@ -48,7 +47,6 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
48#[cfg(test)] 47#[cfg(test)]
49mod tests { 48mod tests {
50 use expect_test::{expect, Expect}; 49 use expect_test::{expect, Expect};
51 use test_utils::mark;
52 50
53 use crate::{ 51 use crate::{
54 test_utils::{check_edit, completion_list_with_config, TEST_CONFIG}, 52 test_utils::{check_edit, completion_list_with_config, TEST_CONFIG},
@@ -66,7 +64,7 @@ mod tests {
66 64
67 #[test] 65 #[test]
68 fn self_fulfilling_completion() { 66 fn self_fulfilling_completion() {
69 mark::check!(self_fulfilling_completion); 67 cov_mark::check!(self_fulfilling_completion);
70 check( 68 check(
71 r#" 69 r#"
72use foo$0 70use foo$0
@@ -185,7 +183,7 @@ fn quux() {
185 183
186 #[test] 184 #[test]
187 fn completes_if_prefix_is_keyword() { 185 fn completes_if_prefix_is_keyword() {
188 mark::check!(completes_if_prefix_is_keyword); 186 cov_mark::check!(completes_if_prefix_is_keyword);
189 check_edit( 187 check_edit(
190 "wherewolf", 188 "wherewolf",
191 r#" 189 r#"
@@ -223,7 +221,7 @@ fn main() {
223 221
224 #[test] 222 #[test]
225 fn does_not_complete_lifetimes() { 223 fn does_not_complete_lifetimes() {
226 mark::check!(skip_lifetime_completion); 224 cov_mark::check!(skip_lifetime_completion);
227 check( 225 check(
228 r#"fn quux<'a>() { $0 }"#, 226 r#"fn quux<'a>() { $0 }"#,
229 expect![[r#" 227 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::{
7 algo::find_node_at_offset, ast, match_ast, AstNode, NodeOrToken, SyntaxKind::*, SyntaxNode, 7 algo::find_node_at_offset, ast, match_ast, AstNode, NodeOrToken, SyntaxKind::*, SyntaxNode,
8 SyntaxToken, TextRange, TextSize, 8 SyntaxToken, TextRange, TextSize,
9}; 9};
10use test_utils::mark; 10
11use text_edit::Indel; 11use text_edit::Indel;
12 12
13use crate::{ 13use crate::{
@@ -240,7 +240,7 @@ impl<'a> CompletionContext<'a> {
240 // check kind of macro-expanded token, but use range of original token 240 // check kind of macro-expanded token, but use range of original token
241 let kind = self.token.kind(); 241 let kind = self.token.kind();
242 if kind == IDENT || kind == UNDERSCORE || kind.is_keyword() { 242 if kind == IDENT || kind == UNDERSCORE || kind.is_keyword() {
243 mark::hit!(completes_if_prefix_is_keyword); 243 cov_mark::hit!(completes_if_prefix_is_keyword);
244 self.original_token.text_range() 244 self.original_token.text_range()
245 } else { 245 } else {
246 TextRange::empty(self.position.offset) 246 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::{
15}; 15};
16use ide_db::{helpers::SnippetCap, RootDatabase, SymbolKind}; 16use ide_db::{helpers::SnippetCap, RootDatabase, SymbolKind};
17use syntax::TextRange; 17use syntax::TextRange;
18use test_utils::mark;
19 18
20use crate::{ 19use crate::{
21 item::ImportEdit, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, 20 item::ImportEdit, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind,
@@ -115,11 +114,11 @@ impl<'a> RenderContext<'a> {
115 114
116 fn active_name_and_type(&self) -> Option<(String, Type)> { 115 fn active_name_and_type(&self) -> Option<(String, Type)> {
117 if let Some(record_field) = &self.completion.record_field_syntax { 116 if let Some(record_field) = &self.completion.record_field_syntax {
118 mark::hit!(record_field_type_match); 117 cov_mark::hit!(record_field_type_match);
119 let (struct_field, _local) = self.completion.sema.resolve_record_field(record_field)?; 118 let (struct_field, _local) = self.completion.sema.resolve_record_field(record_field)?;
120 Some((struct_field.name(self.db()).to_string(), struct_field.signature_ty(self.db()))) 119 Some((struct_field.name(self.db()).to_string(), struct_field.signature_ty(self.db())))
121 } else if let Some(active_parameter) = &self.completion.active_parameter { 120 } else if let Some(active_parameter) = &self.completion.active_parameter {
122 mark::hit!(active_param_type_match); 121 cov_mark::hit!(active_param_type_match);
123 Some((active_parameter.name.clone(), active_parameter.ty.clone())) 122 Some((active_parameter.name.clone(), active_parameter.ty.clone()))
124 } else { 123 } else {
125 None 124 None
@@ -269,7 +268,7 @@ impl<'a> Render<'a> {
269 _ => false, 268 _ => false,
270 }; 269 };
271 if has_non_default_type_params { 270 if has_non_default_type_params {
272 mark::hit!(inserts_angle_brackets_for_generics); 271 cov_mark::hit!(inserts_angle_brackets_for_generics);
273 item = item 272 item = item
274 .lookup_by(local_name.clone()) 273 .lookup_by(local_name.clone())
275 .label(format!("{}<…>", local_name)) 274 .label(format!("{}<…>", local_name))
@@ -358,7 +357,6 @@ mod tests {
358 use std::cmp::Reverse; 357 use std::cmp::Reverse;
359 358
360 use expect_test::{expect, Expect}; 359 use expect_test::{expect, Expect};
361 use test_utils::mark;
362 360
363 use crate::{ 361 use crate::{
364 test_utils::{check_edit, do_completion, get_all_items, TEST_CONFIG}, 362 test_utils::{check_edit, do_completion, get_all_items, TEST_CONFIG},
@@ -734,7 +732,7 @@ fn foo(s: S) { s.$0 }
734 732
735 #[test] 733 #[test]
736 fn no_call_parens_if_fn_ptr_needed() { 734 fn no_call_parens_if_fn_ptr_needed() {
737 mark::check!(no_call_parens_if_fn_ptr_needed); 735 cov_mark::check!(no_call_parens_if_fn_ptr_needed);
738 check_edit( 736 check_edit(
739 "foo", 737 "foo",
740 r#" 738 r#"
@@ -758,7 +756,7 @@ fn main() -> ManualVtable {
758 756
759 #[test] 757 #[test]
760 fn no_parens_in_use_item() { 758 fn no_parens_in_use_item() {
761 mark::check!(no_parens_in_use_item); 759 cov_mark::check!(no_parens_in_use_item);
762 check_edit( 760 check_edit(
763 "foo", 761 "foo",
764 r#" 762 r#"
@@ -802,7 +800,7 @@ fn f(foo: &Foo) { foo.foo(); }
802 800
803 #[test] 801 #[test]
804 fn inserts_angle_brackets_for_generics() { 802 fn inserts_angle_brackets_for_generics() {
805 mark::check!(inserts_angle_brackets_for_generics); 803 cov_mark::check!(inserts_angle_brackets_for_generics);
806 check_edit( 804 check_edit(
807 "Vec", 805 "Vec",
808 r#" 806 r#"
@@ -851,7 +849,7 @@ fn foo(xs: Vec<i128>)
851 849
852 #[test] 850 #[test]
853 fn active_param_score() { 851 fn active_param_score() {
854 mark::check!(active_param_type_match); 852 cov_mark::check!(active_param_type_match);
855 check_scores( 853 check_scores(
856 r#" 854 r#"
857struct S { foo: i64, bar: u32, baz: u32 } 855struct S { foo: i64, bar: u32, baz: u32 }
@@ -868,7 +866,7 @@ fn foo(s: S) { test(s.$0) }
868 866
869 #[test] 867 #[test]
870 fn record_field_scores() { 868 fn record_field_scores() {
871 mark::check!(record_field_type_match); 869 cov_mark::check!(record_field_type_match);
872 check_scores( 870 check_scores(
873 r#" 871 r#"
874struct A { foo: i64, bar: u32, baz: u32 } 872struct 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 @@
1//! Extensions for `Builder` structure required for item rendering. 1//! Extensions for `Builder` structure required for item rendering.
2 2
3use itertools::Itertools; 3use itertools::Itertools;
4use test_utils::mark;
5 4
6use crate::{item::Builder, CompletionContext}; 5use crate::{item::Builder, CompletionContext};
7 6
@@ -30,7 +29,7 @@ impl Builder {
30 return false; 29 return false;
31 } 30 }
32 if ctx.use_item_syntax.is_some() { 31 if ctx.use_item_syntax.is_some() {
33 mark::hit!(no_parens_in_use_item); 32 cov_mark::hit!(no_parens_in_use_item);
34 return false; 33 return false;
35 } 34 }
36 if ctx.is_pattern_call { 35 if ctx.is_pattern_call {
@@ -43,7 +42,7 @@ impl Builder {
43 // Don't add parentheses if the expected type is some function reference. 42 // Don't add parentheses if the expected type is some function reference.
44 if let Some(ty) = &ctx.expected_type { 43 if let Some(ty) = &ctx.expected_type {
45 if ty.is_fn() { 44 if ty.is_fn() {
46 mark::hit!(no_call_parens_if_fn_ptr_needed); 45 cov_mark::hit!(no_call_parens_if_fn_ptr_needed);
47 return false; 46 return false;
48 } 47 }
49 } 48 }
@@ -67,7 +66,7 @@ impl Builder {
67 None => return self, 66 None => return self,
68 }; 67 };
69 // If not an import, add parenthesis automatically. 68 // If not an import, add parenthesis automatically.
70 mark::hit!(inserts_parens_for_function_calls); 69 cov_mark::hit!(inserts_parens_for_function_calls);
71 70
72 let (snippet, label) = if params.is_empty() { 71 let (snippet, label) = if params.is_empty() {
73 (format!("{}()$0", name), format!("{}()", name)) 72 (format!("{}()$0", name), format!("{}()", name))
@@ -82,7 +81,7 @@ impl Builder {
82 format!("{}({})$0", name, function_params_snippet) 81 format!("{}({})$0", name, function_params_snippet)
83 } 82 }
84 _ => { 83 _ => {
85 mark::hit!(suppress_arg_snippets); 84 cov_mark::hit!(suppress_arg_snippets);
86 format!("{}($0)", name) 85 format!("{}($0)", name)
87 } 86 }
88 }; 87 };
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 @@
3use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; 3use hir::{HasAttrs, HirDisplay, ModPath, StructKind};
4use ide_db::SymbolKind; 4use ide_db::SymbolKind;
5use itertools::Itertools; 5use itertools::Itertools;
6use test_utils::mark;
7 6
8use crate::{ 7use crate::{
9 item::{CompletionItem, CompletionKind, ImportEdit}, 8 item::{CompletionItem, CompletionKind, ImportEdit},
@@ -68,7 +67,7 @@ impl<'a> EnumRender<'a> {
68 .detail(self.detail()); 67 .detail(self.detail());
69 68
70 if self.variant_kind == StructKind::Tuple { 69 if self.variant_kind == StructKind::Tuple {
71 mark::hit!(inserts_parens_for_tuple_enums); 70 cov_mark::hit!(inserts_parens_for_tuple_enums);
72 let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len()); 71 let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len());
73 builder = 72 builder =
74 builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params); 73 builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params);
@@ -103,13 +102,11 @@ impl<'a> EnumRender<'a> {
103 102
104#[cfg(test)] 103#[cfg(test)]
105mod tests { 104mod tests {
106 use test_utils::mark;
107
108 use crate::test_utils::check_edit; 105 use crate::test_utils::check_edit;
109 106
110 #[test] 107 #[test]
111 fn inserts_parens_for_tuple_enums() { 108 fn inserts_parens_for_tuple_enums() {
112 mark::check!(inserts_parens_for_tuple_enums); 109 cov_mark::check!(inserts_parens_for_tuple_enums);
113 check_edit( 110 check_edit(
114 "Some", 111 "Some",
115 r#" 112 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 @@
3use hir::{HasSource, HirDisplay, Type}; 3use hir::{HasSource, HirDisplay, Type};
4use ide_db::SymbolKind; 4use ide_db::SymbolKind;
5use syntax::ast::Fn; 5use syntax::ast::Fn;
6use test_utils::mark;
7 6
8use crate::{ 7use crate::{
9 item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, 8 item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit},
@@ -82,7 +81,7 @@ impl<'a> FunctionRender<'a> {
82 self.func.method_params(self.ctx.db()).unwrap_or_default() 81 self.func.method_params(self.ctx.db()).unwrap_or_default()
83 } else { 82 } else {
84 if let Some(s) = ast_params.self_param() { 83 if let Some(s) = ast_params.self_param() {
85 mark::hit!(parens_for_method_call_as_assoc_fn); 84 cov_mark::hit!(parens_for_method_call_as_assoc_fn);
86 params_pats.push(Some(s.to_string())); 85 params_pats.push(Some(s.to_string()));
87 } 86 }
88 self.func.assoc_fn_params(self.ctx.db()) 87 self.func.assoc_fn_params(self.ctx.db())
@@ -114,8 +113,6 @@ impl<'a> FunctionRender<'a> {
114 113
115#[cfg(test)] 114#[cfg(test)]
116mod tests { 115mod tests {
117 use test_utils::mark;
118
119 use crate::{ 116 use crate::{
120 test_utils::{check_edit, check_edit_with_config, TEST_CONFIG}, 117 test_utils::{check_edit, check_edit_with_config, TEST_CONFIG},
121 CompletionConfig, 118 CompletionConfig,
@@ -123,7 +120,7 @@ mod tests {
123 120
124 #[test] 121 #[test]
125 fn inserts_parens_for_function_calls() { 122 fn inserts_parens_for_function_calls() {
126 mark::check!(inserts_parens_for_function_calls); 123 cov_mark::check!(inserts_parens_for_function_calls);
127 check_edit( 124 check_edit(
128 "no_args", 125 "no_args",
129 r#" 126 r#"
@@ -191,7 +188,7 @@ fn bar(s: &S) {
191 188
192 #[test] 189 #[test]
193 fn parens_for_method_call_as_assoc_fn() { 190 fn parens_for_method_call_as_assoc_fn() {
194 mark::check!(parens_for_method_call_as_assoc_fn); 191 cov_mark::check!(parens_for_method_call_as_assoc_fn);
195 check_edit( 192 check_edit(
196 "foo", 193 "foo",
197 r#" 194 r#"
@@ -213,7 +210,7 @@ fn main() { S::foo(${1:&self})$0 }
213 210
214 #[test] 211 #[test]
215 fn suppress_arg_snippets() { 212 fn suppress_arg_snippets() {
216 mark::check!(suppress_arg_snippets); 213 cov_mark::check!(suppress_arg_snippets);
217 check_edit_with_config( 214 check_edit_with_config(
218 CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG }, 215 CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG },
219 "with_args", 216 "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 @@
3use hir::{Documentation, HasSource}; 3use hir::{Documentation, HasSource};
4use ide_db::SymbolKind; 4use ide_db::SymbolKind;
5use syntax::display::macro_label; 5use syntax::display::macro_label;
6use test_utils::mark;
7 6
8use crate::{ 7use crate::{
9 item::{CompletionItem, CompletionKind, ImportEdit}, 8 item::{CompletionItem, CompletionKind, ImportEdit},
@@ -57,7 +56,7 @@ impl<'a> MacroRender<'a> {
57 } 56 }
58 None if needs_bang => builder.insert_text(self.banged_name()), 57 None if needs_bang => builder.insert_text(self.banged_name()),
59 _ => { 58 _ => {
60 mark::hit!(dont_insert_macro_call_parens_unncessary); 59 cov_mark::hit!(dont_insert_macro_call_parens_unncessary);
61 builder.insert_text(&self.name) 60 builder.insert_text(&self.name)
62 } 61 }
63 }; 62 };
@@ -125,13 +124,11 @@ fn guess_macro_braces(macro_name: &str, docs: &str) -> (&'static str, &'static s
125 124
126#[cfg(test)] 125#[cfg(test)]
127mod tests { 126mod tests {
128 use test_utils::mark;
129
130 use crate::test_utils::check_edit; 127 use crate::test_utils::check_edit;
131 128
132 #[test] 129 #[test]
133 fn dont_insert_macro_call_parens_unncessary() { 130 fn dont_insert_macro_call_parens_unncessary() {
134 mark::check!(dont_insert_macro_call_parens_unncessary); 131 cov_mark::check!(dont_insert_macro_call_parens_unncessary);
135 check_edit( 132 check_edit(
136 "frobnicate!", 133 "frobnicate!",
137 r#" 134 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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13log = "0.4.8" 14log = "0.4.8"
14rayon = "1.5.0" 15rayon = "1.5.0"
15fst = { version = "0.4", default-features = false } 16fst = { 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::{
7 ast::{self, ArgListOwner}, 7 ast::{self, ArgListOwner},
8 match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize, 8 match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize,
9}; 9};
10use test_utils::mark;
11 10
12use crate::RootDatabase; 11use crate::RootDatabase;
13 12
@@ -122,7 +121,7 @@ fn call_info_impl(
122 121
123 let arg_list_range = arg_list.syntax().text_range(); 122 let arg_list_range = arg_list.syntax().text_range();
124 if !arg_list_range.contains_inclusive(token.text_range().start()) { 123 if !arg_list_range.contains_inclusive(token.text_range().start()) {
125 mark::hit!(call_info_bad_offset); 124 cov_mark::hit!(call_info_bad_offset);
126 return None; 125 return None;
127 } 126 }
128 let param = std::cmp::min( 127 let param = std::cmp::min(
@@ -162,7 +161,7 @@ impl ActiveParameter {
162 let idx = active_parameter?; 161 let idx = active_parameter?;
163 let mut params = signature.params(sema.db); 162 let mut params = signature.params(sema.db);
164 if !(idx < params.len()) { 163 if !(idx < params.len()) {
165 mark::hit!(too_many_arguments); 164 cov_mark::hit!(too_many_arguments);
166 return None; 165 return None;
167 } 166 }
168 let (pat, ty) = params.swap_remove(idx); 167 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 @@
1use crate::RootDatabase; 1use crate::RootDatabase;
2use base_db::{fixture::ChangeFixture, FilePosition}; 2use base_db::{fixture::ChangeFixture, FilePosition};
3use expect_test::{expect, Expect}; 3use expect_test::{expect, Expect};
4use test_utils::{mark, RangeOrOffset}; 4use test_utils::RangeOrOffset;
5 5
6/// Creates analysis from a multi-file fixture, returns positions marked with $0. 6/// Creates analysis from a multi-file fixture, returns positions marked with $0.
7pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) { 7pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
@@ -347,7 +347,7 @@ pub fn foo(mut r: WriteHandler<()>) {
347 347
348#[test] 348#[test]
349fn call_info_bad_offset() { 349fn call_info_bad_offset() {
350 mark::check!(call_info_bad_offset); 350 cov_mark::check!(call_info_bad_offset);
351 check( 351 check(
352 r#" 352 r#"
353fn foo(x: u32, y: u32) -> u32 {x + y} 353fn 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::{
13 }, 13 },
14 AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken, 14 AstToken, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken,
15}; 15};
16use test_utils::mark;
17 16
18#[derive(Clone, Copy, Debug, PartialEq, Eq)] 17#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19pub struct InsertUseConfig { 18pub struct InsertUseConfig {
@@ -138,7 +137,7 @@ pub fn insert_use<'a>(
138 137
139 if add_blank.has_before() { 138 if add_blank.has_before() {
140 if let Some(indent) = indent.clone() { 139 if let Some(indent) = indent.clone() {
141 mark::hit!(insert_use_indent_before); 140 cov_mark::hit!(insert_use_indent_before);
142 buf.push(indent); 141 buf.push(indent);
143 } 142 }
144 } 143 }
@@ -156,11 +155,11 @@ pub fn insert_use<'a>(
156 // only add indentation *after* our stuff if there's another node directly after it 155 // only add indentation *after* our stuff if there's another node directly after it
157 if add_blank.has_after() && matches!(insert_position, InsertPosition::Before(_)) { 156 if add_blank.has_after() && matches!(insert_position, InsertPosition::Before(_)) {
158 if let Some(indent) = indent { 157 if let Some(indent) = indent {
159 mark::hit!(insert_use_indent_after); 158 cov_mark::hit!(insert_use_indent_after);
160 buf.push(indent); 159 buf.push(indent);
161 } 160 }
162 } else if add_blank.has_after() && matches!(insert_position, InsertPosition::After(_)) { 161 } else if add_blank.has_after() && matches!(insert_position, InsertPosition::After(_)) {
163 mark::hit!(insert_use_no_indent_after); 162 cov_mark::hit!(insert_use_no_indent_after);
164 } 163 }
165 164
166 buf 165 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;",
51 51
52#[test] 52#[test]
53fn insert_start_indent() { 53fn insert_start_indent() {
54 mark::check!(insert_use_indent_after); 54 cov_mark::check!(insert_use_indent_after);
55 check_none( 55 check_none(
56 "std::bar::AA", 56 "std::bar::AA",
57 r" 57 r"
@@ -120,7 +120,7 @@ use std::bar::ZZ;",
120 120
121#[test] 121#[test]
122fn insert_end_indent() { 122fn insert_end_indent() {
123 mark::check!(insert_use_indent_before); 123 cov_mark::check!(insert_use_indent_before);
124 check_none( 124 check_none(
125 "std::bar::ZZ", 125 "std::bar::ZZ",
126 r" 126 r"
@@ -255,7 +255,7 @@ fn insert_empty_file() {
255 255
256#[test] 256#[test]
257fn insert_empty_module() { 257fn insert_empty_module() {
258 mark::check!(insert_use_no_indent_after); 258 cov_mark::check!(insert_use_no_indent_after);
259 check( 259 check(
260 "foo::bar", 260 "foo::bar",
261 "mod x {}", 261 "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"
11doctest = false 11doctest = false
12 12
13[dependencies] 13[dependencies]
14cov-mark = "1.1"
14rustc-hash = "1.1.0" 15rustc-hash = "1.1.0"
15itertools = "0.10.0" 16itertools = "0.10.0"
16 17
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::{
15 ast::{AstNode, AstToken}, 15 ast::{AstNode, AstToken},
16 SmolStr, 16 SmolStr,
17}; 17};
18use test_utils::mark;
19 18
20// Creates a match error. If we're currently attempting to match some code that we thought we were 19// Creates a match error. If we're currently attempting to match some code that we thought we were
21// going to match, as indicated by the --debug-snippet flag, then populate the reason field. 20// going to match, as indicated by the --debug-snippet flag, then populate the reason field.
@@ -731,7 +730,7 @@ impl NodeKind {
731 fn matches(&self, node: &SyntaxNode) -> Result<(), MatchFailed> { 730 fn matches(&self, node: &SyntaxNode) -> Result<(), MatchFailed> {
732 let ok = match self { 731 let ok = match self {
733 Self::Literal => { 732 Self::Literal => {
734 mark::hit!(literal_constraint); 733 cov_mark::hit!(literal_constraint);
735 ast::Literal::can_cast(node.kind()) 734 ast::Literal::can_cast(node.kind())
736 } 735 }
737 }; 736 };
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};
10use rustc_hash::{FxHashMap, FxHashSet}; 10use rustc_hash::{FxHashMap, FxHashSet};
11use std::{fmt::Display, str::FromStr}; 11use std::{fmt::Display, str::FromStr};
12use syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; 12use syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T};
13use test_utils::mark;
14 13
15#[derive(Debug)] 14#[derive(Debug)]
16pub(crate) struct ParsedRule { 15pub(crate) struct ParsedRule {
@@ -131,7 +130,7 @@ impl RuleBuilder {
131 let old_len = self.rules.len(); 130 let old_len = self.rules.len();
132 self.rules.retain(|rule| contains_path(&rule.pattern)); 131 self.rules.retain(|rule| contains_path(&rule.pattern));
133 if self.rules.len() < old_len { 132 if self.rules.len() < old_len {
134 mark::hit!(pattern_is_a_single_segment_path); 133 cov_mark::hit!(pattern_is_a_single_segment_path);
135 } 134 }
136 } 135 }
137 Ok(self.rules) 136 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;
5use rustc_hash::{FxHashMap, FxHashSet}; 5use rustc_hash::{FxHashMap, FxHashSet};
6use syntax::ast::{self, AstNode, AstToken}; 6use syntax::ast::{self, AstNode, AstToken};
7use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; 7use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
8use test_utils::mark; 8
9use text_edit::TextEdit; 9use text_edit::TextEdit;
10 10
11/// Returns a text edit that will replace each match in `matches` with its corresponding replacement 11/// Returns a text edit that will replace each match in `matches` with its corresponding replacement
@@ -128,7 +128,7 @@ impl ReplacementRenderer<'_> {
128 && (placeholder_value.autoderef_count > 0 128 && (placeholder_value.autoderef_count > 0
129 || placeholder_value.autoref_kind != ast::SelfParamKind::Owned) 129 || placeholder_value.autoref_kind != ast::SelfParamKind::Owned)
130 { 130 {
131 mark::hit!(replace_autoref_autoderef_capture); 131 cov_mark::hit!(replace_autoref_autoderef_capture);
132 let ref_kind = match placeholder_value.autoref_kind { 132 let ref_kind = match placeholder_value.autoref_kind {
133 ast::SelfParamKind::Owned => "", 133 ast::SelfParamKind::Owned => "",
134 ast::SelfParamKind::Ref => "&", 134 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;
6use parsing::Placeholder; 6use parsing::Placeholder;
7use rustc_hash::FxHashMap; 7use rustc_hash::FxHashMap;
8use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; 8use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken};
9use test_utils::mark;
10 9
11pub(crate) struct ResolutionScope<'db> { 10pub(crate) struct ResolutionScope<'db> {
12 scope: hir::SemanticsScope<'db>, 11 scope: hir::SemanticsScope<'db>,
@@ -170,13 +169,13 @@ impl Resolver<'_, '_> {
170 // calls. e.g. `Foo::bar($s)` should match `x.bar()`. 169 // calls. e.g. `Foo::bar($s)` should match `x.bar()`.
171 true 170 true
172 } else { 171 } else {
173 mark::hit!(replace_associated_trait_default_function_call); 172 cov_mark::hit!(replace_associated_trait_default_function_call);
174 false 173 false
175 } 174 }
176 } 175 }
177 hir::PathResolution::AssocItem(_) => { 176 hir::PathResolution::AssocItem(_) => {
178 // Not a function. Could be a constant or an associated type. 177 // Not a function. Could be a constant or an associated type.
179 mark::hit!(replace_associated_trait_constant); 178 cov_mark::hit!(replace_associated_trait_constant);
180 false 179 false
181 } 180 }
182 _ => true, 181 _ => true,
@@ -267,7 +266,7 @@ fn pick_node_for_resolution(node: SyntaxNode) -> SyntaxNode {
267 match node.kind() { 266 match node.kind() {
268 SyntaxKind::EXPR_STMT => { 267 SyntaxKind::EXPR_STMT => {
269 if let Some(n) = node.first_child() { 268 if let Some(n) = node.first_child() {
270 mark::hit!(cursor_after_semicolon); 269 cov_mark::hit!(cursor_after_semicolon);
271 return n; 270 return n;
272 } 271 }
273 } 272 }
@@ -291,7 +290,7 @@ fn path_contains_type_arguments(path: Option<ast::Path>) -> bool {
291 if let Some(path) = path { 290 if let Some(path) = path {
292 if let Some(segment) = path.segment() { 291 if let Some(segment) = path.segment() {
293 if segment.generic_arg_list().is_some() { 292 if segment.generic_arg_list().is_some() {
294 mark::hit!(type_arguments_within_path); 293 cov_mark::hit!(type_arguments_within_path);
295 return true; 294 return true;
296 } 295 }
297 } 296 }
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::{
12}; 12};
13use rustc_hash::FxHashSet; 13use rustc_hash::FxHashSet;
14use syntax::{ast, AstNode, SyntaxKind, SyntaxNode}; 14use syntax::{ast, AstNode, SyntaxKind, SyntaxNode};
15use test_utils::mark;
16 15
17/// A cache for the results of find_usages. This is for when we have multiple patterns that have the 16/// A cache for the results of find_usages. This is for when we have multiple patterns that have the
18/// same path. e.g. if the pattern was `foo::Bar` that can parse as a path, an expression, a type 17/// 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> {
61 for file_range in self.find_usages(usage_cache, definition).file_ranges() { 60 for file_range in self.find_usages(usage_cache, definition).file_ranges() {
62 if let Some(node_to_match) = self.find_node_to_match(resolved_path, file_range) { 61 if let Some(node_to_match) = self.find_node_to_match(resolved_path, file_range) {
63 if !is_search_permitted_ancestors(&node_to_match) { 62 if !is_search_permitted_ancestors(&node_to_match) {
64 mark::hit!(use_declaration_with_braces); 63 cov_mark::hit!(use_declaration_with_braces);
65 continue; 64 continue;
66 } 65 }
67 self.try_add_match(rule, &node_to_match, &None, matches_out); 66 self.try_add_match(rule, &node_to_match, &None, matches_out);
@@ -205,7 +204,7 @@ impl<'db> MatchFinder<'db> {
205 matches_out: &mut Vec<Match>, 204 matches_out: &mut Vec<Match>,
206 ) { 205 ) {
207 if !self.within_range_restrictions(code) { 206 if !self.within_range_restrictions(code) {
208 mark::hit!(replace_nonpath_within_selection); 207 cov_mark::hit!(replace_nonpath_within_selection);
209 return; 208 return;
210 } 209 }
211 if let Ok(m) = matching::get_match(false, rule, code, restrict_range, &self.sema) { 210 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};
3use ide_db::base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; 3use ide_db::base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use std::sync::Arc; 5use std::sync::Arc;
6use test_utils::{mark, RangeOrOffset}; 6use test_utils::RangeOrOffset;
7 7
8fn parse_error_text(query: &str) -> String { 8fn parse_error_text(query: &str) -> String {
9 format!("{}", query.parse::<SsrRule>().unwrap_err()) 9 format!("{}", query.parse::<SsrRule>().unwrap_err())
@@ -492,7 +492,7 @@ fn match_resolved_type_name() {
492 492
493#[test] 493#[test]
494fn type_arguments_within_path() { 494fn type_arguments_within_path() {
495 mark::check!(type_arguments_within_path); 495 cov_mark::check!(type_arguments_within_path);
496 let code = r#" 496 let code = r#"
497 mod foo { 497 mod foo {
498 pub struct Bar<T> {t: T} 498 pub struct Bar<T> {t: T}
@@ -508,7 +508,7 @@ fn type_arguments_within_path() {
508 508
509#[test] 509#[test]
510fn literal_constraint() { 510fn literal_constraint() {
511 mark::check!(literal_constraint); 511 cov_mark::check!(literal_constraint);
512 let code = r#" 512 let code = r#"
513 enum Option<T> { Some(T), None } 513 enum Option<T> { Some(T), None }
514 use Option::Some; 514 use Option::Some;
@@ -641,7 +641,7 @@ fn replace_associated_function_call() {
641 641
642#[test] 642#[test]
643fn replace_associated_trait_default_function_call() { 643fn replace_associated_trait_default_function_call() {
644 mark::check!(replace_associated_trait_default_function_call); 644 cov_mark::check!(replace_associated_trait_default_function_call);
645 assert_ssr_transform( 645 assert_ssr_transform(
646 "Bar2::foo() ==>> Bar2::foo2()", 646 "Bar2::foo() ==>> Bar2::foo2()",
647 r#" 647 r#"
@@ -673,7 +673,7 @@ fn replace_associated_trait_default_function_call() {
673 673
674#[test] 674#[test]
675fn replace_associated_trait_constant() { 675fn replace_associated_trait_constant() {
676 mark::check!(replace_associated_trait_constant); 676 cov_mark::check!(replace_associated_trait_constant);
677 assert_ssr_transform( 677 assert_ssr_transform(
678 "Bar2::VALUE ==>> Bar2::VALUE_2222", 678 "Bar2::VALUE ==>> Bar2::VALUE_2222",
679 r#" 679 r#"
@@ -998,7 +998,7 @@ fn use_declaration_with_braces() {
998 // It would be OK for a path rule to match and alter a use declaration. We shouldn't mess it up 998 // It would be OK for a path rule to match and alter a use declaration. We shouldn't mess it up
999 // though. In particular, we must not change `use foo::{baz, bar}` to `use foo::{baz, 999 // though. In particular, we must not change `use foo::{baz, bar}` to `use foo::{baz,
1000 // foo2::bar2}`. 1000 // foo2::bar2}`.
1001 mark::check!(use_declaration_with_braces); 1001 cov_mark::check!(use_declaration_with_braces);
1002 assert_ssr_transform( 1002 assert_ssr_transform(
1003 "foo::bar ==>> foo2::bar2", 1003 "foo::bar ==>> foo2::bar2",
1004 r#" 1004 r#"
@@ -1076,7 +1076,7 @@ fn ufcs_matches_method_call() {
1076 1076
1077#[test] 1077#[test]
1078fn pattern_is_a_single_segment_path() { 1078fn pattern_is_a_single_segment_path() {
1079 mark::check!(pattern_is_a_single_segment_path); 1079 cov_mark::check!(pattern_is_a_single_segment_path);
1080 // The first function should not be altered because the `foo` in scope at the cursor position is 1080 // The first function should not be altered because the `foo` in scope at the cursor position is
1081 // a different `foo`. This case is special because "foo" can be parsed as a pattern (IDENT_PAT -> 1081 // a different `foo`. This case is special because "foo" can be parsed as a pattern (IDENT_PAT ->
1082 // NAME -> IDENT), which contains no path. If we're not careful we'll end up matching the `foo` 1082 // 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() {
1118 // The pattern references a local variable `foo` in the block containing the cursor. We should 1118 // The pattern references a local variable `foo` in the block containing the cursor. We should
1119 // only replace references to this variable `foo`, not other variables that just happen to have 1119 // only replace references to this variable `foo`, not other variables that just happen to have
1120 // the same name. 1120 // the same name.
1121 mark::check!(cursor_after_semicolon); 1121 cov_mark::check!(cursor_after_semicolon);
1122 assert_ssr_transform( 1122 assert_ssr_transform(
1123 "foo + $a ==>> $a - foo", 1123 "foo + $a ==>> $a - foo",
1124 r#" 1124 r#"
@@ -1179,7 +1179,7 @@ fn replace_path_within_selection() {
1179 1179
1180#[test] 1180#[test]
1181fn replace_nonpath_within_selection() { 1181fn replace_nonpath_within_selection() {
1182 mark::check!(replace_nonpath_within_selection); 1182 cov_mark::check!(replace_nonpath_within_selection);
1183 assert_ssr_transform( 1183 assert_ssr_transform(
1184 "$a + $b ==>> $b * $a", 1184 "$a + $b ==>> $b * $a",
1185 r#" 1185 r#"
@@ -1269,7 +1269,7 @@ fn replace_autoref_autoderef_capture() {
1269 // second, we already have a reference, so it isn't. When $a is used in a context where autoref 1269 // second, we already have a reference, so it isn't. When $a is used in a context where autoref
1270 // doesn't apply, we need to prefix it with `&`. Finally, we have some cases where autoderef 1270 // doesn't apply, we need to prefix it with `&`. Finally, we have some cases where autoderef
1271 // needs to be applied. 1271 // needs to be applied.
1272 mark::check!(replace_autoref_autoderef_capture); 1272 cov_mark::check!(replace_autoref_autoderef_capture);
1273 let code = r#" 1273 let code = r#"
1274 struct Foo {} 1274 struct Foo {}
1275 impl Foo { 1275 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"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13cov-mark = "1.1"
13rustc-hash = "1.1.0" 14rustc-hash = "1.1.0"
14smallvec = "1.2.0" 15smallvec = "1.2.0"
15log = "0.4.8" 16log = "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;
17 17
18use std::fmt; 18use std::fmt;
19 19
20use test_utils::mark;
21pub use tt::{Delimiter, DelimiterKind, Punct}; 20pub use tt::{Delimiter, DelimiterKind, Punct};
22 21
23use crate::{ 22use crate::{
@@ -217,7 +216,7 @@ impl MacroDef {
217 let mut rules = Vec::new(); 216 let mut rules = Vec::new();
218 217
219 if Some(tt::DelimiterKind::Brace) == tt.delimiter_kind() { 218 if Some(tt::DelimiterKind::Brace) == tt.delimiter_kind() {
220 mark::hit!(parse_macro_def_rules); 219 cov_mark::hit!(parse_macro_def_rules);
221 while src.len() > 0 { 220 while src.len() > 0 {
222 let rule = Rule::parse(&mut src, true)?; 221 let rule = Rule::parse(&mut src, true)?;
223 rules.push(rule); 222 rules.push(rule);
@@ -229,7 +228,7 @@ impl MacroDef {
229 } 228 }
230 } 229 }
231 } else { 230 } else {
232 mark::hit!(parse_macro_def_simple); 231 cov_mark::hit!(parse_macro_def_simple);
233 let rule = Rule::parse(&mut src, false)?; 232 let rule = Rule::parse(&mut src, false)?;
234 if src.len() != 0 { 233 if src.len() != 0 {
235 return Err(ParseError::Expected("remain tokens in macro def".to_string())); 234 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::{
6 SyntaxKind::{ERROR, IDENT}, 6 SyntaxKind::{ERROR, IDENT},
7 SyntaxNode, WalkEvent, T, 7 SyntaxNode, WalkEvent, T,
8}; 8};
9use test_utils::{assert_eq_text, mark}; 9use test_utils::assert_eq_text;
10 10
11use super::*; 11use super::*;
12 12
@@ -687,7 +687,7 @@ fn test_match_literal() {
687 687
688#[test] 688#[test]
689fn test_parse_macro_def_simple() { 689fn test_parse_macro_def_simple() {
690 mark::check!(parse_macro_def_simple); 690 cov_mark::check!(parse_macro_def_simple);
691 691
692 parse_macro2( 692 parse_macro2(
693 r#" 693 r#"
@@ -701,7 +701,7 @@ macro foo($id:ident) {
701 701
702#[test] 702#[test]
703fn test_parse_macro_def_rules() { 703fn test_parse_macro_def_rules() {
704 mark::check!(parse_macro_def_rules); 704 cov_mark::check!(parse_macro_def_rules);
705 705
706 parse_macro2( 706 parse_macro2(
707 r#" 707 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 {
268 fn mark(unmarked: Self::Unmarked) -> Self; 268 fn mark(unmarked: Self::Unmarked) -> Self;
269} 269}
270 270
271/// Unwrap types wrapped by `Mark::mark` (see `Mark` for details). 271/// Unwrap types wrapped by `cov_mark::mark` (see `Mark` for details).
272trait Unmark { 272trait Unmark {
273 type Unmarked; 273 type Unmarked;
274 fn unmark(self) -> Self::Unmarked; 274 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"
11doctest = false 11doctest = false
12 12
13[dependencies] 13[dependencies]
14cov-mark = "1.1"
14itertools = "0.10.0" 15itertools = "0.10.0"
15rowan = "0.12.2" 16rowan = "0.12.2"
16rustc_lexer = { version = "709.0.0", package = "rustc-ap-rustc_lexer" } 17rustc_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::{
10use indexmap::IndexMap; 10use indexmap::IndexMap;
11use itertools::Itertools; 11use itertools::Itertools;
12use rustc_hash::FxHashMap; 12use rustc_hash::FxHashMap;
13use test_utils::mark;
14use text_edit::TextEditBuilder; 13use text_edit::TextEditBuilder;
15 14
16use crate::{ 15use crate::{
@@ -184,7 +183,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
184 let (lhs, rhs) = match lhs.as_node().zip(rhs.as_node()) { 183 let (lhs, rhs) = match lhs.as_node().zip(rhs.as_node()) {
185 Some((lhs, rhs)) => (lhs, rhs), 184 Some((lhs, rhs)) => (lhs, rhs),
186 _ => { 185 _ => {
187 mark::hit!(diff_node_token_replace); 186 cov_mark::hit!(diff_node_token_replace);
188 diff.replacements.insert(lhs, rhs); 187 diff.replacements.insert(lhs, rhs);
189 return; 188 return;
190 } 189 }
@@ -202,19 +201,19 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
202 (None, Some(element)) => { 201 (None, Some(element)) => {
203 let insert_pos = match last_lhs.clone() { 202 let insert_pos = match last_lhs.clone() {
204 Some(prev) => { 203 Some(prev) => {
205 mark::hit!(diff_insert); 204 cov_mark::hit!(diff_insert);
206 TreeDiffInsertPos::After(prev) 205 TreeDiffInsertPos::After(prev)
207 } 206 }
208 // first iteration, insert into out parent as the first child 207 // first iteration, insert into out parent as the first child
209 None => { 208 None => {
210 mark::hit!(diff_insert_as_first_child); 209 cov_mark::hit!(diff_insert_as_first_child);
211 TreeDiffInsertPos::AsFirstChild(lhs.clone().into()) 210 TreeDiffInsertPos::AsFirstChild(lhs.clone().into())
212 } 211 }
213 }; 212 };
214 diff.insertions.entry(insert_pos).or_insert_with(Vec::new).push(element); 213 diff.insertions.entry(insert_pos).or_insert_with(Vec::new).push(element);
215 } 214 }
216 (Some(element), None) => { 215 (Some(element), None) => {
217 mark::hit!(diff_delete); 216 cov_mark::hit!(diff_delete);
218 diff.deletions.push(element); 217 diff.deletions.push(element);
219 } 218 }
220 (Some(ref lhs_ele), Some(ref rhs_ele)) if syntax_element_eq(lhs_ele, rhs_ele) => {} 219 (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 {
228 let mut insert = false; 227 let mut insert = false;
229 while let Some(rhs_child) = rhs_children_clone.next() { 228 while let Some(rhs_child) = rhs_children_clone.next() {
230 if syntax_element_eq(&lhs_ele, &rhs_child) { 229 if syntax_element_eq(&lhs_ele, &rhs_child) {
231 mark::hit!(diff_insertions); 230 cov_mark::hit!(diff_insertions);
232 insert = true; 231 insert = true;
233 break; 232 break;
234 } else { 233 } else {
@@ -240,7 +239,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
240 let insert_pos = if let Some(prev) = last_lhs.clone().filter(|_| insert) { 239 let insert_pos = if let Some(prev) = last_lhs.clone().filter(|_| insert) {
241 TreeDiffInsertPos::After(prev) 240 TreeDiffInsertPos::After(prev)
242 } else { 241 } else {
243 mark::hit!(insert_first_child); 242 cov_mark::hit!(insert_first_child);
244 TreeDiffInsertPos::AsFirstChild(lhs.clone().into()) 243 TreeDiffInsertPos::AsFirstChild(lhs.clone().into())
245 }; 244 };
246 245
@@ -635,14 +634,13 @@ mod tests {
635 use expect_test::{expect, Expect}; 634 use expect_test::{expect, Expect};
636 use itertools::Itertools; 635 use itertools::Itertools;
637 use parser::SyntaxKind; 636 use parser::SyntaxKind;
638 use test_utils::mark;
639 use text_edit::TextEdit; 637 use text_edit::TextEdit;
640 638
641 use crate::{AstNode, SyntaxElement}; 639 use crate::{AstNode, SyntaxElement};
642 640
643 #[test] 641 #[test]
644 fn replace_node_token() { 642 fn replace_node_token() {
645 mark::check!(diff_node_token_replace); 643 cov_mark::check!(diff_node_token_replace);
646 check_diff( 644 check_diff(
647 r#"use node;"#, 645 r#"use node;"#,
648 r#"ident"#, 646 r#"ident"#,
@@ -666,7 +664,7 @@ mod tests {
666 664
667 #[test] 665 #[test]
668 fn replace_parent() { 666 fn replace_parent() {
669 mark::check!(diff_insert_as_first_child); 667 cov_mark::check!(diff_insert_as_first_child);
670 check_diff( 668 check_diff(
671 r#""#, 669 r#""#,
672 r#"use foo::bar;"#, 670 r#"use foo::bar;"#,
@@ -689,7 +687,7 @@ mod tests {
689 687
690 #[test] 688 #[test]
691 fn insert_last() { 689 fn insert_last() {
692 mark::check!(diff_insert); 690 cov_mark::check!(diff_insert);
693 check_diff( 691 check_diff(
694 r#" 692 r#"
695use foo; 693use foo;
@@ -774,7 +772,7 @@ use baz;"#,
774 772
775 #[test] 773 #[test]
776 fn first_child_insertion() { 774 fn first_child_insertion() {
777 mark::check!(insert_first_child); 775 cov_mark::check!(insert_first_child);
778 check_diff( 776 check_diff(
779 r#"fn main() { 777 r#"fn main() {
780 stdi 778 stdi
@@ -804,7 +802,7 @@ use baz;"#,
804 802
805 #[test] 803 #[test]
806 fn delete_last() { 804 fn delete_last() {
807 mark::check!(diff_delete); 805 cov_mark::check!(diff_delete);
808 check_diff( 806 check_diff(
809 r#"use foo; 807 r#"use foo;
810 use bar;"#, 808 use bar;"#,
@@ -828,7 +826,7 @@ use baz;"#,
828 826
829 #[test] 827 #[test]
830 fn delete_middle() { 828 fn delete_middle() {
831 mark::check!(diff_insertions); 829 cov_mark::check!(diff_insertions);
832 check_diff( 830 check_diff(
833 r#" 831 r#"
834use expect_test::{expect, Expect}; 832use 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 @@
6//! * Extracting markup (mainly, `$0` markers) out of fixture strings. 6//! * Extracting markup (mainly, `$0` markers) out of fixture strings.
7//! * marks (see the eponymous module). 7//! * marks (see the eponymous module).
8 8
9#[macro_use]
10pub mod mark;
11pub mod bench_fixture; 9pub mod bench_fixture;
12mod fixture; 10mod fixture;
13 11
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 @@
1//! This module implements manually tracked test coverage, which is useful for
2//! quickly finding a test responsible for testing a particular bit of code.
3//!
4//! See <https://matklad.github.io/2018/06/18/a-trick-for-test-maintenance.html>
5//! for details, but the TL;DR is that you write your test as
6//!
7//! ```
8//! #[test]
9//! fn test_foo() {
10//! mark::check!(test_foo);
11//! }
12//! ```
13//!
14//! and in the code under test you write
15//!
16//! ```
17//! # use test_utils::mark;
18//! # fn some_condition() -> bool { true }
19//! fn foo() {
20//! if some_condition() {
21//! mark::hit!(test_foo);
22//! }
23//! }
24//! ```
25//!
26//! This module then checks that executing the test indeed covers the specified
27//! function. This is useful if you come back to the `foo` function ten years
28//! later and wonder where the test are: now you can grep for `test_foo`.
29use std::sync::atomic::{AtomicUsize, Ordering};
30
31#[macro_export]
32macro_rules! _hit {
33 ($ident:ident) => {{
34 #[cfg(test)]
35 {
36 extern "C" {
37 #[no_mangle]
38 static $ident: std::sync::atomic::AtomicUsize;
39 }
40 unsafe {
41 $ident.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
42 }
43 }
44 }};
45}
46pub use _hit as hit;
47
48#[macro_export]
49macro_rules! _check {
50 ($ident:ident) => {
51 #[no_mangle]
52 static $ident: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
53 let _checker = $crate::mark::MarkChecker::new(&$ident);
54 };
55}
56pub use _check as check;
57
58pub struct MarkChecker {
59 mark: &'static AtomicUsize,
60 value_on_entry: usize,
61}
62
63impl MarkChecker {
64 pub fn new(mark: &'static AtomicUsize) -> MarkChecker {
65 let value_on_entry = mark.load(Ordering::Relaxed);
66 MarkChecker { mark, value_on_entry }
67 }
68}
69
70impl Drop for MarkChecker {
71 fn drop(&mut self) {
72 if std::thread::panicking() {
73 return;
74 }
75 let value_on_exit = self.mark.load(Ordering::Relaxed);
76 assert!(value_on_exit > self.value_on_entry, "mark was not hit")
77 }
78}