fix ast::Path::segments implementation

This commit is contained in:
davidsemakula 2024-01-06 08:41:11 +03:00
parent e53792b7cb
commit 08c44a6c24

View file

@ -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
}
})
})
}