Skip to content

Better diagnostic for missing components #87871

Closed
@antoyo

Description

@antoyo

When using the rustc_private feature without the components being installed and you use a compiler crate, you'll get an error like this:

can't find crate for `rustc_metadata`

which is not helpful.

Given the following code:

#![feature(rustc_private)]

extern crate rustc_metadata;

fn main() {
}

The current output is:

error[E0463]: can't find crate for `rustc_metadata`
 --> src/main.rs:4:1
  |
4 | extern crate rustc_metadata;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

For more information about this error, try `rustc --explain E0463`.
error: could not compile `metadata-reader` due to previous error

Ideally the output should look like:

error[E0463]: can't find crate for `rustc_metadata`
 --> src/main.rs:4:1
  |
4 | extern crate rustc_metadata;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

For more information about this error, try `rustc --explain E0463`.
error: could not compile `metadata-reader` due to previous error
help: maybe you need to install the following components: rust-src rustc-dev llvm-tools-preview

(the last line was added, specifying what could be done to fix the issue)

cc @GuillaumeGomez

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions