Remove useless lifetime parameter.
This commit is contained in:
parent
9ff071219b
commit
0460c92d52
25 changed files with 59 additions and 86 deletions
|
|
@ -74,7 +74,7 @@ pub(crate) fn codegen_tls_ref<'tcx>(
|
|||
pub(crate) fn eval_mir_constant<'tcx>(
|
||||
fx: &FunctionCx<'_, '_, 'tcx>,
|
||||
constant: &ConstOperand<'tcx>,
|
||||
) -> (ConstValue<'tcx>, Ty<'tcx>) {
|
||||
) -> (ConstValue, Ty<'tcx>) {
|
||||
let cv = fx.monomorphize(constant.const_);
|
||||
// This cannot fail because we checked all required_consts in advance.
|
||||
let val = cv
|
||||
|
|
@ -93,7 +93,7 @@ pub(crate) fn codegen_constant_operand<'tcx>(
|
|||
|
||||
pub(crate) fn codegen_const_value<'tcx>(
|
||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||
const_val: ConstValue<'tcx>,
|
||||
const_val: ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
) -> CValue<'tcx> {
|
||||
let layout = fx.layout_of(ty);
|
||||
|
|
@ -210,7 +210,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
|||
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),
|
||||
layout,
|
||||
),
|
||||
ConstValue::Slice { alloc_id, meta, phantom: _ } => {
|
||||
ConstValue::Slice { alloc_id, meta } => {
|
||||
let ptr = pointer_for_allocation(fx, alloc_id).get_addr(fx);
|
||||
let len = fx.bcx.ins().iconst(fx.pointer_type, meta as i64);
|
||||
CValue::by_val_pair(ptr, len, layout)
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ pub(crate) fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
pub fn asm_const_to_str<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
sp: Span,
|
||||
const_value: mir::ConstValue<'tcx>,
|
||||
const_value: mir::ConstValue,
|
||||
ty_and_layout: TyAndLayout<'tcx>,
|
||||
) -> String {
|
||||
let mir::ConstValue::Scalar(scalar) = const_value else {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
OperandRef::from_const(bx, val, ty)
|
||||
}
|
||||
|
||||
pub fn eval_mir_constant(&self, constant: &mir::ConstOperand<'tcx>) -> mir::ConstValue<'tcx> {
|
||||
pub fn eval_mir_constant(&self, constant: &mir::ConstOperand<'tcx>) -> mir::ConstValue {
|
||||
// `MirUsedCollector` visited all required_consts before codegen began, so if we got here
|
||||
// there can be no more constants that fail to evaluate.
|
||||
self.monomorphize(constant.const_)
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
|
||||
pub(crate) fn from_const<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
|
||||
bx: &mut Bx,
|
||||
val: mir::ConstValue<'tcx>,
|
||||
val: mir::ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Self {
|
||||
let layout = bx.layout_of(ty);
|
||||
|
|
@ -154,7 +154,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||
OperandValue::Immediate(llval)
|
||||
}
|
||||
ConstValue::ZeroSized => return OperandRef::zero_sized(layout),
|
||||
ConstValue::Slice { alloc_id, meta, phantom: _ } => {
|
||||
ConstValue::Slice { alloc_id, meta } => {
|
||||
let BackendRepr::ScalarPair(a_scalar, _) = layout.backend_repr else {
|
||||
bug!("from_const: invalid ScalarPair layout: {:#?}", layout);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ pub(crate) fn mk_eval_cx_to_read_const_val<'tcx>(
|
|||
pub fn mk_eval_cx_for_const_val<'tcx>(
|
||||
tcx: TyCtxtAt<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
val: mir::ConstValue<'tcx>,
|
||||
val: mir::ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Option<(CompileTimeInterpCx<'tcx>, OpTy<'tcx>)> {
|
||||
let ecx = mk_eval_cx_to_read_const_val(tcx.tcx, tcx.span, typing_env, CanAccessMutGlobal::No);
|
||||
|
|
@ -172,7 +172,7 @@ pub(super) fn op_to_const<'tcx>(
|
|||
ecx: &CompileTimeInterpCx<'tcx>,
|
||||
op: &OpTy<'tcx>,
|
||||
for_diagnostics: bool,
|
||||
) -> ConstValue<'tcx> {
|
||||
) -> ConstValue {
|
||||
// Handle ZST consistently and early.
|
||||
if op.layout.is_zst() {
|
||||
return ConstValue::ZeroSized;
|
||||
|
|
@ -243,7 +243,7 @@ pub(super) fn op_to_const<'tcx>(
|
|||
let alloc_id = prov.alloc_id();
|
||||
assert!(offset == abi::Size::ZERO, "{}", msg);
|
||||
let meta = b.to_target_usize(ecx).expect(msg);
|
||||
ConstValue::Slice { alloc_id, meta, phantom: std::marker::PhantomData }
|
||||
ConstValue::Slice { alloc_id, meta }
|
||||
}
|
||||
Immediate::Uninit => bug!("`Uninit` is not a valid value for {}", op.layout.ty),
|
||||
},
|
||||
|
|
@ -255,7 +255,7 @@ pub(crate) fn turn_into_const_value<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
constant: ConstAlloc<'tcx>,
|
||||
key: ty::PseudoCanonicalInput<'tcx, GlobalId<'tcx>>,
|
||||
) -> ConstValue<'tcx> {
|
||||
) -> ConstValue {
|
||||
let cid = key.value;
|
||||
let def_id = cid.instance.def.def_id();
|
||||
let is_static = tcx.is_static(def_id);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const VALTREE_MAX_NODES: usize = 100000;
|
|||
#[instrument(skip(tcx), level = "debug")]
|
||||
pub(crate) fn try_destructure_mir_constant_for_user_output<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
val: mir::ConstValue<'tcx>,
|
||||
val: mir::ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Option<mir::DestructuredConstant<'tcx>> {
|
||||
let typing_env = ty::TypingEnv::fully_monomorphized();
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ pub fn valtree_to_const_value<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
cv: ty::Value<'tcx>,
|
||||
) -> mir::ConstValue<'tcx> {
|
||||
) -> mir::ConstValue {
|
||||
// Basic idea: We directly construct `Scalar` values from trivial `ValTree`s
|
||||
// (those for constants with type bool, int, uint, float or char).
|
||||
// For all other types we create an `MPlace` and fill that by walking
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
//! and miri.
|
||||
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use rustc_abi::{FieldIdx, HasDataLayout, Size};
|
||||
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
|
||||
|
|
@ -129,7 +128,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
let tp_ty = instance.args.type_at(0);
|
||||
ensure_monomorphic_enough(tcx, tp_ty)?;
|
||||
let (alloc_id, meta) = alloc_type_name(tcx, tp_ty);
|
||||
let val = ConstValue::Slice { alloc_id, meta, phantom: PhantomData };
|
||||
let val = ConstValue::Slice { alloc_id, meta };
|
||||
let val = self.const_val_to_op(val, dest.layout.ty, Some(dest.layout))?;
|
||||
self.copy_op(&val, dest)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -836,7 +836,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
|
||||
pub(crate) fn const_val_to_op(
|
||||
&self,
|
||||
val_val: mir::ConstValue<'tcx>,
|
||||
val_val: mir::ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
layout: Option<TyAndLayout<'tcx>>,
|
||||
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
||||
|
|
@ -860,7 +860,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
}
|
||||
mir::ConstValue::Scalar(x) => adjust_scalar(x)?.into(),
|
||||
mir::ConstValue::ZeroSized => Immediate::Uninit,
|
||||
mir::ConstValue::Slice { alloc_id, meta, phantom: _ } => {
|
||||
mir::ConstValue::Slice { alloc_id, meta } => {
|
||||
// This is const data, no mutation allowed.
|
||||
let ptr = Pointer::new(CtfeProvenance::from(alloc_id).as_immutable(), Size::ZERO);
|
||||
Immediate::new_slice(self.global_root_pointer(ptr)?.into(), meta, self)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ pub(crate) fn const_caller_location_provider(
|
|||
file: Symbol,
|
||||
line: u32,
|
||||
col: u32,
|
||||
) -> mir::ConstValue<'_> {
|
||||
) -> mir::ConstValue {
|
||||
trace!("const_caller_location: {}:{}:{}", file, line, col);
|
||||
let mut ecx = mk_eval_cx_to_read_const_val(
|
||||
tcx,
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ macro_rules! declare_hooks {
|
|||
declare_hooks! {
|
||||
/// Tries to destructure an `mir::Const` ADT or array into its variant index
|
||||
/// and its field values. This should only be used for pretty printing.
|
||||
hook try_destructure_mir_constant_for_user_output(val: mir::ConstValue<'tcx>, ty: Ty<'tcx>) -> Option<mir::DestructuredConstant<'tcx>>;
|
||||
hook try_destructure_mir_constant_for_user_output(val: mir::ConstValue, ty: Ty<'tcx>) -> Option<mir::DestructuredConstant<'tcx>>;
|
||||
|
||||
/// Getting a &core::panic::Location referring to a span.
|
||||
hook const_caller_location(file: rustc_span::Symbol, line: u32, col: u32) -> mir::ConstValue<'tcx>;
|
||||
hook const_caller_location(file: rustc_span::Symbol, line: u32, col: u32) -> mir::ConstValue;
|
||||
|
||||
/// Returns `true` if this def is a function-like thing that is eligible for
|
||||
/// coverage instrumentation under `-Cinstrument-coverage`.
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ pub struct ConstAlloc<'tcx> {
|
|||
|
||||
/// Represents a constant value in Rust. `Scalar` and `Slice` are optimizations for
|
||||
/// array length computations, enum discriminants and the pattern matching logic.
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, TyEncodable, TyDecodable, Lift, Hash)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, TyEncodable, TyDecodable, Hash)]
|
||||
#[derive(HashStable)]
|
||||
pub enum ConstValue<'tcx> {
|
||||
pub enum ConstValue {
|
||||
/// Used for types with `layout::abi::Scalar` ABI.
|
||||
///
|
||||
/// Not using the enum `Value` to encode that this must not be `Uninit`.
|
||||
|
|
@ -54,7 +54,6 @@ pub enum ConstValue<'tcx> {
|
|||
/// The metadata field of the reference.
|
||||
/// This is a "target usize", so we use `u64` as in the interpreter.
|
||||
meta: u64,
|
||||
phantom: std::marker::PhantomData<&'tcx ()>,
|
||||
},
|
||||
|
||||
/// A value not representable by the other variants; needs to be stored in-memory.
|
||||
|
|
@ -74,9 +73,9 @@ pub enum ConstValue<'tcx> {
|
|||
}
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
rustc_data_structures::static_assert_size!(ConstValue<'_>, 24);
|
||||
rustc_data_structures::static_assert_size!(ConstValue, 24);
|
||||
|
||||
impl ConstValue<'_> {
|
||||
impl ConstValue {
|
||||
#[inline]
|
||||
pub fn try_to_scalar(&self) -> Option<Scalar> {
|
||||
match *self {
|
||||
|
|
@ -139,7 +138,7 @@ impl ConstValue<'_> {
|
|||
ConstValue::Scalar(_) | ConstValue::ZeroSized => {
|
||||
bug!("`try_get_slice_bytes` on non-slice constant")
|
||||
}
|
||||
&ConstValue::Slice { alloc_id, meta, phantom: _ } => (alloc_id, 0, meta),
|
||||
&ConstValue::Slice { alloc_id, meta } => (alloc_id, 0, meta),
|
||||
&ConstValue::Indirect { alloc_id, offset } => {
|
||||
// The reference itself is stored behind an indirection.
|
||||
// Load the reference, and then load the actual slice contents.
|
||||
|
|
@ -192,7 +191,7 @@ impl ConstValue<'_> {
|
|||
ConstValue::Scalar(Scalar::Ptr(..)) => return true,
|
||||
// It's hard to find out the part of the allocation we point to;
|
||||
// just conservatively check everything.
|
||||
ConstValue::Slice { alloc_id, meta: _, phantom: _ } => {
|
||||
ConstValue::Slice { alloc_id, meta: _ } => {
|
||||
!tcx.global_alloc(alloc_id).unwrap_memory().inner().provenance().ptrs().is_empty()
|
||||
}
|
||||
ConstValue::Indirect { alloc_id, offset } => !tcx
|
||||
|
|
@ -252,7 +251,7 @@ pub enum Const<'tcx> {
|
|||
|
||||
/// This constant cannot go back into the type system, as it represents
|
||||
/// something the type system cannot handle (e.g. pointers).
|
||||
Val(ConstValue<'tcx>, Ty<'tcx>),
|
||||
Val(ConstValue, Ty<'tcx>),
|
||||
}
|
||||
|
||||
impl<'tcx> Const<'tcx> {
|
||||
|
|
@ -348,7 +347,7 @@ impl<'tcx> Const<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
span: Span,
|
||||
) -> Result<ConstValue<'tcx>, ErrorHandled> {
|
||||
) -> Result<ConstValue, ErrorHandled> {
|
||||
match self {
|
||||
Const::Ty(_, c) => {
|
||||
if c.has_non_region_param() {
|
||||
|
|
@ -445,7 +444,7 @@ impl<'tcx> Const<'tcx> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_value(val: ConstValue<'tcx>, ty: Ty<'tcx>) -> Self {
|
||||
pub fn from_value(val: ConstValue, ty: Ty<'tcx>) -> Self {
|
||||
Self::Val(val, ty)
|
||||
}
|
||||
|
||||
|
|
@ -578,7 +577,7 @@ impl<'tcx> Display for Const<'tcx> {
|
|||
/// Const-related utilities
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn span_as_caller_location(self, span: Span) -> ConstValue<'tcx> {
|
||||
pub fn span_as_caller_location(self, span: Span) -> ConstValue {
|
||||
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
||||
let caller = self.sess.source_map().lookup_char_pos(topmost.lo());
|
||||
self.const_caller_location(
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ impl<'tcx> ValTreeCreationError<'tcx> {
|
|||
|
||||
pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled>;
|
||||
pub type EvalStaticInitializerRawResult<'tcx> = Result<ConstAllocation<'tcx>, ErrorHandled>;
|
||||
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
|
||||
pub type EvalToConstValueResult<'tcx> = Result<ConstValue, ErrorHandled>;
|
||||
pub type EvalToValTreeResult<'tcx> = Result<ValTree<'tcx>, ValTreeCreationError<'tcx>>;
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
|
|
|
|||
|
|
@ -1465,7 +1465,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
|||
self.push(&format!("+ user_ty: {user_ty:?}"));
|
||||
}
|
||||
|
||||
let fmt_val = |val: ConstValue<'tcx>, ty: Ty<'tcx>| {
|
||||
let fmt_val = |val: ConstValue, ty: Ty<'tcx>| {
|
||||
let tcx = self.tcx;
|
||||
rustc_data_structures::make_display(move |fmt| {
|
||||
pretty_print_const_value_tcx(tcx, val, ty, fmt)
|
||||
|
|
@ -1562,7 +1562,7 @@ pub fn write_allocations<'tcx>(
|
|||
alloc.inner().provenance().ptrs().values().map(|p| p.alloc_id())
|
||||
}
|
||||
|
||||
fn alloc_id_from_const_val(val: ConstValue<'_>) -> Option<AllocId> {
|
||||
fn alloc_id_from_const_val(val: ConstValue) -> Option<AllocId> {
|
||||
match val {
|
||||
ConstValue::Scalar(interpret::Scalar::Ptr(ptr, _)) => Some(ptr.provenance.alloc_id()),
|
||||
ConstValue::Scalar(interpret::Scalar::Int { .. }) => None,
|
||||
|
|
@ -1881,7 +1881,7 @@ fn pretty_print_byte_str(fmt: &mut Formatter<'_>, byte_str: &[u8]) -> fmt::Resul
|
|||
fn comma_sep<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
fmt: &mut Formatter<'_>,
|
||||
elems: Vec<(ConstValue<'tcx>, Ty<'tcx>)>,
|
||||
elems: Vec<(ConstValue, Ty<'tcx>)>,
|
||||
) -> fmt::Result {
|
||||
let mut first = true;
|
||||
for (ct, ty) in elems {
|
||||
|
|
@ -1896,7 +1896,7 @@ fn comma_sep<'tcx>(
|
|||
|
||||
fn pretty_print_const_value_tcx<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ct: ConstValue<'tcx>,
|
||||
ct: ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
fmt: &mut Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
|
|
@ -1943,7 +1943,7 @@ fn pretty_print_const_value_tcx<'tcx>(
|
|||
let ct = tcx.lift(ct).unwrap();
|
||||
let ty = tcx.lift(ty).unwrap();
|
||||
if let Some(contents) = tcx.try_destructure_mir_constant_for_user_output(ct, ty) {
|
||||
let fields: Vec<(ConstValue<'_>, Ty<'_>)> = contents.fields.to_vec();
|
||||
let fields: Vec<(ConstValue, Ty<'_>)> = contents.fields.to_vec();
|
||||
match *ty.kind() {
|
||||
ty::Array(..) => {
|
||||
fmt.write_str("[")?;
|
||||
|
|
@ -2024,7 +2024,7 @@ fn pretty_print_const_value_tcx<'tcx>(
|
|||
}
|
||||
|
||||
pub(crate) fn pretty_print_const_value<'tcx>(
|
||||
ct: ConstValue<'tcx>,
|
||||
ct: ConstValue,
|
||||
ty: Ty<'tcx>,
|
||||
fmt: &mut Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
|
|
|
|||
|
|
@ -173,5 +173,5 @@ pub enum AnnotationSource {
|
|||
#[derive(Copy, Clone, Debug, HashStable)]
|
||||
pub struct DestructuredConstant<'tcx> {
|
||||
pub variant: Option<VariantIdx>,
|
||||
pub fields: &'tcx [(ConstValue<'tcx>, Ty<'tcx>)],
|
||||
pub fields: &'tcx [(ConstValue, Ty<'tcx>)],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,8 +153,8 @@ impl EraseType for Result<mir::ConstAlloc<'_>, mir::interpret::ErrorHandled> {
|
|||
type Result = [u8; size_of::<Result<mir::ConstAlloc<'static>, mir::interpret::ErrorHandled>>()];
|
||||
}
|
||||
|
||||
impl EraseType for Result<mir::ConstValue<'_>, mir::interpret::ErrorHandled> {
|
||||
type Result = [u8; size_of::<Result<mir::ConstValue<'static>, mir::interpret::ErrorHandled>>()];
|
||||
impl EraseType for Result<mir::ConstValue, mir::interpret::ErrorHandled> {
|
||||
type Result = [u8; size_of::<Result<mir::ConstValue, mir::interpret::ErrorHandled>>()];
|
||||
}
|
||||
|
||||
impl EraseType for EvalToValTreeResult<'_> {
|
||||
|
|
@ -301,6 +301,7 @@ trivial! {
|
|||
rustc_middle::middle::resolve_bound_vars::ResolvedArg,
|
||||
rustc_middle::middle::stability::DeprecationEntry,
|
||||
rustc_middle::mir::ConstQualifs,
|
||||
rustc_middle::mir::ConstValue,
|
||||
rustc_middle::mir::interpret::AllocId,
|
||||
rustc_middle::mir::interpret::CtfeProvenance,
|
||||
rustc_middle::mir::interpret::ErrorHandled,
|
||||
|
|
@ -362,7 +363,6 @@ tcx_lifetime! {
|
|||
rustc_middle::mir::Const,
|
||||
rustc_middle::mir::DestructuredConstant,
|
||||
rustc_middle::mir::ConstAlloc,
|
||||
rustc_middle::mir::ConstValue,
|
||||
rustc_middle::mir::interpret::GlobalId,
|
||||
rustc_middle::mir::interpret::LitToConstInput,
|
||||
rustc_middle::mir::interpret::EvalStaticInitializerRawResult,
|
||||
|
|
|
|||
|
|
@ -1363,7 +1363,7 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
/// Converts a type-level constant value into a MIR constant value.
|
||||
query valtree_to_const_val(key: ty::Value<'tcx>) -> mir::ConstValue<'tcx> {
|
||||
query valtree_to_const_val(key: ty::Value<'tcx>) -> mir::ConstValue {
|
||||
desc { "converting type-level constant value to MIR constant value"}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ TrivialLiftImpls! {
|
|||
rustc_abi::ExternAbi,
|
||||
rustc_abi::Size,
|
||||
rustc_hir::Safety,
|
||||
rustc_middle::mir::ConstValue,
|
||||
rustc_type_ir::BoundConstness,
|
||||
rustc_type_ir::PredicatePolarity,
|
||||
// tidy-alphabetical-end
|
||||
|
|
@ -251,7 +252,7 @@ TrivialTypeTraversalImpls! {
|
|||
crate::mir::BlockTailInfo,
|
||||
crate::mir::BorrowKind,
|
||||
crate::mir::CastKind,
|
||||
crate::mir::ConstValue<'tcx>,
|
||||
crate::mir::ConstValue,
|
||||
crate::mir::CoroutineSavedLocal,
|
||||
crate::mir::FakeReadCause,
|
||||
crate::mir::Local,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
//! See docs in build/expr/mod.rs
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use rustc_abi::Size;
|
||||
use rustc_ast as ast;
|
||||
use rustc_hir::LangItem;
|
||||
|
|
@ -125,11 +123,7 @@ fn lit_to_mir_constant<'tcx>(tcx: TyCtxt<'tcx>, lit_input: LitToConstInput<'tcx>
|
|||
let s = s.as_str().as_bytes();
|
||||
let len = s.len();
|
||||
let allocation = tcx.allocate_bytes_dedup(s, CTFE_ALLOC_SALT);
|
||||
ConstValue::Slice {
|
||||
alloc_id: allocation,
|
||||
meta: len.try_into().unwrap(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
ConstValue::Slice { alloc_id: allocation, meta: len.try_into().unwrap() }
|
||||
}
|
||||
(ast::LitKind::ByteStr(byte_sym, _), ty::Ref(_, inner_ty, _))
|
||||
if matches!(inner_ty.kind(), ty::Slice(_)) =>
|
||||
|
|
@ -137,11 +131,7 @@ fn lit_to_mir_constant<'tcx>(tcx: TyCtxt<'tcx>, lit_input: LitToConstInput<'tcx>
|
|||
let data = byte_sym.as_byte_str();
|
||||
let len = data.len();
|
||||
let allocation = tcx.allocate_bytes_dedup(data, CTFE_ALLOC_SALT);
|
||||
ConstValue::Slice {
|
||||
alloc_id: allocation,
|
||||
meta: len.try_into().unwrap(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
ConstValue::Slice { alloc_id: allocation, meta: len.try_into().unwrap() }
|
||||
}
|
||||
(ast::LitKind::ByteStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => {
|
||||
let id = tcx.allocate_bytes_dedup(byte_sym.as_byte_str(), CTFE_ALLOC_SALT);
|
||||
|
|
@ -152,11 +142,7 @@ fn lit_to_mir_constant<'tcx>(tcx: TyCtxt<'tcx>, lit_input: LitToConstInput<'tcx>
|
|||
let data = byte_sym.as_byte_str();
|
||||
let len = data.len();
|
||||
let allocation = tcx.allocate_bytes_dedup(data, CTFE_ALLOC_SALT);
|
||||
ConstValue::Slice {
|
||||
alloc_id: allocation,
|
||||
meta: len.try_into().unwrap(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
ConstValue::Slice { alloc_id: allocation, meta: len.try_into().unwrap() }
|
||||
}
|
||||
(ast::LitKind::Byte(n), ty::Uint(ty::UintTy::U8)) => {
|
||||
ConstValue::Scalar(Scalar::from_uint(n, Size::from_bytes(1)))
|
||||
|
|
|
|||
|
|
@ -1045,11 +1045,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_float_into_constval<'tcx>(
|
||||
num: Symbol,
|
||||
float_ty: ty::FloatTy,
|
||||
neg: bool,
|
||||
) -> Option<ConstValue<'tcx>> {
|
||||
fn parse_float_into_constval(num: Symbol, float_ty: ty::FloatTy, neg: bool) -> Option<ConstValue> {
|
||||
parse_float_into_scalar(num, float_ty, neg).map(|s| ConstValue::Scalar(s.into()))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1542,7 +1542,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
fn op_to_prop_const<'tcx>(
|
||||
ecx: &mut InterpCx<'tcx, DummyMachine>,
|
||||
op: &OpTy<'tcx>,
|
||||
) -> Option<ConstValue<'tcx>> {
|
||||
) -> Option<ConstValue> {
|
||||
// Do not attempt to propagate unsized locals.
|
||||
if op.layout.is_unsized() {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -659,10 +659,7 @@ impl<'a, 'tcx> MirUsedCollector<'a, 'tcx> {
|
|||
}
|
||||
|
||||
/// Evaluates a *not yet monomorphized* constant.
|
||||
fn eval_constant(
|
||||
&mut self,
|
||||
constant: &mir::ConstOperand<'tcx>,
|
||||
) -> Option<mir::ConstValue<'tcx>> {
|
||||
fn eval_constant(&mut self, constant: &mir::ConstOperand<'tcx>) -> Option<mir::ConstValue> {
|
||||
let const_ = self.monomorphize(constant.const_);
|
||||
// Evaluate the constant. This makes const eval failure a collection-time error (rather than
|
||||
// a codegen-time error). rustc stops after collection if there was an error, so this
|
||||
|
|
@ -1355,17 +1352,15 @@ fn visit_mentioned_item<'tcx>(
|
|||
#[instrument(skip(tcx, output), level = "debug")]
|
||||
fn collect_const_value<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
value: mir::ConstValue<'tcx>,
|
||||
value: mir::ConstValue,
|
||||
output: &mut MonoItems<'tcx>,
|
||||
) {
|
||||
match value {
|
||||
mir::ConstValue::Scalar(Scalar::Ptr(ptr, _size)) => {
|
||||
collect_alloc(tcx, ptr.provenance.alloc_id(), output)
|
||||
}
|
||||
mir::ConstValue::Indirect { alloc_id, .. } => collect_alloc(tcx, alloc_id, output),
|
||||
mir::ConstValue::Slice { alloc_id, meta: _, phantom: _ } => {
|
||||
collect_alloc(tcx, alloc_id, output);
|
||||
}
|
||||
mir::ConstValue::Indirect { alloc_id, .. }
|
||||
| mir::ConstValue::Slice { alloc_id, meta: _ } => collect_alloc(tcx, alloc_id, output),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ fn new_empty_allocation(align: Align) -> Allocation {
|
|||
#[allow(rustc::usage_of_qualified_ty)]
|
||||
pub(crate) fn new_allocation<'tcx>(
|
||||
ty: rustc_middle::ty::Ty<'tcx>,
|
||||
const_value: ConstValue<'tcx>,
|
||||
const_value: ConstValue,
|
||||
tables: &mut Tables<'tcx, BridgeTys>,
|
||||
cx: &CompilerCtxt<'tcx, BridgeTys>,
|
||||
) -> Allocation {
|
||||
|
|
@ -44,7 +44,7 @@ pub(crate) fn new_allocation<'tcx>(
|
|||
#[allow(rustc::usage_of_qualified_ty)]
|
||||
pub(crate) fn try_new_allocation<'tcx>(
|
||||
ty: rustc_middle::ty::Ty<'tcx>,
|
||||
const_value: ConstValue<'tcx>,
|
||||
const_value: ConstValue,
|
||||
tables: &mut Tables<'tcx, BridgeTys>,
|
||||
cx: &CompilerCtxt<'tcx, BridgeTys>,
|
||||
) -> Result<Allocation, Error> {
|
||||
|
|
@ -54,7 +54,7 @@ pub(crate) fn try_new_allocation<'tcx>(
|
|||
alloc::try_new_scalar(layout, scalar, cx).map(|alloc| alloc.stable(tables, cx))
|
||||
}
|
||||
ConstValue::ZeroSized => Ok(new_empty_allocation(layout.align.abi)),
|
||||
ConstValue::Slice { alloc_id, meta, phantom: _ } => {
|
||||
ConstValue::Slice { alloc_id, meta } => {
|
||||
alloc::try_new_slice(layout, alloc_id, meta, cx).map(|alloc| alloc.stable(tables, cx))
|
||||
}
|
||||
ConstValue::Indirect { alloc_id, offset } => {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> {
|
|||
self.tcx.coroutine_movability(def_id)
|
||||
}
|
||||
|
||||
pub fn valtree_to_const_val(&self, key: ty::Value<'tcx>) -> ConstValue<'tcx> {
|
||||
pub fn valtree_to_const_val(&self, key: ty::Value<'tcx>) -> ConstValue {
|
||||
self.tcx.valtree_to_const_val(key)
|
||||
}
|
||||
|
||||
|
|
@ -675,10 +675,7 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> {
|
|||
}
|
||||
|
||||
/// Try to evaluate an instance into a constant.
|
||||
pub fn eval_instance(
|
||||
&self,
|
||||
instance: ty::Instance<'tcx>,
|
||||
) -> Result<ConstValue<'tcx>, ErrorHandled> {
|
||||
pub fn eval_instance(&self, instance: ty::Instance<'tcx>) -> Result<ConstValue, ErrorHandled> {
|
||||
self.tcx.const_eval_instance(
|
||||
self.fully_monomorphized(),
|
||||
instance,
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ impl<'tcx> NonCopyConst<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
typing_env: TypingEnv<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
val: ConstValue<'tcx>,
|
||||
val: ConstValue,
|
||||
) -> Result<bool, ()> {
|
||||
let ty = tcx.try_normalize_erasing_regions(typing_env, ty).unwrap_or(ty);
|
||||
match self.is_ty_freeze(tcx, typing_env, ty) {
|
||||
|
|
@ -477,7 +477,7 @@ impl<'tcx> NonCopyConst<'tcx> {
|
|||
typing_env: TypingEnv<'tcx>,
|
||||
typeck: &'tcx TypeckResults<'tcx>,
|
||||
mut src_expr: &'tcx Expr<'tcx>,
|
||||
mut val: ConstValue<'tcx>,
|
||||
mut val: ConstValue,
|
||||
) -> Result<Option<BorrowSource<'tcx>>, ()> {
|
||||
let mut parents = tcx.hir_parent_iter(src_expr.hir_id);
|
||||
let mut ty = typeck.expr_ty(src_expr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue