rust-lang / rust-lang/rust-analyzer

Show size for types with generics in them

Open
#16,982 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

struct S<T> {
    data: [u8; 1024],
    t: T,
}

hover doesn't show the size. I would like something like

 // size = 1024 (0x400) + size of T

The size is completely turned off when a generic exists so

struct S<T> {
    data: [u8; 1024],
    t: PhantomData<T>,
}

or

struct S<T = SomeEnum> {
    data: [u8; 1024],
    t: T,
}

Don't work even if they should.

cc: https://github.com/rust-lang/rust-analyzer/issues/16634

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce hover output for the three generic struct examples in the issue, then read the related rust-analyzer issue 16634 for context. Trace the hover size calculation and its handling of generic types; done means the applicable examples display useful size information instead of omitting it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.