aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_ide/src/goto_definition.rs10
-rw-r--r--crates/ra_ide/src/references.rs3
-rw-r--r--crates/ra_ide_db/src/defs.rs10
-rw-r--r--crates/ra_ide_db/src/lib.rs1
-rw-r--r--crates/ra_ide_db/src/marks.rs12
-rw-r--r--crates/ra_ide_db/src/search.rs2
-rw-r--r--crates/test_utils/src/marks.rs11
7 files changed, 4 insertions, 45 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index 150895abb..90e85d419 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(
93 93
94#[cfg(test)] 94#[cfg(test)]
95mod tests { 95mod tests {
96 use test_utils::{assert_eq_text, covers}; 96 use test_utils::assert_eq_text;
97 97
98 use crate::mock_analysis::analysis_and_position; 98 use crate::mock_analysis::analysis_and_position;
99 99
@@ -208,7 +208,6 @@ mod tests {
208 208
209 #[test] 209 #[test]
210 fn goto_def_for_macros() { 210 fn goto_def_for_macros() {
211 covers!(ra_ide_db::goto_def_for_macros);
212 check_goto( 211 check_goto(
213 " 212 "
214 //- /lib.rs 213 //- /lib.rs
@@ -225,7 +224,6 @@ mod tests {
225 224
226 #[test] 225 #[test]
227 fn goto_def_for_macros_from_other_crates() { 226 fn goto_def_for_macros_from_other_crates() {
228 covers!(ra_ide_db::goto_def_for_macros);
229 check_goto( 227 check_goto(
230 " 228 "
231 //- /lib.rs 229 //- /lib.rs
@@ -245,7 +243,6 @@ mod tests {
245 243
246 #[test] 244 #[test]
247 fn goto_def_for_use_alias() { 245 fn goto_def_for_use_alias() {
248 covers!(ra_ide_db::goto_def_for_use_alias);
249 check_goto( 246 check_goto(
250 " 247 "
251 //- /lib.rs 248 //- /lib.rs
@@ -370,7 +367,6 @@ mod tests {
370 367
371 #[test] 368 #[test]
372 fn goto_def_for_methods() { 369 fn goto_def_for_methods() {
373 covers!(ra_ide_db::goto_def_for_methods);
374 check_goto( 370 check_goto(
375 " 371 "
376 //- /lib.rs 372 //- /lib.rs
@@ -390,7 +386,6 @@ mod tests {
390 386
391 #[test] 387 #[test]
392 fn goto_def_for_fields() { 388 fn goto_def_for_fields() {
393 covers!(ra_ide_db::goto_def_for_fields);
394 check_goto( 389 check_goto(
395 r" 390 r"
396 //- /lib.rs 391 //- /lib.rs
@@ -409,7 +404,6 @@ mod tests {
409 404
410 #[test] 405 #[test]
411 fn goto_def_for_record_fields() { 406 fn goto_def_for_record_fields() {
412 covers!(ra_ide_db::goto_def_for_record_fields);
413 check_goto( 407 check_goto(
414 r" 408 r"
415 //- /lib.rs 409 //- /lib.rs
@@ -430,7 +424,6 @@ mod tests {
430 424
431 #[test] 425 #[test]
432 fn goto_def_for_record_pat_fields() { 426 fn goto_def_for_record_pat_fields() {
433 covers!(ra_ide_db::goto_def_for_record_field_pats);
434 check_goto( 427 check_goto(
435 r" 428 r"
436 //- /lib.rs 429 //- /lib.rs
@@ -873,7 +866,6 @@ mod tests {
873 866
874 #[test] 867 #[test]
875 fn goto_def_for_field_init_shorthand() { 868 fn goto_def_for_field_init_shorthand() {
876 covers!(ra_ide_db::goto_def_for_field_init_shorthand);
877 check_goto( 869 check_goto(
878 " 870 "
879 //- /lib.rs 871 //- /lib.rs
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index 074284b42..96444bf6a 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(
190 190
191#[cfg(test)] 191#[cfg(test)]
192mod tests { 192mod tests {
193 use test_utils::covers;
194
195 use crate::{ 193 use crate::{
196 mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis}, 194 mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis},
197 Declaration, Reference, ReferenceSearchResult, SearchScope, 195 Declaration, Reference, ReferenceSearchResult, SearchScope,
@@ -301,7 +299,6 @@ mod tests {
301 299
302 #[test] 300 #[test]
303 fn search_filters_by_range() { 301 fn search_filters_by_range() {
304 covers!(ra_ide_db::search_filters_by_range);
305 let code = r#" 302 let code = r#"
306 fn foo() { 303 fn foo() {
307 let spam<|> = 92; 304 let spam<|> = 92;
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index 60c11178e..8b06cbfc5 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -14,7 +14,6 @@ use ra_syntax::{
14 ast::{self, AstNode}, 14 ast::{self, AstNode},
15 match_ast, 15 match_ast,
16}; 16};
17use test_utils::tested_by;
18 17
19use crate::RootDatabase; 18use crate::RootDatabase;
20 19
@@ -118,7 +117,6 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
118 match_ast! { 117 match_ast! {
119 match parent { 118 match parent {
120 ast::Alias(it) => { 119 ast::Alias(it) => {
121 tested_by!(goto_def_for_use_alias; force);
122 let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; 120 let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?;
123 let path = use_tree.path()?; 121 let path = use_tree.path()?;
124 let path_segment = path.segment()?; 122 let path_segment = path.segment()?;
@@ -203,6 +201,8 @@ impl NameRefClass {
203 } 201 }
204} 202}
205 203
204// Note: we don't have unit-tests for this rather important function.
205// It is primarily exercised via goto definition tests in `ra_ide`.
206pub fn classify_name_ref( 206pub fn classify_name_ref(
207 sema: &Semantics<RootDatabase>, 207 sema: &Semantics<RootDatabase>,
208 name_ref: &ast::NameRef, 208 name_ref: &ast::NameRef,
@@ -212,22 +212,18 @@ pub fn classify_name_ref(
212 let parent = name_ref.syntax().parent()?; 212 let parent = name_ref.syntax().parent()?;
213 213
214 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { 214 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
215 tested_by!(goto_def_for_methods; force);
216 if let Some(func) = sema.resolve_method_call(&method_call) { 215 if let Some(func) = sema.resolve_method_call(&method_call) {
217 return Some(NameRefClass::Definition(Definition::ModuleDef(func.into()))); 216 return Some(NameRefClass::Definition(Definition::ModuleDef(func.into())));
218 } 217 }
219 } 218 }
220 219
221 if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) { 220 if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) {
222 tested_by!(goto_def_for_fields; force);
223 if let Some(field) = sema.resolve_field(&field_expr) { 221 if let Some(field) = sema.resolve_field(&field_expr) {
224 return Some(NameRefClass::Definition(Definition::Field(field))); 222 return Some(NameRefClass::Definition(Definition::Field(field)));
225 } 223 }
226 } 224 }
227 225
228 if let Some(record_field) = ast::RecordField::for_field_name(name_ref) { 226 if let Some(record_field) = ast::RecordField::for_field_name(name_ref) {
229 tested_by!(goto_def_for_record_fields; force);
230 tested_by!(goto_def_for_field_init_shorthand; force);
231 if let Some((field, local)) = sema.resolve_record_field(&record_field) { 227 if let Some((field, local)) = sema.resolve_record_field(&record_field) {
232 let field = Definition::Field(field); 228 let field = Definition::Field(field);
233 let res = match local { 229 let res = match local {
@@ -239,7 +235,6 @@ pub fn classify_name_ref(
239 } 235 }
240 236
241 if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) { 237 if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) {
242 tested_by!(goto_def_for_record_field_pats; force);
243 if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { 238 if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) {
244 let field = Definition::Field(field); 239 let field = Definition::Field(field);
245 return Some(NameRefClass::Definition(field)); 240 return Some(NameRefClass::Definition(field));
@@ -247,7 +242,6 @@ pub fn classify_name_ref(
247 } 242 }
248 243
249 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { 244 if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) {
250 tested_by!(goto_def_for_macros; force);
251 if let Some(macro_def) = sema.resolve_macro_call(&macro_call) { 245 if let Some(macro_def) = sema.resolve_macro_call(&macro_call) {
252 return Some(NameRefClass::Definition(Definition::Macro(macro_def))); 246 return Some(NameRefClass::Definition(Definition::Macro(macro_def)));
253 } 247 }
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs
index 52fcd7b6f..4f37954bf 100644
--- a/crates/ra_ide_db/src/lib.rs
+++ b/crates/ra_ide_db/src/lib.rs
@@ -2,7 +2,6 @@
2//! 2//!
3//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search. 3//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
4 4
5pub mod marks;
6pub mod line_index; 5pub mod line_index;
7pub mod line_index_utils; 6pub mod line_index_utils;
8pub mod symbol_index; 7pub 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 386fe605c..000000000
--- a/crates/ra_ide_db/src/marks.rs
+++ /dev/null
@@ -1,12 +0,0 @@
1//! See test_utils/src/marks.rs
2
3test_utils::marks![
4 goto_def_for_macros
5 goto_def_for_use_alias
6 goto_def_for_methods
7 goto_def_for_fields
8 goto_def_for_record_fields
9 goto_def_for_field_init_shorthand
10 goto_def_for_record_field_pats
11 search_filters_by_range
12];
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index b464959fc..589f44771 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};
12use ra_prof::profile; 12use ra_prof::profile;
13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize}; 13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize};
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
15use test_utils::tested_by;
16 15
17use crate::{ 16use crate::{
18 defs::{classify_name_ref, Definition, NameRefClass}, 17 defs::{classify_name_ref, Definition, NameRefClass},
@@ -209,7 +208,6 @@ impl Definition {
209 for (idx, _) in text.match_indices(pat) { 208 for (idx, _) in text.match_indices(pat) {
210 let offset: TextSize = idx.try_into().unwrap(); 209 let offset: TextSize = idx.try_into().unwrap();
211 if !search_range.contains_inclusive(offset) { 210 if !search_range.contains_inclusive(offset) {
212 tested_by!(search_filters_by_range; force);
213 continue; 211 continue;
214 } 212 }
215 213
diff --git a/crates/test_utils/src/marks.rs b/crates/test_utils/src/marks.rs
index c3185e860..f20fb978e 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};
30 30
31#[macro_export] 31#[macro_export]
32macro_rules! tested_by { 32macro_rules! tested_by {
33 ($ident:ident; force) => {{
34 {
35 // sic! use call-site crate
36 crate::marks::$ident.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
37 }
38 }};
39 ($ident:ident) => {{ 33 ($ident:ident) => {{
40 #[cfg(test)] 34 #[cfg(test)]
41 { 35 {
@@ -49,10 +43,7 @@ macro_rules! tested_by {
49macro_rules! covers { 43macro_rules! covers {
50 // sic! use call-site crate 44 // sic! use call-site crate
51 ($ident:ident) => { 45 ($ident:ident) => {
52 $crate::covers!(crate::$ident) 46 let _checker = $crate::marks::MarkChecker::new(&crate::marks::$ident);
53 };
54 ($krate:ident :: $ident:ident) => {
55 let _checker = $crate::marks::MarkChecker::new(&$krate::marks::$ident);
56 }; 47 };
57} 48}
58 49