https://gcc.gnu.org/g:f5e0d1e3f41c688a7dd618ee84fa22ddb4471d63
commit r17-4093-gf5e0d1e3f41c688a7dd618ee84fa22ddb4471d63 Author: Arthur Cohen <[email protected]> Date: Fri Aug 7 17:07:37 2026 +0200 gccrs: lang-items: Register freeze 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. Diff: --- gcc/rust/util/rust-lang-item.cc | 1 + gcc/rust/util/rust-lang-item.h | 1 + gcc/testsuite/rust/compile/freeze-lang-item.rs | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc index e7bcc8f8e482..a2b9192647a8 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 c1fd45d043db..317f17a2b1aa 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 000000000000..d61df798d29d --- /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 {} +
