mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
Auto merge of #12906 - cynecx:fix-completions, r=Veykril
fix: complete path of existing record expr
This commit is contained in:
commit
fb5e49631b
3 changed files with 22 additions and 1 deletions
|
@ -939,10 +939,12 @@ impl<'a> CompletionContext<'a> {
|
||||||
ast::Meta(meta) => make_path_kind_attr(meta)?,
|
ast::Meta(meta) => make_path_kind_attr(meta)?,
|
||||||
ast::Visibility(it) => PathKind::Vis { has_in_token: it.in_token().is_some() },
|
ast::Visibility(it) => PathKind::Vis { has_in_token: it.in_token().is_some() },
|
||||||
ast::UseTree(_) => PathKind::Use,
|
ast::UseTree(_) => PathKind::Use,
|
||||||
|
ast::RecordExpr(it) => make_path_kind_expr(it.into()),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ast::RecordExpr(it) => make_path_kind_expr(it.into()),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -651,3 +651,22 @@ fn main() {
|
||||||
"]],
|
"]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn complete_record_expr_path() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Zulu;
|
||||||
|
impl Zulu {
|
||||||
|
fn test() -> Self { }
|
||||||
|
}
|
||||||
|
fn boi(val: Zulu) { }
|
||||||
|
fn main() {
|
||||||
|
boi(Zulu:: $0 {});
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
fn test() fn() -> Zulu
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn path_for_qualifier(
|
||||||
mut qual: CompletedMarker,
|
mut qual: CompletedMarker,
|
||||||
) -> CompletedMarker {
|
) -> CompletedMarker {
|
||||||
loop {
|
loop {
|
||||||
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
|
let use_tree = mode == Mode::Use && matches!(p.nth(2), T![*] | T!['{']);
|
||||||
if p.at(T![::]) && !use_tree {
|
if p.at(T![::]) && !use_tree {
|
||||||
let path = qual.precede(p);
|
let path = qual.precede(p);
|
||||||
p.bump(T![::]);
|
p.bump(T![::]);
|
||||||
|
|
Loading…
Reference in a new issue