0

I tried to build the following rust file, and get an error.

src/main.rs:

#![feature(rustc_private)]

extern crate rustc_driver;

fn main() {
    let value = Some(42);
    //...
}

cargo.toml:

[package]
name = "cargo_test"
version = "0.1.0"
authors = ["XXX"]
edition = "2018"

[dependencies]

errors:

(base) ➜  cargo_test git:(master) ✗ cargo build                           
   Compiling cargo_test v0.1.0 (XXX/cargo_test)
error[E0463]: can't find crate for `rustc_driver`
 --> src/main.rs:3:1
  |
3 | extern crate rustc_driver;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cargo_test`

To learn more, run the command again with --verbose.

rustc version:

(base) ➜  cargo_test git:(master) ✗ rustc --version
rustc 1.53.0-nightly (673d0db5e 2021-03-23)

What can I do to fix the problem?

Jw C
  • 171
  • 2
  • 6
  • Does this answer your question? [can't find crate \`rustc\` even with \`rustc\_private\`](https://stackoverflow.com/questions/66523526/cant-find-crate-rustc-even-with-rustc-private) – eggyal Apr 10 '21 at 22:03
  • @eggyal nope. After I run `rustup component add --toolchain nightly rust-src rustc-dev llvm-tools-preview`, I got `info: component 'rust-src' is up to date info: component 'rustc-dev' for target 'x86_64-apple-darwin' is up to date info: component 'llvm-tools-preview' for target 'x86_64-apple-darwin' is up to date`. – Jw C Apr 11 '21 at 11:13
  • Does `ls $(dirname $(rustup which --toolchain nightly rustc))/../lib/librustc_driver-*.dylib` find anything? – eggyal Apr 11 '21 at 19:32
  • @eggyal It just show `/XXX/.rustup/toolchains/nightly-x86_64-apple-darwin/bin/../lib/librustc_driver-034c1adc80d3ae5a.dylib` – Jw C Apr 12 '21 at 02:26
  • Can you paste output from `cargo build -v` please? – eggyal Apr 12 '21 at 07:40

0 Answers0