Skip to content

Commit 3e5bc9a

Browse files
committed
impl qualifying_trait for PathSegment
1 parent 23fde40 commit 3e5bc9a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

crates/syntax/src/ast/node_ext.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,12 @@ impl ast::Impl {
361361
}
362362
}
363363

364-
// for `PathSegment` '<i32 as core::ops::Add>', call `first_path_type` will get `i32` and `last_path_type` will get `core::ops::Add`
365-
// 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)`
364+
// [#15778](https://github.com/rust-lang/rust-analyzer/issues/15778)
366365
impl ast::PathSegment {
367-
pub fn first_path_type(&self) -> Option<ast::PathType> {
368-
self.syntax().children().find_map(ast::PathType::cast)
369-
}
370-
371-
pub fn last_path_type(&self) -> Option<ast::PathType> {
372-
self.syntax().children().filter_map(ast::PathType::cast).last()
366+
pub fn qualifying_trait(&self) -> Option<ast::PathType> {
367+
let mut path_types = support::children(self.syntax());
368+
let first = path_types.next()?;
369+
path_types.next().or(Some(first))
373370
}
374371
}
375372

0 commit comments

Comments
 (0)