Skip to content

Commit a1f2999

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

File tree

11 files changed

+28
-26
lines changed

11 files changed

+28
-26
lines changed

Diff for: compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::bug;
77
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
88
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
99
use rustc_middle::query::TyCtxtAt;
10-
use rustc_middle::ty::layout::LayoutOf;
10+
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
1111
use rustc_middle::ty::print::with_no_trimmed_paths;
1212
use rustc_middle::ty::{self, Ty, TyCtxt};
1313
use rustc_span::def_id::LocalDefId;
@@ -30,7 +30,6 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
3030
cid: GlobalId<'tcx>,
3131
body: &'tcx mir::Body<'tcx>,
3232
) -> InterpResult<'tcx, R> {
33-
trace!(?ecx.typing_env);
3433
let tcx = *ecx.tcx;
3534
assert!(
3635
cid.promoted.is_some()
@@ -220,7 +219,7 @@ pub(super) fn op_to_const<'tcx>(
220219
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap(); // `false` = no raw ptrs
221220
debug_assert!(
222221
matches!(
223-
ecx.tcx.struct_tail_for_codegen(pointee_ty, ecx.typing_env).kind(),
222+
ecx.tcx.struct_tail_for_codegen(pointee_ty, ecx.typing_env()).kind(),
224223
ty::Str | ty::Slice(..),
225224
),
226225
"`ConstValue::Slice` is for slice-tailed types only, but got {}",

Diff for: compiler/rustc_const_eval/src/const_eval/machine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
99
use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem};
1010
use rustc_middle::mir::AssertMessage;
1111
use rustc_middle::query::TyCtxtAt;
12-
use rustc_middle::ty::layout::TyAndLayout;
12+
use rustc_middle::ty::layout::{HasTypingEnv, TyAndLayout};
1313
use rustc_middle::ty::{self, Ty, TyCtxt};
1414
use rustc_middle::{bug, mir};
1515
use rustc_span::Span;
@@ -667,7 +667,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
667667
.is_some_and(|p| !p.immutable())
668668
{
669669
// That next check is expensive, that's why we have all the guards above.
670-
let is_immutable = ty.is_freeze(*ecx.tcx, ecx.typing_env);
670+
let is_immutable = ty.is_freeze(*ecx.tcx, ecx.typing_env());
671671
let place = ecx.ref_to_mplace(val)?;
672672
let new_place = if is_immutable {
673673
place.map_provenance(CtfeProvenance::as_immutable)

Diff for: compiler/rustc_const_eval/src/interpret/eval_context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ pub struct InterpCx<'tcx, M: Machine<'tcx>> {
3939
pub tcx: TyCtxtAt<'tcx>,
4040

4141
/// The current context in case we're evaluating in a
42-
/// polymorphic context. This always uses `ty::TypingMode::PostAnalysis`
43-
pub typing_env: ty::TypingEnv<'tcx>,
42+
/// polymorphic context. This always uses `ty::TypingMode::PostAnalysis`.
43+
pub(super) typing_env: ty::TypingEnv<'tcx>,
4444

4545
/// The virtual memory system.
4646
pub memory: Memory<'tcx, M>,

Diff for: compiler/rustc_mir_transform/src/gvn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ use rustc_middle::bug;
100100
use rustc_middle::mir::interpret::GlobalAlloc;
101101
use rustc_middle::mir::visit::*;
102102
use rustc_middle::mir::*;
103-
use rustc_middle::ty::layout::LayoutOf;
103+
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
104104
use rustc_middle::ty::{self, Ty, TyCtxt};
105105
use rustc_span::DUMMY_SP;
106106
use rustc_span::def_id::DefId;
@@ -294,7 +294,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
294294
}
295295

296296
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
297-
self.ecx.typing_env
297+
self.ecx.typing_env()
298298
}
299299

300300
#[instrument(level = "trace", skip(self), ret)]

Diff for: compiler/rustc_target/src/spec/targets/x86_64_win7_windows_msvc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
88
base.vendor = "win7".into();
99

1010
Target {
11-
llvm_target: "x86_64-win7-windows-msvc".into(),
11+
llvm_target: "x86_64-pc-windows-msvc".into(),
1212
metadata: crate::spec::TargetMetadata {
1313
description: Some("64-bit Windows 7 support".into()),
1414
tier: Some(3),

Diff for: library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
#![feature(const_float_methods)]
122122
#![feature(const_heap)]
123123
#![feature(const_nonnull_new)]
124-
#![feature(const_pin_2)]
125124
#![feature(const_ptr_sub_ptr)]
126125
#![feature(const_raw_ptr_comparison)]
127126
#![feature(const_size_of_val)]

Diff for: library/core/src/pin.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,8 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
12141214
/// assert_eq!(*r, 5);
12151215
/// ```
12161216
#[inline(always)]
1217-
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
1217+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
1218+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
12181219
#[stable(feature = "pin_into_inner", since = "1.39.0")]
12191220
pub const fn into_inner(pin: Pin<Ptr>) -> Ptr {
12201221
pin.__pointer
@@ -1503,7 +1504,8 @@ impl<Ptr: Deref> Pin<Ptr> {
15031504
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
15041505
/// instead.
15051506
#[inline(always)]
1506-
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
1507+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
1508+
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
15071509
#[stable(feature = "pin_into_inner", since = "1.39.0")]
15081510
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
15091511
pin.__pointer

Diff for: library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#![feature(const_eval_select)]
2222
#![feature(const_heap)]
2323
#![feature(const_nonnull_new)]
24-
#![feature(const_pin_2)]
2524
#![feature(const_trait_impl)]
2625
#![feature(core_intrinsics)]
2726
#![feature(core_io_borrowed_buf)]

Diff for: src/tools/miri/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(),

Diff for: src/tools/miri/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),

Diff for: src/tools/miri/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)