mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Always emit help when failing to parse enum variant
This commit is contained in:
parent
1575e6e96e
commit
4e524386e9
@ -1450,6 +1450,8 @@ impl<'a> Parser<'a> {
|
||||
self.recover_diff_marker();
|
||||
let variant_attrs = self.parse_outer_attributes()?;
|
||||
self.recover_diff_marker();
|
||||
let help = "enum variants can be `Variant`, `Variant = <integer>`, \
|
||||
`Variant(Type, ..., TypeN)` or `Variant { fields: Types }`";
|
||||
self.collect_tokens_trailing_token(
|
||||
variant_attrs,
|
||||
ForceCollect::No,
|
||||
@ -1486,6 +1488,7 @@ impl<'a> Parser<'a> {
|
||||
this.eat_to_tokens(&[&token::CloseDelim(Delimiter::Brace)]);
|
||||
this.bump(); // }
|
||||
err.span_label(span, "while parsing this enum");
|
||||
err.help(help);
|
||||
err.emit();
|
||||
(thin_vec![], true)
|
||||
}
|
||||
@ -1502,6 +1505,7 @@ impl<'a> Parser<'a> {
|
||||
this.eat_to_tokens(&[&token::CloseDelim(Delimiter::Parenthesis)]);
|
||||
this.bump(); // )
|
||||
err.span_label(span, "while parsing this enum");
|
||||
err.help(help);
|
||||
err.emit();
|
||||
thin_vec![]
|
||||
}
|
||||
@ -1527,8 +1531,9 @@ impl<'a> Parser<'a> {
|
||||
|
||||
Ok((Some(vr), TrailingToken::MaybeComma))
|
||||
},
|
||||
).map_err(|mut err| {
|
||||
err.help("enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`");
|
||||
)
|
||||
.map_err(|mut err| {
|
||||
err.help(help);
|
||||
err
|
||||
})
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ LL | enum e{A((?'a a+?+l))}
|
||||
| - ^ expected one of `)`, `+`, or `,`
|
||||
| |
|
||||
| while parsing this enum
|
||||
|
|
||||
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
|
||||
|
||||
error: expected item, found `)`
|
||||
--> $DIR/issue-68890.rs:1:21
|
||||
|
@ -13,6 +13,8 @@ LL | enum Test4 {
|
||||
| ----- while parsing this enum
|
||||
LL | Nope(i32 {})
|
||||
| ^ expected one of 7 possible tokens
|
||||
|
|
||||
= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-enum2.rs:11:9
|
||||
|
Loading…
Reference in New Issue
Block a user