Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tbu- opened this issue Jun 28, 2022 · 4 comments · Fixed by #98637
Closed
Assignees
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tbu-
Copy link
Contributor

tbu- commented Jun 28, 2022

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

@tbu- tbu- added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jun 28, 2022
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed regression-untriaged Untriaged performance or correctness regression. labels Jun 28, 2022
@apiraino
Copy link
Contributor

Just adding a note. The issue seems to be an old version of num-complex that ndarray used to use back in v0.9.1

$ cargo +nightly build
   Compiling autocfg v1.1.0
   Compiling matrixmultiply v0.1.15
   Compiling ndarray v0.12.1
   Compiling rawpointer v0.1.0
   Compiling either v1.6.1
   Compiling itertools v0.7.11
   Compiling num-traits v0.2.15
   Compiling num-complex v0.2.4
error[E0716]: temporary value dropped while borrowed
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/ndarray-0.12.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)

The crate ndarray from v0.13.0 (released in sept. 2019) compiles fine also on latest Rust nightly

@apiraino
Copy link
Contributor

bisection seems to point to commit 10f4ce3 cc @cjgillot

searched nightlies: from nightly-2022-04-01 to nightly-2022-06-28
regressed nightly: nightly-2022-06-23
searched commits: from dc80ca7 to 10f4ce3
regressed commit: 10f4ce3

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2022-04-01 

(unsure if this regression may hit other more recent crates)

@cjgillot
Copy link
Contributor

I've been suspecting this bug for a few days, but unable to reproduce it. I think I have a patch, will confirm once I manage to MCVE.

@cjgillot cjgillot self-assigned this Jun 28, 2022
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 29, 2022
@apiraino
Copy link
Contributor

apiraino commented Jul 1, 2022

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 1, 2022
@bors bors closed this as completed in 38b7215 Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants