-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
pin!() macro no longer constant-promotes &mut references to empty arrays #142345
Copy link
Copy link
Open
Labels
A-pinArea: PinArea: PinC-bugCategory: This is a bug.Category: This is a bug.P-lowLow priorityLow 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-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Milestone
Metadata
Metadata
Assignees
Labels
A-pinArea: PinArea: PinC-bugCategory: This is a bug.Category: This is a bug.P-lowLow priorityLow 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-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.regression-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.
Code
I tried this code:
I expected to see this happen: The code compiles
Instead, this happened (when compiled with beta rust):
See also #140126, which is about the fact that
&mutreferences to empty arrays are, for some reason, sometimes allowed in const contexts.This was found while messing around. I don't know if any code relies on this.
Version it worked on
It most recently worked on: stable Rust 1.87.0
Version with regression
The error is reproducible on the playground with
1.88.0-beta.5 (2025-06-01 645b44edd3717f02838d)The regression presumably happened due to #139114. cc @m-ou-se
@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged A-pin F-super_let