aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-01-07 18:08:17 +0000
committerEdwin Cheng <[email protected]>2020-01-07 18:08:17 +0000
commite55e6da13adb41d84a53927b9bf02dc03fd2a33a (patch)
treeabb4a754f09adedabab2ee60607b045cdea6dbd2 /crates/ra_ide
parent8f1792fde233799fe3335032834ee7281d78e55b (diff)
Reject tuple index for missing fields assist
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/diagnostics.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index c50a70d99..3264f8f80 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -66,6 +66,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
66 .on::<hir::diagnostics::MissingFields, _>(|d| { 66 .on::<hir::diagnostics::MissingFields, _>(|d| {
67 let mut field_list = d.ast(db); 67 let mut field_list = d.ast(db);
68 for f in d.missed_fields.iter() { 68 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 }
69 let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); 77 let field = make::record_field(make::name_ref(&f.to_string()), Some(make::expr_unit()));
70 field_list = field_list.append_field(&field); 78 field_list = field_list.append_field(&field);
71 } 79 }