[gccrs COMMIT 3/3] lang-items: Register freeze
gerris.rs@gmail.com
gerris.rs@gmail.com
Fri Aug 7 23:05:53 GMT 2026
From: Arthur Cohen <arthur.cohen@embecosm.com>
gcc/rust/ChangeLog:
* util/rust-lang-item.h: Add enum value for Freeze.
* util/rust-lang-item.cc: Register it.
gcc/testsuite/ChangeLog:
* rust/compile/freeze-lang-item.rs: New test.
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github: https://github.com/Rust-GCC/gccrs/commit/4667188af37c2a484dca82435cade18aa7ae59cd
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4770
gcc/rust/util/rust-lang-item.cc | 1 +
gcc/rust/util/rust-lang-item.h | 1 +
.../rust/compile/freeze-lang-item.rs | 25 +++++++++++++++++++
3 files changed, 27 insertions(+)
create mode 100644 gcc/testsuite/rust/compile/freeze-lang-item.rs
diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc
index e7bcc8f8e..a2b919264 100644
--- a/gcc/rust/util/rust-lang-item.cc
+++ b/gcc/rust/util/rust-lang-item.cc
@@ -65,6 +65,7 @@ const BiMap<std::string, LangItem::Kind> Rust::LangItem::lang_items = {{
{"clone", Kind::CLONE},
{"drop", Kind::DROP},
{"sized", Kind::SIZED},
+ {"freeze", Kind::FREEZE},
{"sync", Kind::SYNC},
{"slice_alloc", Kind::SLICE_ALLOC},
{"slice_u8_alloc", Kind::SLICE_U8_ALLOC},
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index c1fd45d04..317f17a2b 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -93,6 +93,7 @@ public:
CLONE,
DROP,
SIZED,
+ FREEZE,
SYNC,
// https://github.com/Rust-GCC/gccrs/issues/1896
diff --git a/gcc/testsuite/rust/compile/freeze-lang-item.rs b/gcc/testsuite/rust/compile/freeze-lang-item.rs
new file mode 100644
index 000000000..d61df798d
--- /dev/null
+++ b/gcc/testsuite/rust/compile/freeze-lang-item.rs
@@ -0,0 +1,25 @@
+#![feature(no_core)]
+#![feature(optin_builtin_traits)]
+#![feature(negative_impls)]
+#![feature(lang_items)]
+#![feature(rustc_attrs)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+#[lang = "freeze"]
+pub(crate) unsafe auto trait Freeze {}
+
+#[lang = "phantom_data"]
+pub struct PhantomData<T>;
+
+pub struct UnsafeCell<T>(T);
+
+impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
+unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
+unsafe impl<T: ?Sized> Freeze for *const T {}
+unsafe impl<T: ?Sized> Freeze for *mut T {}
+unsafe impl<T: ?Sized> Freeze for &T {}
+unsafe impl<T: ?Sized> Freeze for &mut T {}
+
--
2.54.0
More information about the Gcc-rust
mailing list