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

rust-lang/rust: "failed to switch build data" messages #9200

Closed
lf- opened this issue Jun 10, 2021 · 2 comments
Closed

rust-lang/rust: "failed to switch build data" messages #9200

lf- opened this issue Jun 10, 2021 · 2 comments

Comments

@lf-
Copy link
Contributor

lf- commented Jun 10, 2021

Steps I did to reproduce:

Open compiler/rustc_hir/src/hir.rs with this suggested config from the dev guide:

{
    "rust-analyzer.checkOnSave.overrideCommand": [
        "./x.py",
        "check",
        "--json-output"
    ],
    "rust-analyzer.rustfmt.overrideCommand": [
      "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt"
    ],
    "rust-analyzer.cargo.runBuildScripts": false,
    "rust-analyzer.procMacro.enable": true
}

and it did this and showed a sad popup in the corner:

[ERROR rust_analyzer::reload] failed to switch build data: cargo check failed:
error: could not compile `crc32fast`

To learn more, run the command again with --verbose.
error: build failed

Why would it do such a thing? This error looks similar to what cargo check in r-l/r would fail like.... pokes through r-a code, patches in a debug log (it would be nice if we could spit this out automatically, but my patch here requires rust-lang/rust#44434):

[DEBUG project_model::build_data] run cargo in Some("/home/jade/dev/rust") with ["check", "--quiet", "--workspace", "--message-format=json", "--manifest-path", "/home/jade/dev/rust/Cargo.toml", "--all-targets"]

So from what I can understand, project_model::build_data is calling cargo check with its own generated command, which it should not do in r-l/r and probably some other places, in spite of there being a configured checkOnSave.overrideCommand. I'm not sure how this should be handled, but I'm filing it to document it as an issue with r-l/r.

cc #8915

@lf- lf- changed the title rust-lang/rust: "failed to build" messages rust-lang/rust: "failed to switch build data" messages Jun 10, 2021
@flodiebold
Copy link
Member

Setting procMacro.enable to true (contrary to the dev guide) overrides the runBuildScripts setting (as the documentation for the setting mentions), so cargo check will be run.

@lf-
Copy link
Contributor Author

lf- commented Jun 10, 2021

Oh, shoot. I mixed that up while looking for the proc macro issues :/ oops.

@lf- lf- closed this as completed Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants