-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Pretty-print let-else with added parenthesization when needed #125051
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
Conversation
r? @nnethercote rustbot has assigned @nnethercote. Use |
r=me when CI is green |
[ f() ], | ||
"let _ = f() else { return; };", | ||
"let _ = f() else { return; }", | ||
); |
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 initially tried testing this with:
c2_let_expr_else_return!(
[ loop {} ],
"let _ = (loop {}) else { return; };",
"let _ = loop {} else { return; }",
);
but the curly brace diagnostic actually looks inside of the $expr. I am not sure whether that is intentional. (In my opinion it shouldn't do that.) I added a separate test in tests/ui/unpretty instead.
error: right curly brace `}` before `else` in a `let...else` statement not allowed
--> tests/ui/macros/stringify.rs:704:17
|
LL | [ loop {} ],
| ^
|
help: wrap the expression in parentheses
|
LL | [ (loop {}) ],
| + +
@bors r=compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (ecbe3fd): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 677.096s -> 676.356s (-0.11%) |
Rustc used to produce invalid syntax for the following code, which is problematic because it means we cannot apply rustfmt to the output of
-Zunpretty=expanded
.