Skip to content

Possible false-negative with tail-expr-drop-order #132861

Closed
@ehuss

Description

@ehuss

There may be a false-negative with tail-expr-drop-order. Reproduction:

  1. curl -L https://crates.io/api/v1/crates/faer-core/0.17.1/download | tar -xz
  2. cd faer-core-0.17.1
  3. Set up cargo-features and a git repo: git init . && sed -i '1i cargo-features = ["edition2024"]' Cargo.toml && git add . && git commit -m test
  4. cargo fix --edition

On current nightly (2024-11-09), this generates a large number of warnings about tail-expr-drop-order. However, none of them are in the offending function swap_cols. Additionally, after #131326, there are no warnings at all.

After switching to 2024, this yields an error:

error[E0716]: temporary value dropped while borrowed
     --> src/lib.rs:10425:69
      |
10425 |           $crate::zip::ZipEq::new($crate::zip::ViewMut::view_mut(&mut { $head }), $crate::zipped!($($tail,)*))
      |                                                                       ^^^^^^^^^                              - temporary value is freed at the end of this statement
      |                                                                       |
      |                                                                       creates a temporary value which is freed while still in use
      |
     ::: src/permutation.rs:304:9
      |
304   | /         zipped!(
305   | |             mat_a.const_cast().as_2d_mut(),
306   | |             mat_b.const_cast().as_2d_mut(),
307   | |         )
      | |_________- in this macro invocation
308   |       }
309   |       .for_each(|unzipped!(mut a, mut b)| {
      |        -------- borrow later used by call
      |
      = note: consider using a `let` binding to create a longer lived value
      = note: this error originates in the macro `zipped` (in Nightly builds, run with -Z macro-backtrace for more info)

Unfortunately that crate is a maze of types and generics, so it is a bit difficult to minimize.

I'm just assuming this is a tail expression drop change due to the shape of the error.

It does not seem related to the macro, since manually expanding it also does not change anything.

I would expect tail-expr-drop-order to at least warn something here.

cc @dingxiangfei2009

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (59cec72a5 2024-11-08)
binary: rustc
commit-hash: 59cec72a57af178767a7b8e7f624b06cc50f1087
commit-date: 2024-11-08
host: aarch64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-edition-2024Area: The 2024 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.D-editionDiagnostics: An error or lint that should account for edition differences.F-shorter_tail_lifetimes`#![feature(shorter_tail_lifetimes)]`L-false-negativeLint: False negative (should have fired but didn't).L-tail_expr_drop_orderLint: tail_expr_drop_orderT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions