Skip to content

Tracking Issue for the Freeze trait #121675

New issue

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

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

Already on GitHub? # to your account

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

Tracking Issue for the Freeze trait #121675

oli-obk opened this issue Feb 27, 2024 · 12 comments
Assignees
Labels
B-experimental Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize). 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 (requires FCP to stabilize). 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.

@jieyouxu jieyouxu added the F-freeze `#![feature(freeze)]` label Dec 2, 2024
github-merge-queue bot pushed a commit to rust-lang/rust-clippy that referenced this issue Feb 11, 2025
…solve `<T as Trait>::AssocT` projections (#14125)

changelog: [`declare_interior_mutable_const`,
`borrow_interior_mutable_const`]: resolve `<T as Trait>::AssocT`
projections

---

This came up during rust-lang/rust#130543 where
we have `<T as AtomicPrimitive>::Assoc = AtomicT` instead of just
`AtomicT` and clippy failed to resolve that properly.

This really needs a review, because

- I don't know if `try_normalize_erasing_regions` is the right thing to
call here.
- I'm not sure if I peel off the correct amount of `ValTree::Branch`
layers (I think I do).

Also, shouldn't this lint's infrastructure rely on `Freeze` trait
(rust-lang/rust#121675) instead of hardcoding
a list of known-to-be-interior-mutable types?

---

Previously filed this in the main rust repo
(rust-lang/rust#136369), was asked to do it here
instead
(rust-lang/rust#136369 (comment)).
@nikomatsakis nikomatsakis moved this to Exploration in Lang team features Feb 21, 2025
@nikomatsakis nikomatsakis moved this from Exploration to Needs champion in Lang team features Feb 21, 2025
@traviscross traviscross moved this from Needs champion to Exploration in Lang team features Mar 4, 2025
@traviscross traviscross self-assigned this Mar 4, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
B-experimental Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize). 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
Status: Exploration
Development

No branches or pull requests

9 participants