Auto merge of #17277 - Veykril:find-path-fixes, r=Veykril

fix: Various find path fixes

Fixes https://github.com/rust-lang/rust-analyzer/issues/17271
This commit is contained in:
bors 2024-05-22 18:22:32 +00:00
commit 6a16749eb0
33 changed files with 645 additions and 344 deletions

View file

@ -788,7 +788,7 @@ impl Module {
/// Finds a path that can be used to refer to the given item from within
/// this module, if possible.
pub fn find_use_path(
pub fn find_path(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
@ -799,6 +799,8 @@ impl Module {
db,
item.into().into(),
self.into(),
PrefixKind::Plain,
false,
prefer_no_std,
prefer_prelude,
)
@ -806,7 +808,7 @@ impl Module {
/// Finds a path that can be used to refer to the given item from within
/// this module, if possible. This is used for returning import paths for use-statements.
pub fn find_use_path_prefixed(
pub fn find_use_path(
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
@ -814,11 +816,12 @@ impl Module {
prefer_no_std: bool,
prefer_prelude: bool,
) -> Option<ModPath> {
hir_def::find_path::find_path_prefixed(
hir_def::find_path::find_path(
db,
item.into().into(),
self.into(),
prefix_kind,
true,
prefer_no_std,
prefer_prelude,
)