-
Notifications
You must be signed in to change notification settings - Fork 915
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
Nesting of block indented expressions #1572
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.
This looks great, thanks for tackling it! I wonder if tuples need covering and if there are any other constructs that need covering. Other than that, this looks good to merge
src/expr.rs
Outdated
} | ||
} | ||
_ => &**body, | ||
ast::ExprKind::Call(_, ref args) => (args.len() == 1, &**body), | ||
ast::ExprKind::Closure(..) => (true, &**body), |
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.
Should we handle tuples here too?
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.
Tuples are not refered in rust-lang/style-team#61, but if we should, do we use "a single expression parameter" rule or allow exception like clousres?
// A single expression tuple
let a = foo(bar((|x| {
let y = x + 1;
let z = y + 1;
z
})));
// Should we allow this?
let a = foo(bar((b, c, |x| {
let y = x + 1;
let z = y + 1;
z
})));
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 we should allow both (note that tuples with a single element must always have a trailing comma).
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 for clarifying!
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 would like to make it clear, should we use block indent for tuples when fn_call_style = Block
and format like function call? (c.f. rust-lang/style-team#64)
let a = (
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
);
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, I think so
I have added tuple and block. Also added a commit to add a trailing comma to a single arg in multiline. |
Awesome, thank you! |
Closes #1422, closes #1449, and closes #1494.