Skip to content

Commit e55e6da

Browse files
committed
Reject tuple index for missing fields assist
1 parent 8f1792f commit e55e6da

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/ra_ide/src/diagnostics.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
6666
.on::<hir::diagnostics::MissingFields, _>(|d| {
6767
let mut field_list = d.ast(db);
6868
for f in d.missed_fields.iter() {
69+
// Note that although we could add a diagnostics to
70+
// fill the missing tuple field, e.g :
71+
// `struct A(usize);`
72+
// `let a = A { 0: () }`
73+
// but it is uncommon usage and it should not be encouraged.
74+
if f.as_tuple_index().is_some() {
75+
continue;
76+
}
6977
let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit()));
7078
field_list = field_list.append_field(&field);
7179
}

0 commit comments

Comments
 (0)