Skip to content

pin macro no longer lifetime extends argument #138596

@conradludgate

Description

@conradludgate

Code

I tried this code:

fn main() {
    match std::pin::pin!(foo(&mut 0)) {
        _f => {}
    }
}

async fn foo(_s: &mut usize) {}

I expected to see this happen: Compiles without error

Instead, this happened:

error[E0716]: temporary value dropped while borrowed
 --> src/main.rs:2:35
  |
2 |     match std::pin::pin!(foo(&mut 0)) {
  |           ------------------------^--
  |           |                       ||
  |           |                       |temporary value is freed at the end of this statement
  |           |                       creates a temporary value which is freed while still in use
  |           borrow later used here
  |
  = note: consider using a `let` binding to create a longer lived value

Version it worked on

It most recently worked on: 1.86.0-beta.6 (2025-03-16 8c7969a3ae4a292789a4)

Version with regression

rustc --version --verbose:

rustc 1.87.0-nightly (227690a25 2025-03-16)
binary: rustc
commit-hash: 227690a258492c84ae9927d18289208d0180e62f
commit-date: 2025-03-16
host: aarch64-apple-darwin
release: 1.87.0-nightly
LLVM version: 20.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2024Area: The 2024 editionA-pinArea: PinC-bugCategory: This is a bug.S-has-bisectionStatus: a bisection has been found for this issueT-libsRelevant to the library 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