Open
Description
Feature gate: #![feature(freeze)]
This is a tracking issue for the core::marker::Freeze
trait
This trait allows generic code to restrict generic parameters to types without interior mutability.
Public API
use std::marker::Freeze;
trait Trait<T: Freeze + 'static> {
const VALUE: T;
const VALUE_REF: &'static T = &Self::VALUE;
}
Steps / History
Unresolved Questions
- naming the trait differently (see #121501 (comment))
Footnotes
Metadata
Metadata
Assignees
Labels
Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Category: An issue tracking the progress of sth. like the implementation of an RFC`#![feature(freeze)]`Relevant to the language teamRelevant to the library API team, which will review and decide on the PR/issue.
Type
Projects
Status
Exploration
Milestone
Relationships
Development
No branches or pull requests
Activity
Copy
types in aconst
context #120119RalfJung commentedon May 2, 2024
@rust-lang/lang -- quick vibe check, do you think this needs an RFC or can it be done with a writeup and FCP in this issue?
nikomatsakis commentedon May 8, 2024
RalfJung commentedon May 8, 2024
nikomatsakis commentedon May 9, 2024
RalfJung commentedon May 9, 2024
Okay, thanks.
So -- if someone wants to help push this towards stabilization, drafting an RFC would be a good next step. :)
p-avital commentedon May 10, 2024
Here is a stabilization RFC for this feature: rust-lang/rfcs#3633 :)
jdonszelmann commentedon Sep 28, 2024
I found an interesting case in which I needed
Freeze
. Currently, the diagnostics for this are very confusing (I might follow with a PR that improves that) but @WaffleLapkin said it might be nice to comment this here.not-working example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9939beef497fc78bf2951342b379cf4b
fixed using freeze: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1efad00dbd416d99abe2da4c9758e2a1
RalfJung commentedon Sep 28, 2024
Yeah that's basically the same case as @p-avital's
NickGeek commentedon Nov 19, 2024
NickGeek commentedon Nov 19, 2024
RalfJung commentedon Nov 19, 2024
NickGeek commentedon Nov 19, 2024
declare_interior_mutable_const
,borrow_interior_mutable_const
: resolve<T as Trait>::AssocT
projections rust-lang/rust-clippy#14125`declare_interior_mutable_const`, `borrow_interior_mutable_const`: re…
declare_interior_mutable_const
(andborrow_interior_mutable_const
?) should probably useFreeze
rust-lang/rust-clippy#14222