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

Inline errors not shown for multi-crate project with custom build script #5962

Closed
RalfJung opened this issue Sep 7, 2020 · 6 comments
Closed
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@RalfJung
Copy link
Member

RalfJung commented Sep 7, 2020

I am trying to get vscode to work properly with Miri. The tricky part is that Miri consists of two (independent) crates, but is not a workspace because that wouldn't work with it also being part of the rustc workspace. So (and also for other reasons) I have a ./miri script somewhat similar to ./x.py. I configured vscode to use that script:

    "rust-analyzer.checkOnSave.overrideCommand": [
        "./miri",
        "check",
        "--message-format=json",
    ],

When I run this on the command-line, it works fine -- at least there is lots of JSON and some of it looks like the error message I am expecting. But in vscode, it doesn't show errors for cargo-miri (the crate that is in a subfolder). It does show errors for the "root" crate -- almost as if it would ignore my command?
I am not sure how to debug this. I found a thing called "extension debug log folder" and in there I found this

[ERROR rust_analyzer::main_loop] File with cargo diagnostic not found in VFS: file not found: /home/r/src/rust/miri/bin.rs

but I am not sure if that has any significance. That folder indeed does not exist, there's a cargo-miri subfolder that is missing -- but the JSON is giving the absolute path correctly:

{"reason":"compiler-message","package_id":"cargo-miri 0.1.0 (path+file:///home/r/src/rust/miri/cargo-miri)","target":{"kind":["bin"],"crate_types":["bin"],"name":"cargo-miri","src_path":"/home/r/src/rust/miri/cargo-miri/bin.rs","edition":"2018","doctest":false,"test":false},"message":{"rendered":"For more information about an error, try `rustc --explain E0069`.\n","children":[],"code":null,"level":"failure-note","message":"For more information about an error, try `rustc --explain E0069`.","spans":[]}}

Any idea why vscode does not show inline errors for cargo-miri?

I realize this is a strange setup, but it is no more strange than rustc's x.py so I am trying to figure out why it does not work.^^

@bjorn3
Copy link
Member

bjorn3 commented Sep 7, 2020

Try setting rust-analyzer.linkedProjects to an array with the paths of all Cargo.toml files (["./Cargo.toml", "./cargo-miri/Cargo.toml"])

@RalfJung
Copy link
Member Author

RalfJung commented Sep 7, 2020

Interesting option. However, just setting that does not change anything.

Isn't there a debug log of how it invokes the check-on-save command and if that was executing properly? When I save, the "cargo check" label doesn't appear at all (or it disappears very quickly), so I am not sure it is even running the right thing.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 7, 2020

Oh, in the last few minutes it decided that my language server was outdated. (That message wasn't there yet 30min ago and I didn't notice it popping up.) Let's see if that changes anything...

No, doesn't seem to help either.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 8, 2020

Strangely, even if I remove my custom build script but keep linkedProjects, it still does not show any inline errors:

// Place your settings in this file to overwrite default and user settings.
{
    "rust-analyzer.rustfmt.extraArgs": [
        "+nightly"
    ],
    "rust-analyzer.linkedProjects": ["./Cargo.toml", "./cargo-miri/Cargo.toml"]
}

So maybe the problem is not with my build script but with with the extension's handling of having multiple "linked project"?

@RalfJung
Copy link
Member Author

RalfJung commented Sep 8, 2020

A possible factor in this might be this part of cargo-miri/Cargo.toml:

[[bin]]
name = "cargo-miri"
path = "bin.rs"
test = false # we have no unit tests
doctest = false # and no doc tests

Maybe it incorrectly interprets path as relative to the root, not relative to the Cargo.toml file?

@flodiebold flodiebold added the S-actionable Someone could pick this issue up and work on it right now label Dec 21, 2020
@RalfJung
Copy link
Member Author

I think this is fixed / tracked elsewhere these days:

@RalfJung RalfJung closed this as not planned Won't fix, can't repro, duplicate, stale Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

3 participants