-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
pin!() has incorrect/unexpected drop order inside if-let. #145328
Copy link
Copy link
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-pinArea: PinArea: PinC-bugCategory: This is a bug.Category: This is a bug.F-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`F-super_letit's super, let's go!it's super, let's go!P-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)A-pinArea: PinArea: PinC-bugCategory: This is a bug.Category: This is a bug.F-let_chains`#![feature(let_chains)]``#![feature(let_chains)]`F-super_letit's super, let's go!it's super, let's go!P-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
My intuition is that, with regards to drop order,
pin!(expr)should behave like&mut expr. However, this is not the case inside let chains.The above code outputs:
0,1,2,3. It should output1,0,2,3.cc @m-ou-se
Discovered in #141295 (comment)
Note that
pin!()started being implemented withsuper letin version 1.88.0, the same version where let chains were stabilized.@rustbot labels +A-pin +F-let_chains +A-destructors +F-super_let
Meta
Reproducible on the playground with version
1.89.0and version1.91.0-nightly (2025-08-11 1ebbd87a62ce96a72b22)Related PRs:
super letbindings withinif let#145342