aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs13
-rw-r--r--crates/ra_hir_ty/src/diagnostics/expr.rs23
2 files changed, 29 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index 0b1509e13..4182a9e3b 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -219,21 +219,20 @@ impl Ctx {
219 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldDefList) -> IdRange<Field> { 219 fn lower_tuple_fields(&mut self, fields: &ast::TupleFieldDefList) -> IdRange<Field> {
220 let start = self.next_field_idx(); 220 let start = self.next_field_idx();
221 for (i, field) in fields.fields().enumerate() { 221 for (i, field) in fields.fields().enumerate() {
222 if let Some(data) = self.lower_tuple_field(i, &field) { 222 let data = self.lower_tuple_field(i, &field);
223 let idx = self.data().fields.alloc(data); 223 let idx = self.data().fields.alloc(data);
224 self.add_attrs(idx.into(), Attrs::new(&field, &self.hygiene)); 224 self.add_attrs(idx.into(), Attrs::new(&field, &self.hygiene));
225 }
226 } 225 }
227 let end = self.next_field_idx(); 226 let end = self.next_field_idx();
228 IdRange::new(start..end) 227 IdRange::new(start..end)
229 } 228 }
230 229
231 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Option<Field> { 230 fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Field {
232 let name = Name::new_tuple_field(idx); 231 let name = Name::new_tuple_field(idx);
233 let visibility = self.lower_visibility(field); 232 let visibility = self.lower_visibility(field);
234 let type_ref = self.lower_type_ref(&field.type_ref()?); 233 let type_ref = self.lower_type_ref_opt(field.type_ref());
235 let res = Field { name, type_ref, visibility }; 234 let res = Field { name, type_ref, visibility };
236 Some(res) 235 res
237 } 236 }
238 237
239 fn lower_union(&mut self, union: &ast::UnionDef) -> Option<FileItemTreeId<Union>> { 238 fn lower_union(&mut self, union: &ast::UnionDef) -> Option<FileItemTreeId<Union>> {
diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs
index 91caedc3d..21ff99a8c 100644
--- a/crates/ra_hir_ty/src/diagnostics/expr.rs
+++ b/crates/ra_hir_ty/src/diagnostics/expr.rs
@@ -489,4 +489,27 @@ fn f() {
489"#, 489"#,
490 ) 490 )
491 } 491 }
492
493 #[test]
494 fn enum_variant_type_macro() {
495 check_diagnostics(
496 r#"
497macro_rules! Type {
498 () => { u32 };
499}
500enum Foo {
501 Bar(Type![])
502}
503impl Foo {
504 fn new() {
505 Foo::Bar(0);
506 Foo::Bar(0, 1);
507 //^^^^^^^^^^^^^^ Expected 1 argument, found 2
508 Foo::Bar();
509 //^^^^^^^^^^ Expected 1 argument, found 0
510 }
511}
512 "#,
513 );
514 }
492} 515}