Skip to content

Commit 591b5ec

Browse files
simplify determining whether the field is a tuple field
1 parent 59f195a commit 591b5ec

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

crates/ra_ide/src/diagnostics.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,7 @@ fn check_struct_shorthand_initialization(
187187
if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
188188
let field_name = name_ref.syntax().text().to_string();
189189
let field_expr = expr.syntax().text().to_string();
190-
let field_name_is_tup_index = name_ref
191-
.syntax()
192-
.first_token()
193-
.map(|token| token.kind().is_literal())
194-
.unwrap_or(false);
190+
let field_name_is_tup_index = name_ref.as_tuple_field().is_some();
195191
if field_name == field_expr && !field_name_is_tup_index {
196192
let mut edit_builder = TextEditBuilder::default();
197193
edit_builder.delete(record_field.syntax().text_range());

0 commit comments

Comments
 (0)