Skip to content

Generate less code when deriving #31972

Closed
@bluss

Description

@bluss

Here are some ideas for generating less code when deriving. All of these break down with generic fields, since then we have to fall back to the current general scheme.

PartialEq

For C-like enums, only produce eq and not ne. The default ne calls eq and is always enough. Edit: implemented in #31977.

PartialOrd

For C-like enums only produce partial_cmp and not the four other methods lt, le, gt, ge. This needs an experiment to see if only partial_cmp is good enough. Maybe another of the single methods can be enough, too.

PartialOrd, Ord together

When there are no generic parameters, simply call .cmp() in .partial_cmp().

cc @durka

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions