Uh oh!
There was an error while loading. Please reload this page.
Error when using catch after try - #59847
Conversation
rust-highfive
commented
Apr 10, 2019
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @michaelwoerister (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
rust-highfive
commented
Apr 10, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Apr 10, 2019
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
| let (iattrs, body) = self.parse_inner_attrs_and_block()?; | ||
| attrs.extend(iattrs); | ||
| Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs)) | ||
| if self.eat_keyword(keywords::Catch) { |
There was a problem hiding this comment.
It would be preferable to ban any form of try { ... } $ident { .. } from a perspective of having maximum flexibility in the future.
There was a problem hiding this comment.
Should those all suggest match instead, or should that just be catch?
There was a problem hiding this comment.
cc @estebank ^-- I would probably say yes, but that's more a diagnostics issue than future lang design flexibility.
There was a problem hiding this comment.
I'm thinking of the following case:
let _ = try {
true
}
let _ = ();
where the error is the lack of ;, which is why I'm a bit weary of suggesting the right syntax for every ident. The current output for this the following, which I feel doesn't hinder understanding more than complaining about an inexistent catch would:
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> src/main.rs:7:5
|
6 | }
| - expected one of `.`, `;`, `?`, or an operator here
7 | let _ = ();
| ^^^ unexpected token
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| let (iattrs, body) = self.parse_inner_attrs_and_block()?; | ||
| attrs.extend(iattrs); | ||
| Ok(self.mk_expr(span_lo.to(body.span), ExprKind::TryBlock(body), attrs)) | ||
| if self.eat_keyword(keywords::Catch) { |
There was a problem hiding this comment.
I'm thinking of the following case:
let _ = try {
true
}
let _ = ();
where the error is the lack of ;, which is why I'm a bit weary of suggesting the right syntax for every ident. The current output for this the following, which I feel doesn't hinder understanding more than complaining about an inexistent catch would:
error: expected one of `.`, `;`, `?`, or an operator, found `let`
--> src/main.rs:7:5
|
6 | }
| - expected one of `.`, `;`, `?`, or an operator here
7 | let _ = ();
| ^^^ unexpected token
Uh oh!
There was an error while loading. Please reload this page.
Centril
commented
Apr 10, 2019
r? @estebank |
estebank
commented
Apr 10, 2019
The only action item from me would be rewording the error message and maybe fleshing out the |
Kampfkarren
commented
Apr 11, 2019
Out of the house right now so I'll work on all that when I can, thanks for the reviews! |
Kampfkarren
commented
Apr 11, 2019
Tests passed @estebank |
Didn't realize I accidentally closed this, 🤦♂️ |
estebank
commented
Apr 11, 2019
@bors r+ |
bors
commented
Apr 11, 2019
📌 Commit 1156ce6 has been approved by |
Centril
commented
Apr 11, 2019
@estebank This still accepts |
Kampfkarren
commented
Apr 11, 2019
@Centril I can do that in a separate PR later. |
Centril
commented
Apr 11, 2019
@Kampfkarren Excellent! Thank you. |
estebank
commented
Apr 11, 2019
It doesn't accept it, it just keeps the current right? |
Kampfkarren
commented
Apr 11, 2019
@estebank Yes, but I'm assuming he meant an explicit check against it for forwards compatibility? |
Centril
commented
Apr 12, 2019
Not sure... I'll have a look on nightly once this is merged... :) |
…bank Error when using `catch` after `try` Part of rust-lang#31436
Rollup of 8 pull requests Successful merges: - #59781 (Remove check_match from const_eval) - #59820 (proc_macro: stop using LEB128 for RPC.) - #59846 (clarify what the item is in "not a module" error) - #59847 (Error when using `catch` after `try`) - #59859 (Suggest removing `?` to resolve type errors.) - #59862 (Tweak unstable diagnostic output) - #59866 (Recover from missing semicolon based on the found token) - #59892 (Impl RawFd conversion traits for WASI TcpListener, TcpStream and UdpSocket) Failed merges: r? @ghost
Part of #31436