Skip to content

Commit 902fd6d

Browse files
committed
fix: complete path of existing record expr
1 parent ec3586e commit 902fd6d

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

crates/ide-completion/src/context/analysis.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,10 +939,12 @@ impl<'a> CompletionContext<'a> {
939939
ast::Meta(meta) => make_path_kind_attr(meta)?,
940940
ast::Visibility(it) => PathKind::Vis { has_in_token: it.in_token().is_some() },
941941
ast::UseTree(_) => PathKind::Use,
942+
ast::RecordExpr(it) => make_path_kind_expr(it.into()),
942943
_ => return None,
943944
}
944945
}
945946
},
947+
ast::RecordExpr(it) => make_path_kind_expr(it.into()),
946948
_ => return None,
947949
}
948950
};

crates/ide-completion/src/tests/expression.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,3 +651,22 @@ fn main() {
651651
"]],
652652
);
653653
}
654+
655+
#[test]
656+
fn complete_record_expr_path() {
657+
check(
658+
r#"
659+
struct Zulu;
660+
impl Zulu {
661+
fn test() -> Self { }
662+
}
663+
fn boi(val: Zulu) { }
664+
fn main() {
665+
boi(Zulu:: $0 {});
666+
}
667+
"#,
668+
expect![[r#"
669+
fn test() fn() -> Zulu
670+
"#]],
671+
);
672+
}

crates/parser/src/grammar/paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn path_for_qualifier(
5454
mut qual: CompletedMarker,
5555
) -> CompletedMarker {
5656
loop {
57-
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
57+
let use_tree = mode == Mode::Use && matches!(p.nth(2), T![*] | T!['{']);
5858
if p.at(T![::]) && !use_tree {
5959
let path = qual.precede(p);
6060
p.bump(T![::]);

0 commit comments

Comments
 (0)