From: Arthur Cohen <[email protected]>
Unless we realize in the future that we absolutely need to implement this
intrinsic, we might
as well not do it since it got removed in 2025 - per rust-lang/rust#91971
gcc/rust/ChangeLog:
* util/rust-intrinsic-values.h: New value for pref_align_of.
* backend/rust-compile-intrinsic.cc: Add the sorry handler for it.
* typecheck/rust-hir-type-check-intrinsic.cc: Add tychk information for
it.
gcc/testsuite/ChangeLog:
* rust/compile/pref_align_of.rs: New test.
Tested on x86_64-pc-linux-gnu.
---
gcc/rust/backend/rust-compile-intrinsic.cc | 1 +
.../rust-hir-type-check-intrinsic.cc | 3 +++
gcc/rust/util/rust-intrinsic-values.h | 2 ++
gcc/testsuite/rust/compile/pref_align_of.rs | 21 +++++++++++++++++++
4 files changed, 27 insertions(+)
create mode 100644 gcc/testsuite/rust/compile/pref_align_of.rs
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc
b/gcc/rust/backend/rust-compile-intrinsic.cc
index 5cdee95aad8..881c03cc615 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -92,6 +92,7 @@ static const std::map<std::string, Intrinsic::CompileFn>
intrinsics = {
{IValue::FLOAT_TO_INT_UNCHECKED, handlers::float_to_int_unchecked},
{IValue::EXACT_DIV, handlers::exact_div_handler},
{IValue::BREAKPOINT, handlers::breakpoint},
+ {IValue::PREF_ALIGN_OF, handlers::sorry},
{IValue::ASSERT_ZERO_VALID, handlers::type_assert (TyAssert::ZeroValid)},
{IValue::ASSERT_INHABITED, handlers::type_assert (TyAssert::Inhabited)},
{IValue::ASSERT_UNINIT_VALID, handlers::type_assert (TyAssert::UninitValid)},
diff --git a/gcc/rust/typecheck/rust-hir-type-check-intrinsic.cc
b/gcc/rust/typecheck/rust-hir-type-check-intrinsic.cc
index 9914a292849..69424e053ce 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-intrinsic.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-intrinsic.cc
@@ -315,6 +315,9 @@ const std::unordered_map<std::string, IntrinsicRules>
// fn breakpoint()
{IValue::BREAKPOINT, {0, {}, IRT::Unit}},
+ // fn pref_align_of<T>()
+ {IValue::PREF_ALIGN_OF, {1, {}, IRT::Unit}},
+
// pub fn assert_zero_valid<T>();
{IValue::ASSERT_ZERO_VALID, {1, {}, IRT::Unit}},
// fn assert_inhabited<T>();
diff --git a/gcc/rust/util/rust-intrinsic-values.h
b/gcc/rust/util/rust-intrinsic-values.h
index e748616eba5..1308444b895 100644
--- a/gcc/rust/util/rust-intrinsic-values.h
+++ b/gcc/rust/util/rust-intrinsic-values.h
@@ -177,6 +177,8 @@ public:
static constexpr auto &BREAKPOINT = "breakpoint";
+ static constexpr auto &PREF_ALIGN_OF = "pref_align_of";
+
static constexpr auto &ASSERT_ZERO_VALID = "assert_zero_valid";
static constexpr auto &ASSERT_INHABITED = "assert_inhabited";
static constexpr auto &ASSERT_UNINIT_VALID = "assert_uninit_valid";
diff --git a/gcc/testsuite/rust/compile/pref_align_of.rs
b/gcc/testsuite/rust/compile/pref_align_of.rs
new file mode 100644
index 00000000000..0387e9beed5
--- /dev/null
+++ b/gcc/testsuite/rust/compile/pref_align_of.rs
@@ -0,0 +1,21 @@
+#![feature(no_core)]
+#![feature(intrinsics)]
+#![feature(lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+extern "rust-intrinsic" {
+ fn pref_align_of<T>();
+}
+
+fn foo() {
+ unsafe {
+ let _ = pref_align_of::<i32>(); // { dg-message "sorry, unimplemented"
}
+ };
+}
+
+fn main() {
+ foo();
+}
--
2.55.0