Skip to content

Commit 5258c81

Browse files
committed
Remove cross-crate marks
They create quite a bit of friction. Really, we should just move the tests to the same crate, rather than paper over existing split.
1 parent d18d1c0 commit 5258c81

File tree

7 files changed

+4
-45
lines changed

7 files changed

+4
-45
lines changed

crates/ra_ide/src/goto_definition.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub(crate) fn reference_definition(
9393

9494
#[cfg(test)]
9595
mod tests {
96-
use test_utils::{assert_eq_text, covers};
96+
use test_utils::assert_eq_text;
9797

9898
use crate::mock_analysis::analysis_and_position;
9999

@@ -208,7 +208,6 @@ mod tests {
208208

209209
#[test]
210210
fn goto_def_for_macros() {
211-
covers!(ra_ide_db::goto_def_for_macros);
212211
check_goto(
213212
"
214213
//- /lib.rs
@@ -225,7 +224,6 @@ mod tests {
225224

226225
#[test]
227226
fn goto_def_for_macros_from_other_crates() {
228-
covers!(ra_ide_db::goto_def_for_macros);
229227
check_goto(
230228
"
231229
//- /lib.rs
@@ -245,7 +243,6 @@ mod tests {
245243

246244
#[test]
247245
fn goto_def_for_use_alias() {
248-
covers!(ra_ide_db::goto_def_for_use_alias);
249246
check_goto(
250247
"
251248
//- /lib.rs
@@ -370,7 +367,6 @@ mod tests {
370367

371368
#[test]
372369
fn goto_def_for_methods() {
373-
covers!(ra_ide_db::goto_def_for_methods);
374370
check_goto(
375371
"
376372
//- /lib.rs
@@ -390,7 +386,6 @@ mod tests {
390386

391387
#[test]
392388
fn goto_def_for_fields() {
393-
covers!(ra_ide_db::goto_def_for_fields);
394389
check_goto(
395390
r"
396391
//- /lib.rs
@@ -409,7 +404,6 @@ mod tests {
409404

410405
#[test]
411406
fn goto_def_for_record_fields() {
412-
covers!(ra_ide_db::goto_def_for_record_fields);
413407
check_goto(
414408
r"
415409
//- /lib.rs
@@ -430,7 +424,6 @@ mod tests {
430424

431425
#[test]
432426
fn goto_def_for_record_pat_fields() {
433-
covers!(ra_ide_db::goto_def_for_record_field_pats);
434427
check_goto(
435428
r"
436429
//- /lib.rs
@@ -873,7 +866,6 @@ mod tests {
873866

874867
#[test]
875868
fn goto_def_for_field_init_shorthand() {
876-
covers!(ra_ide_db::goto_def_for_field_init_shorthand);
877869
check_goto(
878870
"
879871
//- /lib.rs

crates/ra_ide/src/references.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ fn get_struct_def_name_for_struct_literal_search(
190190

191191
#[cfg(test)]
192192
mod tests {
193-
use test_utils::covers;
194-
195193
use crate::{
196194
mock_analysis::{analysis_and_position, single_file_with_position, MockAnalysis},
197195
Declaration, Reference, ReferenceSearchResult, SearchScope,
@@ -301,7 +299,6 @@ mod tests {
301299

302300
#[test]
303301
fn search_filters_by_range() {
304-
covers!(ra_ide_db::search_filters_by_range);
305302
let code = r#"
306303
fn foo() {
307304
let spam<|> = 92;

crates/ra_ide_db/src/defs.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use ra_syntax::{
1414
ast::{self, AstNode},
1515
match_ast,
1616
};
17-
use test_utils::tested_by;
1817

1918
use crate::RootDatabase;
2019

@@ -118,7 +117,6 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
118117
match_ast! {
119118
match parent {
120119
ast::Alias(it) => {
121-
tested_by!(goto_def_for_use_alias; force);
122120
let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?;
123121
let path = use_tree.path()?;
124122
let path_segment = path.segment()?;
@@ -203,6 +201,8 @@ impl NameRefClass {
203201
}
204202
}
205203

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`.
206206
pub fn classify_name_ref(
207207
sema: &Semantics<RootDatabase>,
208208
name_ref: &ast::NameRef,
@@ -212,22 +212,18 @@ pub fn classify_name_ref(
212212
let parent = name_ref.syntax().parent()?;
213213

214214
if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
215-
tested_by!(goto_def_for_methods; force);
216215
if let Some(func) = sema.resolve_method_call(&method_call) {
217216
return Some(NameRefClass::Definition(Definition::ModuleDef(func.into())));
218217
}
219218
}
220219

221220
if let Some(field_expr) = ast::FieldExpr::cast(parent.clone()) {
222-
tested_by!(goto_def_for_fields; force);
223221
if let Some(field) = sema.resolve_field(&field_expr) {
224222
return Some(NameRefClass::Definition(Definition::Field(field)));
225223
}
226224
}
227225

228226
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);
231227
if let Some((field, local)) = sema.resolve_record_field(&record_field) {
232228
let field = Definition::Field(field);
233229
let res = match local {
@@ -239,15 +235,13 @@ pub fn classify_name_ref(
239235
}
240236

241237
if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent.clone()) {
242-
tested_by!(goto_def_for_record_field_pats; force);
243238
if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) {
244239
let field = Definition::Field(field);
245240
return Some(NameRefClass::Definition(field));
246241
}
247242
}
248243

249244
if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) {
250-
tested_by!(goto_def_for_macros; force);
251245
if let Some(macro_def) = sema.resolve_macro_call(&macro_call) {
252246
return Some(NameRefClass::Definition(Definition::Macro(macro_def)));
253247
}

crates/ra_ide_db/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
44
5-
pub mod marks;
65
pub mod line_index;
76
pub mod line_index_utils;
87
pub mod symbol_index;

crates/ra_ide_db/src/marks.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

crates/ra_ide_db/src/search.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use ra_db::{FileId, FileRange, SourceDatabaseExt};
1212
use ra_prof::profile;
1313
use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize};
1414
use rustc_hash::FxHashMap;
15-
use test_utils::tested_by;
1615

1716
use crate::{
1817
defs::{classify_name_ref, Definition, NameRefClass},
@@ -209,7 +208,6 @@ impl Definition {
209208
for (idx, _) in text.match_indices(pat) {
210209
let offset: TextSize = idx.try_into().unwrap();
211210
if !search_range.contains_inclusive(offset) {
212-
tested_by!(search_filters_by_range; force);
213211
continue;
214212
}
215213

crates/test_utils/src/marks.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
3030

3131
#[macro_export]
3232
macro_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-
}};
3933
($ident:ident) => {{
4034
#[cfg(test)]
4135
{
@@ -49,10 +43,7 @@ macro_rules! tested_by {
4943
macro_rules! covers {
5044
// sic! use call-site crate
5145
($ident:ident) => {
52-
$crate::covers!(crate::$ident)
53-
};
54-
($krate:ident :: $ident:ident) => {
55-
let _checker = $crate::marks::MarkChecker::new(&$krate::marks::$ident);
46+
let _checker = $crate::marks::MarkChecker::new(&crate::marks::$ident);
5647
};
5748
}
5849

0 commit comments

Comments
 (0)