Restructure find_path into a separate functions for modules and non-module items

Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc
This commit is contained in:
Lukas Wirth 2022-09-13 15:09:40 +02:00
parent b1a4ba3e84
commit a8ecaa1979
31 changed files with 322 additions and 231 deletions

View file

@ -585,9 +585,9 @@ impl Module {
self,
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
prefer_core: bool,
prefer_no_std: bool,
) -> Option<ModPath> {
hir_def::find_path::find_path(db, item.into().into(), self.into(), prefer_core)
hir_def::find_path::find_path(db, item.into().into(), self.into(), prefer_no_std)
}
/// Finds a path that can be used to refer to the given item from within
@ -597,14 +597,14 @@ impl Module {
db: &dyn DefDatabase,
item: impl Into<ItemInNs>,
prefix_kind: PrefixKind,
prefer_core: bool,
prefer_no_std: bool,
) -> Option<ModPath> {
hir_def::find_path::find_path_prefixed(
db,
item.into().into(),
self.into(),
prefix_kind,
prefer_core,
prefer_no_std,
)
}
}