Skip to content

Nightly regression: ndarray 0.9.1 stops compiling: temporary value dropped while borrowed #98616

Closed
@tbu-

Description

@tbu-

ndarray 0.9.1 compiles with rustc 1.61.0 but not with rustc 1.64.0-nightly (2f3ddd9 2022-06-27).

Code

Put this into a Cargo.toml of a new project:

[package]
name = "test-ndarray"
version = "0.1.0"
edition = "2021"

[dependencies]
ndarray = "0.9.1"

rustc stable <= 1.61.0 compiles the crate fine, rustc nightly gives the following error:

error[E0716]: temporary value dropped while borrowed
  --> .cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0.9.1/src/layout/layoutfmt.rs:29:24
   |
25 |                        .format_with(" | ", |i, f| {
   |                                                - has type `&mut dyn FnMut(&'1 (dyn std::fmt::Display + '1)) -> Result<(), std::fmt::Error>`
...
29 |                     f(&format_args!("0x{:x}", i))
   |                     ---^^^^^^^^^^^^^^^^^^^^^^^^^-
   |                     |  |
   |                     |  creates a temporary which is freed while still in use
   |                     argument requires that borrow lasts for `'1`
30 |                 }
   |                 - temporary value is freed at the end of this statement
   |
   = note: this error originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0597]: `i` does not live long enough
  --> .cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0.9.1/src/layout/layoutfmt.rs:29:47
   |
25 |                        .format_with(" | ", |i, f| {
   |                                                - has type `&mut dyn FnMut(&'1 (dyn std::fmt::Display + '1)) -> Result<(), std::fmt::Error>`
...
29 |                     f(&format_args!("0x{:x}", i))
   |                     --------------------------^--
   |                     |                         |
   |                     |                         borrowed value does not live long enough
   |                     argument requires that `i` is borrowed for `'1`
30 |                 }
31 |             }))
   |             - `i` dropped here while still borrowed
   |
   = note: this error originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0597, E0716.
For more information about an error, try `rustc --explain E0597`.
error: could not compile `ndarray` due to 2 previous errors

Version it worked on

$ rustc --version --verbose
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0

Version with regression

$ rustc +nightly --version --verbose
rustc 1.64.0-nightly (2f3ddd9f5 2022-06-27)
binary: rustc
commit-hash: 2f3ddd9f594adf9773547aa7cedb43c4ac8ffd2f
commit-date: 2022-06-27
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions