Skip to content

Strange formatting of @, |, and parens patterns #4110

Closed
@Centril

Description

@Centril

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#r405165086

The diff was:

-                    category: category @ ConstraintCategory::Return,
+                    category:
+                        category
+                        @
+                        (ConstraintCategory::Return
+                        | ConstraintCategory::CallArgument
+                        | ConstraintCategory::OpaqueType),

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:

-                    category: category @ ConstraintCategory::Return,
+                    category: category @ (
+                        ConstraintCategory::Return
+                        | ConstraintCategory::CallArgument
+                        | ConstraintCategory::OpaqueType
+                    ),

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions