rust-lang / rust-lang/rust-analyzer

"Inline macro" doesn't work inside proc_macro_attribute

Open
#19,795 3 comments 0 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

If I have normal function, I could expand macros like println inside it

fn test1() {
  println!("hello"); // I could do "inline macro" here
}

But I couldn't if the function under proc_macro_attribute like async_trait

#[async_trait]
impl A for S {
  fn test2() {
    println!("hello"); // I couldn't do "inline macro" here
  }
}

I know in some cases the outer proc_macro_attribute would change the AST inside it while I think in many cases it just keeps the inner TokenStream

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

Start by reproducing the two examples in the issue: an inline println! in a normal function and inside an impl using #[async_trait]. Trace how rust-analyzer handles the proc_macro_attribute and its inner TokenStream, then verify that inline macros work in the attributed case without breaking cases where the attribute changes the AST.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
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.