Skip to content

"can't find crate" errors are easy to miss because they result in many more follow-up errors #97685

Open
@jplatte

Description

@jplatte

Given a crate that depends on bytes 1.1.0, trying to cargo build --target target_that_is_not_installed results in

error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-redox` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-redox`

error[E0463]: can't find crate for `compiler_builtins`

error[E0463]: can't find crate for `alloc`
  --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-1.1.0/src/lib.rs:78:1
   |
78 | extern crate alloc;
   | ^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `std`
  --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-1.1.0/src/lib.rs:81:1
   |
81 | extern crate std;
   | ^^^^^^^^^^^^^^^^^ can't find crate
   |
   = note: the `x86_64-unknown-redox` target may not be installed
   = help: consider downloading the target with `rustup target add x86_64-unknown-redox`

error[E0463]: can't find crate for `core`
 --> /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-1.1.0/src/buf/buf_impl.rs:5:5
  |
5 | use core::{cmp, mem, ptr};
  |     ^^^^ can't find crate
  |
  = note: the `x86_64-unknown-redox` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-redox`

followed by a few more can't find crate for `core` errors, followed by around 500 additional errors about individual items from the standard library not being found. The first of these appear very fast, so it's inconvenient (and sometimes impossible due to scrollback limitations) to actually find the relevant errors at the start.

I think at least one of two things should happen here:

  • Failing to find a critical crate like core or std should abort compilation immediately
  • If an external crate (or a module?) can't be resolved, don't report errors about symbols not being found that were meant to be imported from there

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.T-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