From fc9eed4836dfc88fe2893c81b015ab440cea2ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 8 Mar 2021 22:19:44 +0200 Subject: Use upstream cov-mark --- crates/ide_assists/src/handlers/add_turbo_fish.rs | 22 ++++++------- crates/ide_assists/src/handlers/apply_demorgan.rs | 10 +++--- .../ide_assists/src/handlers/change_visibility.rs | 7 ++-- .../ide_assists/src/handlers/extract_function.rs | 21 ++++++------ .../ide_assists/src/handlers/extract_variable.rs | 15 ++++----- crates/ide_assists/src/handlers/fill_match_arms.rs | 6 ++-- .../handlers/generate_default_from_enum_variant.rs | 11 +++---- .../src/handlers/generate_default_from_new.rs | 17 +++++----- .../src/handlers/generate_from_impl_for_enum.rs | 7 ++-- .../src/handlers/infer_function_return_type.rs | 37 +++++++++++----------- crates/ide_assists/src/handlers/inline_function.rs | 5 ++- .../src/handlers/inline_local_variable.rs | 19 +++++------ .../src/handlers/move_module_to_file.rs | 5 ++- .../ide_assists/src/handlers/pull_assignment_up.rs | 13 ++++---- crates/ide_assists/src/handlers/qualify_path.rs | 17 +++++----- crates/ide_assists/src/handlers/raw_string.rs | 7 ++-- .../src/handlers/remove_unused_param.rs | 6 ++-- crates/ide_assists/src/handlers/reorder_fields.rs | 7 ++-- crates/ide_assists/src/handlers/reorder_impl.rs | 7 ++-- .../src/handlers/replace_for_loop_with_for_each.rs | 5 ++- .../handlers/replace_qualified_name_with_use.rs | 5 ++- crates/ide_assists/src/handlers/unmerge_use.rs | 5 ++- .../src/handlers/wrap_return_type_in_result.rs | 5 ++- 23 files changed, 109 insertions(+), 150 deletions(-) (limited to 'crates/ide_assists/src/handlers') diff --git a/crates/ide_assists/src/handlers/add_turbo_fish.rs b/crates/ide_assists/src/handlers/add_turbo_fish.rs index a08b55ebb..3b6efbab4 100644 --- a/crates/ide_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ide_assists/src/handlers/add_turbo_fish.rs @@ -1,6 +1,5 @@ use ide_db::defs::{Definition, NameRefClass}; use syntax::{ast, AstNode, SyntaxKind, T}; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -30,13 +29,13 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( if arg_list.args().count() > 0 { return None; } - mark::hit!(add_turbo_fish_after_call); - mark::hit!(add_type_ascription_after_call); + cov_mark::hit!(add_turbo_fish_after_call); + cov_mark::hit!(add_type_ascription_after_call); arg_list.l_paren_token()?.prev_token().filter(|it| it.kind() == SyntaxKind::IDENT) })?; let next_token = ident.next_token()?; if next_token.kind() == T![::] { - mark::hit!(add_turbo_fish_one_fish_is_enough); + cov_mark::hit!(add_turbo_fish_one_fish_is_enough); return None; } let name_ref = ast::NameRef::cast(ident.parent())?; @@ -50,7 +49,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( }; let generics = hir::GenericDef::Function(fun).params(ctx.sema.db); if generics.is_empty() { - mark::hit!(add_turbo_fish_non_generic); + cov_mark::hit!(add_turbo_fish_non_generic); return None; } @@ -67,7 +66,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( }, )? } else { - mark::hit!(add_type_ascription_already_typed); + cov_mark::hit!(add_type_ascription_already_typed); } } @@ -87,7 +86,6 @@ mod tests { use crate::tests::{check_assist, check_assist_by_label, check_assist_not_applicable}; use super::*; - use test_utils::mark; #[test] fn add_turbo_fish_function() { @@ -110,7 +108,7 @@ fn main() { #[test] fn add_turbo_fish_after_call() { - mark::check!(add_turbo_fish_after_call); + cov_mark::check!(add_turbo_fish_after_call); check_assist( add_turbo_fish, r#" @@ -155,7 +153,7 @@ fn main() { #[test] fn add_turbo_fish_one_fish_is_enough() { - mark::check!(add_turbo_fish_one_fish_is_enough); + cov_mark::check!(add_turbo_fish_one_fish_is_enough); check_assist_not_applicable( add_turbo_fish, r#" @@ -169,7 +167,7 @@ fn main() { #[test] fn add_turbo_fish_non_generic() { - mark::check!(add_turbo_fish_non_generic); + cov_mark::check!(add_turbo_fish_non_generic); check_assist_not_applicable( add_turbo_fish, r#" @@ -203,7 +201,7 @@ fn main() { #[test] fn add_type_ascription_after_call() { - mark::check!(add_type_ascription_after_call); + cov_mark::check!(add_type_ascription_after_call); check_assist_by_label( add_turbo_fish, r#" @@ -250,7 +248,7 @@ fn main() { #[test] fn add_type_ascription_already_typed() { - mark::check!(add_type_ascription_already_typed); + cov_mark::check!(add_type_ascription_already_typed); check_assist( add_turbo_fish, r#" diff --git a/crates/ide_assists/src/handlers/apply_demorgan.rs b/crates/ide_assists/src/handlers/apply_demorgan.rs index 128b1eb56..a1c339603 100644 --- a/crates/ide_assists/src/handlers/apply_demorgan.rs +++ b/crates/ide_assists/src/handlers/apply_demorgan.rs @@ -1,5 +1,4 @@ use syntax::ast::{self, AstNode}; -use test_utils::mark; use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists}; @@ -64,10 +63,10 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( edit.replace(lhs_range, not_lhs.syntax().text()); edit.replace(rhs_range, not_rhs.syntax().text()); if let Some(neg_expr) = neg_expr { - mark::hit!(demorgan_double_negation); + cov_mark::hit!(demorgan_double_negation); edit.replace(neg_expr.op_token().unwrap().text_range(), ""); } else { - mark::hit!(demorgan_double_parens); + cov_mark::hit!(demorgan_double_parens); edit.replace(paren_expr.l_paren_token().unwrap().text_range(), "!("); } } else { @@ -90,7 +89,6 @@ fn opposite_logic_op(kind: ast::BinOp) -> Option<&'static str> { #[cfg(test)] mod tests { use ide_db::helpers::FamousDefs; - use test_utils::mark; use super::*; @@ -188,13 +186,13 @@ fn f() { #[test] fn demorgan_doesnt_double_negation() { - mark::check!(demorgan_double_negation); + cov_mark::check!(demorgan_double_negation); check_assist(apply_demorgan, "fn f() { !(x ||$0 x) }", "fn f() { (!x && !x) }") } #[test] fn demorgan_doesnt_double_parens() { - mark::check!(demorgan_double_parens); + cov_mark::check!(demorgan_double_parens); check_assist(apply_demorgan, "fn f() { (x ||$0 x) }", "fn f() { !(!x && !x) }") } } diff --git a/crates/ide_assists/src/handlers/change_visibility.rs b/crates/ide_assists/src/handlers/change_visibility.rs index ac8c44124..ec99a5505 100644 --- a/crates/ide_assists/src/handlers/change_visibility.rs +++ b/crates/ide_assists/src/handlers/change_visibility.rs @@ -4,7 +4,6 @@ use syntax::{ SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, VISIBILITY}, T, }; -use test_utils::mark; use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; @@ -56,7 +55,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { } else if let Some(field_name) = ctx.find_node_at_offset::() { let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?; if field.name()? != field_name { - mark::hit!(change_visibility_field_false_positive); + cov_mark::hit!(change_visibility_field_false_positive); return None; } if field.visibility().is_some() { @@ -110,8 +109,6 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; use super::*; @@ -139,7 +136,7 @@ mod tests { #[test] fn change_visibility_field_false_positive() { - mark::check!(change_visibility_field_false_positive); + cov_mark::check!(change_visibility_field_false_positive); check_assist_not_applicable( change_visibility, r"struct S { field: [(); { let $0x = ();}] }", diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index 8779d8bd1..dd4501709 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs @@ -20,7 +20,6 @@ use syntax::{ SyntaxKind::{self, BLOCK_EXPR, BREAK_EXPR, COMMENT, PATH_EXPR, RETURN_EXPR}, SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, WalkEvent, T, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -59,7 +58,7 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext) -> Option let node = ctx.covering_element(); if node.kind() == COMMENT { - mark::hit!(extract_function_in_comment_is_not_applicable); + cov_mark::hit!(extract_function_in_comment_is_not_applicable); return None; } @@ -197,14 +196,14 @@ fn external_control_flow(ctx: &AssistContext, body: &FunctionBody) -> Option return None, }, (Some(_), _, _, _) => { - mark::hit!(external_control_flow_try_and_bc); + cov_mark::hit!(external_control_flow_try_and_bc); return None; } (None, Some(r), None, None) => match r.expr() { @@ -212,11 +211,11 @@ fn external_control_flow(ctx: &AssistContext, body: &FunctionBody) -> Option Some(FlowKind::Return), }, (None, Some(_), _, _) => { - mark::hit!(external_control_flow_return_and_bc); + cov_mark::hit!(external_control_flow_return_and_bc); return None; } (None, None, Some(_), Some(_)) => { - mark::hit!(external_control_flow_break_and_continue); + cov_mark::hit!(external_control_flow_break_and_continue); return None; } (None, None, Some(b), None) => match b.expr() { @@ -1837,7 +1836,7 @@ fn $0fun_name(n: u32) -> u32 { #[test] fn in_comment_is_not_applicable() { - mark::check!(extract_function_in_comment_is_not_applicable); + cov_mark::check!(extract_function_in_comment_is_not_applicable); check_assist_not_applicable(extract_function, r"fn main() { 1 + /* $0comment$0 */ 1; }"); } @@ -2822,7 +2821,7 @@ fn $0fun_name(n: i32) -> Result { #[test] fn break_and_continue() { - mark::check!(external_control_flow_break_and_continue); + cov_mark::check!(external_control_flow_break_and_continue); check_assist_not_applicable( extract_function, r##" @@ -2842,7 +2841,7 @@ fn foo() { #[test] fn return_and_break() { - mark::check!(external_control_flow_return_and_bc); + cov_mark::check!(external_control_flow_return_and_bc); check_assist_not_applicable( extract_function, r##" @@ -3341,7 +3340,7 @@ fn $0fun_name() -> Result { #[test] fn try_and_break() { - mark::check!(external_control_flow_try_and_bc); + cov_mark::check!(external_control_flow_try_and_bc); check_assist_not_applicable( extract_function, r##" @@ -3363,7 +3362,7 @@ fn foo() -> Option<()> { #[test] fn try_and_return_ok() { - mark::check!(external_control_flow_try_and_return_non_err); + cov_mark::check!(external_control_flow_try_and_return_non_err); check_assist_not_applicable( extract_function, r##" diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs index 312ac7ac4..7a32483dc 100644 --- a/crates/ide_assists/src/handlers/extract_variable.rs +++ b/crates/ide_assists/src/handlers/extract_variable.rs @@ -6,7 +6,6 @@ use syntax::{ }, SyntaxNode, }; -use test_utils::mark; use crate::{utils::suggest_name, AssistContext, AssistId, AssistKind, Assists}; @@ -32,7 +31,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option } let node = ctx.covering_element(); if node.kind() == COMMENT { - mark::hit!(extract_var_in_comment_is_not_applicable); + cov_mark::hit!(extract_var_in_comment_is_not_applicable); return None; } let to_extract = node.ancestors().find_map(valid_target_expr)?; @@ -69,7 +68,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option format_to!(buf, "{}", to_extract.syntax()); if let Anchor::Replace(stmt) = anchor { - mark::hit!(test_extract_var_expr_stmt); + cov_mark::hit!(test_extract_var_expr_stmt); if stmt.semicolon_token().is_none() { buf.push_str(";"); } @@ -142,7 +141,7 @@ impl Anchor { node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.tail_expr()) { if expr.syntax() == &node { - mark::hit!(test_extract_var_last_expr); + cov_mark::hit!(test_extract_var_last_expr); return Some(Anchor::Before(node)); } } @@ -175,8 +174,6 @@ impl Anchor { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; use super::*; @@ -199,13 +196,13 @@ fn foo() { #[test] fn extract_var_in_comment_is_not_applicable() { - mark::check!(extract_var_in_comment_is_not_applicable); + cov_mark::check!(extract_var_in_comment_is_not_applicable); check_assist_not_applicable(extract_variable, "fn main() { 1 + /* $0comment$0 */ 1; }"); } #[test] fn test_extract_var_expr_stmt() { - mark::check!(test_extract_var_expr_stmt); + cov_mark::check!(test_extract_var_expr_stmt); check_assist( extract_variable, r#" @@ -250,7 +247,7 @@ fn foo() { #[test] fn test_extract_var_last_expr() { - mark::check!(test_extract_var_last_expr); + cov_mark::check!(test_extract_var_last_expr); check_assist( extract_variable, r#" diff --git a/crates/ide_assists/src/handlers/fill_match_arms.rs b/crates/ide_assists/src/handlers/fill_match_arms.rs index 7086e47d2..878b3a3fa 100644 --- a/crates/ide_assists/src/handlers/fill_match_arms.rs +++ b/crates/ide_assists/src/handlers/fill_match_arms.rs @@ -5,7 +5,6 @@ use ide_db::helpers::{mod_path_to_ast, FamousDefs}; use ide_db::RootDatabase; use itertools::Itertools; use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; -use test_utils::mark; use crate::{ utils::{does_pat_match_variant, render_snippet, Cursor}, @@ -62,7 +61,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< .collect::>(); if Some(enum_def) == FamousDefs(&ctx.sema, Some(module.krate())).core_option_Option() { // Match `Some` variant first. - mark::hit!(option_order); + cov_mark::hit!(option_order); variants.reverse() } variants @@ -195,7 +194,6 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::Variant) -> Optio #[cfg(test)] mod tests { use ide_db::helpers::FamousDefs; - use test_utils::mark; use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; @@ -730,7 +728,7 @@ fn main() { #[test] fn option_order() { - mark::check!(option_order); + cov_mark::check!(option_order); let before = r#" fn foo(opt: Option) { match opt$0 { diff --git a/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs b/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs index 6a2ab9596..588ee1350 100644 --- a/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/generate_default_from_enum_variant.rs @@ -1,7 +1,6 @@ use ide_db::helpers::FamousDefs; use ide_db::RootDatabase; use syntax::ast::{self, AstNode, NameOwner}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -38,12 +37,12 @@ pub(crate) fn generate_default_from_enum_variant( let variant_name = variant.name()?; let enum_name = variant.parent_enum().name()?; if !matches!(variant.kind(), ast::StructKind::Unit) { - mark::hit!(test_gen_default_on_non_unit_variant_not_implemented); + cov_mark::hit!(test_gen_default_on_non_unit_variant_not_implemented); return None; } if existing_default_impl(&ctx.sema, &variant).is_some() { - mark::hit!(test_gen_default_impl_already_exists); + cov_mark::hit!(test_gen_default_impl_already_exists); return None; } @@ -89,8 +88,6 @@ fn existing_default_impl( #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -127,7 +124,7 @@ impl Default for Variant { #[test] fn test_generate_default_already_implemented() { - mark::check!(test_gen_default_impl_already_exists); + cov_mark::check!(test_gen_default_impl_already_exists); check_not_applicable( r#" enum Variant { @@ -146,7 +143,7 @@ impl Default for Variant { #[test] fn test_add_from_impl_no_element() { - mark::check!(test_gen_default_on_non_unit_variant_not_implemented); + cov_mark::check!(test_gen_default_on_non_unit_variant_not_implemented); check_not_applicable( r#" enum Variant { diff --git a/crates/ide_assists/src/handlers/generate_default_from_new.rs b/crates/ide_assists/src/handlers/generate_default_from_new.rs index fa1254579..81c54ba3e 100644 --- a/crates/ide_assists/src/handlers/generate_default_from_new.rs +++ b/crates/ide_assists/src/handlers/generate_default_from_new.rs @@ -7,7 +7,6 @@ use syntax::{ ast::{self, Impl, NameOwner}, AstNode, }; -use test_utils::mark; // Assist: generate_default_from_new // @@ -43,19 +42,19 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext) let fn_name = fn_node.name()?; if fn_name.text() != "new" { - mark::hit!(other_function_than_new); + cov_mark::hit!(other_function_than_new); return None; } if fn_node.param_list()?.params().next().is_some() { - mark::hit!(new_function_with_parameters); + cov_mark::hit!(new_function_with_parameters); return None; } let impl_ = fn_node.syntax().ancestors().into_iter().find_map(ast::Impl::cast)?; if is_default_implemented(ctx, &impl_) { - mark::hit!(default_block_is_already_present); - mark::hit!(struct_in_module_with_default); + cov_mark::hit!(default_block_is_already_present); + cov_mark::hit!(struct_in_module_with_default); return None; } @@ -178,7 +177,7 @@ impl Default for Test { #[test] fn new_function_with_parameters() { - mark::check!(new_function_with_parameters); + cov_mark::check!(new_function_with_parameters); check_not_applicable( r#" struct Example { _inner: () } @@ -194,7 +193,7 @@ impl Example { #[test] fn other_function_than_new() { - mark::check!(other_function_than_new); + cov_mark::check!(other_function_than_new); check_not_applicable( r#" struct Example { _inner: () } @@ -211,7 +210,7 @@ impl Example { #[test] fn default_block_is_already_present() { - mark::check!(default_block_is_already_present); + cov_mark::check!(default_block_is_already_present); check_not_applicable( r#" struct Example { _inner: () } @@ -340,7 +339,7 @@ impl Default for Example { #[test] fn struct_in_module_with_default() { - mark::check!(struct_in_module_with_default); + cov_mark::check!(struct_in_module_with_default); check_not_applicable( r#" mod test { diff --git a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs index d9388a737..c13c6eebe 100644 --- a/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs +++ b/crates/ide_assists/src/handlers/generate_from_impl_for_enum.rs @@ -1,7 +1,6 @@ use ide_db::helpers::FamousDefs; use ide_db::RootDatabase; use syntax::ast::{self, AstNode, NameOwner}; -use test_utils::mark; use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists}; @@ -44,7 +43,7 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext }; if existing_from_impl(&ctx.sema, &variant).is_some() { - mark::hit!(test_add_from_impl_already_exists); + cov_mark::hit!(test_add_from_impl_already_exists); return None; } @@ -103,8 +102,6 @@ fn existing_from_impl( #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -172,7 +169,7 @@ impl From for A { #[test] fn test_add_from_impl_already_exists() { - mark::check!(test_add_from_impl_already_exists); + cov_mark::check!(test_add_from_impl_already_exists); check_not_applicable( r#" enum A { $0One(u32), } diff --git a/crates/ide_assists/src/handlers/infer_function_return_type.rs b/crates/ide_assists/src/handlers/infer_function_return_type.rs index 5279af1f3..66113751c 100644 --- a/crates/ide_assists/src/handlers/infer_function_return_type.rs +++ b/crates/ide_assists/src/handlers/infer_function_return_type.rs @@ -1,6 +1,5 @@ use hir::HirDisplay; use syntax::{ast, AstNode, TextRange, TextSize}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -42,7 +41,7 @@ pub(crate) fn infer_function_return_type(acc: &mut Assists, ctx: &AssistContext) } } if let FnType::Closure { wrap_expr: true } = fn_type { - mark::hit!(wrap_closure_non_block_expr); + cov_mark::hit!(wrap_closure_non_block_expr); // `|x| x` becomes `|x| -> T x` which is invalid, so wrap it in a block builder.replace(tail_expr.syntax().text_range(), &format!("{{{}}}", tail_expr)); } @@ -61,13 +60,13 @@ fn ret_ty_to_action(ret_ty: Option, insert_pos: TextSize) -> Optio match ret_ty { Some(ret_ty) => match ret_ty.ty() { Some(ast::Type::InferType(_)) | None => { - mark::hit!(existing_infer_ret_type); - mark::hit!(existing_infer_ret_type_closure); + cov_mark::hit!(existing_infer_ret_type); + cov_mark::hit!(existing_infer_ret_type_closure); Some(InsertOrReplace::Replace(ret_ty.syntax().text_range())) } _ => { - mark::hit!(existing_ret_type); - mark::hit!(existing_ret_type_closure); + cov_mark::hit!(existing_ret_type); + cov_mark::hit!(existing_ret_type_closure); None } }, @@ -109,11 +108,11 @@ fn extract_tail(ctx: &AssistContext) -> Option<(FnType, ast::Expr, InsertOrRepla }; let frange = ctx.frange.range; if return_type_range.contains_range(frange) { - mark::hit!(cursor_in_ret_position); - mark::hit!(cursor_in_ret_position_closure); + cov_mark::hit!(cursor_in_ret_position); + cov_mark::hit!(cursor_in_ret_position_closure); } else if tail_expr.syntax().text_range().contains_range(frange) { - mark::hit!(cursor_on_tail); - mark::hit!(cursor_on_tail_closure); + cov_mark::hit!(cursor_on_tail); + cov_mark::hit!(cursor_on_tail_closure); } else { return None; } @@ -128,7 +127,7 @@ mod tests { #[test] fn infer_return_type_specified_inferred() { - mark::check!(existing_infer_ret_type); + cov_mark::check!(existing_infer_ret_type); check_assist( infer_function_return_type, r#"fn foo() -> $0_ { @@ -142,7 +141,7 @@ mod tests { #[test] fn infer_return_type_specified_inferred_closure() { - mark::check!(existing_infer_ret_type_closure); + cov_mark::check!(existing_infer_ret_type_closure); check_assist( infer_function_return_type, r#"fn foo() { @@ -156,7 +155,7 @@ mod tests { #[test] fn infer_return_type_cursor_at_return_type_pos() { - mark::check!(cursor_in_ret_position); + cov_mark::check!(cursor_in_ret_position); check_assist( infer_function_return_type, r#"fn foo() $0{ @@ -170,7 +169,7 @@ mod tests { #[test] fn infer_return_type_cursor_at_return_type_pos_closure() { - mark::check!(cursor_in_ret_position_closure); + cov_mark::check!(cursor_in_ret_position_closure); check_assist( infer_function_return_type, r#"fn foo() { @@ -184,7 +183,7 @@ mod tests { #[test] fn infer_return_type() { - mark::check!(cursor_on_tail); + cov_mark::check!(cursor_on_tail); check_assist( infer_function_return_type, r#"fn foo() { @@ -219,7 +218,7 @@ mod tests { #[test] fn not_applicable_ret_type_specified() { - mark::check!(existing_ret_type); + cov_mark::check!(existing_ret_type); check_assist_not_applicable( infer_function_return_type, r#"fn foo() -> i32 { @@ -251,7 +250,7 @@ mod tests { #[test] fn infer_return_type_closure_block() { - mark::check!(cursor_on_tail_closure); + cov_mark::check!(cursor_on_tail_closure); check_assist( infer_function_return_type, r#"fn foo() { @@ -282,7 +281,7 @@ mod tests { #[test] fn infer_return_type_closure_wrap() { - mark::check!(wrap_closure_non_block_expr); + cov_mark::check!(wrap_closure_non_block_expr); check_assist( infer_function_return_type, r#"fn foo() { @@ -321,7 +320,7 @@ mod tests { #[test] fn not_applicable_ret_type_specified_closure() { - mark::check!(existing_ret_type_closure); + cov_mark::check!(existing_ret_type_closure); check_assist_not_applicable( infer_function_return_type, r#"fn foo() { diff --git a/crates/ide_assists/src/handlers/inline_function.rs b/crates/ide_assists/src/handlers/inline_function.rs index 6ec99b09b..8e56029cb 100644 --- a/crates/ide_assists/src/handlers/inline_function.rs +++ b/crates/ide_assists/src/handlers/inline_function.rs @@ -4,7 +4,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, ArgListOwner}, AstNode, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -49,7 +48,7 @@ pub(crate) fn inline_function(acc: &mut Assists, ctx: &AssistContext) -> Option< if arguments.len() != parameters.len() { // Can't inline the function because they've passed the wrong number of // arguments to this function - mark::hit!(inline_function_incorrect_number_of_arguments); + cov_mark::hit!(inline_function_incorrect_number_of_arguments); return None; } @@ -155,7 +154,7 @@ fn main() { Foo.bar$0(); } #[test] fn not_applicable_when_incorrect_number_of_parameters_are_provided() { - mark::check!(inline_function_incorrect_number_of_arguments); + cov_mark::check!(inline_function_incorrect_number_of_arguments); check_assist_not_applicable( inline_function, r#" diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs index da5522670..ea1466dc8 100644 --- a/crates/ide_assists/src/handlers/inline_local_variable.rs +++ b/crates/ide_assists/src/handlers/inline_local_variable.rs @@ -4,7 +4,6 @@ use syntax::{ ast::{self, AstNode, AstToken}, TextRange, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -34,11 +33,11 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O _ => return None, }; if bind_pat.mut_token().is_some() { - mark::hit!(test_not_inline_mut_variable); + cov_mark::hit!(test_not_inline_mut_variable); return None; } if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) { - mark::hit!(not_applicable_outside_of_bind_pat); + cov_mark::hit!(not_applicable_outside_of_bind_pat); return None; } let initializer_expr = let_stmt.initializer()?; @@ -47,7 +46,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O let def = Definition::Local(def); let usages = def.usages(&ctx.sema).all(); if usages.is_empty() { - mark::hit!(test_not_applicable_if_variable_unused); + cov_mark::hit!(test_not_applicable_if_variable_unused); return None; }; @@ -130,7 +129,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O Some(name_ref) if ast::RecordExprField::for_field_name(name_ref).is_some() => { - mark::hit!(inline_field_shorthand); + cov_mark::hit!(inline_field_shorthand); builder.insert(reference.range.end(), format!(": {}", replacement)); } _ => builder.replace(reference.range, replacement), @@ -143,8 +142,6 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; @@ -351,7 +348,7 @@ fn foo() { #[test] fn test_not_inline_mut_variable() { - mark::check!(test_not_inline_mut_variable); + cov_mark::check!(test_not_inline_mut_variable); check_assist_not_applicable( inline_local_variable, r" @@ -684,7 +681,7 @@ fn foo() { #[test] fn inline_field_shorthand() { - mark::check!(inline_field_shorthand); + cov_mark::check!(inline_field_shorthand); check_assist( inline_local_variable, r" @@ -705,7 +702,7 @@ fn main() { #[test] fn test_not_applicable_if_variable_unused() { - mark::check!(test_not_applicable_if_variable_unused); + cov_mark::check!(test_not_applicable_if_variable_unused); check_assist_not_applicable( inline_local_variable, r" @@ -718,7 +715,7 @@ fn foo() { #[test] fn not_applicable_outside_of_bind_pat() { - mark::check!(not_applicable_outside_of_bind_pat); + cov_mark::check!(not_applicable_outside_of_bind_pat); check_assist_not_applicable( inline_local_variable, r" diff --git a/crates/ide_assists/src/handlers/move_module_to_file.rs b/crates/ide_assists/src/handlers/move_module_to_file.rs index 91c395c1b..6e685b4b2 100644 --- a/crates/ide_assists/src/handlers/move_module_to_file.rs +++ b/crates/ide_assists/src/handlers/move_module_to_file.rs @@ -5,7 +5,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, NameOwner}, AstNode, TextRange, }; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -28,7 +27,7 @@ pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext) -> Opt let l_curly_offset = module_items.syntax().text_range().start(); if l_curly_offset <= ctx.offset() { - mark::hit!(available_before_curly); + cov_mark::hit!(available_before_curly); return None; } let target = TextRange::new(module_ast.syntax().text_range().start(), l_curly_offset); @@ -182,7 +181,7 @@ pub(crate) mod tests; #[test] fn available_before_curly() { - mark::check!(available_before_curly); + cov_mark::check!(available_before_curly); check_assist_not_applicable(move_module_to_file, r#"mod m { $0 }"#); } } diff --git a/crates/ide_assists/src/handlers/pull_assignment_up.rs b/crates/ide_assists/src/handlers/pull_assignment_up.rs index 377ed4f2f..04bae4e58 100644 --- a/crates/ide_assists/src/handlers/pull_assignment_up.rs +++ b/crates/ide_assists/src/handlers/pull_assignment_up.rs @@ -2,7 +2,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, make}, AstNode, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -104,7 +103,7 @@ fn exprify_if( ast::ElseBranch::Block(exprify_block(block, sema, name)?) } ast::ElseBranch::IfExpr(expr) => { - mark::hit!(test_pull_assignment_up_chained_if); + cov_mark::hit!(test_pull_assignment_up_chained_if); ast::ElseBranch::IfExpr(ast::IfExpr::cast( exprify_if(&expr, sema, name)?.syntax().to_owned(), )?) @@ -144,7 +143,7 @@ fn is_equivalent( ) -> bool { match (expr0, expr1) { (ast::Expr::FieldExpr(field_expr0), ast::Expr::FieldExpr(field_expr1)) => { - mark::hit!(test_pull_assignment_up_field_assignment); + cov_mark::hit!(test_pull_assignment_up_field_assignment); sema.resolve_field(field_expr0) == sema.resolve_field(field_expr1) } (ast::Expr::PathExpr(path0), ast::Expr::PathExpr(path1)) => { @@ -160,7 +159,7 @@ fn is_equivalent( if prefix0.op_kind() == Some(ast::PrefixOp::Deref) && prefix1.op_kind() == Some(ast::PrefixOp::Deref) => { - mark::hit!(test_pull_assignment_up_deref); + cov_mark::hit!(test_pull_assignment_up_deref); if let (Some(prefix0), Some(prefix1)) = (prefix0.expr(), prefix1.expr()) { is_equivalent(sema, &prefix0, &prefix1) } else { @@ -263,7 +262,7 @@ fn foo() { #[test] fn test_pull_assignment_up_chained_if() { - mark::check!(test_pull_assignment_up_chained_if); + cov_mark::check!(test_pull_assignment_up_chained_if); check_assist( pull_assignment_up, r#" @@ -379,7 +378,7 @@ fn foo() { #[test] fn test_pull_assignment_up_field_assignment() { - mark::check!(test_pull_assignment_up_field_assignment); + cov_mark::check!(test_pull_assignment_up_field_assignment); check_assist( pull_assignment_up, r#" @@ -411,7 +410,7 @@ fn foo() { #[test] fn test_pull_assignment_up_deref() { - mark::check!(test_pull_assignment_up_deref); + cov_mark::check!(test_pull_assignment_up_deref); check_assist( pull_assignment_up, r#" diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs index d84ca0e55..d3e34e540 100644 --- a/crates/ide_assists/src/handlers/qualify_path.rs +++ b/crates/ide_assists/src/handlers/qualify_path.rs @@ -8,7 +8,6 @@ use syntax::{ ast::{make, ArgListOwner}, AstNode, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -47,25 +46,25 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let qualify_candidate = match candidate { ImportCandidate::Path(candidate) => { if candidate.qualifier.is_some() { - mark::hit!(qualify_path_qualifier_start); + cov_mark::hit!(qualify_path_qualifier_start); let path = ast::Path::cast(syntax_under_caret)?; let (prev_segment, segment) = (path.qualifier()?.segment()?, path.segment()?); QualifyCandidate::QualifierStart(segment, prev_segment.generic_arg_list()) } else { - mark::hit!(qualify_path_unqualified_name); + cov_mark::hit!(qualify_path_unqualified_name); let path = ast::Path::cast(syntax_under_caret)?; let generics = path.segment()?.generic_arg_list(); QualifyCandidate::UnqualifiedName(generics) } } ImportCandidate::TraitAssocItem(_) => { - mark::hit!(qualify_path_trait_assoc_item); + cov_mark::hit!(qualify_path_trait_assoc_item); let path = ast::Path::cast(syntax_under_caret)?; let (qualifier, segment) = (path.qualifier()?, path.segment()?); QualifyCandidate::TraitAssocItem(qualifier, segment) } ImportCandidate::TraitMethod(_) => { - mark::hit!(qualify_path_trait_method); + cov_mark::hit!(qualify_path_trait_method); let mcall_expr = ast::MethodCallExpr::cast(syntax_under_caret)?; QualifyCandidate::TraitMethod(ctx.sema.db, mcall_expr) } @@ -212,7 +211,7 @@ mod tests { #[test] fn applicable_when_found_an_import_partial() { - mark::check!(qualify_path_unqualified_name); + cov_mark::check!(qualify_path_unqualified_name); check_assist( qualify_path, r" @@ -504,7 +503,7 @@ fn main() { #[test] fn associated_struct_const() { - mark::check!(qualify_path_qualifier_start); + cov_mark::check!(qualify_path_qualifier_start); check_assist( qualify_path, r" @@ -605,7 +604,7 @@ fn main() { #[test] fn associated_trait_const() { - mark::check!(qualify_path_trait_assoc_item); + cov_mark::check!(qualify_path_trait_assoc_item); check_assist( qualify_path, r" @@ -675,7 +674,7 @@ fn main() { #[test] fn trait_method() { - mark::check!(qualify_path_trait_method); + cov_mark::check!(qualify_path_trait_method); check_assist( qualify_path, r" diff --git a/crates/ide_assists/src/handlers/raw_string.rs b/crates/ide_assists/src/handlers/raw_string.rs index d95267607..d0f1613f3 100644 --- a/crates/ide_assists/src/handlers/raw_string.rs +++ b/crates/ide_assists/src/handlers/raw_string.rs @@ -1,7 +1,6 @@ use std::borrow::Cow; use syntax::{ast, AstToken, TextRange, TextSize}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -149,7 +148,7 @@ pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let internal_text = &text[token.text_range_between_quotes()? - text_range.start()]; if existing_hashes == required_hashes(internal_text) { - mark::hit!(cant_remove_required_hash); + cov_mark::hit!(cant_remove_required_hash); return None; } @@ -182,8 +181,6 @@ fn test_required_hashes() { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; use super::*; @@ -396,7 +393,7 @@ string"###; #[test] fn cant_remove_required_hash() { - mark::check!(cant_remove_required_hash); + cov_mark::check!(cant_remove_required_hash); check_assist_not_applicable( remove_hash, r##" diff --git a/crates/ide_assists/src/handlers/remove_unused_param.rs b/crates/ide_assists/src/handlers/remove_unused_param.rs index c961680e2..2699d2861 100644 --- a/crates/ide_assists/src/handlers/remove_unused_param.rs +++ b/crates/ide_assists/src/handlers/remove_unused_param.rs @@ -4,7 +4,7 @@ use syntax::{ ast::{self, ArgListOwner}, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, T, }; -use test_utils::mark; + use SyntaxKind::WHITESPACE; use crate::{ @@ -49,7 +49,7 @@ pub(crate) fn remove_unused_param(acc: &mut Assists, ctx: &AssistContext) -> Opt Definition::Local(local) }; if param_def.usages(&ctx.sema).at_least_one() { - mark::hit!(keep_used); + cov_mark::hit!(keep_used); return None; } acc.add( @@ -243,7 +243,7 @@ fn b2() { foo(9) } #[test] fn keep_used() { - mark::check!(keep_used); + cov_mark::check!(keep_used); check_assist_not_applicable( remove_unused_param, r#" diff --git a/crates/ide_assists/src/handlers/reorder_fields.rs b/crates/ide_assists/src/handlers/reorder_fields.rs index fba7d6ddb..794c89323 100644 --- a/crates/ide_assists/src/handlers/reorder_fields.rs +++ b/crates/ide_assists/src/handlers/reorder_fields.rs @@ -4,7 +4,6 @@ use rustc_hash::FxHashMap; use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; use ide_db::RootDatabase; use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -39,7 +38,7 @@ fn reorder(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { }); if sorted_fields == fields { - mark::hit!(reorder_sorted_fields); + cov_mark::hit!(reorder_sorted_fields); return None; } @@ -109,15 +108,13 @@ fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option Option<()> // Don't edit already sorted methods: if methods == sorted { - mark::hit!(not_applicable_if_sorted); + cov_mark::hit!(not_applicable_if_sorted); return None; } @@ -121,15 +120,13 @@ fn get_methods(items: &ast::AssocItemList) -> Vec { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::tests::{check_assist, check_assist_not_applicable}; use super::*; #[test] fn not_applicable_if_sorted() { - mark::check!(not_applicable_if_sorted); + cov_mark::check!(not_applicable_if_sorted); check_assist_not_applicable( reorder_impl, r#" diff --git a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs index 27da28bc0..50b05ab0b 100644 --- a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs +++ b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs @@ -3,7 +3,6 @@ use hir::known; use ide_db::helpers::FamousDefs; use stdx::format_to; use syntax::{ast, AstNode}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -34,7 +33,7 @@ pub(crate) fn replace_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistCont let pat = for_loop.pat()?; let body = for_loop.loop_body()?; if body.syntax().text_range().start() < ctx.offset() { - mark::hit!(not_available_in_body); + cov_mark::hit!(not_available_in_body); return None; } @@ -187,7 +186,7 @@ fn main() { #[test] fn not_available_in_body() { - mark::check!(not_available_in_body); + cov_mark::check!(not_available_in_body); check_assist_not_applicable( replace_for_loop_with_for_each, r" diff --git a/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs index 55481af34..36d2e0331 100644 --- a/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ide_assists/src/handlers/replace_qualified_name_with_use.rs @@ -1,6 +1,5 @@ use ide_db::helpers::insert_use::{insert_use, ImportScope}; use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SyntaxNode}; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -27,7 +26,7 @@ pub(crate) fn replace_qualified_name_with_use( return None; } if path.qualifier().is_none() { - mark::hit!(dont_import_trivial_paths); + cov_mark::hit!(dont_import_trivial_paths); return None; } @@ -458,7 +457,7 @@ impl Debug for Foo { #[test] fn dont_import_trivial_paths() { - mark::check!(dont_import_trivial_paths); + cov_mark::check!(dont_import_trivial_paths); check_assist_not_applicable( replace_qualified_name_with_use, r" diff --git a/crates/ide_assists/src/handlers/unmerge_use.rs b/crates/ide_assists/src/handlers/unmerge_use.rs index 3dbef8e51..616af7c2e 100644 --- a/crates/ide_assists/src/handlers/unmerge_use.rs +++ b/crates/ide_assists/src/handlers/unmerge_use.rs @@ -3,7 +3,6 @@ use syntax::{ ast::{self, edit::AstNodeEdit, VisibilityOwner}, AstNode, SyntaxKind, }; -use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -27,7 +26,7 @@ pub(crate) fn unmerge_use(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let tree_list = tree.syntax().parent().and_then(ast::UseTreeList::cast)?; if tree_list.use_trees().count() < 2 { - mark::hit!(skip_single_use_item); + cov_mark::hit!(skip_single_use_item); return None; } @@ -89,7 +88,7 @@ mod tests { #[test] fn skip_single_use_item() { - mark::check!(skip_single_use_item); + cov_mark::check!(skip_single_use_item); check_assist_not_applicable( unmerge_use, r" diff --git a/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs b/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs index fec16fc49..e838630ea 100644 --- a/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs +++ b/crates/ide_assists/src/handlers/wrap_return_type_in_result.rs @@ -4,7 +4,6 @@ use syntax::{ ast::{self, make, BlockExpr, Expr, LoopBodyOwner}, match_ast, AstNode, SyntaxNode, }; -use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -39,7 +38,7 @@ pub(crate) fn wrap_return_type_in_result(acc: &mut Assists, ctx: &AssistContext) let first_part_ret_type = ret_type_str.splitn(2, '<').next(); if let Some(ret_type_first_part) = first_part_ret_type { if ret_type_first_part.ends_with("Result") { - mark::hit!(wrap_return_type_in_result_simple_return_type_already_result); + cov_mark::hit!(wrap_return_type_in_result_simple_return_type_already_result); return None; } } @@ -367,7 +366,7 @@ fn foo() -> std::result::Result { #[test] fn wrap_return_type_in_result_simple_return_type_already_result() { - mark::check!(wrap_return_type_in_result_simple_return_type_already_result); + cov_mark::check!(wrap_return_type_in_result_simple_return_type_already_result); check_assist_not_applicable( wrap_return_type_in_result, r#" -- cgit v1.2.3