mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
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
This commit is contained in:
commit
a1f2999536
@ -7,7 +7,7 @@ use rustc_middle::bug;
|
|||||||
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
|
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
|
||||||
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
|
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
|
||||||
use rustc_middle::query::TyCtxtAt;
|
use rustc_middle::query::TyCtxtAt;
|
||||||
use rustc_middle::ty::layout::LayoutOf;
|
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
|
||||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
@ -30,7 +30,6 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
|
|||||||
cid: GlobalId<'tcx>,
|
cid: GlobalId<'tcx>,
|
||||||
body: &'tcx mir::Body<'tcx>,
|
body: &'tcx mir::Body<'tcx>,
|
||||||
) -> InterpResult<'tcx, R> {
|
) -> InterpResult<'tcx, R> {
|
||||||
trace!(?ecx.typing_env);
|
|
||||||
let tcx = *ecx.tcx;
|
let tcx = *ecx.tcx;
|
||||||
assert!(
|
assert!(
|
||||||
cid.promoted.is_some()
|
cid.promoted.is_some()
|
||||||
@ -220,7 +219,7 @@ pub(super) fn op_to_const<'tcx>(
|
|||||||
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap(); // `false` = no raw ptrs
|
let pointee_ty = imm.layout.ty.builtin_deref(false).unwrap(); // `false` = no raw ptrs
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
matches!(
|
matches!(
|
||||||
ecx.tcx.struct_tail_for_codegen(pointee_ty, ecx.typing_env).kind(),
|
ecx.tcx.struct_tail_for_codegen(pointee_ty, ecx.typing_env()).kind(),
|
||||||
ty::Str | ty::Slice(..),
|
ty::Str | ty::Slice(..),
|
||||||
),
|
),
|
||||||
"`ConstValue::Slice` is for slice-tailed types only, but got {}",
|
"`ConstValue::Slice` is for slice-tailed types only, but got {}",
|
||||||
|
@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
|
|||||||
use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem};
|
use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem};
|
||||||
use rustc_middle::mir::AssertMessage;
|
use rustc_middle::mir::AssertMessage;
|
||||||
use rustc_middle::query::TyCtxtAt;
|
use rustc_middle::query::TyCtxtAt;
|
||||||
use rustc_middle::ty::layout::TyAndLayout;
|
use rustc_middle::ty::layout::{HasTypingEnv, TyAndLayout};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_middle::{bug, mir};
|
use rustc_middle::{bug, mir};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
@ -667,7 +667,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
|
|||||||
.is_some_and(|p| !p.immutable())
|
.is_some_and(|p| !p.immutable())
|
||||||
{
|
{
|
||||||
// That next check is expensive, that's why we have all the guards above.
|
// That next check is expensive, that's why we have all the guards above.
|
||||||
let is_immutable = ty.is_freeze(*ecx.tcx, ecx.typing_env);
|
let is_immutable = ty.is_freeze(*ecx.tcx, ecx.typing_env());
|
||||||
let place = ecx.ref_to_mplace(val)?;
|
let place = ecx.ref_to_mplace(val)?;
|
||||||
let new_place = if is_immutable {
|
let new_place = if is_immutable {
|
||||||
place.map_provenance(CtfeProvenance::as_immutable)
|
place.map_provenance(CtfeProvenance::as_immutable)
|
||||||
|
@ -39,8 +39,8 @@ pub struct InterpCx<'tcx, M: Machine<'tcx>> {
|
|||||||
pub tcx: TyCtxtAt<'tcx>,
|
pub tcx: TyCtxtAt<'tcx>,
|
||||||
|
|
||||||
/// The current context in case we're evaluating in a
|
/// The current context in case we're evaluating in a
|
||||||
/// polymorphic context. This always uses `ty::TypingMode::PostAnalysis`
|
/// polymorphic context. This always uses `ty::TypingMode::PostAnalysis`.
|
||||||
pub typing_env: ty::TypingEnv<'tcx>,
|
pub(super) typing_env: ty::TypingEnv<'tcx>,
|
||||||
|
|
||||||
/// The virtual memory system.
|
/// The virtual memory system.
|
||||||
pub memory: Memory<'tcx, M>,
|
pub memory: Memory<'tcx, M>,
|
||||||
|
@ -100,7 +100,7 @@ use rustc_middle::bug;
|
|||||||
use rustc_middle::mir::interpret::GlobalAlloc;
|
use rustc_middle::mir::interpret::GlobalAlloc;
|
||||||
use rustc_middle::mir::visit::*;
|
use rustc_middle::mir::visit::*;
|
||||||
use rustc_middle::mir::*;
|
use rustc_middle::mir::*;
|
||||||
use rustc_middle::ty::layout::LayoutOf;
|
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
@ -294,7 +294,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
|
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
|
||||||
self.ecx.typing_env
|
self.ecx.typing_env()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", skip(self), ret)]
|
#[instrument(level = "trace", skip(self), ret)]
|
||||||
|
@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
|
|||||||
base.vendor = "win7".into();
|
base.vendor = "win7".into();
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "x86_64-win7-windows-msvc".into(),
|
llvm_target: "x86_64-pc-windows-msvc".into(),
|
||||||
metadata: crate::spec::TargetMetadata {
|
metadata: crate::spec::TargetMetadata {
|
||||||
description: Some("64-bit Windows 7 support".into()),
|
description: Some("64-bit Windows 7 support".into()),
|
||||||
tier: Some(3),
|
tier: Some(3),
|
||||||
|
@ -121,7 +121,6 @@
|
|||||||
#![feature(const_float_methods)]
|
#![feature(const_float_methods)]
|
||||||
#![feature(const_heap)]
|
#![feature(const_heap)]
|
||||||
#![feature(const_nonnull_new)]
|
#![feature(const_nonnull_new)]
|
||||||
#![feature(const_pin_2)]
|
|
||||||
#![feature(const_ptr_sub_ptr)]
|
#![feature(const_ptr_sub_ptr)]
|
||||||
#![feature(const_raw_ptr_comparison)]
|
#![feature(const_raw_ptr_comparison)]
|
||||||
#![feature(const_size_of_val)]
|
#![feature(const_size_of_val)]
|
||||||
|
@ -1214,7 +1214,8 @@ impl<Ptr: Deref<Target: Unpin>> Pin<Ptr> {
|
|||||||
/// assert_eq!(*r, 5);
|
/// assert_eq!(*r, 5);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
|
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
|
||||||
|
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[stable(feature = "pin_into_inner", since = "1.39.0")]
|
#[stable(feature = "pin_into_inner", since = "1.39.0")]
|
||||||
pub const fn into_inner(pin: Pin<Ptr>) -> Ptr {
|
pub const fn into_inner(pin: Pin<Ptr>) -> Ptr {
|
||||||
pin.__pointer
|
pin.__pointer
|
||||||
@ -1503,7 +1504,8 @@ impl<Ptr: Deref> Pin<Ptr> {
|
|||||||
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
|
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
|
||||||
/// instead.
|
/// instead.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[rustc_const_unstable(feature = "const_pin_2", issue = "76654")]
|
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
|
||||||
|
#[rustc_const_stable(feature = "const_pin", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[stable(feature = "pin_into_inner", since = "1.39.0")]
|
#[stable(feature = "pin_into_inner", since = "1.39.0")]
|
||||||
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
|
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
|
||||||
pin.__pointer
|
pin.__pointer
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#![feature(const_eval_select)]
|
#![feature(const_eval_select)]
|
||||||
#![feature(const_heap)]
|
#![feature(const_heap)]
|
||||||
#![feature(const_nonnull_new)]
|
#![feature(const_nonnull_new)]
|
||||||
#![feature(const_pin_2)]
|
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
#![feature(core_intrinsics)]
|
#![feature(core_intrinsics)]
|
||||||
#![feature(core_io_borrowed_buf)]
|
#![feature(core_io_borrowed_buf)]
|
||||||
|
@ -12,6 +12,7 @@ use std::{cmp, mem};
|
|||||||
use rustc_abi::{BackendRepr, Size};
|
use rustc_abi::{BackendRepr, Size};
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_middle::mir::{Mutability, RetagKind};
|
use rustc_middle::mir::{Mutability, RetagKind};
|
||||||
|
use rustc_middle::ty::layout::HasTypingEnv;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
|
|
||||||
use self::diagnostics::{RetagCause, RetagInfo};
|
use self::diagnostics::{RetagCause, RetagInfo};
|
||||||
@ -70,7 +71,7 @@ impl NewPermission {
|
|||||||
access: None,
|
access: None,
|
||||||
protector: None,
|
protector: None,
|
||||||
}
|
}
|
||||||
} else if pointee.is_unpin(*cx.tcx, cx.typing_env) {
|
} else if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
|
||||||
// A regular full mutable reference. On `FnEntry` this is `noalias` and `dereferenceable`.
|
// A regular full mutable reference. On `FnEntry` this is `noalias` and `dereferenceable`.
|
||||||
NewPermission::Uniform {
|
NewPermission::Uniform {
|
||||||
perm: Permission::Unique,
|
perm: Permission::Unique,
|
||||||
@ -128,7 +129,7 @@ impl NewPermission {
|
|||||||
fn from_box_ty<'tcx>(ty: Ty<'tcx>, kind: RetagKind, cx: &crate::MiriInterpCx<'tcx>) -> Self {
|
fn from_box_ty<'tcx>(ty: Ty<'tcx>, kind: RetagKind, cx: &crate::MiriInterpCx<'tcx>) -> Self {
|
||||||
// `ty` is not the `Box` but the field of the Box with this pointer (due to allocator handling).
|
// `ty` is not the `Box` but the field of the Box with this pointer (due to allocator handling).
|
||||||
let pointee = ty.builtin_deref(true).unwrap();
|
let pointee = ty.builtin_deref(true).unwrap();
|
||||||
if pointee.is_unpin(*cx.tcx, cx.typing_env) {
|
if pointee.is_unpin(*cx.tcx, cx.typing_env()) {
|
||||||
// A regular box. On `FnEntry` this is `noalias`, but not `dereferenceable` (hence only
|
// A regular box. On `FnEntry` this is `noalias`, but not `dereferenceable` (hence only
|
||||||
// a weak protector).
|
// a weak protector).
|
||||||
NewPermission::Uniform {
|
NewPermission::Uniform {
|
||||||
@ -607,7 +608,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
match new_perm {
|
match new_perm {
|
||||||
NewPermission::Uniform { perm, .. } =>
|
NewPermission::Uniform { perm, .. } =>
|
||||||
write!(kind_str, "{perm:?} permission").unwrap(),
|
write!(kind_str, "{perm:?} permission").unwrap(),
|
||||||
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env) =>
|
NewPermission::FreezeSensitive { freeze_perm, .. } if ty.is_freeze(*this.tcx, this.typing_env()) =>
|
||||||
write!(kind_str, "{freeze_perm:?} permission").unwrap(),
|
write!(kind_str, "{freeze_perm:?} permission").unwrap(),
|
||||||
NewPermission::FreezeSensitive { freeze_perm, nonfreeze_perm, .. } =>
|
NewPermission::FreezeSensitive { freeze_perm, nonfreeze_perm, .. } =>
|
||||||
write!(kind_str, "{freeze_perm:?}/{nonfreeze_perm:?} permission for frozen/non-frozen parts").unwrap(),
|
write!(kind_str, "{freeze_perm:?}/{nonfreeze_perm:?} permission for frozen/non-frozen parts").unwrap(),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use rustc_abi::{BackendRepr, Size};
|
use rustc_abi::{BackendRepr, Size};
|
||||||
use rustc_middle::mir::{Mutability, RetagKind};
|
use rustc_middle::mir::{Mutability, RetagKind};
|
||||||
|
use rustc_middle::ty::layout::HasTypingEnv;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
|
|
||||||
@ -131,8 +132,8 @@ impl<'tcx> NewPermission {
|
|||||||
kind: RetagKind,
|
kind: RetagKind,
|
||||||
cx: &crate::MiriInterpCx<'tcx>,
|
cx: &crate::MiriInterpCx<'tcx>,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
let ty_is_freeze = pointee.is_freeze(*cx.tcx, cx.typing_env);
|
let ty_is_freeze = pointee.is_freeze(*cx.tcx, cx.typing_env());
|
||||||
let ty_is_unpin = pointee.is_unpin(*cx.tcx, cx.typing_env);
|
let ty_is_unpin = pointee.is_unpin(*cx.tcx, cx.typing_env());
|
||||||
let is_protected = kind == RetagKind::FnEntry;
|
let is_protected = kind == RetagKind::FnEntry;
|
||||||
// As demonstrated by `tests/fail/tree_borrows/reservedim_spurious_write.rs`,
|
// As demonstrated by `tests/fail/tree_borrows/reservedim_spurious_write.rs`,
|
||||||
// interior mutability and protectors interact poorly.
|
// interior mutability and protectors interact poorly.
|
||||||
@ -163,10 +164,10 @@ impl<'tcx> NewPermission {
|
|||||||
zero_size: bool,
|
zero_size: bool,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
let pointee = ty.builtin_deref(true).unwrap();
|
let pointee = ty.builtin_deref(true).unwrap();
|
||||||
pointee.is_unpin(*cx.tcx, cx.typing_env).then_some(()).map(|()| {
|
pointee.is_unpin(*cx.tcx, cx.typing_env()).then_some(()).map(|()| {
|
||||||
// Regular `Unpin` box, give it `noalias` but only a weak protector
|
// Regular `Unpin` box, give it `noalias` but only a weak protector
|
||||||
// because it is valid to deallocate it within the function.
|
// because it is valid to deallocate it within the function.
|
||||||
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env);
|
let ty_is_freeze = ty.is_freeze(*cx.tcx, cx.typing_env());
|
||||||
let protected = kind == RetagKind::FnEntry;
|
let protected = kind == RetagKind::FnEntry;
|
||||||
let initial_state = Permission::new_reserved(ty_is_freeze, protected);
|
let initial_state = Permission::new_reserved(ty_is_freeze, protected);
|
||||||
Self {
|
Self {
|
||||||
@ -520,7 +521,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
// Note: if we were to inline `new_reserved` below we would find out that
|
// Note: if we were to inline `new_reserved` below we would find out that
|
||||||
// `ty_is_freeze` is eventually unused because it appears in a `ty_is_freeze || true`.
|
// `ty_is_freeze` is eventually unused because it appears in a `ty_is_freeze || true`.
|
||||||
// We are nevertheless including it here for clarity.
|
// We are nevertheless including it here for clarity.
|
||||||
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env);
|
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
|
||||||
// Retag it. With protection! That is the entire point.
|
// Retag it. With protection! That is the entire point.
|
||||||
let new_perm = NewPermission {
|
let new_perm = NewPermission {
|
||||||
initial_state: Permission::new_reserved(ty_is_freeze, /* protected */ true),
|
initial_state: Permission::new_reserved(ty_is_freeze, /* protected */ true),
|
||||||
|
@ -17,7 +17,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||||||
use rustc_data_structures::static_assert_size;
|
use rustc_data_structures::static_assert_size;
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::query::TyCtxtAt;
|
use rustc_middle::query::TyCtxtAt;
|
||||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout};
|
use rustc_middle::ty::layout::{
|
||||||
|
HasTyCtxt, HasTypingEnv, LayoutCx, LayoutError, LayoutOf, TyAndLayout,
|
||||||
|
};
|
||||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||||
use rustc_session::config::InliningThreshold;
|
use rustc_session::config::InliningThreshold;
|
||||||
use rustc_span::def_id::{CrateNum, DefId};
|
use rustc_span::def_id::{CrateNum, DefId};
|
||||||
@ -1127,9 +1129,8 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
|||||||
};
|
};
|
||||||
let info = ecx.get_alloc_info(alloc_id);
|
let info = ecx.get_alloc_info(alloc_id);
|
||||||
let def_ty = ecx.tcx.type_of(def_id).instantiate_identity();
|
let def_ty = ecx.tcx.type_of(def_id).instantiate_identity();
|
||||||
let extern_decl_layout = ecx.tcx.layout_of(
|
let extern_decl_layout =
|
||||||
ecx.typing_env.as_query_input(def_ty)
|
ecx.tcx.layout_of(ecx.typing_env().as_query_input(def_ty)).unwrap();
|
||||||
).unwrap();
|
|
||||||
if extern_decl_layout.size != info.size || extern_decl_layout.align.abi != info.align {
|
if extern_decl_layout.size != info.size || extern_decl_layout.align.abi != info.align {
|
||||||
throw_unsup_format!(
|
throw_unsup_format!(
|
||||||
"extern static `{link_name}` has been declared as `{krate}::{name}` \
|
"extern static `{link_name}` has been declared as `{krate}::{name}` \
|
||||||
|
Loading…
Reference in New Issue
Block a user