Skip to content

Commit 0dedd3b

Browse files
committed
InterpCx store TypingEnv instead of a ParamEnv
1 parent b3975b6 commit 0dedd3b

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl NewPermission {
7070
access: None,
7171
protector: None,
7272
}
73-
} else if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
73+
} else if pointee.is_unpin(*cx.tcx, cx.typing_env) {
7474
// A regular full mutable reference. On `FnEntry` this is `noalias` and `dereferenceable`.
7575
NewPermission::Uniform {
7676
perm: Permission::Unique,
@@ -128,7 +128,7 @@ impl NewPermission {
128128
fn from_box_ty<'tcx>(ty: Ty<'tcx>, kind: RetagKind, cx: &crate::MiriInterpCx<'tcx>) -> Self {
129129
// `ty` is not the `Box` but the field of the Box with this pointer (due to allocator handling).
130130
let pointee = ty.builtin_deref(true).unwrap();
131-
if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
131+
if pointee.is_unpin(*cx.tcx, cx.typing_env) {
132132
// A regular box. On `FnEntry` this is `noalias`, but not `dereferenceable` (hence only
133133
// a weak protector).
134134
NewPermission::Uniform {
@@ -607,7 +607,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
607607
match new_perm {
608608
NewPermission::Uniform { perm, .. } =>
609609
write!(kind_str, "{perm:?} permission").unwrap(),
610-
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env()) =>
610+
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env) =>
611611
write!(kind_str, "{freeze_perm:?} permission").unwrap(),
612612
NewPermission::FreezeSensitive { freeze_perm, nonfreeze_perm, .. } =>
613613
write!(kind_str, "{freeze_perm:?}/{nonfreeze_perm:?} permission for frozen/non-frozen parts").unwrap(),

src/borrow_tracker/tree_borrows/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ impl<'tcx> NewPermission {
131131
kind: RetagKind,
132132
cx: &crate::MiriInterpCx<'tcx>,
133133
) -> Option<Self> {
134-
let ty_is_freeze = pointee.is_freeze(*cx.tcx, cx.typing_env());
135-
let ty_is_unpin = pointee.is_unpin(*cx.tcx, cx.typing_env());
134+
let ty_is_freeze = pointee.is_freeze(*cx.tcx, cx.typing_env);
135+
let ty_is_unpin = pointee.is_unpin(*cx.tcx, cx.typing_env);
136136
let is_protected = kind == RetagKind::FnEntry;
137137
// As demonstrated by `tests/fail/tree_borrows/reservedim_spurious_write.rs`,
138138
// interior mutability and protectors interact poorly.
@@ -163,10 +163,10 @@ impl<'tcx> NewPermission {
163163
zero_size: bool,
164164
) -> Option<Self> {
165165
let pointee = ty.builtin_deref(true).unwrap();
166-
pointee.is_unpin(*cx.tcx, cx.typing_env()).then_some(()).map(|()| {
166+
pointee.is_unpin(*cx.tcx, cx.typing_env).then_some(()).map(|()| {
167167
// Regular `Unpin` box, give it `noalias` but only a weak protector
168168
// because it is valid to deallocate it within the function.
169-
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env());
169+
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env);
170170
let protected = kind == RetagKind::FnEntry;
171171
let initial_state = Permission::new_reserved(ty_is_freeze, protected);
172172
Self {
@@ -520,7 +520,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
520520
// Note: if we were to inline `new_reserved` below we would find out that
521521
// `ty_is_freeze` is eventually unused because it appears in a `ty_is_freeze || true`.
522522
// We are nevertheless including it here for clarity.
523-
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
523+
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env);
524524
// Retag it. With protection! That is the entire point.
525525
let new_perm = NewPermission {
526526
initial_state: Permission::new_reserved(ty_is_freeze, /* protected */ true),

src/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub fn create_ecx<'tcx>(
273273
let mut ecx = InterpCx::new(
274274
tcx,
275275
rustc_span::DUMMY_SP,
276-
typing_env.param_env,
276+
typing_env,
277277
MiriMachine::new(config, layout_cx)
278278
);
279279

src/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11281128
let info = ecx.get_alloc_info(alloc_id);
11291129
let def_ty = ecx.tcx.type_of(def_id).instantiate_identity();
11301130
let extern_decl_layout = ecx.tcx.layout_of(
1131-
ecx.typing_env().as_query_input(def_ty)
1131+
ecx.typing_env.as_query_input(def_ty)
11321132
).unwrap();
11331133
if extern_decl_layout.size != info.size || extern_decl_layout.align.abi != info.align {
11341134
throw_unsup_format!(

0 commit comments

Comments
 (0)