https://gcc.gnu.org/g:0aa3550f06fc1ac126f7cd27f3d11ca8ee55bd59

commit r17-5714-g0aa3550f06fc1ac126f7cd27f3d11ca8ee55bd59
Author: Arthur Cohen <[email protected]>
Date:   Thu Oct 22 01:46:56 2026 +0200

    gccrs: intrinsics: Add sorry implementation for pref_align_of
    
    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.

Diff:
---
 gcc/rust/backend/rust-compile-intrinsic.cc          |  1 +
 gcc/rust/typecheck/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(+)

diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc 
b/gcc/rust/backend/rust-compile-intrinsic.cc
index 5cdee95aad81..881c03cc615f 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 9914a2928498..69424e053cef 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 e748616eba5c..1308444b895b 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 000000000000..0387e9beed50
--- /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();
+}

Reply via email to