diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-19 19:07:33 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-19 19:07:33 +0000 |
commit | f647e134a785245579da3de04235887a5e958c9b (patch) | |
tree | d0e54ef23ff0714497ac251b6f2e1c7512c092e1 /crates/completion/src/completions | |
parent | 02edb4b31be02fdab9c970cafb38439f472c0696 (diff) | |
parent | bed12833cc4ce7c6b4085ba8dc47fc167c83f8ea (diff) |
Merge #7351
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 <[email protected]>
Diffstat (limited to 'crates/completion/src/completions')
-rw-r--r-- | crates/completion/src/completions/unqualified_path.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index ac5596ca4..809e1645a 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs | |||
@@ -29,6 +29,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC | |||
29 | } | 29 | } |
30 | 30 | ||
31 | ctx.scope.process_all_names(&mut |name, res| { | 31 | ctx.scope.process_all_names(&mut |name, res| { |
32 | if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { | ||
33 | mark::hit!(skip_lifetime_completion); | ||
34 | return; | ||
35 | } | ||
32 | if ctx.use_item_syntax.is_some() { | 36 | if ctx.use_item_syntax.is_some() { |
33 | if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { | 37 | if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { |
34 | if name_ref.syntax().text() == name.to_string().as_str() { | 38 | 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 | |||
37 | } | 41 | } |
38 | } | 42 | } |
39 | } | 43 | } |
40 | acc.add_resolution(ctx, name.to_string(), &res) | 44 | acc.add_resolution(ctx, name.to_string(), &res); |
41 | }); | 45 | }); |
42 | } | 46 | } |
43 | 47 | ||
@@ -234,6 +238,24 @@ fn main() { | |||
234 | fn quux() fn quux<T>() | 238 | fn quux() fn quux<T>() |
235 | "#]], | 239 | "#]], |
236 | ); | 240 | ); |
241 | check( | ||
242 | r#"fn quux<const C: usize>() { $0 }"#, | ||
243 | expect![[r#" | ||
244 | tp C | ||
245 | fn quux() fn quux<const C: usize>() | ||
246 | "#]], | ||
247 | ); | ||
248 | } | ||
249 | |||
250 | #[test] | ||
251 | fn does_not_complete_lifetimes() { | ||
252 | mark::check!(skip_lifetime_completion); | ||
253 | check( | ||
254 | r#"fn quux<'a>() { $0 }"#, | ||
255 | expect![[r#" | ||
256 | fn quux() fn quux<'a>() | ||
257 | "#]], | ||
258 | ); | ||
237 | } | 259 | } |
238 | 260 | ||
239 | #[test] | 261 | #[test] |