File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -397,7 +397,19 @@ impl<'tcx> Validator<'_, 'tcx> {
397397 }
398398
399399 BorrowKind :: Shared => {
400- let has_mut_interior = self . qualif_local :: < qualifs:: HasMutInterior > ( place. local ) ;
400+ // Let's just see what happens if we reject anything `!Freeze`...
401+ // (Except ZST which definitely can't have interior mut)
402+ let ty = place. ty ( self . body , self . tcx ) . ty ;
403+ let has_mut_interior = match ty. kind ( ) {
404+ // Empty arrays have no interior mutability no matter their element type.
405+ ty:: Array ( _elem, count)
406+ if count. try_to_target_usize ( self . tcx ) . is_some_and ( |v| v == 0 ) =>
407+ {
408+ false
409+ }
410+ // Fallback to checking `Freeze`.
411+ _ => !ty. is_freeze ( self . tcx , self . typing_env ) ,
412+ } ;
401413 if has_mut_interior {
402414 return Err ( Unpromotable ) ;
403415 }
You can’t perform that action at this time.
0 commit comments