mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
fix PathSegment
grammar
This commit is contained in:
parent
69432287cb
commit
23fde40fed
3 changed files with 60 additions and 47 deletions
|
@ -361,6 +361,18 @@ impl ast::Impl {
|
|||
}
|
||||
}
|
||||
|
||||
// for `PathSegment` '<i32 as core::ops::Add>', call `first_path_type` will get `i32` and `last_path_type` will get `core::ops::Add`
|
||||
// for '<&i32 as core::ops::Add>', call `first_path_type` and `last_path_type` will both get `core::ops::Add` cause `&i32` is `Type(RefType)`
|
||||
impl ast::PathSegment {
|
||||
pub fn first_path_type(&self) -> Option<ast::PathType> {
|
||||
self.syntax().children().find_map(ast::PathType::cast)
|
||||
}
|
||||
|
||||
pub fn last_path_type(&self) -> Option<ast::PathType> {
|
||||
self.syntax().children().filter_map(ast::PathType::cast).last()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum StructKind {
|
||||
Record(ast::RecordFieldList),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue