mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Lower fully qualified associated type paths
I.e. `<T as Trait>::Foo`.
This commit is contained in:
parent
6cfdfdecba
commit
22724f37f3
5 changed files with 128 additions and 23 deletions
|
@ -91,6 +91,7 @@ impl ast::Attr {
|
|||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum PathSegmentKind {
|
||||
Name(ast::NameRef),
|
||||
Type { type_ref: Option<ast::TypeRef>, trait_ref: Option<ast::PathType> },
|
||||
SelfKw,
|
||||
SuperKw,
|
||||
CrateKw,
|
||||
|
@ -112,6 +113,15 @@ impl ast::PathSegment {
|
|||
T![self] => PathSegmentKind::SelfKw,
|
||||
T![super] => PathSegmentKind::SuperKw,
|
||||
T![crate] => PathSegmentKind::CrateKw,
|
||||
T![<] => {
|
||||
// <T> or <T as Trait>
|
||||
// T is any TypeRef, Trait has to be a PathType
|
||||
let mut type_refs =
|
||||
self.syntax().children().filter(|node| ast::TypeRef::can_cast(node.kind()));
|
||||
let type_ref = type_refs.next().and_then(ast::TypeRef::cast);
|
||||
let trait_ref = type_refs.next().and_then(ast::PathType::cast);
|
||||
PathSegmentKind::Type { type_ref, trait_ref }
|
||||
}
|
||||
_ => return None,
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue