Skip to content

Request to add a warning for large type sizes #6600

Closed
@mstewartgallus

Description

@mstewartgallus

Many times it easy to accidentally create types that are many bytes in size. These structures are of course expensive to copy, and move around. Because there is already an option to check the size of structures in rustc (-Z count-type-sizes) it'd be nice to have a warning if some the sizes of some data structures are suspiciously large. I'd greatly appreciate this "-W large-type-sizes" feature as it'd reduce the chances of accidentally creating slow programs with silly mistakes, and already has a lot of the work done towards it implemented. Furthermore, giant know everything objects are usually a sign of a badly factored design.

As well, it might be useful to have a warning for medium sized data types that have sizes that are powers of two as they can have weird, and pathological worst-case effects on CPU caches (I don't fully understand exactly how they effect the cache so I'd appreciate if someone with a more detailed knowledge of cache effects can comment on whether this is a good idea.)

Basically, I think that as long as the type size information is already being collected it should start being used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions