Skip to content

Commit a44152a

Browse files
Add cov_marks to test rust-lang#17927
1 parent a57def2 commit a44152a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/tools/rust-analyzer/crates/ide-db/src/search.rs

+9
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ impl<'a> FindUsages<'a> {
629629
alias.syntax().text_range(),
630630
)) {
631631
tracing::debug!("found alias: {alias}");
632+
cov_mark::hit!(container_use_rename);
632633
// FIXME: `use`s have no easy way to determine their search scope, but they are rare.
633634
to_process.push((
634635
alias.text().to_smolstr(),
@@ -644,12 +645,15 @@ impl<'a> FindUsages<'a> {
644645
name.syntax().text_range(),
645646
)) {
646647
if let Some(def) = is_alias(&alias) {
648+
cov_mark::hit!(container_type_alias);
647649
insert_type_alias(
648650
sema.db,
649651
&mut to_process,
650652
name.text().as_str(),
651653
def.into(),
652654
);
655+
} else {
656+
cov_mark::hit!(same_name_different_def_type_alias);
653657
}
654658
}
655659
}
@@ -706,12 +710,15 @@ impl<'a> FindUsages<'a> {
706710
name.syntax().text_range(),
707711
)) {
708712
if let Some(def) = is_alias(&type_alias) {
713+
cov_mark::hit!(self_type_alias);
709714
insert_type_alias(
710715
sema.db,
711716
&mut to_process,
712717
name.text().as_str(),
713718
def.into(),
714719
);
720+
} else {
721+
cov_mark::hit!(same_name_different_def_type_alias);
715722
}
716723
}
717724
}
@@ -793,6 +800,8 @@ impl<'a> FindUsages<'a> {
793800
return false;
794801
};
795802

803+
cov_mark::hit!(short_associated_function_fast_search);
804+
796805
// FIXME: If Rust ever gains the ability to `use Struct::method` we'll also need to account for free
797806
// functions.
798807
let finder = Finder::new(name.as_bytes());

src/tools/rust-analyzer/crates/ide/src/references.rs

+10
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,7 @@ fn main() {
25162516

25172517
#[test]
25182518
fn goto_ref_on_short_associated_function() {
2519+
cov_mark::check!(short_associated_function_fast_search);
25192520
check(
25202521
r#"
25212522
struct Foo;
@@ -2541,6 +2542,9 @@ fn baz() {
25412542

25422543
#[test]
25432544
fn goto_ref_on_short_associated_function_with_aliases() {
2545+
cov_mark::check!(short_associated_function_fast_search);
2546+
cov_mark::check!(container_use_rename);
2547+
cov_mark::check!(container_type_alias);
25442548
check(
25452549
r#"
25462550
//- /lib.rs
@@ -2589,6 +2593,8 @@ pub(in super::super) type Baz = Itself<crate::Foo>;
25892593

25902594
#[test]
25912595
fn goto_ref_on_short_associated_function_self_works() {
2596+
cov_mark::check!(short_associated_function_fast_search);
2597+
cov_mark::check!(self_type_alias);
25922598
check(
25932599
r#"
25942600
//- /lib.rs
@@ -2651,6 +2657,7 @@ impl Foo {
26512657

26522658
#[test]
26532659
fn goto_ref_on_short_associated_function_no_direct_self_but_path_contains_self() {
2660+
cov_mark::check!(short_associated_function_fast_search);
26542661
check(
26552662
r#"
26562663
struct Foo;
@@ -2684,6 +2691,8 @@ impl Foo {
26842691
// Usages search is not 100% accurate anyway; we miss macros.
26852692
#[test]
26862693
fn goto_ref_on_short_associated_function_complicated_type_magic_can_confuse_our_logic() {
2694+
cov_mark::check!(short_associated_function_fast_search);
2695+
cov_mark::check!(same_name_different_def_type_alias);
26872696
check(
26882697
r#"
26892698
struct Foo;
@@ -2718,6 +2727,7 @@ fn bar() {
27182727

27192728
#[test]
27202729
fn goto_ref_on_short_associated_function_same_path_mention_alias_and_self() {
2730+
cov_mark::check!(short_associated_function_fast_search);
27212731
check(
27222732
r#"
27232733
struct Foo;

0 commit comments

Comments
 (0)