[英]can't find crate `rustc` even with `rustc_private`
I stole this code from a tutorial and put it in src/lib.rs
我从教程中偷了这段代码并将其放在
src/lib.rs
#![feature(rustc_private)]
#![feature(plugin_registrar)]
extern crate rustc;
extern crate syntax;
use rustc::plugin::Registry;
use syntax::ast::{Item, MetaItem};
use syntax::codemap::Span;
use syntax::ext::base::ExtCtxt;
use syntax::ext::base::SyntaxExtension::Modifier;
use syntax::parse::token::intern;
use syntax::ptr::P;
#[plugin_registrar]
pub fn registrar(reg: &mut Registry) {
reg.register_syntax_extension(intern("extension"), Modifier(Box::new(expand)));
}
fn expand(_: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>) -> P<Item> {
println!("Hello world!");
return item;
}
and Cargo.toml
和
Cargo.toml
[package]
name = "inductive"
version = "0.1.0"
authors = ["fakedrake"]
[lib]
name = "inductive"
plugin=true
[dependencies]
But但
$ rustup component add rustc-dev
info: downloading component 'rustc-dev'
info: installing component 'rustc-dev'
info: using up to 500.0 MiB of RAM to unpack components
102.5 MiB / 102.5 MiB (100 %) 18.9 MiB/s in 5s ETA: 0s
$ cargo --version
cargo 1.52.0-nightly (c68432f1e 2021-03-02)
$ rustc --version
rustc 1.52.0-nightly (caca2121f 2021-03-05)
$ cargo build --verbose
Compiling inductive v0.1.0 (/Users/fakedrake/Projects/Rust/inductive)
Running `rustc --crate-name inductive src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 -C metadata=9adf86ab36dcd7bb --out-dir /Users/fakedrake/Projects/Rust/inductive/target/debug/deps -C incremental=/Users/fakedrake/Projects/Rust/inductive/target/debug/incremental -L dependency=/Users/fakedrake/Projects/Rust/inductive/target/debug/deps`
error[E0463]: can't find crate for `rustc`
--> src/lib.rs:4:1
|
4 | extern crate rustc;
| ^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `inductive`
Caused by:
process didn't exit successfully: `rustc --crate-name inductive src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 -C metadata=9adf86ab36dcd7bb --out-dir /Users/fakedrake/Projects/Rust/inductive/target/debug/deps -C incremental=/Users/fakedrake/Projects/Rust/inductive/target/debug/incremental -L dependency=/Users/fakedrake/Projects/Rust/inductive/target/debug/deps` (exit code: 1)
What am i doing wrong?我究竟做错了什么?
rustup component add --toolchain nightly rust-src rustc-dev llvm-tools-preview
https://github.com/rust-lang/rust/issues/72564 https://github.com/rust-lang/rust/issues/72564
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.