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/Cargo.toml | 1 + crates/ide/src/hover.rs | 9 +++--- crates/ide/src/join_lines.rs | 8 ++--- crates/ide/src/matching_brace.rs | 5 ++-- crates/ide/src/parent_module.rs | 6 ++-- crates/ide/src/references/rename.rs | 58 +++++++++++++++++++------------------ crates/ide/src/runnables.rs | 8 ++--- crates/ide/src/typing/on_enter.rs | 8 ++--- 8 files changed, 51 insertions(+), 52 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index f6aaaeda4..f7c5efaf3 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" doctest = false [dependencies] +cov-mark = "1.1" either = "1.5.3" indexmap = "1.4.0" itertools = "0.10.0" diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index a9454cfa3..5d1cc2052 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -11,7 +11,6 @@ use ide_db::{ use itertools::Itertools; use stdx::format_to; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; -use test_utils::mark; use crate::{ display::{macro_label, ShortLabel, TryToNav}, @@ -193,8 +192,8 @@ fn runnable_action( ModuleDef::Function(func) => { let src = func.source(sema.db)?; if src.file_id != file_id.into() { - mark::hit!(hover_macro_generated_struct_fn_doc_comment); - mark::hit!(hover_macro_generated_struct_fn_doc_attr); + cov_mark::hit!(hover_macro_generated_struct_fn_doc_comment); + cov_mark::hit!(hover_macro_generated_struct_fn_doc_attr); return None; } @@ -2101,7 +2100,7 @@ pub fn fo$0o() {} #[test] fn test_hover_macro_generated_struct_fn_doc_comment() { - mark::check!(hover_macro_generated_struct_fn_doc_comment); + cov_mark::check!(hover_macro_generated_struct_fn_doc_comment); check( r#" @@ -2139,7 +2138,7 @@ fn foo() { let bar = Bar; bar.fo$0o(); } #[test] fn test_hover_macro_generated_struct_fn_doc_attr() { - mark::check!(hover_macro_generated_struct_fn_doc_attr); + cov_mark::check!(hover_macro_generated_struct_fn_doc_attr); check( r#" diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index 7fcae13e0..20a920ddb 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs @@ -7,7 +7,7 @@ use syntax::{ SyntaxKind::{self, USE_TREE, WHITESPACE}, SyntaxNode, SyntaxToken, TextRange, TextSize, T, }; -use test_utils::mark; + use text_edit::{TextEdit, TextEditBuilder}; // Feature: Join Lines @@ -60,7 +60,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS let mut string_open_quote = false; if let Some(string) = ast::String::cast(token.clone()) { if let Some(range) = string.open_quote_text_range() { - mark::hit!(join_string_literal); + cov_mark::hit!(join_string_literal); string_open_quote = range.end() == offset; } } @@ -206,7 +206,7 @@ fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { #[cfg(test)] mod tests { use syntax::SourceFile; - use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range, mark}; + use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range}; use super::*; @@ -786,7 +786,7 @@ fn foo() { #[test] fn join_string_literal() { - mark::check!(join_string_literal); + cov_mark::check!(join_string_literal); check_join_lines( r#" fn main() { diff --git a/crates/ide/src/matching_brace.rs b/crates/ide/src/matching_brace.rs index 1bfa1439d..000c412d9 100644 --- a/crates/ide/src/matching_brace.rs +++ b/crates/ide/src/matching_brace.rs @@ -2,7 +2,6 @@ use syntax::{ ast::{self, AstNode}, SourceFile, SyntaxKind, TextSize, T, }; -use test_utils::mark; // Feature: Matching Brace // @@ -28,7 +27,7 @@ pub(crate) fn matching_brace(file: &SourceFile, offset: TextSize) -> Option 92 } }", "fn main() { match 92 { 1 | 2 |$0 3 => 92 } }", diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs index ddbaf22b7..03d71b380 100644 --- a/crates/ide/src/parent_module.rs +++ b/crates/ide/src/parent_module.rs @@ -5,7 +5,6 @@ use syntax::{ algo::find_node_at_offset, ast::{self, AstNode}, }; -use test_utils::mark; use crate::NavigationTarget; @@ -33,7 +32,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec Vec { #[cfg(test)] mod tests { use ide_db::base_db::FileRange; - use test_utils::mark; use crate::fixture; @@ -92,7 +90,7 @@ $0// empty #[test] fn test_resolve_parent_module_on_module_decl() { - mark::check!(test_resolve_parent_module_on_module_decl); + cov_mark::check!(test_resolve_parent_module_on_module_decl); check( r#" //- /lib.rs diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 1919639a3..05c73de88 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs @@ -14,7 +14,7 @@ use syntax::{ ast::{self, NameOwner}, lex_single_syntax_kind, AstNode, SyntaxKind, SyntaxNode, T, }; -use test_utils::mark; + use text_edit::TextEdit; use crate::{display::TryToNav, FilePosition, FileSystemEdit, RangeInfo, SourceChange, TextRange}; @@ -226,34 +226,36 @@ fn rename_reference( | (IdentifierKind::Ident, _) if def_is_lbl_or_lt => { - mark::hit!(rename_not_a_lifetime_ident_ref); + cov_mark::hit!(rename_not_a_lifetime_ident_ref); bail!("Invalid name `{}`: not a lifetime identifier", new_name) } - (IdentifierKind::Lifetime, _) if def_is_lbl_or_lt => mark::hit!(rename_lifetime), + (IdentifierKind::Lifetime, _) if def_is_lbl_or_lt => cov_mark::hit!(rename_lifetime), (IdentifierKind::Lifetime, _) => { - mark::hit!(rename_not_an_ident_ref); + cov_mark::hit!(rename_not_an_ident_ref); bail!("Invalid name `{}`: not an identifier", new_name) } (IdentifierKind::ToSelf, Definition::Local(local)) if local.is_self(sema.db) => { // no-op - mark::hit!(rename_self_to_self); + cov_mark::hit!(rename_self_to_self); return Ok(SourceChange::default()); } (ident_kind, Definition::Local(local)) if local.is_self(sema.db) => { - mark::hit!(rename_self_to_param); + cov_mark::hit!(rename_self_to_param); return rename_self_to_param(sema, local, new_name, ident_kind); } (IdentifierKind::ToSelf, Definition::Local(local)) => { - mark::hit!(rename_to_self); + cov_mark::hit!(rename_to_self); return rename_to_self(sema, local); } (IdentifierKind::ToSelf, _) => bail!("Invalid name `{}`: not an identifier", new_name), - (IdentifierKind::Ident, _) | (IdentifierKind::Underscore, _) => mark::hit!(rename_ident), + (IdentifierKind::Ident, _) | (IdentifierKind::Underscore, _) => { + cov_mark::hit!(rename_ident) + } } let usages = def.usages(sema).all(); if !usages.is_empty() && ident_kind == IdentifierKind::Underscore { - mark::hit!(rename_underscore_multiple); + cov_mark::hit!(rename_underscore_multiple); bail!("Cannot rename reference to `_` as it is being referenced multiple times"); } let mut source_change = SourceChange::default(); @@ -444,7 +446,7 @@ fn source_edit_from_name_ref( (Some(field_name), Some(init)) => { if field_name == *name_ref { if init.text() == new_name { - mark::hit!(test_rename_field_put_init_shorthand); + cov_mark::hit!(test_rename_field_put_init_shorthand); // same names, we can use a shorthand here instead. // we do not want to erase attributes hence this range start let s = field_name.syntax().text_range().start(); @@ -453,7 +455,7 @@ fn source_edit_from_name_ref( } } else if init == *name_ref { if field_name.text() == new_name { - mark::hit!(test_rename_local_put_init_shorthand); + cov_mark::hit!(test_rename_local_put_init_shorthand); // same names, we can use a shorthand here instead. // we do not want to erase attributes hence this range start let s = field_name.syntax().text_range().start(); @@ -467,12 +469,12 @@ fn source_edit_from_name_ref( // FIXME: instead of splitting the shorthand, recursively trigger a rename of the // other name https://github.com/rust-analyzer/rust-analyzer/issues/6547 (None, Some(_)) if matches!(def, Definition::Field(_)) => { - mark::hit!(test_rename_field_in_field_shorthand); + cov_mark::hit!(test_rename_field_in_field_shorthand); let s = name_ref.syntax().text_range().start(); Some((TextRange::empty(s), format!("{}: ", new_name))) } (None, Some(_)) if matches!(def, Definition::Local(_)) => { - mark::hit!(test_rename_local_in_field_shorthand); + cov_mark::hit!(test_rename_local_in_field_shorthand); let s = name_ref.syntax().text_range().end(); Some((TextRange::empty(s), format!(": {}", new_name))) } @@ -486,7 +488,7 @@ fn source_edit_from_name_ref( (Some(field_name), Some(ast::Pat::IdentPat(pat))) if field_name == *name_ref => { // field name is being renamed if pat.name().map_or(false, |it| it.text() == new_name) { - mark::hit!(test_rename_field_put_init_shorthand_pat); + cov_mark::hit!(test_rename_field_put_init_shorthand_pat); // same names, we can use a shorthand here instead/ // we do not want to erase attributes hence this range start let s = field_name.syntax().text_range().start(); @@ -538,7 +540,7 @@ fn source_edit_from_def( mod tests { use expect_test::{expect, Expect}; use stdx::trim_indent; - use test_utils::{assert_eq_text, mark}; + use test_utils::assert_eq_text; use text_edit::TextEdit; use crate::{fixture, FileId}; @@ -627,7 +629,7 @@ mod tests { #[test] fn test_rename_to_invalid_identifier_lifetime() { - mark::check!(rename_not_an_ident_ref); + cov_mark::check!(rename_not_an_ident_ref); check( "'foo", r#"fn main() { let i$0 = 1; }"#, @@ -637,7 +639,7 @@ mod tests { #[test] fn test_rename_to_invalid_identifier_lifetime2() { - mark::check!(rename_not_a_lifetime_ident_ref); + cov_mark::check!(rename_not_a_lifetime_ident_ref); check( "foo", r#"fn main<'a>(_: &'a$0 ()) {}"#, @@ -647,7 +649,7 @@ mod tests { #[test] fn test_rename_to_underscore_invalid() { - mark::check!(rename_underscore_multiple); + cov_mark::check!(rename_underscore_multiple); check( "_", r#"fn main(foo$0: ()) {foo;}"#, @@ -666,7 +668,7 @@ mod tests { #[test] fn test_rename_for_local() { - mark::check!(rename_ident); + cov_mark::check!(rename_ident); check( "k", r#" @@ -829,7 +831,7 @@ impl Foo { #[test] fn test_rename_field_in_field_shorthand() { - mark::check!(test_rename_field_in_field_shorthand); + cov_mark::check!(test_rename_field_in_field_shorthand); check( "j", r#" @@ -855,7 +857,7 @@ impl Foo { #[test] fn test_rename_local_in_field_shorthand() { - mark::check!(test_rename_local_in_field_shorthand); + cov_mark::check!(test_rename_local_in_field_shorthand); check( "j", r#" @@ -1261,7 +1263,7 @@ fn foo(f: foo::Foo) { #[test] fn test_parameter_to_self() { - mark::check!(rename_to_self); + cov_mark::check!(rename_to_self); check( "self", r#" @@ -1401,7 +1403,7 @@ impl Foo { #[test] fn test_owned_self_to_parameter() { - mark::check!(rename_self_to_param); + cov_mark::check!(rename_self_to_param); check( "foo", r#" @@ -1454,7 +1456,7 @@ impl Foo { #[test] fn test_rename_field_put_init_shorthand() { - mark::check!(test_rename_field_put_init_shorthand); + cov_mark::check!(test_rename_field_put_init_shorthand); check( "bar", r#" @@ -1476,7 +1478,7 @@ fn foo(bar: i32) -> Foo { #[test] fn test_rename_local_put_init_shorthand() { - mark::check!(test_rename_local_put_init_shorthand); + cov_mark::check!(test_rename_local_put_init_shorthand); check( "i", r#" @@ -1498,7 +1500,7 @@ fn foo(i: i32) -> Foo { #[test] fn test_struct_field_pat_into_shorthand() { - mark::check!(test_rename_field_put_init_shorthand_pat); + cov_mark::check!(test_rename_field_put_init_shorthand_pat); check( "baz", r#" @@ -1610,7 +1612,7 @@ fn foo(foo: Foo) { #[test] fn test_rename_lifetimes() { - mark::check!(rename_lifetime); + cov_mark::check!(rename_lifetime); check( "'yeeee", r#" @@ -1698,7 +1700,7 @@ fn foo<'a>() -> &'a () { #[test] fn test_self_to_self() { - mark::check!(rename_self_to_self); + cov_mark::check!(rename_self_to_self); check( "self", r#" diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 65f60891e..280565563 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs @@ -9,7 +9,6 @@ use syntax::{ ast::{self, AstNode, AttrsOwner}, match_ast, SyntaxNode, }; -use test_utils::mark; use crate::{ display::{ToNav, TryToNav}, @@ -130,7 +129,9 @@ fn runnables_mod(sema: &Semantics, acc: &mut Vec, module if let hir::ModuleDef::Module(submodule) = def { match submodule.definition_source(sema.db).value { hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule), - hir::ModuleSource::SourceFile(_) => mark::hit!(dont_recurse_in_outline_submodules), + hir::ModuleSource::SourceFile(_) => { + cov_mark::hit!(dont_recurse_in_outline_submodules) + } hir::ModuleSource::BlockExpr(_) => {} // inner items aren't runnable } } @@ -328,7 +329,6 @@ fn has_test_function_or_multiple_test_submodules( #[cfg(test)] mod tests { use expect_test::{expect, Expect}; - use test_utils::mark; use crate::fixture; @@ -1056,7 +1056,7 @@ mod tests { #[test] fn dont_recurse_in_outline_submodules() { - mark::check!(dont_recurse_in_outline_submodules); + cov_mark::check!(dont_recurse_in_outline_submodules); check( r#" //- /lib.rs diff --git a/crates/ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs index 63cd51b69..978c479de 100644 --- a/crates/ide/src/typing/on_enter.rs +++ b/crates/ide/src/typing/on_enter.rs @@ -9,7 +9,7 @@ use syntax::{ SyntaxKind::*, SyntaxToken, TextRange, TextSize, TokenAtOffset, }; -use test_utils::mark; + use text_edit::TextEdit; // Feature: On Enter @@ -55,7 +55,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option Option { #[cfg(test)] mod tests { use stdx::trim_indent; - use test_utils::{assert_eq_text, mark}; + use test_utils::assert_eq_text; use crate::fixture; @@ -238,7 +238,7 @@ fn main() { #[test] fn continues_end_of_line_comment_with_space() { - mark::check!(continues_end_of_line_comment_with_space); + cov_mark::check!(continues_end_of_line_comment_with_space); do_check( r#" fn main() { -- cgit v1.2.3