rust-lang / rust-lang/rust-analyzer

Bug: Inlay hint type annotation for includes_bytes! macro displays size 0 rather than the correct size

Open
#12,181 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The type hint for a variable that is the result of the include_bytes! macro shows size zero rather than its correct size (which is known at compile time)

Screen Shot 2022-05-06 at 2 19 02 PM

However after typing the exact hint in as it is presented, RA shows an error indicating a type mismatch on the size of the array.

image

I would expect the hint to display : &[u8; 122880].

rust-analyzer version: (eg. output of "Rust Analyzer: Show RA Version" command)
rust-analyzer version: 5dce1ff02 2022-05-02 stable

rustc version: (eg. output of rustc -V)
rustc 1.60.0 (7737e0b5c 2022-04-04)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)

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 the issue with a Rust variable initialized by the include_bytes! macro and compare the inlay hint with the compiler's array length. Trace the inlay-hint and type-inference path for this macro; done means the hint shows the correct byte-array size and no longer suggests a mismatched type.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.