Skip to content

Commit

Permalink
Add cov_marks to test #17927
Browse files Browse the repository at this point in the history
  • Loading branch information
ChayimFriedman2 committed Aug 22, 2024
1 parent d89bdd9 commit 6a910f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/ide-db/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ impl<'a> FindUsages<'a> {
alias.syntax().text_range(),
)) {
tracing::debug!("found alias: {alias}");
cov_mark::hit!(container_use_rename);
// FIXME: `use`s have no easy way to determine their search scope, but they are rare.
to_process.push((
alias.text().to_smolstr(),
Expand All @@ -644,12 +645,15 @@ impl<'a> FindUsages<'a> {
name.syntax().text_range(),
)) {
if let Some(def) = is_alias(&alias) {
cov_mark::hit!(container_type_alias);
insert_type_alias(
sema.db,
&mut to_process,
name.text().as_str(),
def.into(),
);
} else {
cov_mark::hit!(same_name_different_def_type_alias);
}
}
}
Expand Down Expand Up @@ -706,12 +710,15 @@ impl<'a> FindUsages<'a> {
name.syntax().text_range(),
)) {
if let Some(def) = is_alias(&type_alias) {
cov_mark::hit!(self_type_alias);
insert_type_alias(
sema.db,
&mut to_process,
name.text().as_str(),
def.into(),
);
} else {
cov_mark::hit!(same_name_different_def_type_alias);
}
}
}
Expand Down Expand Up @@ -793,6 +800,8 @@ impl<'a> FindUsages<'a> {
return false;
};

cov_mark::hit!(short_associated_function_fast_search);

// FIXME: If Rust ever gains the ability to `use Struct::method` we'll also need to account for free
// functions.
let finder = Finder::new(name.as_bytes());
Expand Down
10 changes: 10 additions & 0 deletions crates/ide/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2516,6 +2516,7 @@ fn main() {

#[test]
fn goto_ref_on_short_associated_function() {
cov_mark::check!(short_associated_function_fast_search);
check(
r#"
struct Foo;
Expand All @@ -2541,6 +2542,9 @@ fn baz() {

#[test]
fn goto_ref_on_short_associated_function_with_aliases() {
cov_mark::check!(short_associated_function_fast_search);
cov_mark::check!(container_use_rename);
cov_mark::check!(container_type_alias);
check(
r#"
//- /lib.rs
Expand Down Expand Up @@ -2589,6 +2593,8 @@ pub(in super::super) type Baz = Itself<crate::Foo>;

#[test]
fn goto_ref_on_short_associated_function_self_works() {
cov_mark::check!(short_associated_function_fast_search);
cov_mark::check!(self_type_alias);
check(
r#"
//- /lib.rs
Expand Down Expand Up @@ -2651,6 +2657,7 @@ impl Foo {

#[test]
fn goto_ref_on_short_associated_function_no_direct_self_but_path_contains_self() {
cov_mark::check!(short_associated_function_fast_search);
check(
r#"
struct Foo;
Expand Down Expand Up @@ -2684,6 +2691,8 @@ impl Foo {
// Usages search is not 100% accurate anyway; we miss macros.
#[test]
fn goto_ref_on_short_associated_function_complicated_type_magic_can_confuse_our_logic() {
cov_mark::check!(short_associated_function_fast_search);
cov_mark::check!(same_name_different_def_type_alias);
check(
r#"
struct Foo;
Expand Down Expand Up @@ -2718,6 +2727,7 @@ fn bar() {

#[test]
fn goto_ref_on_short_associated_function_same_path_mention_alias_and_self() {
cov_mark::check!(short_associated_function_fast_search);
check(
r#"
struct Foo;
Expand Down

0 comments on commit 6a910f6

Please sign in to comment.