-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Description
Code
I tried this code:
use std::pin::{pin, Pin};
fn require_static(_: Pin<&'static mut [i32; 0]>) {}
pub fn weird() {
require_static(pin!([]));
}
I expected to see this happen: The code compiles
Instead, this happened (when compiled with beta rust):
error[E0716]: temporary value dropped while borrowed
--> src/lib.rs:6:20
|
6 | require_static(pin!([]));
| ---------------^^^^^^^^-- temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
|
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0716`.
error: could not compile `playground` (lib) due to 1 previous error
See also #140126, which is about the fact that &mut
references 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
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-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.