7351: Show const params in completions r=Veykril a=Veykril

bors r+
![image](https://user-images.githubusercontent.com/3757771/105080872-bba76680-5a91-11eb-91cd-0910da4c8312.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-01-19 19:07:33 +00:00 committed by GitHub
commit f647e134a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 12 deletions

View file

@ -29,6 +29,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
}
ctx.scope.process_all_names(&mut |name, res| {
if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res {
mark::hit!(skip_lifetime_completion);
return;
}
if ctx.use_item_syntax.is_some() {
if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) {
if name_ref.syntax().text() == name.to_string().as_str() {
@ -37,7 +41,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
}
}
}
acc.add_resolution(ctx, name.to_string(), &res)
acc.add_resolution(ctx, name.to_string(), &res);
});
}
@ -234,6 +238,24 @@ fn main() {
fn quux() fn quux<T>()
"#]],
);
check(
r#"fn quux<const C: usize>() { $0 }"#,
expect![[r#"
tp C
fn quux() fn quux<const C: usize>()
"#]],
);
}
#[test]
fn does_not_complete_lifetimes() {
mark::check!(skip_lifetime_completion);
check(
r#"fn quux<'a>() { $0 }"#,
expect![[r#"
fn quux() fn quux<'a>()
"#]],
);
}
#[test]