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

Cargo-powered diagnostics fail silently when a dependency fails to build #7517

Closed
nightkr opened this issue Feb 2, 2021 · 4 comments
Closed
Labels
A-diagnostics diagnostics / error reporting S-actionable Someone could pick this issue up and work on it right now

Comments

@nightkr
Copy link

nightkr commented Feb 2, 2021

Repro

  1. Set up a new project with broken dependencies (assuming cargo-edit and cargo-feature, otherwise do the Cargo.toml edits manually :P):
cargo new my-repro --bin
cd my-repro
cargo add [email protected] --no-default-features
# Only one version feature may be enabled at a time
cargo feature k8s-openapi +v1_16 +v1_17
# Confirm that it fails to build...
cargo build
  1. Open in whatever Rust-Analyzer-powered editor you prefer (so far I've tested and confirmed emacs+lsp-mode and vscode+ra plugin)
  2. Write some invalid code (such as adding a call to a missing asdf(); function to main)

Expected outcome

Rust-Analyzer reports an error building dependencies.

Actual outcome

Rust-Analyzer reports no errors, and displays the asdf(); call as a valid call of type {unknown}.

Well, duh, of course this doesn't work

This example is pretty contrived, but it's easy to get bit by in multi-crate workspaces. If you have multiple bin crates then they can end up with conflicting dependencies, which work fine when building any crate in isolation (such as running cargo run, or cargo build inside of the crate directory), but break when building the whole workspace (such as running cargo build in the workspace dir, or running Rust-Analyzer).

@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Feb 2, 2021
@theduke
Copy link
Contributor

theduke commented Feb 2, 2021

The issue started happening on master 1-2 weeks ago, and I see it regularly.

Note: this is apparently not exclusive to failing dependencies.
It also happens inside a single crate between modules.

It's extremely cumbersome during refactoring, since the issue seems to pop up especially when changing a lot (type signatures, moving modules around, ...).

@nightkr
Copy link
Author

nightkr commented Feb 2, 2021

@theduke

Just to confirm that we're talking about the same issue... Are you talking about {unknown} showing up, or errors from rustc/cargo build missing in Rust-Analyzer? This issue also seems to be completely deterministic: it's unaffected by restarting Rust-Analyzer, the buffer, or the editor.

@theduke
Copy link
Contributor

theduke commented Feb 2, 2021

Are you talking about {unknown} showing up, or errors from rustc/cargo build missing in Rust-Analyzer?

The latter.

This issue also seems to be completely deterministic

This is the behaviour I'm seeing as well.

Things start to work again after fixing enough of the errors, and stop working when undoing those changes.

If it's helpful I can also try to find a minimal single-crate reproduction.

@lnicola lnicola added the A-diagnostics diagnostics / error reporting label Feb 20, 2021
@lnicola
Copy link
Member

lnicola commented Apr 7, 2021

This is more or less working after #8355:

image

I'll file a new issue for the ungreat error messages.

@lnicola lnicola closed this as completed Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting 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