diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 150895abb42..90e85d41971 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -93,7 +93,7 @@ pub(crate) fn reference_definition( #[cfg(test)] mod tests { - use test_utils::{assert_eq_text, covers}; + use test_utils::assert_eq_text; use crate::mock_analysis::analysis_and_position; @@ -208,7 +208,6 @@ mod tests { #[test] fn goto_def_for_macros() { - covers!(ra_ide_db::goto_def_for_macros); check_goto( " //- /lib.rs @@ -225,7 +224,6 @@ mod tests { #[test] fn goto_def_for_macros_from_other_crates() { - covers!(ra_ide_db::goto_def_for_macros); check_goto( " //- /lib.rs @@ -245,7 +243,6 @@ mod tests { #[test] fn goto_def_for_use_alias() { - covers!(ra_ide_db::goto_def_for_use_alias); check_goto( " //- /lib.rs @@ -370,7 +367,6 @@ mod tests { #[test] fn goto_def_for_methods() { - covers!(ra_ide_db::goto_def_for_methods); check_goto( " //- /lib.rs @@ -390,7 +386,6 @@ mod tests { #[test] fn goto_def_for_fields() { - covers!(ra_ide_db::goto_def_for_fields); check_goto( r" //- /lib.rs @@ -409,7 +404,6 @@ mod tests { #[test] fn goto_def_for_record_fields() { - covers!(ra_ide_db::goto_def_for_record_fields); check_goto( r" //- /lib.rs @@ -430,7 +424,6 @@ mod tests { #[test] fn goto_def_for_record_pat_fields() { - covers!(ra_ide_db::goto_def_for_record_field_pats); check_goto( r" //- /lib.rs @@ -873,7 +866,6 @@ mod tests { #[test] fn goto_def_for_field_init_shorthand() { - covers!(ra_ide_db::goto_def_for_field_init_shorthand); check_goto( " //- /lib.rs diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 074284b42e2..96444bf6a52 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -190,8 +190,6 @@ fn get_struct_def_name_for_struct_literal_search( #[cfg(test)] mod tests { - use test_utils::covers; - use crate::{ mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis}, Declaration, Reference, ReferenceSearchResult, SearchScope, @@ -301,7 +299,6 @@ mod tests { #[test] fn search_filters_by_range() { - covers!(ra_ide_db::search_filters_by_range); let code = r#" fn foo() { let spam<|> = 92; diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 60c11178eea..8b06cbfc54b 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -14,7 +14,6 @@ use ra_syntax::{ ast::{self, AstNode}, match_ast, }; -use test_utils::tested_by; use crate::RootDatabase; @@ -118,7 +117,6 @@ fn classify_name_inner(sema: &Semantics, name: &ast::Name) -> Opti match_ast! { match parent { ast::Alias(it) => { - tested_by!(goto_def_for_use_alias; force); let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; let path = use_tree.path()?; let path_segment = path.segment()?; @@ -203,6 +201,8 @@ impl NameRefClass { } } +// Note: we don't have unit-tests for this rather important function. +// It is primarily exercised via goto definition tests in `ra_ide`. pub fn classify_name_ref( sema: &Semantics, name_ref: &ast::NameRef, @@ -212,22 +212,18 @@ pub fn classify_name_ref( let parent = name_ref.syntax().parent()?; if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { - tested_by!(goto_def_for_methods; force); if let Some(func) = sema.resolve_method_call(&method_call) { return Some(NameRefClass::Definition(Definition::ModuleDef(func.into()))); } } if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) { - tested_by!(goto_def_for_fields; force); if let Some(field) = sema.resolve_field(&field_expr) { return Some(NameRefClass::Definition(Definition::Field(field))); } } if let Some(record_field) = ast::RecordField::for_field_name(name_ref) { - tested_by!(goto_def_for_record_fields; force); - tested_by!(goto_def_for_field_init_shorthand; force); if let Some((field, local)) = sema.resolve_record_field(&record_field) { let field = Definition::Field(field); let res = match local { @@ -239,7 +235,6 @@ pub fn classify_name_ref( } if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { - tested_by!(goto_def_for_record_field_pats; force); if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { let field = Definition::Field(field); return Some(NameRefClass::Definition(field)); @@ -247,7 +242,6 @@ pub fn classify_name_ref( } if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { - tested_by!(goto_def_for_macros; force); if let Some(macro_def) = sema.resolve_macro_call(¯o_call) { return Some(NameRefClass::Definition(Definition::Macro(macro_def))); } diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs index 52fcd7b6f0b..4f37954bf7f 100644 --- a/crates/ra_ide_db/src/lib.rs +++ b/crates/ra_ide_db/src/lib.rs @@ -2,7 +2,6 @@ //! //! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search. -pub mod marks; pub mod line_index; pub mod line_index_utils; pub mod symbol_index; diff --git a/crates/ra_ide_db/src/marks.rs b/crates/ra_ide_db/src/marks.rs deleted file mode 100644 index 386fe605c74..00000000000 --- a/crates/ra_ide_db/src/marks.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! See test_utils/src/marks.rs - -test_utils::marks![ - goto_def_for_macros - goto_def_for_use_alias - goto_def_for_methods - goto_def_for_fields - goto_def_for_record_fields - goto_def_for_field_init_shorthand - goto_def_for_record_field_pats - search_filters_by_range -]; diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index b464959fce0..589f4477192 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -12,7 +12,6 @@ use ra_db::{FileId, FileRange, SourceDatabaseExt}; use ra_prof::profile; use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize}; use rustc_hash::FxHashMap; -use test_utils::tested_by; use crate::{ defs::{classify_name_ref, Definition, NameRefClass}, @@ -209,7 +208,6 @@ impl Definition { for (idx, _) in text.match_indices(pat) { let offset: TextSize = idx.try_into().unwrap(); if !search_range.contains_inclusive(offset) { - tested_by!(search_filters_by_range; force); continue; } diff --git a/crates/test_utils/src/marks.rs b/crates/test_utils/src/marks.rs index c3185e860c8..f20fb978ee3 100644 --- a/crates/test_utils/src/marks.rs +++ b/crates/test_utils/src/marks.rs @@ -30,12 +30,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; #[macro_export] macro_rules! tested_by { - ($ident:ident; force) => {{ - { - // sic! use call-site crate - crate::marks::$ident.fetch_add(1, std::sync::atomic::Ordering::SeqCst); - } - }}; ($ident:ident) => {{ #[cfg(test)] { @@ -49,10 +43,7 @@ macro_rules! tested_by { macro_rules! covers { // sic! use call-site crate ($ident:ident) => { - $crate::covers!(crate::$ident) - }; - ($krate:ident :: $ident:ident) => { - let _checker = $crate::marks::MarkChecker::new(&$krate::marks::$ident); + let _checker = $crate::marks::MarkChecker::new(&crate::marks::$ident); }; }