-
Notifications
You must be signed in to change notification settings - Fork 901
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
Strange formatting of @
, |
, and parens patterns
#4110
Comments
Not a duplicate but similar report in #4031. Fixes will likely be similar (if not identical) |
Did this pattern exist before, or is it something new that has been introduced recently? Either way, we should fix this. |
I believe it's a new-ish change, but not sure precisely when it was introduced |
category: category @ Record { ... } has existed since Rust 1.0 I think, so that isn't new, but |
Oops, I misunderstood the question anyway. I don't know definitively but I believe that the poor binding formatting described in #4031 was a change rustfmt started doing relatively recently. Not sure what, if any, impact that may have on the formatting here |
Happens equally as root for a match arm: match head.packet_type()? {
p
@
(PacketType::Connect
| PacketType::ConnAck
| PacketType::SubAck
| PacketType::UnsubAck) => return Err(Error::WrongPacket(p)), Manually, I would probably format it as: match head.packet_type()? {
p @ (
PacketType::Connect
| PacketType::ConnAck
| PacketType::SubAck
| PacketType::UnsubAck
) => return Err(Error::WrongPacket(p)), Interestingly enough, we still end up with N+2 lines. But moving the output expression to the left is definitely a huge win. |
"Fixing" this by locally by increasing I wonder if this would be more worthwhile to investigate now that rust-lang/rust#54883 is stabilized (?), etc. |
This was fixed in #4978, and a test case was added for this issue |
In a rust-lang/rust PR, I saw some pretty strange formatting of pattern matching with
@
,|
, and parens patterns: https://github.com/rust-lang/rust/pull/70906/files#r405165086The diff was:
which seems odd because it is putting
@
on its own line and doing(
on the same line as a pattern and then)
also on the same line as a pattern.I would have expected:
The text was updated successfully, but these errors were encountered: