@@ -619,7 +619,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
619619 } ;
620620 // Determine what it actually points to.
621621 let alloc_actual_mutbl =
622- global_alloc. mutability ( * self . ecx . tcx , self . ecx . param_env ) ;
622+ global_alloc. mutability ( * self . ecx . tcx , self . ecx . typing_env ( ) ) ;
623623 // Mutable pointer to immutable memory is no good.
624624 if ptr_expected_mutbl == Mutability :: Mut
625625 && alloc_actual_mutbl == Mutability :: Not
@@ -848,7 +848,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
848848 if let Some ( alloc_id) = mplace. ptr ( ) . provenance . and_then ( |p| p. get_alloc_id ( ) ) {
849849 let tcx = * self . ecx . tcx ;
850850 // Everything must be already interned.
851- let mutbl = tcx. global_alloc ( alloc_id) . mutability ( tcx, self . ecx . param_env ) ;
851+ let mutbl = tcx. global_alloc ( alloc_id) . mutability ( tcx, self . ecx . typing_env ( ) ) ;
852852 if let Some ( ( _, alloc) ) = self . ecx . memory . alloc_map . get ( alloc_id) {
853853 assert_eq ! ( alloc. mutability, mutbl) ;
854854 }
@@ -1085,7 +1085,9 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
10851085 ) -> InterpResult < ' tcx > {
10861086 // Special check for CTFE validation, preventing `UnsafeCell` inside unions in immutable memory.
10871087 if self . ctfe_mode . is_some_and ( |c| !c. allow_immutable_unsafe_cell ( ) ) {
1088- if !val. layout . is_zst ( ) && !val. layout . ty . is_freeze ( * self . ecx . tcx , self . ecx . param_env ) {
1088+ if !val. layout . is_zst ( )
1089+ && !val. layout . ty . is_freeze ( * self . ecx . tcx , self . ecx . typing_env ( ) )
1090+ {
10891091 if !self . in_mutable_memory ( val) {
10901092 throw_validation_failure ! ( self . path, UnsafeCellInImmutable ) ;
10911093 }
0 commit comments