mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Merge #7778
7778: Fix lowering trailing self paths in UseTrees r=Veykril a=Veykril Noticed that hovering over `self` in a use tree like `use foo::bar::{self}` showing documentation and such for the current module instead of `bar`. Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
f3139d46b0
2 changed files with 40 additions and 2 deletions
|
@ -101,8 +101,12 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
|
|||
break;
|
||||
}
|
||||
ast::PathSegmentKind::SelfKw => {
|
||||
kind = PathKind::Super(0);
|
||||
break;
|
||||
// don't break out if `self` is the last segment of a path, this mean we got an
|
||||
// use tree like `foo::{self}` which we want to resolve as `foo`
|
||||
if !segments.is_empty() {
|
||||
kind = PathKind::Super(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ast::PathSegmentKind::SuperKw => {
|
||||
let nested_super_count = if let PathKind::Super(n) = kind { n } else { 0 };
|
||||
|
@ -117,6 +121,11 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
|
|||
segments.reverse();
|
||||
generic_args.reverse();
|
||||
|
||||
if segments.is_empty() && kind == PathKind::Plain && type_anchor.is_none() {
|
||||
// plain empty paths don't exist, this means we got a single `self` segment as our path
|
||||
kind = PathKind::Super(0);
|
||||
}
|
||||
|
||||
// handle local_inner_macros :
|
||||
// Basically, even in rustc it is quite hacky:
|
||||
// https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue