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_ssr/src/matching.rs | 3 +-- crates/ide_ssr/src/parsing.rs | 3 +-- crates/ide_ssr/src/replacing.rs | 4 ++-- crates/ide_ssr/src/resolving.rs | 9 ++++----- crates/ide_ssr/src/search.rs | 5 ++--- crates/ide_ssr/src/tests.rs | 20 ++++++++++---------- 6 files changed, 20 insertions(+), 24 deletions(-) (limited to 'crates/ide_ssr/src') diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs index df013bae9..e1adb381e 100644 --- a/crates/ide_ssr/src/matching.rs +++ b/crates/ide_ssr/src/matching.rs @@ -15,7 +15,6 @@ use syntax::{ ast::{AstNode, AstToken}, SmolStr, }; -use test_utils::mark; // Creates a match error. If we're currently attempting to match some code that we thought we were // going to match, as indicated by the --debug-snippet flag, then populate the reason field. @@ -731,7 +730,7 @@ impl NodeKind { fn matches(&self, node: &SyntaxNode) -> Result<(), MatchFailed> { let ok = match self { Self::Literal => { - mark::hit!(literal_constraint); + cov_mark::hit!(literal_constraint); ast::Literal::can_cast(node.kind()) } }; diff --git a/crates/ide_ssr/src/parsing.rs b/crates/ide_ssr/src/parsing.rs index 3d5e4feb7..5ff25cb6d 100644 --- a/crates/ide_ssr/src/parsing.rs +++ b/crates/ide_ssr/src/parsing.rs @@ -10,7 +10,6 @@ use crate::{SsrError, SsrPattern, SsrRule}; use rustc_hash::{FxHashMap, FxHashSet}; use std::{fmt::Display, str::FromStr}; use syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; -use test_utils::mark; #[derive(Debug)] pub(crate) struct ParsedRule { @@ -131,7 +130,7 @@ impl RuleBuilder { let old_len = self.rules.len(); self.rules.retain(|rule| contains_path(&rule.pattern)); if self.rules.len() < old_len { - mark::hit!(pattern_is_a_single_segment_path); + cov_mark::hit!(pattern_is_a_single_segment_path); } } Ok(self.rules) diff --git a/crates/ide_ssr/src/replacing.rs b/crates/ide_ssr/src/replacing.rs index 06a94a46c..c9ccc1961 100644 --- a/crates/ide_ssr/src/replacing.rs +++ b/crates/ide_ssr/src/replacing.rs @@ -5,7 +5,7 @@ use itertools::Itertools; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::ast::{self, AstNode, AstToken}; use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; -use test_utils::mark; + use text_edit::TextEdit; /// Returns a text edit that will replace each match in `matches` with its corresponding replacement @@ -128,7 +128,7 @@ impl ReplacementRenderer<'_> { && (placeholder_value.autoderef_count > 0 || placeholder_value.autoref_kind != ast::SelfParamKind::Owned) { - mark::hit!(replace_autoref_autoderef_capture); + cov_mark::hit!(replace_autoref_autoderef_capture); let ref_kind = match placeholder_value.autoref_kind { ast::SelfParamKind::Owned => "", ast::SelfParamKind::Ref => "&", diff --git a/crates/ide_ssr/src/resolving.rs b/crates/ide_ssr/src/resolving.rs index 14e5a3b69..af94c7bb1 100644 --- a/crates/ide_ssr/src/resolving.rs +++ b/crates/ide_ssr/src/resolving.rs @@ -6,7 +6,6 @@ use ide_db::base_db::FilePosition; use parsing::Placeholder; use rustc_hash::FxHashMap; use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; -use test_utils::mark; pub(crate) struct ResolutionScope<'db> { scope: hir::SemanticsScope<'db>, @@ -170,13 +169,13 @@ impl Resolver<'_, '_> { // calls. e.g. `Foo::bar($s)` should match `x.bar()`. true } else { - mark::hit!(replace_associated_trait_default_function_call); + cov_mark::hit!(replace_associated_trait_default_function_call); false } } hir::PathResolution::AssocItem(_) => { // Not a function. Could be a constant or an associated type. - mark::hit!(replace_associated_trait_constant); + cov_mark::hit!(replace_associated_trait_constant); false } _ => true, @@ -267,7 +266,7 @@ fn pick_node_for_resolution(node: SyntaxNode) -> SyntaxNode { match node.kind() { SyntaxKind::EXPR_STMT => { if let Some(n) = node.first_child() { - mark::hit!(cursor_after_semicolon); + cov_mark::hit!(cursor_after_semicolon); return n; } } @@ -291,7 +290,7 @@ fn path_contains_type_arguments(path: Option) -> bool { if let Some(path) = path { if let Some(segment) = path.segment() { if segment.generic_arg_list().is_some() { - mark::hit!(type_arguments_within_path); + cov_mark::hit!(type_arguments_within_path); return true; } } diff --git a/crates/ide_ssr/src/search.rs b/crates/ide_ssr/src/search.rs index 836eb94b2..28cef742c 100644 --- a/crates/ide_ssr/src/search.rs +++ b/crates/ide_ssr/src/search.rs @@ -12,7 +12,6 @@ use ide_db::{ }; use rustc_hash::FxHashSet; use syntax::{ast, AstNode, SyntaxKind, SyntaxNode}; -use test_utils::mark; /// A cache for the results of find_usages. This is for when we have multiple patterns that have the /// same path. e.g. if the pattern was `foo::Bar` that can parse as a path, an expression, a type @@ -61,7 +60,7 @@ impl<'db> MatchFinder<'db> { for file_range in self.find_usages(usage_cache, definition).file_ranges() { if let Some(node_to_match) = self.find_node_to_match(resolved_path, file_range) { if !is_search_permitted_ancestors(&node_to_match) { - mark::hit!(use_declaration_with_braces); + cov_mark::hit!(use_declaration_with_braces); continue; } self.try_add_match(rule, &node_to_match, &None, matches_out); @@ -205,7 +204,7 @@ impl<'db> MatchFinder<'db> { matches_out: &mut Vec, ) { if !self.within_range_restrictions(code) { - mark::hit!(replace_nonpath_within_selection); + cov_mark::hit!(replace_nonpath_within_selection); return; } if let Ok(m) = matching::get_match(false, rule, code, restrict_range, &self.sema) { diff --git a/crates/ide_ssr/src/tests.rs b/crates/ide_ssr/src/tests.rs index a3ea44f23..1d8565dc0 100644 --- a/crates/ide_ssr/src/tests.rs +++ b/crates/ide_ssr/src/tests.rs @@ -3,7 +3,7 @@ use expect_test::{expect, Expect}; use ide_db::base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; use rustc_hash::FxHashSet; use std::sync::Arc; -use test_utils::{mark, RangeOrOffset}; +use test_utils::RangeOrOffset; fn parse_error_text(query: &str) -> String { format!("{}", query.parse::().unwrap_err()) @@ -492,7 +492,7 @@ fn match_resolved_type_name() { #[test] fn type_arguments_within_path() { - mark::check!(type_arguments_within_path); + cov_mark::check!(type_arguments_within_path); let code = r#" mod foo { pub struct Bar {t: T} @@ -508,7 +508,7 @@ fn type_arguments_within_path() { #[test] fn literal_constraint() { - mark::check!(literal_constraint); + cov_mark::check!(literal_constraint); let code = r#" enum Option { Some(T), None } use Option::Some; @@ -641,7 +641,7 @@ fn replace_associated_function_call() { #[test] fn replace_associated_trait_default_function_call() { - mark::check!(replace_associated_trait_default_function_call); + cov_mark::check!(replace_associated_trait_default_function_call); assert_ssr_transform( "Bar2::foo() ==>> Bar2::foo2()", r#" @@ -673,7 +673,7 @@ fn replace_associated_trait_default_function_call() { #[test] fn replace_associated_trait_constant() { - mark::check!(replace_associated_trait_constant); + cov_mark::check!(replace_associated_trait_constant); assert_ssr_transform( "Bar2::VALUE ==>> Bar2::VALUE_2222", r#" @@ -998,7 +998,7 @@ fn use_declaration_with_braces() { // It would be OK for a path rule to match and alter a use declaration. We shouldn't mess it up // though. In particular, we must not change `use foo::{baz, bar}` to `use foo::{baz, // foo2::bar2}`. - mark::check!(use_declaration_with_braces); + cov_mark::check!(use_declaration_with_braces); assert_ssr_transform( "foo::bar ==>> foo2::bar2", r#" @@ -1076,7 +1076,7 @@ fn ufcs_matches_method_call() { #[test] fn pattern_is_a_single_segment_path() { - mark::check!(pattern_is_a_single_segment_path); + cov_mark::check!(pattern_is_a_single_segment_path); // The first function should not be altered because the `foo` in scope at the cursor position is // a different `foo`. This case is special because "foo" can be parsed as a pattern (IDENT_PAT -> // NAME -> IDENT), which contains no path. If we're not careful we'll end up matching the `foo` @@ -1118,7 +1118,7 @@ fn replace_local_variable_reference() { // The pattern references a local variable `foo` in the block containing the cursor. We should // only replace references to this variable `foo`, not other variables that just happen to have // the same name. - mark::check!(cursor_after_semicolon); + cov_mark::check!(cursor_after_semicolon); assert_ssr_transform( "foo + $a ==>> $a - foo", r#" @@ -1179,7 +1179,7 @@ fn replace_path_within_selection() { #[test] fn replace_nonpath_within_selection() { - mark::check!(replace_nonpath_within_selection); + cov_mark::check!(replace_nonpath_within_selection); assert_ssr_transform( "$a + $b ==>> $b * $a", r#" @@ -1269,7 +1269,7 @@ fn replace_autoref_autoderef_capture() { // second, we already have a reference, so it isn't. When $a is used in a context where autoref // doesn't apply, we need to prefix it with `&`. Finally, we have some cases where autoderef // needs to be applied. - mark::check!(replace_autoref_autoderef_capture); + cov_mark::check!(replace_autoref_autoderef_capture); let code = r#" struct Foo {} impl Foo { -- cgit v1.2.3