如何允许弃用的功能?

7

我有一个依赖于string_cache的Rust项目,它需要使用nightly版本。然而,最新版本的nightly由于过时的特性而无法编译:

$ cargo build
   Compiling string_cache v0.1.0 (https://github.com/servo/string-cache#45f19068)
/home/wilfred/.multirust/toolchains/nightly/cargo/git/checkouts/string-cache-efa5c30b1d5a962c/master/src/atom/mod.rs:65:21: 65:37 error: use of deprecated item: use `String::from` instead, #[deny(deprecated)] on by default
/home/wilfred/.multirust/toolchains/nightly/cargo/git/checkouts/string-cache-efa5c30b1d5a962c/master/src/atom/mod.rs:65             string: String::from_str(string_to_add),
                                                                                                                                            ^~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `string_cache`.

To learn more, run the command again with --verbose.

我该如何编译string_cache?我尝试添加了一些内容。
#![allow(deprecated)]

我将对我的main.rs进行更改,但这并不会改变其行为。

1个回答

3
编译器默认情况下不会对弃用方法的使用施加任何限制:
fn main() {
   (32.0f64).is_positive();
}

编译成功,但有警告:

warning: use of deprecated item: renamed to is_sign_positive, #[warn(deprecated)] on by default

您的错误信息有助于指出罪魁祸首:

#[deny(deprecated)] on by default

您需要找出 deny 指定的位置。


啊哈,你说得对。看起来 #[deny(deprecated)] 是由库本身设置的。我能覆盖它吗? - Wilfred Hughes
1
@WilfredHughes:不,你不能更改你依赖的crate的代码。 - Chris Morgan
3
除非有可用的fork代码并依赖于您自己的fork,否则无法解决这个问题。 - llogiq

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接