Closed
Description
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.rs
s.
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
Labels
No labels