Skip to content

Lints to identify enums where variants have wildly different sizes #10362

Closed
@nikomatsakis

Description

@nikomatsakis

Because an enum takes the size of its largest member, it is very easy to have enums whose size grows surprisingly large if you are not careful. ast::Expr, for example, is currently 120 bytes in our compiler. It'd be helpful to have a lint that checks the size of the smallest and largest variant in an enum and reports if the difference is "too" big. What "too big" means I don't know -- perhaps if one is 2x the other?

One issue is what to do about generic enums. We could (for now) just assume that generics have a certain size, or else wait and report lint warnings on individual instantiations -- but this seems like a warning that should be associated with the def'n of the structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions