-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
propagate the error from parsing enum variant to the parser and emit out #105098
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eholk (or someone else) soon. Please see the contribution instructions for more information. |
0ec3e61
to
199d72f
Compare
199d72f
to
51726ac
Compare
@@ -1414,7 +1414,10 @@ impl<'a> Parser<'a> { | |||
|
|||
Ok((Some(vr), TrailingToken::MaybeComma)) | |||
}, | |||
) | |||
).map_err(|mut err|{ | |||
err.help("enum variants can be `Variant` or `Variant = <integer>` or `Variant(Type)` or `Variant { field: Type }`"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err.help("enum variants can be `Variant` or `Variant = <integer>` or `Variant(Type)` or `Variant { field: Type }`"); | |
err.help("enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type)`, or `Variant { field: Type }`"); |
I wonder if we should write Variant(Type)
as Variant(Type, ...)
or Variant(Type1, ..., TypeN)
, and similarly for the struct case? Or maybe Variant(Types)
and Variant { fields: types }
. Basically, I wonder if it's worth trying to also show that enum variants can have multiple fields or is showing one enough?
Thanks for the contribution! Overall, this looks pretty good. I posted a couple of questions about minor tweaks to the hint message, but I think this is a big improvement. One suggestion I'd add for future PRs. In the commit description, rather than just saying "fix #103869," it'd be helpful if you could include a brief summary of the bug you're fixing (just a sentence or two and maybe a short code example if it makes sense) and how your PR fixes it (this isn't always going to be that interesting, but especially if there's something subtle about the fix this can be really helpful). As a reviewer that helps a lot because it saves me a step in having to pull up the issue and read the description first. Thanks again! I'll give you a little time in case you want to respond to any of my review comments, but I don't think I'd consider any of them blockers. |
Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case rust-lang#103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix rust-lang#103869
51726ac
to
0e19fb9
Compare
|
Thanks, looks good! @bors r+ |
propagate the error from parsing enum variant to the parser and emit out While parsing enum variant, the error message always disappear Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case rust-lang#103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix rust-lang#103869
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#104439 (Add prototype to generate `COPYRIGHT` from REUSE metadata) - rust-lang#105005 (On E0195 point at where clause lifetime bounds) - rust-lang#105098 (propagate the error from parsing enum variant to the parser and emit out) - rust-lang#105243 (remove no-op 'let _ = ') - rust-lang#105254 (Recurse into nested impl-trait when computing variance.) - rust-lang#105287 (Synthesize substitutions for bad auto traits in dyn types) - rust-lang#105310 (Be more careful about unresolved exprs in suggestion) - rust-lang#105318 (Make `get_impl_future_output_ty` work with AFIT) - rust-lang#105339 (support `ConstKind::Expr` in `is_const_evaluatable` and `WfPredicates::compute`) - rust-lang#105340 (Avoid ICE by accounting for missing type) - rust-lang#105342 (Make `note_obligation_cause_code` take a `impl ToPredicate` for predicate) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
While parsing enum variant, the error message always disappear
Because the error message that emit out is from main error of parser
The information of enum variant disappears while parsing enum variant with error
We only check the syntax of expecting token, i.e, in case #103869
It will error it without telling the message that this error is from pasring enum variant.
Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err
Check the sub-error before emitting the main error of parser and attach it.
Fix #103869