From 71875721233cdaafadc7436f0a0ec61899348e89 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Wed, 22 Jul 2026 19:45:46 +0000
Subject: [PATCH 09/30] trans: handle the renamed
 `assert_mem_uninitialized_valid` intrinsic

rustc 1.71 renamed `assert_uninit_valid`; treat both as the existing
no-op (hit by `itoa` 0.4.x's use of `mem::uninitialized` under 1.90
libcore).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011M9MvswSD3mEeJcBm6S8z7
---
 src/hir_conv/constant_evaluation.cpp | 4 ++++
 src/trans/codegen_c.cpp              | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index 039349b6..15c54ea7 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -2923,6 +2923,10 @@ namespace HIR {
                     MIR_ASSERT(state, !ty.data().is_Borrow(), "`assert_zero_valid`: Borrow cannot be zero");
                     // TODO: Other cases?
                 }
+                else if( te->name == "assert_uninit_valid" || te->name == "assert_mem_uninitialized_valid" ) {
+                    // No-op: allow `mem::uninitialized` to (unsoundly) produce any value
+                    // NOTE: `assert_mem_uninitialized_valid` is the post-1.70 name
+                }
                 else if( te->name == "is_val_statically_known" ) {
                     dst.write_uint(state, 8, e.args.at(0).is_Constant() || e.args.at(0).is_Borrow());
                 }
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 676d7a2e..a4673b7e 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -6230,8 +6230,9 @@ namespace {
             else if( name == "assert_zero_valid" ) {
                 // TODO: Detect nonzero within
             }
-            else if( name == "assert_uninit_valid" ) {
+            else if( name == "assert_uninit_valid" || name == "assert_mem_uninitialized_valid" ) {
                 // TODO: Detect nonzero or enum within
+                // NOTE: `assert_mem_uninitialized_valid` is the post-1.70 name
             }
             else if( name == "const_eval_select" ) {
                 const auto& arg_ty_tuple = params.m_types.at(0).data().as_Tuple();
-- 
2.43.0

