mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
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.
This commit is contained in:
parent
d18d1c0594
commit
5258c817f7
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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<RootDatabase>, 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<RootDatabase>,
|
||||
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)));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
];
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user