From 62570c234960b8b6f89ee68edb6c6ce2d0527905 Mon Sep 17 00:00:00 2001 From: Mohammad Date: Fri, 17 Oct 2025 05:19:26 +0330 Subject: [PATCH] Fix UnwrapUnsafeBinder handling in borrow conflict detection Replace `todo!()` with proper conflict analysis for `UnwrapUnsafeBinder` projection elements in `places_conflict.rs`. `UnwrapUnsafeBinder` is treated as a transparent wrapper that doesn't affect place aliasing, returning `EqualOrDisjoint` when both projections match. --- compiler/rustc_borrowck/src/places_conflict.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_borrowck/src/places_conflict.rs b/compiler/rustc_borrowck/src/places_conflict.rs index 60676ac6b8644..d4e8da9766fa1 100644 --- a/compiler/rustc_borrowck/src/places_conflict.rs +++ b/compiler/rustc_borrowck/src/places_conflict.rs @@ -504,6 +504,11 @@ fn place_projection_conflict<'tcx>( debug!("place_element_conflict: DISJOINT-OR-EQ-SLICE-SUBSLICES"); Overlap::EqualOrDisjoint } + (ProjectionElem::UnwrapUnsafeBinder(_), ProjectionElem::UnwrapUnsafeBinder(_)) => { + // UnwrapUnsafeBinder is a transparent wrapper that doesn't affect aliasing + debug!("place_element_conflict: DISJOINT-OR-EQ-UNWRAP-UNSAFE-BINDER"); + Overlap::EqualOrDisjoint + } ( ProjectionElem::Deref | ProjectionElem::Field(..) @@ -511,16 +516,13 @@ fn place_projection_conflict<'tcx>( | ProjectionElem::ConstantIndex { .. } | ProjectionElem::OpaqueCast { .. } | ProjectionElem::Subslice { .. } - | ProjectionElem::Downcast(..), + | ProjectionElem::Downcast(..) + | ProjectionElem::UnwrapUnsafeBinder(_), _, ) => bug!( "mismatched projections in place_element_conflict: {:?} and {:?}", pi1_elem, pi2_elem ), - - (ProjectionElem::UnwrapUnsafeBinder(_), _) => { - todo!() - } } }