Rust 使用不稳定库功能的防锈包装';国际热核聚变实验堆背面';

Rust 使用不稳定库功能的防锈包装';国际热核聚变实验堆背面';,rust,rust-cargo,Rust,Rust Cargo,我有一个我不太了解的Rust应用程序,我从一个我正在开发的Python程序中调用它。我没有更改Rust源代码中的任何内容,但这两个项目的构建过程中出现了如下错误: [... several similar errors] error[E0658]: use of unstable library feature 'iter_nth_back' --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0

我有一个我不太了解的Rust应用程序,我从一个我正在开发的Python程序中调用它。我没有更改Rust源代码中的任何内容,但这两个项目的构建过程中出现了如下错误:

[... 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`.
我查看了列表,几天前发布了0.13.0版,所以我怀疑它与我的构建环境不兼容

我怎样才能让我的构建再次工作

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

$ 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
#
$sudo docker run-it--rm rust:1.36.0
#USER=foo cargo new hello\u world--bin
已创建二进制(应用程序)`hello_world`包
#世界你好/
#echo'bio=“^0”>>Cargo.toml
#货物建造
更新crates.io索引
下载的bio v0.29.0
下载[…更多…]
下载的Ndaray v0.13.0
下载[…更多…]
编译proc-macro2 v1.0.4
编译[…更多…]
编译ndarray v0.13.0
编译[…更多…]
编译statrs v0.11.0
错误[E0658]:使用不稳定的库功能“iter N TU back”
-->/usr/local/cargo/registry/src/github.com-1ec6299db9ec823/ndarray-0.13.0/src/iterators/mod.rs:134:5
|
134 |/fn第n个返回(&mut self,n:usize)->选项{
135 | |让索引=自索引?;
136 | | let len=self.dim[0]-索引[0];
137 | |如果n
有趣的是,如果我运行rust的最新docker映像1.38,我看不到错误。然而,我的构建过程是从Ubuntu Xenial的软件包管理器安装Rust,所以我可能无法轻松升级它。

新答案:升级Rust 事实证明,升级rust并不像我想象的那么难,然后我就不必更改rust的源代码了

在我的
.travis.yml
文件中,我替换了以下内容:

-sudo-apt-get-install-y-cargo
为此:

-sudo curlhttps://sh.rustup.rs -sSf | sh-s--y
-来源~/.cargo/env
原始答案:Pin依赖性 我尝试添加一个显式的
ndarray
依赖项,并将其固定在0.12,但没有成功。然后我注意到,
bio
在过去几天里也发布了一个新版本。将这种依赖性固定起来是有效的

$ 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
#