Skip to content

Parameter and chaning inlay hints no longer work in attribute proc macros #19834

Closed
@ChayimFriedman2

Description

@ChayimFriedman2
Contributor

As @mlesin reported, same problem is showing on latest versions (pre-release RA, vscode nightly) with #[instrument]

Originally posted by @insilications in #14527

Activity

insilications

insilications commented on May 21, 2025

@insilications

Thanks for opening the issue. I think the issue could be more general when it comes to inlay hints. Some minimal reproduction showing how closure capture inlay hints disappear when the #[instrument] attribute macro is present:

Using the latest Rustup nightlies. Happens if I use the rust-analyzer 1.89.0-nightly (bc82152 2025-05-20) binary directly, by using the rust-analyzer.server.path setting, or if I use the included rust-analyzer from the VS Code extension.

VS Code Rust Analyzer version: rust-lang.rust-analyzer-0.4.2468-linux-x64

VS Code:

Version: 1.101.0-insider
Commit: 496ebc4723371f29c9ffa0319dcccb2d7bee7ee0
Date: 2025-05-21T05:04:29.987Z
Electron: 35.4.0
ElectronBuildId: 11602177
Chromium: 134.0.6998.205
Node.js: 22.15.0
V8: 13.4.114.21-electron.0
OS: Linux x64 6.5.3-1358.native

Minimal reproduction:

#[tracing::instrument]
fn my_function() {
    let t = "Hello, world!";
    spawn(move || {
        println!("Function executed: {t}");
    });
}

fn spawn(f: impl FnOnce()) {
    f();
}

Without #[tracing::instrument]:
Image

With #[tracing::instrument]:
Image

insilications

insilications commented on May 21, 2025

@insilications

If you need any extra logs/traces, please tell me how to enable such extra logs/traces from RA and its LSP.

ChayimFriedman2

ChayimFriedman2 commented on May 21, 2025

@ChayimFriedman2
ContributorAuthor

Yes, they all have the same reason. I'm diagnosing it now.

insilications

insilications commented on May 22, 2025

@insilications

I tried https://github.com/rust-lang/rust-analyzer/releases/tag/nightly with the minimally reproducible example and the closure capture inlay hints are still gone. No errors in rust-analyzer extension and rust-analyzer Language Server...

Veykril

Veykril commented on May 22, 2025

@Veykril
Member

The fix in #19839 is on the proc-macro server side. So you won't be able to observe it until its synced back to rust-lang/rust and published as the corresponding rustup componenet, or you build that component manually and point rust-analyzer to use the self-build one.

insilications

insilications commented on May 22, 2025

@insilications

@Veykril thanks for clarifying! I should have looked at which files were changed in the commit 😛

I will build it manually.

insilications

insilications commented on May 25, 2025

@insilications

For those waiting, it seems that the fix may land in the next nightly and available through rustup.

ChayimFriedman2

ChayimFriedman2 commented on May 25, 2025

@ChayimFriedman2
ContributorAuthor

@insilications Did you verify it works?

Anyway it will only be available for those using nightly toolchain. Those using stable toolchains will have to wait until the next Rust release.

insilications

insilications commented on May 25, 2025

@insilications

@insilications Did you verify it works?

Anyway it will only be available for those using nightly toolchain. Those using stable toolchains will have to wait until the next Rust release.

I decided to wait for it to drop in the next nightly toolchain in order to test it. Seems like it is very close to bring your changes into it (https://github.com/rust-lang/rust/commits/master/src/tools/rust-analyzer/crates/proc-macro-srv/src). I am being lazy, I could build it manually.

insilications

insilications commented on Jun 8, 2025

@insilications

@ChayimFriedman2 It seems it is still happening with the nightly-x86_64-unknown-linux-gnu (2025-06-07) toolchain.

VS Code Rust Analyzer version: rust-lang.rust-analyzer-0.4.2488-linux-x64

VS Code:

Version: 1.101.0-insider
Commit: f832c6b59a2ed11890f4988a29e85658b092a69a
Date: 2025-06-06T20:43:03.362Z
Electron: 35.5.1
ElectronBuildId: 11708675
Chromium: 134.0.6998.205
Node.js: 22.15.1
V8: 13.4.114.21-electron.0
OS: Linux x64 6.5.3-1358.native

When removing #[tracing::instrument] or using the ignore options to ignore proc-macro analysis of tracing::instrument in the proc-macro srv:

  "rust-analyzer.procMacro.ignored": {
    "tracing-attributes": ["instrument"]
  }
#[tracing::instrument]
fn my_function() {
    let t = "Hello, world!";
    spawn(move || {
        println!("Function executed: {t}");
    });
}

fn spawn(f: impl FnOnce()) {
    f();
}

It shows the correct closure capture inlay hints:
Image

When I remove the ignore options, the closure capture inlay hints disappear:
Image

ChayimFriedman2

ChayimFriedman2 commented on Jun 8, 2025

@ChayimFriedman2
ContributorAuthor

@insilications I didn't check closure capture hints when analyzing this, and in fact now when analyzing them I see they will indeed not work (they don't descend into attributes). Can you check with chaining and parameter hints?

insilications

insilications commented on Jun 8, 2025

@insilications

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Veykril@ChayimFriedman2@insilications

        Issue actions

          Parameter and chaning inlay hints no longer work in attribute proc macros · Issue #19834 · rust-lang/rust-analyzer