rust-lang / rust-lang/rust-analyzer
RA cannot defer the type from a macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 69
Description
rust-analyzer version: rust-analyzer version: 0.4.2369-standalone (588948f267 2025-04-06)
rustc version: rustc 1.86.0 (05f9846f8 2025-03-31)
editor or extension: pre-release (release same problem): Version
0.4.2369
Last Updated
2025-04-07,
code snippet to reproduce:
cargo.toml
crabtime = "1.1.3"
fn main() {
let x = {
#[crabtime::eval_function()]
fn boo2() {
crabtime::output! {
5u32
}
}
};
}
RA reports x: () while with the expanded code from RA, it reports correctly u32
expanded:
let x = {
#[doc = " # Compilation Stats"]
#[doc = " Start: 01:23:04 (771)"]
#[doc = " Duration: 0.50 s"]
#[doc = " Cached: false"]
#[doc = " Output Dir: /Users/indra/Code/git/flecs_rust/target/rust-analyzer/debug/build/crabtime/project_f940e44a8c006acd/pid_59609"]
#[doc = " Macro Options: MacroOptions {"]
#[doc = " cache: true,"]
#[doc = " content_base_name: false,"]
#[doc = " }"]
#[cfg(any())]
const _:() = ();
5u32
};
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report using the dependency in cargo.toml and the crabtime macro snippet, then compare rust-analyzer's inferred type for x with the expanded code shown in the issue. The work is done when rust-analyzer reports x as u32 for this case rather than ().
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
- 38/100