-
Notifications
You must be signed in to change notification settings - Fork 926
Libsyntax #1553
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
Libsyntax #1553
Conversation
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.
Thank you! Could you add some tests for catch
blocks please?
src/expr.rs
Outdated
// FIXME(#1537) | ||
ast::ExprKind::Catch(..) => unimplemented!(), | ||
// 6 = `catch ` | ||
ast::ExprKind::Catch(ref block) => block.rewrite(&context, try_opt!(shape.sub_width(6))), |
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.
I think the keywords are do catch
, rather than just catch
and you should explicitly emit these rather than rely on the missed span.
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.
Thanks!
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.
I have few questions:
- Should
do catch { ... }
stay in a single line asunsafe
when it is short? I found an example withoutdo
(let x = match catch { ... }
). How should I treat these differently?
I just found the above example is depricated. Sorry!
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.
Yeah, I think do catch
should follow unsafe
. I don't think we should ever line-break between do
and catch
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.
Thanks!
It would be nice if rustfmt could handle single line case inside impl Rewrite for ast::Block
along with unsafe
(here). However, as far as I know, ast::Block
does not carry information whether it is catch
block or not. Hence we need to handle single line case for catch
before calling block.rewrite
here. Is this correct?
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.
Yeah, that is correct (and unfortunate). I'm not sure how to best address it, to be honest. Perhaps pull the code out of the Rewrite impl and into a free function with an extra flag?
How does this fix the comments issue? (It looks like it does fix it from the test, but I don't understand how). |
The comments are inside |
EDIT: rebased with the lastet libsyntax branch. The latest commit implements |
Looks good, thank you! |
Closes #1542, closes #1541, closes #1538 and closes #1537.