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_completion/src/completions/dot.rs | 6 ++---- crates/ide_completion/src/completions/flyimport.rs | 10 ++++------ crates/ide_completion/src/completions/keyword.rs | 14 ++++++-------- .../ide_completion/src/completions/qualified_path.rs | 6 ++---- .../ide_completion/src/completions/unqualified_path.rs | 12 +++++------- crates/ide_completion/src/context.rs | 4 ++-- crates/ide_completion/src/render.rs | 18 ++++++++---------- crates/ide_completion/src/render/builder_ext.rs | 9 ++++----- crates/ide_completion/src/render/enum_variant.rs | 7 ++----- crates/ide_completion/src/render/function.rs | 11 ++++------- crates/ide_completion/src/render/macro_.rs | 7 ++----- 11 files changed, 41 insertions(+), 63 deletions(-) (limited to 'crates/ide_completion/src') diff --git a/crates/ide_completion/src/completions/dot.rs b/crates/ide_completion/src/completions/dot.rs index 084d7721d..5ee9a9f07 100644 --- a/crates/ide_completion/src/completions/dot.rs +++ b/crates/ide_completion/src/completions/dot.rs @@ -2,7 +2,6 @@ use hir::{HasVisibility, Type}; use rustc_hash::FxHashSet; -use test_utils::mark; use crate::{context::CompletionContext, Completions}; @@ -19,7 +18,7 @@ pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { }; if ctx.is_call { - mark::hit!(test_no_struct_field_completion_for_method_call); + cov_mark::hit!(test_no_struct_field_completion_for_method_call); } else { complete_fields(acc, ctx, &receiver_ty); } @@ -62,7 +61,6 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{test_utils::completion_list, CompletionKind}; @@ -122,7 +120,7 @@ impl A { #[test] fn test_no_struct_field_completion_for_method_call() { - mark::check!(test_no_struct_field_completion_for_method_call); + cov_mark::check!(test_no_struct_field_completion_for_method_call); check( r#" struct A { the_field: u32 } diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index da8375af9..f34764b61 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -55,7 +55,6 @@ use ide_db::helpers::{ }; use rustc_hash::FxHashSet; use syntax::{AstNode, SyntaxNode, T}; -use test_utils::mark; use crate::{ context::CompletionContext, @@ -174,7 +173,7 @@ fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option usize { - mark::hit!(certain_fuzzy_order_test); + cov_mark::hit!(certain_fuzzy_order_test); let proposed_import_name = match proposed_mod_path.segments().last() { Some(name) => name.to_string().to_lowercase(), None => return usize::MAX, @@ -200,7 +199,6 @@ fn compute_fuzzy_completion_order_key( #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ item::CompletionKind, @@ -295,7 +293,7 @@ fn main() { #[test] fn short_paths_are_ignored() { - mark::check!(ignore_short_input_for_path); + cov_mark::check!(ignore_short_input_for_path); check( r#" @@ -319,7 +317,7 @@ fn main() { #[test] fn fuzzy_completions_come_in_specific_order() { - mark::check!(certain_fuzzy_order_test); + cov_mark::check!(certain_fuzzy_order_test); check( r#" //- /lib.rs crate:dep diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs index 03c6dd454..80aa9fb06 100644 --- a/crates/ide_completion/src/completions/keyword.rs +++ b/crates/ide_completion/src/completions/keyword.rs @@ -3,7 +3,6 @@ use std::iter; use syntax::SyntaxKind; -use test_utils::mark; use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions}; @@ -47,11 +46,11 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionContext) { if ctx.token.kind() == SyntaxKind::COMMENT { - mark::hit!(no_keyword_completion_in_comments); + cov_mark::hit!(no_keyword_completion_in_comments); return; } if ctx.record_lit_syntax.is_some() { - mark::hit!(no_keyword_completion_in_record_lit); + cov_mark::hit!(no_keyword_completion_in_record_lit); return; } @@ -172,7 +171,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet Some(cap) => { let tmp; let snippet = if snippet.ends_with('}') && ctx.incomplete_let { - mark::hit!(let_semi); + cov_mark::hit!(let_semi); tmp = format!("{};", snippet); &tmp } else { @@ -188,7 +187,6 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, completion_list}, @@ -494,7 +492,7 @@ fn quux() -> i32 { #[test] fn no_keyword_completion_in_comments() { - mark::check!(no_keyword_completion_in_comments); + cov_mark::check!(no_keyword_completion_in_comments); check( r#" fn test() { @@ -599,7 +597,7 @@ struct Foo { #[test] fn skip_struct_initializer() { - mark::check!(no_keyword_completion_in_record_lit); + cov_mark::check!(no_keyword_completion_in_record_lit); check( r#" struct Foo { @@ -643,7 +641,7 @@ fn foo() { #[test] fn let_semi() { - mark::check!(let_semi); + cov_mark::check!(let_semi); check_edit( "match", r#" diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 72fb757b1..df74b739e 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs @@ -3,7 +3,6 @@ use hir::{Adt, HasVisibility, PathResolution, ScopeDef}; use rustc_hash::FxHashSet; use syntax::AstNode; -use test_utils::mark; use crate::{CompletionContext, Completions}; @@ -39,7 +38,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon if let Some(name_ref) = ctx.name_ref_syntax.as_ref() { if name_ref.syntax().text() == name.to_string().as_str() { // for `use self::foo$0`, don't suggest `foo` as a completion - mark::hit!(dont_complete_current_use); + cov_mark::hit!(dont_complete_current_use); continue; } } @@ -155,7 +154,6 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, completion_list}, @@ -174,7 +172,7 @@ mod tests { #[test] fn dont_complete_current_use() { - mark::check!(dont_complete_current_use); + cov_mark::check!(dont_complete_current_use); check(r#"use self::foo$0;"#, expect![[""]]); } diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index e9d0ff665..044dfd160 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -2,7 +2,6 @@ use hir::ScopeDef; use syntax::AstNode; -use test_utils::mark; use crate::{CompletionContext, Completions}; @@ -30,13 +29,13 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC ctx.scope.process_all_names(&mut |name, res| { if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { - mark::hit!(skip_lifetime_completion); + cov_mark::hit!(skip_lifetime_completion); return; } if ctx.use_item_syntax.is_some() { if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { if name_ref.syntax().text() == name.to_string().as_str() { - mark::hit!(self_fulfilling_completion); + cov_mark::hit!(self_fulfilling_completion); return; } } @@ -48,7 +47,6 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, completion_list_with_config, TEST_CONFIG}, @@ -66,7 +64,7 @@ mod tests { #[test] fn self_fulfilling_completion() { - mark::check!(self_fulfilling_completion); + cov_mark::check!(self_fulfilling_completion); check( r#" use foo$0 @@ -185,7 +183,7 @@ fn quux() { #[test] fn completes_if_prefix_is_keyword() { - mark::check!(completes_if_prefix_is_keyword); + cov_mark::check!(completes_if_prefix_is_keyword); check_edit( "wherewolf", r#" @@ -223,7 +221,7 @@ fn main() { #[test] fn does_not_complete_lifetimes() { - mark::check!(skip_lifetime_completion); + cov_mark::check!(skip_lifetime_completion); check( r#"fn quux<'a>() { $0 }"#, expect![[r#" diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 3db357855..17d9a3adf 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -7,7 +7,7 @@ use syntax::{ algo::find_node_at_offset, ast, match_ast, AstNode, NodeOrToken, SyntaxKind::*, SyntaxNode, SyntaxToken, TextRange, TextSize, }; -use test_utils::mark; + use text_edit::Indel; use crate::{ @@ -240,7 +240,7 @@ impl<'a> CompletionContext<'a> { // check kind of macro-expanded token, but use range of original token let kind = self.token.kind(); if kind == IDENT || kind == UNDERSCORE || kind.is_keyword() { - mark::hit!(completes_if_prefix_is_keyword); + cov_mark::hit!(completes_if_prefix_is_keyword); self.original_token.text_range() } else { TextRange::empty(self.position.offset) diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index eddaaa6f3..dcfac23c5 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs @@ -15,7 +15,6 @@ use hir::{ }; use ide_db::{helpers::SnippetCap, RootDatabase, SymbolKind}; use syntax::TextRange; -use test_utils::mark; use crate::{ item::ImportEdit, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, @@ -115,11 +114,11 @@ impl<'a> RenderContext<'a> { fn active_name_and_type(&self) -> Option<(String, Type)> { if let Some(record_field) = &self.completion.record_field_syntax { - mark::hit!(record_field_type_match); + cov_mark::hit!(record_field_type_match); let (struct_field, _local) = self.completion.sema.resolve_record_field(record_field)?; Some((struct_field.name(self.db()).to_string(), struct_field.signature_ty(self.db()))) } else if let Some(active_parameter) = &self.completion.active_parameter { - mark::hit!(active_param_type_match); + cov_mark::hit!(active_param_type_match); Some((active_parameter.name.clone(), active_parameter.ty.clone())) } else { None @@ -269,7 +268,7 @@ impl<'a> Render<'a> { _ => false, }; if has_non_default_type_params { - mark::hit!(inserts_angle_brackets_for_generics); + cov_mark::hit!(inserts_angle_brackets_for_generics); item = item .lookup_by(local_name.clone()) .label(format!("{}<…>", local_name)) @@ -358,7 +357,6 @@ mod tests { use std::cmp::Reverse; use expect_test::{expect, Expect}; - use test_utils::mark; use crate::{ test_utils::{check_edit, do_completion, get_all_items, TEST_CONFIG}, @@ -734,7 +732,7 @@ fn foo(s: S) { s.$0 } #[test] fn no_call_parens_if_fn_ptr_needed() { - mark::check!(no_call_parens_if_fn_ptr_needed); + cov_mark::check!(no_call_parens_if_fn_ptr_needed); check_edit( "foo", r#" @@ -758,7 +756,7 @@ fn main() -> ManualVtable { #[test] fn no_parens_in_use_item() { - mark::check!(no_parens_in_use_item); + cov_mark::check!(no_parens_in_use_item); check_edit( "foo", r#" @@ -802,7 +800,7 @@ fn f(foo: &Foo) { foo.foo(); } #[test] fn inserts_angle_brackets_for_generics() { - mark::check!(inserts_angle_brackets_for_generics); + cov_mark::check!(inserts_angle_brackets_for_generics); check_edit( "Vec", r#" @@ -851,7 +849,7 @@ fn foo(xs: Vec) #[test] fn active_param_score() { - mark::check!(active_param_type_match); + cov_mark::check!(active_param_type_match); check_scores( r#" struct S { foo: i64, bar: u32, baz: u32 } @@ -868,7 +866,7 @@ fn foo(s: S) { test(s.$0) } #[test] fn record_field_scores() { - mark::check!(record_field_type_match); + cov_mark::check!(record_field_type_match); check_scores( r#" struct A { foo: i64, bar: u32, baz: u32 } diff --git a/crates/ide_completion/src/render/builder_ext.rs b/crates/ide_completion/src/render/builder_ext.rs index d053a988b..95a7596c1 100644 --- a/crates/ide_completion/src/render/builder_ext.rs +++ b/crates/ide_completion/src/render/builder_ext.rs @@ -1,7 +1,6 @@ //! Extensions for `Builder` structure required for item rendering. use itertools::Itertools; -use test_utils::mark; use crate::{item::Builder, CompletionContext}; @@ -30,7 +29,7 @@ impl Builder { return false; } if ctx.use_item_syntax.is_some() { - mark::hit!(no_parens_in_use_item); + cov_mark::hit!(no_parens_in_use_item); return false; } if ctx.is_pattern_call { @@ -43,7 +42,7 @@ impl Builder { // Don't add parentheses if the expected type is some function reference. if let Some(ty) = &ctx.expected_type { if ty.is_fn() { - mark::hit!(no_call_parens_if_fn_ptr_needed); + cov_mark::hit!(no_call_parens_if_fn_ptr_needed); return false; } } @@ -67,7 +66,7 @@ impl Builder { None => return self, }; // If not an import, add parenthesis automatically. - mark::hit!(inserts_parens_for_function_calls); + cov_mark::hit!(inserts_parens_for_function_calls); let (snippet, label) = if params.is_empty() { (format!("{}()$0", name), format!("{}()", name)) @@ -82,7 +81,7 @@ impl Builder { format!("{}({})$0", name, function_params_snippet) } _ => { - mark::hit!(suppress_arg_snippets); + cov_mark::hit!(suppress_arg_snippets); format!("{}($0)", name) } }; diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs index 9214193b4..ed055c1fb 100644 --- a/crates/ide_completion/src/render/enum_variant.rs +++ b/crates/ide_completion/src/render/enum_variant.rs @@ -3,7 +3,6 @@ use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; use ide_db::SymbolKind; use itertools::Itertools; -use test_utils::mark; use crate::{ item::{CompletionItem, CompletionKind, ImportEdit}, @@ -68,7 +67,7 @@ impl<'a> EnumRender<'a> { .detail(self.detail()); if self.variant_kind == StructKind::Tuple { - mark::hit!(inserts_parens_for_tuple_enums); + cov_mark::hit!(inserts_parens_for_tuple_enums); let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len()); builder = builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params); @@ -103,13 +102,11 @@ impl<'a> EnumRender<'a> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::test_utils::check_edit; #[test] fn inserts_parens_for_tuple_enums() { - mark::check!(inserts_parens_for_tuple_enums); + cov_mark::check!(inserts_parens_for_tuple_enums); check_edit( "Some", r#" diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index e46e21d24..5931945a8 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs @@ -3,7 +3,6 @@ use hir::{HasSource, HirDisplay, Type}; use ide_db::SymbolKind; use syntax::ast::Fn; -use test_utils::mark; use crate::{ item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, @@ -82,7 +81,7 @@ impl<'a> FunctionRender<'a> { self.func.method_params(self.ctx.db()).unwrap_or_default() } else { if let Some(s) = ast_params.self_param() { - mark::hit!(parens_for_method_call_as_assoc_fn); + cov_mark::hit!(parens_for_method_call_as_assoc_fn); params_pats.push(Some(s.to_string())); } self.func.assoc_fn_params(self.ctx.db()) @@ -114,8 +113,6 @@ impl<'a> FunctionRender<'a> { #[cfg(test)] mod tests { - use test_utils::mark; - use crate::{ test_utils::{check_edit, check_edit_with_config, TEST_CONFIG}, CompletionConfig, @@ -123,7 +120,7 @@ mod tests { #[test] fn inserts_parens_for_function_calls() { - mark::check!(inserts_parens_for_function_calls); + cov_mark::check!(inserts_parens_for_function_calls); check_edit( "no_args", r#" @@ -191,7 +188,7 @@ fn bar(s: &S) { #[test] fn parens_for_method_call_as_assoc_fn() { - mark::check!(parens_for_method_call_as_assoc_fn); + cov_mark::check!(parens_for_method_call_as_assoc_fn); check_edit( "foo", r#" @@ -213,7 +210,7 @@ fn main() { S::foo(${1:&self})$0 } #[test] fn suppress_arg_snippets() { - mark::check!(suppress_arg_snippets); + cov_mark::check!(suppress_arg_snippets); check_edit_with_config( CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG }, "with_args", diff --git a/crates/ide_completion/src/render/macro_.rs b/crates/ide_completion/src/render/macro_.rs index a4535786f..a6cf3e479 100644 --- a/crates/ide_completion/src/render/macro_.rs +++ b/crates/ide_completion/src/render/macro_.rs @@ -3,7 +3,6 @@ use hir::{Documentation, HasSource}; use ide_db::SymbolKind; use syntax::display::macro_label; -use test_utils::mark; use crate::{ item::{CompletionItem, CompletionKind, ImportEdit}, @@ -57,7 +56,7 @@ impl<'a> MacroRender<'a> { } None if needs_bang => builder.insert_text(self.banged_name()), _ => { - mark::hit!(dont_insert_macro_call_parens_unncessary); + cov_mark::hit!(dont_insert_macro_call_parens_unncessary); builder.insert_text(&self.name) } }; @@ -125,13 +124,11 @@ fn guess_macro_braces(macro_name: &str, docs: &str) -> (&'static str, &'static s #[cfg(test)] mod tests { - use test_utils::mark; - use crate::test_utils::check_edit; #[test] fn dont_insert_macro_call_parens_unncessary() { - mark::check!(dont_insert_macro_call_parens_unncessary); + cov_mark::check!(dont_insert_macro_call_parens_unncessary); check_edit( "frobnicate!", r#" -- cgit v1.2.3