Skip to content

Commit 6521db1

Browse files
committed
Auto merge of #133251 - matthiaskrgr:rollup-gjeis3q, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #131904 (Stabilize const_pin_2) - #133239 (Fix LLVM target triple for `x86_64-win7-windows-msvc`) - #133241 (interpret: make typing_env field private) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1be21b3 + 28f4473 commit 6521db1

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ 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;
1516
use rustc_middle::ty::{self, Ty};
1617

1718
use self::diagnostics::{RetagCause, RetagInfo};
@@ -70,7 +71,7 @@ impl NewPermission {
7071
access: None,
7172
protector: None,
7273
}
73-
} else if pointee.is_unpin(*cx.tcx, cx.typing_env) {
74+
} else if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
7475
// A regular full mutable reference. On `FnEntry` this is `noalias` and `dereferenceable`.
7576
NewPermission::Uniform {
7677
perm: Permission::Unique,
@@ -128,7 +129,7 @@ impl NewPermission {
128129
fn from_box_ty<'tcx>(ty: Ty<'tcx>, kind: RetagKind, cx: &crate::MiriInterpCx<'tcx>) -> Self {
129130
// `ty` is not the `Box` but the field of the Box with this pointer (due to allocator handling).
130131
let pointee = ty.builtin_deref(true).unwrap();
131-
if pointee.is_unpin(*cx.tcx, cx.typing_env) {
132+
if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
132133
// A regular box. On `FnEntry` this is `noalias`, but not `dereferenceable` (hence only
133134
// a weak protector).
134135
NewPermission::Uniform {
@@ -607,7 +608,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
607608
match new_perm {
608609
NewPermission::Uniform { perm, .. } =>
609610
write!(kind_str, "{perm:?} permission").unwrap(),
610-
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env) =>
611+
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env()) =>
611612
write!(kind_str, "{freeze_perm:?} permission").unwrap(),
612613
NewPermission::FreezeSensitive { freeze_perm, nonfreeze_perm, .. } =>
613614
write!(kind_str, "{freeze_perm:?}/{nonfreeze_perm:?} permission for frozen/non-frozen parts").unwrap(),

src/borrow_tracker/tree_borrows/mod.rs

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

@@ -131,8 +132,8 @@ impl<'tcx> NewPermission {
131132
kind: RetagKind,
132133
cx: &crate::MiriInterpCx<'tcx>,
133134
) -> 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);
135+
let ty_is_freeze = pointee.is_freeze(*cx.tcx, cx.typing_env());
136+
let ty_is_unpin = pointee.is_unpin(*cx.tcx, cx.typing_env());
136137
let is_protected = kind == RetagKind::FnEntry;
137138
// As demonstrated by `tests/fail/tree_borrows/reservedim_spurious_write.rs`,
138139
// interior mutability and protectors interact poorly.
@@ -163,10 +164,10 @@ impl<'tcx> NewPermission {
163164
zero_size: bool,
164165
) -> Option<Self> {
165166
let pointee = ty.builtin_deref(true).unwrap();
166-
pointee.is_unpin(*cx.tcx, cx.typing_env).then_some(()).map(|()| {
167+
pointee.is_unpin(*cx.tcx, cx.typing_env()).then_some(()).map(|()| {
167168
// Regular `Unpin` box, give it `noalias` but only a weak protector
168169
// because it is valid to deallocate it within the function.
169-
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env);
170+
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env());
170171
let protected = kind == RetagKind::FnEntry;
171172
let initial_state = Permission::new_reserved(ty_is_freeze, protected);
172173
Self {
@@ -520,7 +521,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
520521
// Note: if we were to inline `new_reserved` below we would find out that
521522
// `ty_is_freeze` is eventually unused because it appears in a `ty_is_freeze || true`.
522523
// We are nevertheless including it here for clarity.
523-
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env);
524+
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
524525
// Retag it. With protection! That is the entire point.
525526
let new_perm = NewPermission {
526527
initial_state: Permission::new_reserved(ty_is_freeze, /* protected */ true),

src/machine.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1717
use rustc_data_structures::static_assert_size;
1818
use rustc_middle::mir;
1919
use rustc_middle::query::TyCtxtAt;
20-
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout};
20+
use rustc_middle::ty::layout::{
21+
HasTyCtxt, HasTypingEnv, LayoutCx, LayoutError, LayoutOf, TyAndLayout,
22+
};
2123
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2224
use rustc_session::config::InliningThreshold;
2325
use rustc_span::def_id::{CrateNum, DefId};
@@ -1127,9 +1129,8 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11271129
};
11281130
let info = ecx.get_alloc_info(alloc_id);
11291131
let def_ty = ecx.tcx.type_of(def_id).instantiate_identity();
1130-
let extern_decl_layout = ecx.tcx.layout_of(
1131-
ecx.typing_env.as_query_input(def_ty)
1132-
).unwrap();
1132+
let extern_decl_layout =
1133+
ecx.tcx.layout_of(ecx.typing_env().as_query_input(def_ty)).unwrap();
11331134
if extern_decl_layout.size != info.size || extern_decl_layout.align.abi != info.align {
11341135
throw_unsup_format!(
11351136
"extern static `{link_name}` has been declared as `{krate}::{name}` \

0 commit comments

Comments
 (0)