Skip to content

rustc: With proc macros disabled, instrument functions do not get Ctrl-click and other RA goodness #12669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RalfJung opened this issue Jul 1, 2022 · 1 comment · Fixed by #12670
Assignees
Labels
A-proc-macro proc macro C-bug Category: bug

Comments

@RalfJung
Copy link
Member

RalfJung commented Jul 1, 2022

With the following in my settings

    "rust-analyzer.procMacro.enable": false,
    "rust-analyzer.cargo.buildScripts.enable": false,

when working on the rustc repo, when I go to a function that has an instrument attribute (e.g. fn operand_projection), inside that function, RA does not seem to exist -- no types on hover, no Ctrl-click, no inlay hints, nothing.

Enabling proc macros and build scripts fixes that, but I was told this is supposed to work even without proc macros being enabled -- RA could just assume the attribute macro is the identity.

rust-analyzer version: rust-analyzer version: 0.0.0 (b74e96f 2022-06-26)

rustc version: rustc bootstrapping

relevant settings:

{
    "rust-analyzer.checkOnSave.overrideCommand": [
        "python3",
        "x.py",
        "check",
        "--json-output",
        "library/std",
        "compiler/rustc",
    ],
    "rust-analyzer.rustfmt.overrideCommand": [
        "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt",
        "--edition=2021"
    ],
    // This also affects proc macros
    "rust-analyzer.cargo.buildScripts.overrideCommand": [
        "cargo",
        "check",
        "-p",
        "rustc_driver",
        "--message-format=json"
    ],
    "rust-analyzer.procMacro.enable": false,
    "rust-analyzer.cargo.buildScripts.enable": false,
    "rust-analyzer.rustc.source": "./Cargo.toml",
}
@flodiebold flodiebold added C-bug Category: bug A-proc-macro proc macro labels Jul 1, 2022
@flodiebold
Copy link
Member

This is actually easy to reproduce outside rustc:

use tracing::instrument;
struct Foo;
impl Foo {
    #[instrument]
    fn foo() {
        let xxx = 1;
    }
}

DIsabling attribute macros is not enough, it only seems to break when proc macros in general are disabled. We also don't report an unresolved-proc-macro diagnostic for impl items.

@flodiebold flodiebold self-assigned this Jul 1, 2022
@bors bors closed this as completed in 8489cd7 Jul 1, 2022
flodiebold added a commit to flodiebold/rust-analyzer that referenced this issue Jul 1, 2022
bors added a commit that referenced this issue Jul 1, 2022
flodiebold added a commit to flodiebold/rust-analyzer that referenced this issue Jul 1, 2022
bors added a commit that referenced this issue Jul 1, 2022
bors added a commit that referenced this issue Jul 1, 2022
flodiebold added a commit to flodiebold/rust-analyzer that referenced this issue Jul 1, 2022
bors added a commit that referenced this issue Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macro proc macro C-bug Category: bug
Projects
None yet
2 participants