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

Leverage core::marker::Freeze #941

Closed
jswrenn opened this issue Feb 23, 2024 · 1 comment
Closed

Leverage core::marker::Freeze #941

jswrenn opened this issue Feb 23, 2024 · 1 comment

Comments

@jswrenn
Copy link
Collaborator

jswrenn commented Feb 23, 2024

With rust-lang/rust#121501, Rust may expose and subsequently stabilize the Freeze trait, which is automatically implemented for all types free of UnsafeCell (excluding by indirection such as &UnsafeCell). This is analogous to our NoCell trait, but our trait must be explicitly derived.

Once Freeze is stabilized, we should first emit a

where
     Self: Freeze

bound on the definition of NoCell when zerocopy is compiled with sufficiently-recent toolchains.

Then, we should consider whether to eliminate our NoCell trait altogether in favor of re-exporting Freeze as NoCell.

jhpratt added a commit to jhpratt/rust that referenced this issue Mar 10, 2024
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang#121501

cc rust-lang#60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc `@RalfJung`

T-lang signed off on reexposing this unstably: rust-lang#121501 (comment)
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 11, 2024
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang#121501

cc rust-lang#60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc ``@RalfJung``

T-lang signed off on reexposing this unstably: rust-lang#121501 (comment)
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 11, 2024
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang#121501

cc rust-lang#60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: rust-lang#121501 (comment)
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 11, 2024
Rollup merge of rust-lang#121840 - oli-obk:freeze, r=dtolnay

Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang#121501

cc rust-lang#60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: rust-lang#121501 (comment)
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Mar 12, 2024
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang/rust#121501

cc #60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: rust-lang/rust#121501 (comment)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this issue Mar 16, 2024
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang/rust#121501

cc #60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: rust-lang/rust#121501 (comment)
GuillaumeGomez pushed a commit to GuillaumeGomez/rustc_codegen_gcc that referenced this issue Mar 26, 2024
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of rust-lang/rust#121501

cc #60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: google/zerocopy#941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: rust-lang/rust#121501 (comment)
@joshlf
Copy link
Member

joshlf commented May 3, 2024

We've decided that our Immutable will need to have slightly different semantics than stdlib Freeze - namely, it bans interior mutability recursively (ie, even via reference/pointer indirection), while Freeze does not. See #1155.

@joshlf joshlf closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants