File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -184,8 +184,14 @@ TypeCheckPattern::visit (HIR::StructPattern &pattern)
184
184
{
185
185
std::string variant_type
186
186
= TyTy::VariantDef::variant_type_string (variant->get_variant_type ());
187
- rust_error_at (pattern.get_locus (),
188
- " expected struct variant, found %s variant %s" ,
187
+
188
+ rich_location rich_locus (line_table, pattern.get_locus ());
189
+ std::string rich_msg = " use the tuple variant pattern syntax instead "
190
+ + variant->get_identifier () + " (_)" ;
191
+ rich_locus.add_fixit_replace (rich_msg.c_str ());
192
+
193
+ rust_error_at (rich_locus, ErrorCode::E0769 ,
194
+ " %s variant %qs written as struct variant" ,
189
195
variant_type.c_str (),
190
196
variant->get_identifier ().c_str ());
191
197
return ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ fn inspect(f: Foo) {
10
10
Foo :: A => { }
11
11
Foo :: B => { }
12
12
Foo :: C { a } => { }
13
- // { dg-error "expected struct variant, found tuple variant C " "" { target *-*-* } .-1 }
13
+ // { dg-error "tuple variant .C. written as struct variant " "" { target *-*-* } .-1 }
14
14
Foo :: D { x, y } => { }
15
15
}
16
16
}
You can’t perform that action at this time.
0 commit comments