From ecac5d7de2192873c24b7b06d4964d188d8abe6a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 12:59:20 +0200 Subject: Switch to new magic marks --- crates/ra_assists/src/handlers/add_from_impl_for_enum.rs | 8 ++++---- crates/ra_assists/src/handlers/change_visibility.rs | 8 ++++---- crates/ra_assists/src/handlers/fill_match_arms.rs | 9 +++++---- crates/ra_assists/src/handlers/inline_local_variable.rs | 16 ++++++++-------- crates/ra_assists/src/handlers/introduce_variable.rs | 16 ++++++++-------- 5 files changed, 29 insertions(+), 28 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs index eb57b7231..5f6c8b19a 100644 --- a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs @@ -1,6 +1,6 @@ use ra_ide_db::RootDatabase; use ra_syntax::ast::{self, AstNode, NameOwner}; -use test_utils::tested_by; +use test_utils::mark; use crate::{utils::FamousDefs, AssistContext, AssistId, Assists}; @@ -39,7 +39,7 @@ pub(crate) fn add_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> }; if existing_from_impl(&ctx.sema, &variant).is_some() { - tested_by!(test_add_from_impl_already_exists); + mark::hit!(test_add_from_impl_already_exists); return None; } @@ -90,7 +90,7 @@ fn existing_from_impl( #[cfg(test)] mod tests { - use test_utils::covers; + use test_utils::mark; use crate::tests::{check_assist, check_assist_not_applicable}; @@ -149,7 +149,7 @@ impl From for A { #[test] fn test_add_from_impl_already_exists() { - covers!(test_add_from_impl_already_exists); + mark::check!(test_add_from_impl_already_exists); check_not_applicable( r#" enum A { <|>One(u32), } diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 40cf4b422..71d55e0c3 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs @@ -9,7 +9,7 @@ use ra_syntax::{ }; use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; -use test_utils::tested_by; +use test_utils::mark; use crate::{AssistContext, AssistId, Assists}; use ra_db::FileId; @@ -55,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::RecordFieldDef::cast)?; if field.name()? != field_name { - tested_by!(change_visibility_field_false_positive); + mark::hit!(change_visibility_field_false_positive); return None; } if field.visibility().is_some() { @@ -255,7 +255,7 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { #[cfg(test)] mod tests { - use test_utils::covers; + use test_utils::mark; use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; @@ -288,7 +288,7 @@ mod tests { #[test] fn change_visibility_field_false_positive() { - covers!(change_visibility_field_false_positive); + mark::check!(change_visibility_field_false_positive); check_assist_not_applicable( change_visibility, r"struct S { field: [(); { let <|>x = ();}] }", diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index b57ff75ae..bbdcdc626 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -4,7 +4,7 @@ use hir::{Adt, HasSource, ModuleDef, Semantics}; use itertools::Itertools; use ra_ide_db::RootDatabase; use ra_syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; -use test_utils::tested_by; +use test_utils::mark; use crate::{utils::FamousDefs, AssistContext, AssistId, Assists}; @@ -58,7 +58,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< .collect::>(); if Some(enum_def) == FamousDefs(&ctx.sema, module.krate()).core_option_Option() { // Match `Some` variant first. - tested_by!(option_order); + mark::hit!(option_order); variants.reverse() } variants @@ -174,13 +174,14 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> O #[cfg(test)] mod tests { + use test_utils::mark; + use crate::{ tests::{check_assist, check_assist_not_applicable, check_assist_target}, utils::FamousDefs, }; use super::fill_match_arms; - use test_utils::covers; #[test] fn all_match_arms_provided() { @@ -750,7 +751,7 @@ mod tests { #[test] fn option_order() { - covers!(option_order); + mark::check!(option_order); let before = r#" fn foo(opt: Option) { match opt<|> { diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index 5b26814d3..46d675a4e 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs @@ -3,7 +3,7 @@ use ra_syntax::{ ast::{self, AstNode, AstToken}, TextRange, }; -use test_utils::tested_by; +use test_utils::mark; use crate::{ assist_context::{AssistContext, Assists}, @@ -33,11 +33,11 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O _ => return None, }; if bind_pat.mut_token().is_some() { - tested_by!(test_not_inline_mut_variable); + mark::hit!(test_not_inline_mut_variable); return None; } if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) { - tested_by!(not_applicable_outside_of_bind_pat); + mark::hit!(not_applicable_outside_of_bind_pat); return None; } let initializer_expr = let_stmt.initializer()?; @@ -46,7 +46,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O let def = Definition::Local(def); let refs = def.find_usages(ctx.db, None); if refs.is_empty() { - tested_by!(test_not_applicable_if_variable_unused); + mark::hit!(test_not_applicable_if_variable_unused); return None; }; @@ -122,7 +122,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O #[cfg(test)] mod tests { - use test_utils::covers; + use test_utils::mark; use crate::tests::{check_assist, check_assist_not_applicable}; @@ -330,7 +330,7 @@ fn foo() { #[test] fn test_not_inline_mut_variable() { - covers!(test_not_inline_mut_variable); + mark::check!(test_not_inline_mut_variable); check_assist_not_applicable( inline_local_variable, r" @@ -663,7 +663,7 @@ fn foo() { #[test] fn test_not_applicable_if_variable_unused() { - covers!(test_not_applicable_if_variable_unused); + mark::check!(test_not_applicable_if_variable_unused); check_assist_not_applicable( inline_local_variable, r" @@ -676,7 +676,7 @@ fn foo() { #[test] fn not_applicable_outside_of_bind_pat() { - covers!(not_applicable_outside_of_bind_pat); + mark::check!(not_applicable_outside_of_bind_pat); check_assist_not_applicable( inline_local_variable, r" diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs index fdf3ada0d..56c610fed 100644 --- a/crates/ra_assists/src/handlers/introduce_variable.rs +++ b/crates/ra_assists/src/handlers/introduce_variable.rs @@ -7,7 +7,7 @@ use ra_syntax::{ SyntaxNode, TextSize, }; use stdx::format_to; -use test_utils::tested_by; +use test_utils::mark; use crate::{AssistContext, AssistId, Assists}; @@ -33,7 +33,7 @@ pub(crate) fn introduce_variable(acc: &mut Assists, ctx: &AssistContext) -> Opti } let node = ctx.covering_element(); if node.kind() == COMMENT { - tested_by!(introduce_var_in_comment_is_not_applicable); + mark::hit!(introduce_var_in_comment_is_not_applicable); return None; } let expr = node.ancestors().find_map(valid_target_expr)?; @@ -61,7 +61,7 @@ pub(crate) fn introduce_variable(acc: &mut Assists, ctx: &AssistContext) -> Opti false }; if is_full_stmt { - tested_by!(test_introduce_var_expr_stmt); + mark::hit!(test_introduce_var_expr_stmt); if full_stmt.unwrap().semicolon_token().is_none() { buf.push_str(";"); } @@ -113,7 +113,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { expr.syntax().ancestors().find_map(|node| { if let Some(expr) = node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.expr()) { if expr.syntax() == &node { - tested_by!(test_introduce_var_last_expr); + mark::hit!(test_introduce_var_last_expr); return Some((node, false)); } } @@ -134,7 +134,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { #[cfg(test)] mod tests { - use test_utils::covers; + use test_utils::mark; use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; @@ -158,13 +158,13 @@ fn foo() { #[test] fn introduce_var_in_comment_is_not_applicable() { - covers!(introduce_var_in_comment_is_not_applicable); + mark::check!(introduce_var_in_comment_is_not_applicable); check_assist_not_applicable(introduce_variable, "fn main() { 1 + /* <|>comment<|> */ 1; }"); } #[test] fn test_introduce_var_expr_stmt() { - covers!(test_introduce_var_expr_stmt); + mark::check!(test_introduce_var_expr_stmt); check_assist( introduce_variable, " @@ -209,7 +209,7 @@ fn foo() { #[test] fn test_introduce_var_last_expr() { - covers!(test_introduce_var_last_expr); + mark::check!(test_introduce_var_last_expr); check_assist( introduce_variable, " -- cgit v1.2.3