mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
fix ast::Path::segments implementation
This commit is contained in:
parent
e53792b7cb
commit
08c44a6c24
1 changed files with 9 additions and 2 deletions
|
@ -289,8 +289,15 @@ impl ast::Path {
|
|||
}
|
||||
|
||||
pub fn segments(&self) -> impl Iterator<Item = ast::PathSegment> + Clone {
|
||||
successors(self.first_segment(), |p| {
|
||||
p.parent_path().parent_path().and_then(|p| p.segment())
|
||||
let path_range = self.syntax().text_range();
|
||||
successors(self.first_segment(), move |p| {
|
||||
p.parent_path().parent_path().and_then(|p| {
|
||||
if path_range.contains_range(p.syntax().text_range()) {
|
||||
p.segment()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue