-
Notifications
You must be signed in to change notification settings - Fork 893
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
Fix #5624 #5904
base: master
Are you sure you want to change the base?
Fix #5624 #5904
Conversation
Thanks for the PR @GambitingMan! @ytmimi since you'd commented on the link issue, do you still have enough mental context on it to remember whether this could introduce formatting changes/need to be version gated to maintain stability in any other contexts? |
@calebcartwright are there contexts outside of closures that you're worried about? This could have an impact anywhere a closures can be used because the old behavior was to return
For example, This PR enables the following to reformat the same binary expression closure who's fn main() {
f(||
{
let a =1;
a
} + { 2 } + {
let b = 3;
b
} + { 4 }
);
let c = ||
{
let d =1;
d
} + { 2 } + {
let e = 3;
e
} + { 4 };
let f = MyStruct {
field: ||
{
let g =1;
g
} + { 2 } + {
let h = 3;
h
} + { 4 }
};
} output: fn main() {
f(|| {
let a = 1;
a
} + { 2 }
+ {
let b = 3;
b
}
+ { 4 });
let c = || {
let d = 1;
d
} + { 2 }
+ {
let e = 3;
e
}
+ { 4 };
let f = MyStruct {
field: || {
let g = 1;
g
} + { 2 }
+ {
let h = 3;
h
}
+ { 4 },
};
} Here's the diff: Diff in <stdin> at line 1:
fn main() {
- f(||
- {
- let a =1;
- a
- } + { 2 } + {
+ f(|| {
+ let a = 1;
+ a
+ } + { 2 }
+ + {
let b = 3;
b
- } + { 4 }
- );
+ }
+ + { 4 });
- let c = ||
- {
- let d =1;
- d
- } + { 2 } + {
+ let c = || {
+ let d = 1;
+ d
+ } + { 2 }
+ + {
let e = 3;
e
- } + { 4 };
+ }
+ + { 4 };
let f = MyStruct {
- field: ||
- {
- let g =1;
+ field: || {
+ let g = 1;
g
- } + { 2 } + {
- let h = 3;
- h
- } + { 4 }
+ } + { 2 }
+ + {
+ let h = 3;
+ h
+ }
+ + { 4 },
};
} |
Might be safer to gate this on |
For what it's worth, the diff check job passed ✅ |
I added a check for version two, though it unfortunately changes the signature of the |
Fixes #5624. The output seems to follow the style guide for closures without any additional effort.