Skip to content

Commit 08c44a6

Browse files
committed
fix ast::Path::segments implementation
1 parent e53792b commit 08c44a6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/syntax/src/ast/node_ext.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,15 @@ impl ast::Path {
289289
}
290290

291291
pub fn segments(&self) -> impl Iterator<Item = ast::PathSegment> + Clone {
292-
successors(self.first_segment(), |p| {
293-
p.parent_path().parent_path().and_then(|p| p.segment())
292+
let path_range = self.syntax().text_range();
293+
successors(self.first_segment(), move |p| {
294+
p.parent_path().parent_path().and_then(|p| {
295+
if path_range.contains_range(p.syntax().text_range()) {
296+
p.segment()
297+
} else {
298+
None
299+
}
300+
})
294301
})
295302
}
296303

0 commit comments

Comments
 (0)