Skip to content

Feature request: reorder_type_constraints #5116

Open
@orenbenkiki

Description

@orenbenkiki

Requested feature(s):

EDIT: (1) is a duplicate of #4112, which was a duplicate of #1867 - ignore this and focus on #2.

  1. Use reorder_derive_items to have rustfmt change:
#[derive(PartialEq, Copy, Display, Clone)]

Into:

#[derive(Clone, Copy, Display, PartialEq)]

That is, alphabetically sort the derived types.

  1. Use reorder_type_constraints to have rustfmt change:
pub fn<T: PartialEq + Copy + Debug + 'static + Clone>foo(...) { ... }

Into:

pub fn<T: 'static + Clone + Copy + Debug + PartialEq>foo(...) { ... }

That is, alphabetically sort the contsraint types (and sort lifetimes before types).

Motivation:

When there are more than 2-3 types in either derive or a constraint, it is tedius and error-prone to manually ensure they all appear in the same order. However it is useful for them to be in a deterministic order as this makes it easier to read a list, and more importantly to see the difference between two lists.

Options

Perhaps "standard" traits should be sorted before all other traits?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions