Skip to content

Commit b3975b6

Browse files
committed
move fn is_item_raw to TypingEnv
1 parent 87ed39a commit b3975b6

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use std::{cmp, mem};
1212
use rustc_abi::{BackendRepr, Size};
1313
use rustc_data_structures::fx::FxHashSet;
1414
use rustc_middle::mir::{Mutability, RetagKind};
15-
use rustc_middle::ty::layout::HasTypingEnv;
1615
use rustc_middle::ty::{self, Ty};
1716

1817
use self::diagnostics::{RetagCause, RetagInfo};
@@ -71,7 +70,7 @@ impl NewPermission {
7170
access: None,
7271
protector: None,
7372
}
74-
} else if pointee.is_unpin(*cx.tcx, cx.param_env()) {
73+
} else if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
7574
// A regular full mutable reference. On `FnEntry` this is `noalias` and `dereferenceable`.
7675
NewPermission::Uniform {
7776
perm: Permission::Unique,
@@ -129,7 +128,7 @@ impl NewPermission {
129128
fn from_box_ty<'tcx>(ty: Ty<'tcx>, kind: RetagKind, cx: &crate::MiriInterpCx<'tcx>) -> Self {
130129
// `ty` is not the `Box` but the field of the Box with this pointer (due to allocator handling).
131130
let pointee = ty.builtin_deref(true).unwrap();
132-
if pointee.is_unpin(*cx.tcx, cx.param_env()) {
131+
if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
133132
// A regular box. On `FnEntry` this is `noalias`, but not `dereferenceable` (hence only
134133
// a weak protector).
135134
NewPermission::Uniform {
@@ -608,7 +607,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
608607
match new_perm {
609608
NewPermission::Uniform { perm, .. } =>
610609
write!(kind_str, "{perm:?} permission").unwrap(),
611-
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.param_env()) =>
610+
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env()) =>
612611
write!(kind_str, "{freeze_perm:?} permission").unwrap(),
613612
NewPermission::FreezeSensitive { freeze_perm, nonfreeze_perm, .. } =>
614613
write!(kind_str, "{freeze_perm:?}/{nonfreeze_perm:?} permission for frozen/non-frozen parts").unwrap(),

src/borrow_tracker/tree_borrows/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_abi::{BackendRepr, Size};
22
use rustc_middle::mir::{Mutability, RetagKind};
3-
use rustc_middle::ty::layout::HasTypingEnv;
43
use rustc_middle::ty::{self, Ty};
54
use rustc_span::def_id::DefId;
65

@@ -132,8 +131,8 @@ impl<'tcx> NewPermission {
132131
kind: RetagKind,
133132
cx: &crate::MiriInterpCx<'tcx>,
134133
) -> Option<Self> {
135-
let ty_is_freeze = pointee.is_freeze(*cx.tcx, cx.param_env());
136-
let ty_is_unpin = pointee.is_unpin(*cx.tcx, cx.param_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());
137136
let is_protected = kind == RetagKind::FnEntry;
138137
// As demonstrated by `tests/fail/tree_borrows/reservedim_spurious_write.rs`,
139138
// interior mutability and protectors interact poorly.
@@ -164,10 +163,10 @@ impl<'tcx> NewPermission {
164163
zero_size: bool,
165164
) -> Option<Self> {
166165
let pointee = ty.builtin_deref(true).unwrap();
167-
pointee.is_unpin(*cx.tcx, cx.param_env()).then_some(()).map(|()| {
166+
pointee.is_unpin(*cx.tcx, cx.typing_env()).then_some(()).map(|()| {
168167
// Regular `Unpin` box, give it `noalias` but only a weak protector
169168
// because it is valid to deallocate it within the function.
170-
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.param_env());
169+
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env());
171170
let protected = kind == RetagKind::FnEntry;
172171
let initial_state = Permission::new_reserved(ty_is_freeze, protected);
173172
Self {
@@ -521,7 +520,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
521520
// Note: if we were to inline `new_reserved` below we would find out that
522521
// `ty_is_freeze` is eventually unused because it appears in a `ty_is_freeze || true`.
523522
// We are nevertheless including it here for clarity.
524-
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.param_env());
523+
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
525524
// Retag it. With protection! That is the entire point.
526525
let new_perm = NewPermission {
527526
initial_state: Permission::new_reserved(ty_is_freeze, /* protected */ true),

0 commit comments

Comments
 (0)