如何解决“使用带有`extern crate`项目引入的extern前奏名称是不稳定的”

时间:2019-01-28 20:36:49

标签: rust rust-cargo

当我运行cargo build时(甚至在cargo clean之后),无法编译包装箱v_escape_derive 0.2.1版。我收到以下消息:

error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
 --> /Users/***/.cargo/registry/src/github.com-***/v_escape_derive-0.2.1/src/lib.rs:7:5
  |
7 | use proc_macro::TokenStream;
  |     ^^^^^^^^^^
  |
  = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable

我尝试在cargo clean之前运行cargo build,但没有成功。

当我之前看到这些extern crate错误时,问题出在edition =2015上,但是我项目的版本是2018,并且项目文件中没有extern crate ...行。据我所知,问题出在外部lib.rs文件(即该v_escape_derive包的内部文件中,所以我认为更改它不是一个好主意)。

1 个答案:

答案 0 :(得分:4)

即使在Rust 2018中,some crates are special and must be imported via extern crate。这包括proc_macro条板箱。

要解决此问题,请在代码中添加extern crate proc_macro;行。

  

据我所知,问题出在[另一个箱子]

然后,您必须针对该板条箱提出问题;在稳定的Rust中不起作用。

特别是关于v_escape_derive 0.2.1;那是旧版本。 current version is 0.4没有这个问题。升级您的依赖项以合并更新。

另请参阅:

相关问题