Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for the Freeze trait #121675

Open
3 tasks
oli-obk opened this issue Feb 27, 2024 · 13 comments
Open
3 tasks

Tracking Issue for the Freeze trait #121675

oli-obk opened this issue Feb 27, 2024 · 13 comments
Labels
B-experimental Blocker: In-tree experiment; RFC pending, not yet approved or unneeded. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC F-freeze `#![feature(freeze)]` T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Feb 27, 2024

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

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@oli-obk oli-obk added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Feb 27, 2024
@fmease fmease added T-lang Relevant to the language team, which will review and decide on the PR/issue. B-experimental Blocker: In-tree experiment; RFC pending, not yet approved or unneeded. labels Mar 1, 2024
@RalfJung
Copy link
Member

RalfJung commented 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
Copy link
Contributor

nikomatsakis commented May 8, 2024 via email

@RalfJung
Copy link
Member

RalfJung commented May 8, 2024 via email

@nikomatsakis
Copy link
Contributor

nikomatsakis commented May 9, 2024 via email

@RalfJung
Copy link
Member

RalfJung commented 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
Copy link

Here is a stabilization RFC for this feature: rust-lang/rfcs#3633 :)

@jdonszelmann
Copy link
Contributor

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
Copy link
Member

Yeah that's basically the same case as @p-avital's

@NickGeek

This comment has been minimized.

@NickGeek

This comment has been minimized.

@RalfJung

This comment has been minimized.

@NickGeek

This comment has been minimized.

@Kyykek
Copy link

Kyykek commented Nov 25, 2024

What are the soundness implications of writing a value of generic type into a MaybeUninit buffer, promoting that (with sufficient alignment) and casting the reference back to the original type? This should be usable today as a workaround for types that have a written guarantee for their lack of interior mutability, though it might be nice if there were more guarantees like this in the standard library.

@jieyouxu jieyouxu added the F-freeze `#![feature(freeze)]` label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-experimental Blocker: In-tree experiment; RFC pending, not yet approved or unneeded. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC F-freeze `#![feature(freeze)]` T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants