@@ -619,7 +619,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
619
619
} ;
620
620
// Determine what it actually points to.
621
621
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 ( ) ) ;
623
623
// Mutable pointer to immutable memory is no good.
624
624
if ptr_expected_mutbl == Mutability :: Mut
625
625
&& alloc_actual_mutbl == Mutability :: Not
@@ -848,7 +848,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
848
848
if let Some ( alloc_id) = mplace. ptr ( ) . provenance . and_then ( |p| p. get_alloc_id ( ) ) {
849
849
let tcx = * self . ecx . tcx ;
850
850
// 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 ( ) ) ;
852
852
if let Some ( ( _, alloc) ) = self . ecx . memory . alloc_map . get ( alloc_id) {
853
853
assert_eq ! ( alloc. mutability, mutbl) ;
854
854
}
@@ -1085,7 +1085,9 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
1085
1085
) -> InterpResult < ' tcx > {
1086
1086
// Special check for CTFE validation, preventing `UnsafeCell` inside unions in immutable memory.
1087
1087
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
+ {
1089
1091
if !self . in_mutable_memory ( val) {
1090
1092
throw_validation_failure ! ( self . path, UnsafeCellInImmutable ) ;
1091
1093
}
0 commit comments