1
Fork 0

interpret: make typing_env field private

This commit is contained in:
Ralf Jung 2024-11-20 11:05:53 +01:00
parent 70e814bd9e
commit d04088fa36
7 changed files with 23 additions and 21 deletions

View file

@ -7,7 +7,7 @@ use rustc_middle::bug;
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
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::{self, Ty, TyCtxt};
use rustc_span::def_id::LocalDefId;
@ -30,7 +30,6 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
cid: GlobalId<'tcx>,
body: &'tcx mir::Body<'tcx>,
) -> InterpResult<'tcx, R> {
trace!(?ecx.typing_env);
let tcx = *ecx.tcx;
assert!(
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
debug_assert!(
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(..),
),
"`ConstValue::Slice` is for slice-tailed types only, but got {}",

View file

@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem};
use rustc_middle::mir::AssertMessage;
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::{bug, mir};
use rustc_span::Span;
@ -667,7 +667,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
.is_some_and(|p| !p.immutable())
{
// 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 new_place = if is_immutable {
place.map_provenance(CtfeProvenance::as_immutable)

View file

@ -39,8 +39,8 @@ pub struct InterpCx<'tcx, M: Machine<'tcx>> {
pub tcx: TyCtxtAt<'tcx>,
/// The current context in case we're evaluating in a
/// polymorphic context. This always uses `ty::TypingMode::PostAnalysis`
pub typing_env: ty::TypingEnv<'tcx>,
/// polymorphic context. This always uses `ty::TypingMode::PostAnalysis`.
pub(super) typing_env: ty::TypingEnv<'tcx>,
/// The virtual memory system.
pub memory: Memory<'tcx, M>,