mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
simplify determining whether the field is a tuple field
This commit is contained in:
parent
59f195a323
commit
591b5ec2c1
1 changed files with 1 additions and 5 deletions
|
@ -187,11 +187,7 @@ fn check_struct_shorthand_initialization(
|
||||||
if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
|
if let (Some(name_ref), Some(expr)) = (record_field.name_ref(), record_field.expr()) {
|
||||||
let field_name = name_ref.syntax().text().to_string();
|
let field_name = name_ref.syntax().text().to_string();
|
||||||
let field_expr = expr.syntax().text().to_string();
|
let field_expr = expr.syntax().text().to_string();
|
||||||
let field_name_is_tup_index = name_ref
|
let field_name_is_tup_index = name_ref.as_tuple_field().is_some();
|
||||||
.syntax()
|
|
||||||
.first_token()
|
|
||||||
.map(|token| token.kind().is_literal())
|
|
||||||
.unwrap_or(false);
|
|
||||||
if field_name == field_expr && !field_name_is_tup_index {
|
if field_name == field_expr && !field_name_is_tup_index {
|
||||||
let mut edit_builder = TextEditBuilder::default();
|
let mut edit_builder = TextEditBuilder::default();
|
||||||
edit_builder.delete(record_field.syntax().text_range());
|
edit_builder.delete(record_field.syntax().text_range());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue