-
Notifications
You must be signed in to change notification settings - Fork 883
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
Force to use block for closure body with a single control flow expression #1877
Force to use block for closure body with a single control flow expression #1877
Conversation
1 | ||
} else { | ||
2 | ||
loong_func().quux(move || { |
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.
This looks funny. Isn't the indentation too deep here?
Edit: nope - it's fine. Tabs just render really wide on my machine.
Thanks for this PR. I might leave this open for a while until we've decided on what the behaviour ought to be (see rust-lang/style-team#35 (comment)). Is that ok? |
let index = *first as usize; | ||
if index >= ENCODINGS.len() { | ||
return; | ||
} | ||
} | ||
let encoding = ENCODINGS[index]; | ||
dispatch_test(encoding, &data[1..]); |
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.
Did these two lines move from inside the if let
to outside it?
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.
Yes, this is a regression. Thank you for pointing out.
@nrc That would be perfectly fine with me. |
d42d437
to
bb1697e
Compare
64901fe
to
a42f9f2
Compare
@nrc Could you share how you feel about this PR now? |
Hmm, there wasn't much movement there and I don't have a strong preference myself. Lets land this, I think. Better to err on the side of using a block (some of the examples without looked a bit odd). Are you OK to rebase? |
a42f9f2
to
b17de62
Compare
@nrc Rebased. Could you please review it? |
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.
Looks good, just needs that one comment, then r+
src/expr.rs
Outdated
@@ -2310,6 +2302,22 @@ where | |||
} | |||
} | |||
|
|||
fn args_have_many_closure<T>(args: &[&T]) -> bool |
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.
Could you add a comment describing what this function does please?
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! Added a comment.
Thanks! |
Thank you @topecongiro; if I understand what the change does, this has been driving me batty for a while now! |
This PR forces rustfmt to use block when rewriting the body of closure with a single control flow expression.
CC #1791, rust-lang/style-team#35.