Skip to content

[Feature request, Inlay Hints] Option for showing type size and padding in an inlay hint #13662

Closed
@Alonely0

Description

@Alonely0

Description

The purpose of this feature is to add a new inlay hint at the end of each type with its size and padding. When a type (a struct, an enum, etc) is bigger than a pointer, it is more efficient to pass it by reference where possible to avoid large copies. In rust this needs special attention since it is not very stack-efficient. This feature is trivial to implement, as the compiler already provides all the information required. In enums and structs, this could be added to every variant/field. The feature could also be extended to function arguments in function declarations.

Current solution

Manually calculating it or using -Zprint-type-sizes. Both are very cumbersome, the latter specially in files with lots of types, like massive lib.rss.

Possible settings

  • Enable/Disable, obviously.
  • Unit: bytes or bits. I would default to bytes, but personally I prefer bits.
  • Size threshold: Only show for types bigger than a given size. A good default would be to show for size > sizeof(usize).
  • Remove padding and size as separate labels and show the whole size in a single number. I actually think this should be the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions