错误[E0554]:`#![feature]`可能无法在稳定发布通道上使用

问题描述 投票:0回答:1

我的 Rust 程序中的

math
模块出现以下错误。

如何解决?

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> C:\Users\pc\.cargo\registry\src\github.com-1ecc6299db9ec823\math-0.10.0\src\lib.rs:3:12
  |
3 | #![feature(drain_filter)]
  |            ^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> C:\Users\pc\.cargo\registry\src\github.com-1ecc6299db9ec823\math-0.10.0\src\lib.rs:4:12
  |
4 | #![feature(bool_to_option)]
  |            ^^^^^^^^^^^^^^

   Compiling rand_distr v0.4.3
For more information about this error, try `rustc --explain E0554`.
error: could not compile `math` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
rust rust-cargo
1个回答
1
投票

错误消息表明某些模块正在使用不稳定的功能(实际上是两个)。例如,

drain_filter
不稳定,而 issue 43244 已开放。

除了知道您自己是否写了“

#[feature(...
”之外,您还可以看到出现错误的文件以
.cargo\registry\
开头,因此它位于您正在使用的板条箱中。

错误的原因是不稳定的功能可能会发生很大的变化。如果您使用此代码并期望它“正常工作”,那么它可能会以令您的用户极其惊讶的方式失败。因此,假设您正在使用 Rust 的“稳定”通道,并且不希望不稳定的功能突然破坏事物。

如果您确实想要不稳定的功能破坏某些东西,您可以切换到“每晚”频道:

rustup update -- nightly

这将允许您在自己的模块或不稳定的板条箱中使用

#[feature]

© www.soinside.com 2019 - 2024. All rights reserved.