使用不稳定库功能

使用不稳定库功能

本文介绍了使用不稳定库功能“iter_nth_back"的 Rust 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我不太了解的 Rust 应用程序,我正在从我正在处理的 Python 程序中调用它.我没有更改 Rust 源代码中的任何内容,但这两个项目的构建过程只是停止工作,出现如下错误:

I have a Rust application that I don't know much about, and I'm calling it from a Python program that I'm working on. I haven't changed anything in the Rust source code, but the build process for these two projects just stopped working with an error like this:

[... several similar errors]
error[E0658]: use of unstable library feature 'iter_nth_back'
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0.13.0/src/iterators/mod.rs:585:46
    |
585 |         either_mut!(self.inner, iter => iter.nth_back(n))
    |                                              ^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/56995

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
error: Could not compile `ndarray`.

我查看了 ndarray 版本 的列表,版本 0.13.0 来了几天前出来了,所以我怀疑它与我的构建环境不兼容.

I looked at the list of ndarray releases, and release 0.13.0 came out a few days ago, so I suspect that it's incompatible with my build environment.

我怎样才能让我的构建重新工作?

How can I get my build working again?

以下是重现问题的完整步骤:

Here are the full steps to reproduce the problem:

$ sudo docker run -it --rm rust:1.36.0
# USER=foo cargo new hello_world --bin
     Created binary (application) `hello_world` package
# cd hello_world/
# echo 'bio = "^0"' >> Cargo.toml
# cargo build
    Updating crates.io index
  Downloaded bio v0.29.0
  Downloaded [... many more ...]
  Downloaded ndarray v0.13.0
  Downloaded [... many more ...]
   Compiling proc-macro2 v1.0.4
   Compiling [... many more ...]
   Compiling ndarray v0.13.0
   Compiling [... many more ...]
   Compiling statrs v0.11.0
error[E0658]: use of unstable library feature 'iter_nth_back'
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0.13.0/src/iterators/mod.rs:134:5
    |
134 | /     fn nth_back(&mut self, n: usize) -> Option<*mut A> {
135 | |         let index = self.index?;
136 | |         let len = self.dim[0] - index[0];
137 | |         if n < len {
...   |
147 | |         }
148 | |     }
    | |_____^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/56995
[... other, similar errors ...]
   Compiling serde_derive v1.0.101
   Compiling strum_macros v0.16.0
   Compiling snafu-derive v0.5.0
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
error: Could not compile `ndarray`.
warning: build failed, waiting for other jobs to finish...
error: build failed
#

有趣的是,如果我为 rust 运行最新的 docker 镜像 1.38,我没有看到错误.但是,我的构建过程是从 Ubuntu Xenial 的包管理器安装 Rust,所以我可能无法轻松升级它.

Interestingly, if I run the latest docker image for rust, 1.38, I don't see the error. However, my build process is installing Rust from Ubuntu Xenial's package manager, so I probably can't upgrade it easily.

推荐答案

新答案:升级 Rust

原来升级 Rust 并没有我想象的那么难,然后我就不用改 Rust 源代码了.

New Answer: Upgrade Rust

It turned out that upgrading rust wasn't as hard as I thought, and then I don't have to change the Rust source code.

在我的 .travis.yml 文件中,我替换了这个:

In my .travis.yml file, I replaced this:

- sudo apt-get install -y cargo

这样:

- sudo curl https://sh.rustup.rs -sSf | sh -s -- -y
- source ~/.cargo/env

原始答案:引脚依赖

我尝试添加一个显式的 ndarray 依赖项并将其固定在 0.12,但这不起作用.然后我注意到 bio 在最近几天也有一个新版本.固定该依赖项有效.

Original Answer: Pin Dependencies

I tried adding an explicit ndarray dependency and pinning it at 0.12, but that didn't work. Then I noticed that bio also had a new release in the last few days. Pinning that dependency worked.

$ sudo docker run -it --rm rust:1.36.0
# USER=foo cargo new hello_world --bin
     Created binary (application) `hello_world` package
# cd hello_world/
# echo 'bio = "~0.28.2"' >> Cargo.toml
# cargo build
    Updating crates.io index
  Downloaded bio v0.28.2
  Downloaded [... many more ...]
  Downloaded ndarray v0.12.1
  Downloaded [... many more ...]
   Compiling proc-macro2 v1.0.4
   Compiling [... many more ...]
   Compiling ndarray v0.12.1
   Compiling [... many more ...]
   Compiling csv v1.1.1
   Compiling hello_world v0.1.0 (/hello_world)
    Finished dev [unoptimized + debuginfo] target(s) in 14m 15s
#

这篇关于使用不稳定库功能“iter_nth_back"的 Rust 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:53