Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Alonely0 opened this issue Nov 21, 2022 · 1 comment

Comments

@Alonely0
Copy link

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.
@jonas-schievink
Copy link
Contributor

Duplicate of #4091

@jonas-schievink jonas-schievink marked this as a duplicate of #4091 Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants