rust - 如何在不 fork crate 的情况下将 #![feature(***)] 添加到另一个 crate 的属性?

标签 rust rust-cargo rust-crates

每次我看到这样的错误:

error: associated constants are experimental (see issue #29646)
...
= help: add #![feature(associated_consts)] to the crate attributes to enable
= note: this error originates in a macro outside of the current crate

我 fork 了 crate 并将功能添加到 crate 属性中,然后替换了我的 Cargo.toml 中的依赖项:

[replace."bitflags:1.0.0"]
git = "https://github.com/boehm-s/bitflags"
rev = "bb2afce"

有没有办法在不 fork crate 的情况下消除这些错误?

最佳答案

最近在 Rust 1.20 中稳定了相关常量;如果升级 Rust 编译器,此错误应该会消失,无需任何代码更改。

除了[replace] and [patch] , 还有使用 .cargo/config 的选项至 override a dependency locally无需更改 Cargo.toml

关于rust - 如何在不 fork crate 的情况下将 #![feature(***)] 添加到另一个 crate 的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46777457/

相关文章:

rust - 无法使用 std::process::Command - 没有这样的文件或目录

Rust pkg mgr Cargo - 如何设置默认 VCS,以便为该 VCS 设置每个 "cargo new projname"

dependencies - 如何使本地依赖依赖于 Cargo 中的功能?

rust - 从 "reqwest"crate rust 发出 post 请求时请求正文为空

rust - 是否可以在 Cargo.toml 中指定依赖项的版本?

rust - 如何使用 HashMap 创建一个结构,其中的键与容器的类型相同

rust - 我们可以自动导出用户定义的特征吗?

rust - 为什么 &str 在 Rust 中被称为切片?

multithreading - Rust 相当于 Intel 的 tbb::concurrent_queue 吗?

rust - 找不到 `rayon` 的箱子