about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-03-11 03:47:19 -0400
committerGitHub <noreply@github.com>2024-03-11 03:47:19 -0400
commit221402e86301a9680f6c0dbee197ce83b0ff99e3 (patch)
tree22c08a1526d62408785186959051e70408c930b3
parent01affeb53a32f2e29bb90ebd3eff4c4c687e6746 (diff)
parenta11756ca757e37aa19fb5101aa44f8c82cd17d81 (diff)
downloadrust-221402e86301a9680f6c0dbee197ce83b0ff99e3.tar.gz
rust-221402e86301a9680f6c0dbee197ce83b0ff99e3.zip
Rollup merge of #121840 - oli-obk:freeze, r=dtolnay
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of https://github.com/rust-lang/rust/pull/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: https://github.com/google/zerocopy/issues/941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
-rw-r--r--example/mini_core.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs
index 67a0d0dabea..39988cf64e5 100644
--- a/example/mini_core.rs
+++ b/example/mini_core.rs
@@ -8,6 +8,7 @@
     rustc_attrs,
     transparent_unions,
     auto_traits,
+    freeze_impls,
     thread_local
 )]
 #![no_core]