diff options
author | Laurențiu Nicola <[email protected]> | 2021-03-08 20:19:44 +0000 |
---|---|---|
committer | Laurențiu Nicola <[email protected]> | 2021-03-08 20:19:44 +0000 |
commit | fc9eed4836dfc88fe2893c81b015ab440cea2ba6 (patch) | |
tree | 3905029a42c8bb6c5d363753b34cd6b5dd43f4d5 /crates/ide_assists/src | |
parent | c5189a22ccf4c28e309e4189defbb88b83bb2aea (diff) |
Use upstream cov-mark
Diffstat (limited to 'crates/ide_assists/src')
23 files changed, 109 insertions, 150 deletions
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 @@ | |||
1 | use ide_db::defs::{Definition, NameRefClass}; | 1 | use ide_db::defs::{Definition, NameRefClass}; |
2 | use syntax::{ast, AstNode, SyntaxKind, T}; | 2 | use syntax::{ast, AstNode, SyntaxKind, T}; |
3 | use test_utils::mark; | ||
4 | 3 | ||
5 | use crate::{ | 4 | use 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 @@ | |||
1 | use syntax::ast::{self, AstNode}; | 1 | use syntax::ast::{self, AstNode}; |
2 | use test_utils::mark; | ||
3 | 2 | ||
4 | use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists}; | 3 | use 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)] |
91 | mod tests { | 90 | mod 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 | }; |
7 | use test_utils::mark; | ||
8 | 7 | ||
9 | use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; | 8 | use 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)] |
112 | mod tests { | 111 | mod 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 | }; |
23 | use test_utils::mark; | ||
24 | 23 | ||
25 | use crate::{ | 24 | use 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 | }; |
9 | use test_utils::mark; | ||
10 | 9 | ||
11 | use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists}; | 10 | use 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)] |
177 | mod tests { | 176 | mod 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}; | |||
5 | use ide_db::RootDatabase; | 5 | use ide_db::RootDatabase; |
6 | use itertools::Itertools; | 6 | use itertools::Itertools; |
7 | use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; | 7 | use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; |
8 | use test_utils::mark; | ||
9 | 8 | ||
10 | use crate::{ | 9 | use 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)] |
196 | mod tests { | 195 | mod 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#" |
735 | fn foo(opt: Option<i32>) { | 733 | fn 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 @@ | |||
1 | use ide_db::helpers::FamousDefs; | 1 | use ide_db::helpers::FamousDefs; |
2 | use ide_db::RootDatabase; | 2 | use ide_db::RootDatabase; |
3 | use syntax::ast::{self, AstNode, NameOwner}; | 3 | use syntax::ast::{self, AstNode, NameOwner}; |
4 | use test_utils::mark; | ||
5 | 4 | ||
6 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 5 | use 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)] |
91 | mod tests { | 90 | mod 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#" |
133 | enum Variant { | 130 | enum 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#" |
152 | enum Variant { | 149 | enum Variant { |
diff --git a/crates/ide_assists/src/handlers/generate_default_from_new.rs b/crates/ide_assists/src/handlers/generate_default_from_new.rs index fa1254579..81c54ba3e 100644 --- a/crates/ide_assists/src/handlers/generate_default_from_new.rs +++ b/crates/ide_assists/src/handlers/generate_default_from_new.rs | |||
@@ -7,7 +7,6 @@ use syntax::{ | |||
7 | ast::{self, Impl, NameOwner}, | 7 | ast::{self, Impl, NameOwner}, |
8 | AstNode, | 8 | AstNode, |
9 | }; | 9 | }; |
10 | use 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#" |
184 | struct Example { _inner: () } | 183 | struct 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#" |
200 | struct Example { _inner: () } | 199 | struct 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#" |
217 | struct Example { _inner: () } | 216 | struct 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#" |
346 | mod test { | 345 | mod test { |
diff --git a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs index d9388a737..c13c6eebe 100644 --- a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs +++ b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | use ide_db::helpers::FamousDefs; | 1 | use ide_db::helpers::FamousDefs; |
2 | use ide_db::RootDatabase; | 2 | use ide_db::RootDatabase; |
3 | use syntax::ast::{self, AstNode, NameOwner}; | 3 | use syntax::ast::{self, AstNode, NameOwner}; |
4 | use test_utils::mark; | ||
5 | 4 | ||
6 | use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists}; | 5 | use 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)] |
105 | mod tests { | 104 | mod 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#" |
178 | enum A { $0One(u32), } | 175 | enum A { $0One(u32), } |
diff --git a/crates/ide_assists/src/handlers/infer_function_return_type.rs b/crates/ide_assists/src/handlers/infer_function_return_type.rs index 5279af1f3..66113751c 100644 --- a/crates/ide_assists/src/handlers/infer_function_return_type.rs +++ b/crates/ide_assists/src/handlers/infer_function_return_type.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use hir::HirDisplay; | 1 | use hir::HirDisplay; |
2 | use syntax::{ast, AstNode, TextRange, TextSize}; | 2 | use syntax::{ast, AstNode, TextRange, TextSize}; |
3 | use test_utils::mark; | ||
4 | 3 | ||
5 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 4 | use 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 | }; |
7 | use test_utils::mark; | ||
8 | 7 | ||
9 | use crate::{ | 8 | use 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 | }; |
7 | use test_utils::mark; | ||
8 | 7 | ||
9 | use crate::{ | 8 | use 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)] |
145 | mod tests { | 144 | mod 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 | }; |
8 | use test_utils::mark; | ||
9 | 8 | ||
10 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 9 | use 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 | }; |
5 | use test_utils::mark; | ||
6 | 5 | ||
7 | use crate::{ | 6 | use 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 | }; |
11 | use test_utils::mark; | ||
12 | 11 | ||
13 | use crate::{ | 12 | use 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 @@ | |||
1 | use std::borrow::Cow; | 1 | use std::borrow::Cow; |
2 | 2 | ||
3 | use syntax::{ast, AstToken, TextRange, TextSize}; | 3 | use syntax::{ast, AstToken, TextRange, TextSize}; |
4 | use test_utils::mark; | ||
5 | 4 | ||
6 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 5 | use 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)] |
184 | mod tests { | 183 | mod 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 | }; |
7 | use test_utils::mark; | 7 | |
8 | use SyntaxKind::WHITESPACE; | 8 | use SyntaxKind::WHITESPACE; |
9 | 9 | ||
10 | use crate::{ | 10 | use 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; | |||
4 | use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; | 4 | use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; |
5 | use ide_db::RootDatabase; | 5 | use ide_db::RootDatabase; |
6 | use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; | 6 | use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; |
7 | use test_utils::mark; | ||
8 | 7 | ||
9 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 8 | use 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)] |
111 | mod tests { | 110 | mod 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 | }; |
11 | use test_utils::mark; | ||
12 | 11 | ||
13 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 12 | use 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)] |
123 | mod tests { | 122 | mod 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; | |||
3 | use ide_db::helpers::FamousDefs; | 3 | use ide_db::helpers::FamousDefs; |
4 | use stdx::format_to; | 4 | use stdx::format_to; |
5 | use syntax::{ast, AstNode}; | 5 | use syntax::{ast, AstNode}; |
6 | use test_utils::mark; | ||
7 | 6 | ||
8 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 7 | use 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 @@ | |||
1 | use ide_db::helpers::insert_use::{insert_use, ImportScope}; | 1 | use ide_db::helpers::insert_use::{insert_use, ImportScope}; |
2 | use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode}; | 2 | use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode}; |
3 | use test_utils::mark; | ||
4 | 3 | ||
5 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 4 | use 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 | }; |
6 | use test_utils::mark; | ||
7 | 6 | ||
8 | use crate::{ | 7 | use 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 | }; |
7 | use test_utils::mark; | ||
8 | 7 | ||
9 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 8 | use 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#" |