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

Add more information to the error code for 'crate not found' #81676

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0463.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,24 @@ extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
You need to link your code to the relevant crate in order to be able to use it
(through Cargo or the `-L` option of rustc example). Plugins are crates as
well, and you link to them the same way.

## Common causes

- The crate is not present at all. If using Cargo, add it to `[dependencies]`
in Cargo.toml.
- The crate is present, but under a different name. If using Cargo, look for
`package = ` under `[dependencies]` in Cargo.toml.

## Common causes for missing `std` or `core`

- You are cross-compiling for a target which doesn't have `std` prepackaged.
Consider one of the following:
+ Adding a pre-compiled version of std with `rustup target add`
+ Building std from source with `cargo build -Z build-std`
+ Using `#![no_std]` at the crate root, so you won't need `std` in the first
place.
- You are developing the compiler itself and haven't built libstd from source.
You can usually build it with `x.py build library/std`. More information
about x.py is available in the [rustc-dev-guide].

[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler
Comment on lines +30 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... this seems ok-ish to mention, but it's odd having that in the regular error message docs. That said... let's leave it in, it's pretty obvious to any reader whether it's relevant for them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's here partly because using ˋxpy build rustdocˋ does not build the standard library for the same stage so ˋrustup toolchain link ...ˋ works but calling the relevant compiler or rustdoc fails with this error. It's either put it here or in the dev guide but this has a lot more visibility and it doesn't take much space. This particular code shouldn't come up too often for "regular" Rust usage too and so should not confuse many people