mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Don't expose hir::Path out of hir
Conjecture: it's impossible to use hir::Path *correctly* from an IDE. I am not entirely sure about this, and we might need to add it back at some point, but I have to arguments that convince me that we probably won't: * `hir::Path` has to know about hygiene, which an IDE can't set up properly. * `hir::Path` lacks identity, but you actually have to know identity to resolve it correctly
This commit is contained in:
parent
2052d33b9b
commit
0ca1ba29e8
9 changed files with 51 additions and 92 deletions
|
@ -12,6 +12,7 @@ use hir_def::{
|
|||
docs::Documentation,
|
||||
expr::{BindingAnnotation, Pat, PatId},
|
||||
import_map,
|
||||
path::ModPath,
|
||||
per_ns::PerNs,
|
||||
resolver::{HasResolver, Resolver},
|
||||
src::HasSource as _,
|
||||
|
@ -344,11 +345,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(
|
||||
self,
|
||||
db: &dyn DefDatabase,
|
||||
item: impl Into<ItemInNs>,
|
||||
) -> Option<hir_def::path::ModPath> {
|
||||
pub fn find_use_path(self, db: &dyn DefDatabase, item: impl Into<ItemInNs>) -> Option<ModPath> {
|
||||
hir_def::find_path::find_path(db, item.into(), self.into())
|
||||
}
|
||||
}
|
||||
|
@ -1126,7 +1123,7 @@ impl ImplDef {
|
|||
.value
|
||||
.attrs()
|
||||
.filter_map(|it| {
|
||||
let path = hir_def::path::ModPath::from_src(it.path()?, &hygenic)?;
|
||||
let path = ModPath::from_src(it.path()?, &hygenic)?;
|
||||
if path.as_ident()?.to_string() == "derive" {
|
||||
Some(it)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue