Skip to content
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

In rustc workspace, cranelift errors are ignored #8937

Open
Tracked by #8915
RalfJung opened this issue May 23, 2021 · 3 comments
Open
Tracked by #8915

In rustc workspace, cranelift errors are ignored #8937

RalfJung opened this issue May 23, 2021 · 3 comments
Labels
A-cargo cargo related issues A-diagnostics diagnostics / error reporting C-bug Category: bug

Comments

@RalfJung
Copy link
Member

RalfJung commented May 23, 2021

My rustc workspace settings.json looks like this:

{
    "rust-analyzer.checkOnSave.overrideCommand": [
        "./x.py",
        "check",
        "--json-output",
        "library/std",
        "compiler/rustc",
        "compiler/rustc_codegen_cranelift",
    ],
    "rust-analyzer.rustfmt.overrideCommand": [
        "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt"
    ],
    "rust-analyzer.cargo.runBuildScripts": false,
    "rust-analyzer.procMacro.enable": false,
    "editor.formatOnSave": false,
    "files.watcherExclude": {
        "*rustc*/src/llvm-project/**": true,
        "*rustc*/build/**": true,
    },
    "files.exclude": {
        "src/llvm-project/**": true,
        "build/**": true
    },
}

However, it seems like RA for some reason ignores the compiler/rustc_codegen_cranelift part of the check-on-save command: even when I deliberately introduce an error in, e.g., compiler/rustc_codegen_cranelift/src/constant.rs, RA shows no diagnostic at all. Running the exact command that is given here on the console does show an error. Errors in rustc itself are shown. It's almost as if RA just "forgets" to pass the last argument to x.py. (Yes I did "reload window" after changing my settings.json. I even tried restarting vscode.)

@bjorn3
Copy link
Member

bjorn3 commented May 23, 2021

cg_clif is a separate workspace. You need to point to it's Cargo.toml in the rust-analyzer.linkedProjects array. You may also need to add the root Cargo.toml if you set it.

@RalfJung
Copy link
Member Author

When I set linkedProjects, I get some really strange errors about "Failed to run cargo metadata". Probably the rustc provided by rustup that is set inside the rustc tree is not working, but that rustc should not even be needed -- and it wasn't needed when I did not set linkedProjects.

Does RA just silently drop all errors that it cannot assign to one of the linkedProjects? Couldn't there be a way for it to report all the errors shown by the check-on-save command?

@RalfJung
Copy link
Member Author

RalfJung commented Aug 23, 2022

When I set linkedProjects, I get some really strange errors about "Failed to run cargo metadata".

This is due to #10793.

And the "ignoring errors" is because ./x.py check will print paths relative to the cranelift workspace root, but of course RA thinks they are relative to the rustc repo root (where it invoked ./x.py), so it just cannot figure out which file the error refers to. And RA is not wrong here, as a user I would also expect that, but due to rust-lang/cargo#11007, x.py will print paths relative to different roots depending on what it is currently building.

@Veykril Veykril added A-diagnostics diagnostics / error reporting A-cargo cargo related issues C-bug Category: bug labels Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo cargo related issues A-diagnostics diagnostics / error reporting C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants