Skip to content

rust-analyzer shows thousands of rustc errors but running the build command on the terminal works fine #15942

Closed
@RalfJung

Description

@RalfJung

Since somewhat recently, RA shows >1800 errors in src/tools/miri in the rustc workspace, even though Miri builds perfectly fine. The errors all claim that various types from rustc cannot be found.

cannot find type `AllocId` in this scope
not found in this scope
cannot find type `MemoryKind` in this scope
not found in this scope
cannot find type `ImmTy` in this scope
not found in this scope

Running the same build command inside vscode in the terminal, everything succeeds just fine -- so it looks very much like this is caused by how RA invokes the build command. The same command still worked last week or so (I don't exactly remember when I used vscode in rustc the last time).

rustc itself builds just fine, it is only Miri where it shows errors.

rust-analyzer version: 0.3.1740-standalone

rustc version: bootstrap beta

relevant settings:

{
    "rust-analyzer.linkedProjects": [
        "Cargo.toml",
        "src/bootstrap/Cargo.toml",
    ],
    "rust-analyzer.check.invocationLocation": "root",
    "rust-analyzer.check.invocationStrategy": "once",
    "rust-analyzer.check.overrideCommand": [
        "./myx",
        "check",
        "--json-output",
        "library/std",
        "compiler/rustc", "src/tools/miri",
    ],
    "rust-analyzer.rustfmt.overrideCommand": [
        "${workspaceFolder}/build/host/rustfmt/bin/rustfmt",
        "--edition=2021",
    ],
    "rust-analyzer.rustc.source": "./Cargo.toml",
    "rust-analyzer.cargo.sysrootSrc": "./library",
    "rust-analyzer.cargo.extraEnv": {
        "RUSTC_BOOTSTRAP": "1"
    },
    // These just make everything way too slow.
    "rust-analyzer.cargo.buildScripts.enable": false,
    "rust-analyzer.procMacro.enable": false,
    // Some diagnostics don't work properly here
    "rust-analyzer.showUnlinkedFileNotification": false,
    "rust-analyzer.diagnostics.enable": false, // without proc macros, there's just too many false positives
    //
    "files.watcherExclude": {
        "*rustc*/src/llvm-project/**": true,
        "*rustc*/build/**": true,
    },
    "files.exclude": {
        "src/llvm-project/**": true,
        "build/**": true
    },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions