Skip to content

Commit f1cf1cc

Browse files
Code review fixes
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
1 parent 00cbe81 commit f1cf1cc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/ra_ide/src/completion/complete_record_literal.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! FIXME: write short doc here
22
33
use crate::completion::{CompletionContext, Completions};
4+
use ra_syntax::SmolStr;
45

56
/// Complete fields in fields literals.
67
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
1112
_ => return,
1213
};
1314

14-
let already_present_names: Vec<String> = ctx
15+
let already_present_names: Vec<SmolStr> = ctx
1516
.record_lit_syntax
1617
.as_ref()
1718
.and_then(|record_literal| record_literal.record_field_list())
@@ -20,13 +21,13 @@ pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionCon
2021
fields
2122
.into_iter()
2223
.filter_map(|field| field.name_ref())
23-
.map(|name_ref| name_ref.to_string())
24+
.map(|name_ref| name_ref.text().clone())
2425
.collect()
2526
})
2627
.unwrap_or_default();
2728

2829
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())) {
3031
acc.add_field(ctx, field, &field_ty);
3132
}
3233
}

0 commit comments

Comments
 (0)