我正在尝试在我的程序中使用rustc
的crate。
#[macro_use]
extern crate rustc;
extern crate rustc_typeck;
extern crate syntax;
extern crate syntax_pos;
use rustc::hir;
fn main() {
println!("Hello, World!");
}
我还在 Cargo.toml 文件中添加了一个额外的依赖项:
[dependencies]
log = "0.4.1"
cargo run
告诉您它只适用于私有和夜间版本,产生了一堆错误:
error: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? (see issue #27812)
--> src/main.rs:2:1
|
2 | extern crate rustc;
| ^^^^^^^^^^^^^^^^^^^
似乎Cargo想要从crates.io获取一个稳定的crate,但我不知道应该使用哪个crate。在crates.io上没有名为rustc的crate。
这是我的Rust安装版本:
rustc 1.23.0 (766bd11c8 2018-01-01) cargo 0.24.0 (45043115c 2017-12-05)
我使用rustup进行了安装。
如何为我的程序使用rustc crate?
我尝试将rustc = "1.23.0"添加到Cargo.toml中,但仍然无法正常工作,出现以下错误:
error: no matching package named `rustc` found (required by `rust-swift-serde-gen`)
Cargo.toml
中声明rustc
吗? - tadmancrates.io
上找不到rustc
crate 的页面。 - eonilCargo.toml
中,以拉取该依赖项,而不是使用 Rust 附带的私有依赖项。只需添加那一行并尝试它! - tadman错误: 找不到匹配的名为 \
rustc` 的包(由 `rust-swift-serde-gen` 要求)`... 太遗憾了。 - eonil