diff options
Diffstat (limited to 'crates/ra_ide/src/completion')
-rw-r--r-- | crates/ra_ide/src/completion/complete_record_literal.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_ide/src/completion/complete_record_literal.rs b/crates/ra_ide/src/completion/complete_record_literal.rs index a0bc3ee0a..e4e764f58 100644 --- a/crates/ra_ide/src/completion/complete_record_literal.rs +++ b/crates/ra_ide/src/completion/complete_record_literal.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use crate::completion::{CompletionContext, Completions}; | 3 | use crate::completion::{CompletionContext, Completions}; |
4 | use ra_syntax::SmolStr; | ||
4 | 5 | ||
5 | /// Complete fields in fields literals. | 6 | /// Complete fields in fields literals. |
6 | pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionContext) { | 7 | pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionContext) { |
@@ -11,7 +12,7 @@ pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionCon | |||
11 | _ => return, | 12 | _ => return, |
12 | }; | 13 | }; |
13 | 14 | ||
14 | let already_present_names: Vec<String> = ctx | 15 | let already_present_names: Vec<SmolStr> = ctx |
15 | .record_lit_syntax | 16 | .record_lit_syntax |
16 | .as_ref() | 17 | .as_ref() |
17 | .and_then(|record_literal| record_literal.record_field_list()) | 18 | .and_then(|record_literal| record_literal.record_field_list()) |
@@ -20,13 +21,13 @@ pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionCon | |||
20 | fields | 21 | fields |
21 | .into_iter() | 22 | .into_iter() |
22 | .filter_map(|field| field.name_ref()) | 23 | .filter_map(|field| field.name_ref()) |
23 | .map(|name_ref| name_ref.to_string()) | 24 | .map(|name_ref| name_ref.text().clone()) |
24 | .collect() | 25 | .collect() |
25 | }) | 26 | }) |
26 | .unwrap_or_default(); | 27 | .unwrap_or_default(); |
27 | 28 | ||
28 | for (field, field_ty) in ty.variant_fields(ctx.db, variant) { | 29 | for (field, field_ty) in ty.variant_fields(ctx.db, variant) { |
29 | if !already_present_names.contains(&field.name(ctx.db).to_string()) { | 30 | if !already_present_names.contains(&SmolStr::from(field.name(ctx.db).to_string())) { |
30 | acc.add_field(ctx, field, &field_ty); | 31 | acc.add_field(ctx, field, &field_ty); |
31 | } | 32 | } |
32 | } | 33 | } |