Skip to content

Commit 8b27e4a

Browse files
authored
fix: treat {self} in braced use as parent path (#1118)
1 parent 8baf1a2 commit 8b27e4a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/hir/src/lower/use_tree.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,17 @@ fn decompose_subtree<'db>(
148148
)> {
149149
let (mut succ_path, mut succ_desugared) = succ;
150150
if let Some(path) = subtree.path() {
151-
for seg in path {
151+
let segs: Vec<ast::UsePathSegment> = path.into_iter().collect();
152+
153+
let is_self_only = segs.len() == 1 && segs[0]
154+
.kind()
155+
.is_some_and(|k| matches!(k, ast::UsePathSegmentKind::Self_(_)));
156+
157+
for seg in segs {
152158
succ_desugared.push_seg(&seg);
153-
succ_path.push(seg.clone());
159+
if !is_self_only {
160+
succ_path.push(seg.clone());
161+
}
154162
}
155163
}
156164

0 commit comments

Comments
 (0)