review feedback
This commit is contained in:
parent
052651dd13
commit
ac265cdc19
@ -167,7 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||
}
|
||||
|
||||
match const_val {
|
||||
ConstValue::ZST => unreachable!(), // we already handles ZST above
|
||||
ConstValue::Zst => unreachable!(), // we already handles ZST above
|
||||
ConstValue::Scalar(x) => match x {
|
||||
Scalar::Int(int) => {
|
||||
if fx.clif_type(layout.ty).is_some() {
|
||||
|
@ -84,7 +84,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
|
||||
OperandValue::Immediate(llval)
|
||||
}
|
||||
ConstValue::ZST => {
|
||||
ConstValue::Zst => {
|
||||
let llval = bx.zst_to_backend(bx.immediate_backend_type(layout));
|
||||
OperandValue::Immediate(llval)
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ pub(super) fn op_to_const<'tcx>(
|
||||
"this MPlaceTy must come from a validated constant, thus we can assume the \
|
||||
alignment is correct",
|
||||
);
|
||||
ConstValue::ZST
|
||||
ConstValue::Zst
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -272,7 +272,7 @@ pub fn valtree_to_const_value<'tcx>(
|
||||
match ty.kind() {
|
||||
ty::FnDef(..) => {
|
||||
assert!(valtree.unwrap_branch().is_empty());
|
||||
ConstValue::ZST
|
||||
ConstValue::Zst
|
||||
}
|
||||
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char => match valtree {
|
||||
ty::ValTree::Leaf(scalar_int) => ConstValue::Scalar(Scalar::Int(scalar_int)),
|
||||
|
@ -709,7 +709,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Operand::Indirect(MemPlace::from_ptr(ptr.into()))
|
||||
}
|
||||
ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x)?.into()),
|
||||
ConstValue::ZST => Operand::Immediate(Immediate::Uninit),
|
||||
ConstValue::Zst => Operand::Immediate(Immediate::Uninit),
|
||||
ConstValue::Slice { data, start, end } => {
|
||||
// We rely on mutability being set correctly in `data` to prevent writes
|
||||
// where none should happen.
|
||||
|
@ -35,7 +35,7 @@ pub enum ConstValue<'tcx> {
|
||||
Scalar(Scalar),
|
||||
|
||||
/// Only used for ZSTs.
|
||||
ZST,
|
||||
Zst,
|
||||
|
||||
/// Used only for `&[u8]` and `&str`
|
||||
Slice { data: ConstAllocation<'tcx>, start: usize, end: usize },
|
||||
@ -58,7 +58,7 @@ impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ConstValue<'tcx>> {
|
||||
Some(match self {
|
||||
ConstValue::Scalar(s) => ConstValue::Scalar(s),
|
||||
ConstValue::ZST => ConstValue::ZST,
|
||||
ConstValue::Zst => ConstValue::Zst,
|
||||
ConstValue::Slice { data, start, end } => {
|
||||
ConstValue::Slice { data: tcx.lift(data)?, start, end }
|
||||
}
|
||||
@ -73,7 +73,7 @@ impl<'tcx> ConstValue<'tcx> {
|
||||
#[inline]
|
||||
pub fn try_to_scalar(&self) -> Option<Scalar<AllocId>> {
|
||||
match *self {
|
||||
ConstValue::ByRef { .. } | ConstValue::Slice { .. } | ConstValue::ZST => None,
|
||||
ConstValue::ByRef { .. } | ConstValue::Slice { .. } | ConstValue::Zst => None,
|
||||
ConstValue::Scalar(val) => Some(val),
|
||||
}
|
||||
}
|
||||
|
@ -1711,7 +1711,7 @@ impl<'tcx> Operand<'tcx> {
|
||||
Operand::Constant(Box::new(Constant {
|
||||
span,
|
||||
user_ty: None,
|
||||
literal: ConstantKind::Val(ConstValue::ZST, ty),
|
||||
literal: ConstantKind::Val(ConstValue::Zst, ty),
|
||||
}))
|
||||
}
|
||||
|
||||
@ -2196,7 +2196,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||
|
||||
#[inline]
|
||||
pub fn zero_sized(ty: Ty<'tcx>) -> Self {
|
||||
let cv = ConstValue::ZST;
|
||||
let cv = ConstValue::Zst;
|
||||
Self::Val(cv, ty)
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
}
|
||||
|
||||
let fmt_val = |val: &ConstValue<'tcx>| match val {
|
||||
ConstValue::ZST => format!("ZST"),
|
||||
ConstValue::Zst => format!("ZST"),
|
||||
ConstValue::Scalar(s) => format!("Scalar({:?})", s),
|
||||
ConstValue::Slice { .. } => format!("Slice(..)"),
|
||||
ConstValue::ByRef { .. } => format!("ByRef(..)"),
|
||||
@ -680,7 +680,7 @@ pub fn write_allocations<'tcx>(
|
||||
ConstValue::Scalar(interpret::Scalar::Int { .. }) => {
|
||||
Either::Left(Either::Right(std::iter::empty()))
|
||||
}
|
||||
ConstValue::ZST => Either::Left(Either::Right(std::iter::empty())),
|
||||
ConstValue::Zst => Either::Left(Either::Right(std::iter::empty())),
|
||||
ConstValue::ByRef { alloc, .. } | ConstValue::Slice { data: alloc, .. } => {
|
||||
Either::Right(alloc_ids_from_alloc(alloc))
|
||||
}
|
||||
|
@ -458,12 +458,6 @@ pub enum ExprKind<'tcx> {
|
||||
},
|
||||
}
|
||||
|
||||
impl<'tcx> ExprKind<'tcx> {
|
||||
pub fn zero_sized_literal(user_ty: Option<Canonical<'tcx, UserType<'tcx>>>) -> Self {
|
||||
ExprKind::ZstLiteral { user_ty }
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the association of a field identifier and an expression.
|
||||
///
|
||||
/// This is used in struct constructors.
|
||||
|
@ -61,7 +61,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
inferred_ty: ty,
|
||||
})
|
||||
});
|
||||
let literal = ConstantKind::Val(ConstValue::ZST, ty);
|
||||
let literal = ConstantKind::Val(ConstValue::Zst, ty);
|
||||
|
||||
Constant { span, user_ty: user_ty, literal }
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ impl<'tcx> Cx<'tcx> {
|
||||
}
|
||||
};
|
||||
let ty = self.tcx().mk_fn_def(def_id, substs);
|
||||
Expr { temp_lifetime, ty, span, kind: ExprKind::zero_sized_literal(user_ty) }
|
||||
Expr { temp_lifetime, ty, span, kind: ExprKind::ZstLiteral { user_ty } }
|
||||
}
|
||||
|
||||
fn convert_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) -> ArmId {
|
||||
@ -828,7 +828,7 @@ impl<'tcx> Cx<'tcx> {
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::SelfCtor(_) => {
|
||||
let user_ty = self.user_substs_applied_to_res(expr.hir_id, res);
|
||||
ExprKind::zero_sized_literal(user_ty)
|
||||
ExprKind::ZstLiteral { user_ty }
|
||||
}
|
||||
|
||||
Res::Def(DefKind::ConstParam, def_id) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user