From ca3a2265e128895add622ebf3f0dad7d528065af Mon Sep 17 00:00:00 2001 From: Sebastien Tardif Date: Tue, 23 Jun 2026 22:36:06 -0700 Subject: [PATCH] ty_utils: recurse through unsafe binder ops in const expr build Wrap/unwrap unsafe binder THIR nodes do not change the constant value; build the const from the inner source expression instead of todo!. Signed-off-by: Sebastien Tardif --- compiler/rustc_ty_utils/src/consts.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 85bc9b985a277..8a2a8c6a635f0 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -51,11 +51,11 @@ fn recurse_build<'tcx>( | &ExprKind::ValueTypeAscription { source, .. } => { recurse_build(tcx, body, source, root_span)? } - &ExprKind::PlaceUnwrapUnsafeBinder { .. } - | &ExprKind::ValueUnwrapUnsafeBinder { .. } - | &ExprKind::WrapUnsafeBinder { .. } => { - todo!("FIXME(unsafe_binders)") - } + // Unsafe binder ops are transparent for const evaluation of the inner + // expression (wrap/unwrap does not change the constant value tree). + &ExprKind::PlaceUnwrapUnsafeBinder { source } + | &ExprKind::ValueUnwrapUnsafeBinder { source } + | &ExprKind::WrapUnsafeBinder { source } => recurse_build(tcx, body, source, root_span)?, &ExprKind::Literal { lit, neg } => { let sp = node.span; match tcx.at(sp).lit_to_const(LitToConstInput { lit: lit.node, ty: Some(node.ty), neg })