From: Arthur Cohen <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.