Skip to content

feat: exclude refs(find all refs) from deps and stdlib#21906

Open
Young-Flash wants to merge 4 commits intorust-lang:masterfrom
Young-Flash:master
Open

feat: exclude refs(find all refs) from deps and stdlib#21906
Young-Flash wants to merge 4 commits intorust-lang:masterfrom
Young-Flash:master

Conversation

@Young-Flash
Copy link
Copy Markdown
Member

follow up #16441, close #17184

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 29, 2026
@Young-Flash Young-Flash changed the title feat: exclude refs from deps and stdlib feat: exclude refs(find all refs) from deps and stdlib Mar 29, 2026
@rustbot

This comment has been minimized.

@ChayimFriedman2
Copy link
Copy Markdown
Contributor

I'm not keen on another config to be honest. I prefer an idea @Veykril has suggested in the past (@Veykril do you agree?): search in dependencies if the search is triggered from dependency source, exclude them if the search is from user code. This seems intuitive.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 11, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

/// whether to search for the `self` module
search_self_mod: bool,
/// categories to exclude while collecting usages
excluded_categories: ReferenceCategory,
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

I prefer this to be included_categories.

Some(scope) => base.intersection(scope),
}
};
if self.exclude_library_files {
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

It's better to do that in scope_files(). This will also handle the case you forgot in short_associated_function_fast_search().

}
});
})
.filter(|decl| !(exclude_library_refs && is_library_file(sema.db, decl.nav.file_id)));
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

No need to do that here given it's already filtered by the search.

FileId(0) 9..12 import
FileId(0) 31..34
"#]],
);
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

I think we always want the definition, even when inside a library. Only exclude other references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: improve references search

3 participants