Skip to content

Commit ac265cd

Browse files
committed
review feedback
1 parent 052651d commit ac265cd

File tree

11 files changed

+15
-21
lines changed

11 files changed

+15
-21
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
167167
}
168168

169169
match const_val {
170-
ConstValue::ZST => unreachable!(), // we already handles ZST above
170+
ConstValue::Zst => unreachable!(), // we already handles ZST above
171171
ConstValue::Scalar(x) => match x {
172172
Scalar::Int(int) => {
173173
if fx.clif_type(layout.ty).is_some() {

compiler/rustc_codegen_ssa/src/mir/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
8484
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
8585
OperandValue::Immediate(llval)
8686
}
87-
ConstValue::ZST => {
87+
ConstValue::Zst => {
8888
let llval = bx.zst_to_backend(bx.immediate_backend_type(layout));
8989
OperandValue::Immediate(llval)
9090
}

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub(super) fn op_to_const<'tcx>(
157157
"this MPlaceTy must come from a validated constant, thus we can assume the \
158158
alignment is correct",
159159
);
160-
ConstValue::ZST
160+
ConstValue::Zst
161161
}
162162
}
163163
};

compiler/rustc_const_eval/src/const_eval/valtrees.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub fn valtree_to_const_value<'tcx>(
272272
match ty.kind() {
273273
ty::FnDef(..) => {
274274
assert!(valtree.unwrap_branch().is_empty());
275-
ConstValue::ZST
275+
ConstValue::Zst
276276
}
277277
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char => match valtree {
278278
ty::ValTree::Leaf(scalar_int) => ConstValue::Scalar(Scalar::Int(scalar_int)),

compiler/rustc_const_eval/src/interpret/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
709709
Operand::Indirect(MemPlace::from_ptr(ptr.into()))
710710
}
711711
ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x)?.into()),
712-
ConstValue::ZST => Operand::Immediate(Immediate::Uninit),
712+
ConstValue::Zst => Operand::Immediate(Immediate::Uninit),
713713
ConstValue::Slice { data, start, end } => {
714714
// We rely on mutability being set correctly in `data` to prevent writes
715715
// where none should happen.

compiler/rustc_middle/src/mir/interpret/value.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum ConstValue<'tcx> {
3535
Scalar(Scalar),
3636

3737
/// Only used for ZSTs.
38-
ZST,
38+
Zst,
3939

4040
/// Used only for `&[u8]` and `&str`
4141
Slice { data: ConstAllocation<'tcx>, start: usize, end: usize },
@@ -58,7 +58,7 @@ impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
5858
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ConstValue<'tcx>> {
5959
Some(match self {
6060
ConstValue::Scalar(s) => ConstValue::Scalar(s),
61-
ConstValue::ZST => ConstValue::ZST,
61+
ConstValue::Zst => ConstValue::Zst,
6262
ConstValue::Slice { data, start, end } => {
6363
ConstValue::Slice { data: tcx.lift(data)?, start, end }
6464
}
@@ -73,7 +73,7 @@ impl<'tcx> ConstValue<'tcx> {
7373
#[inline]
7474
pub fn try_to_scalar(&self) -> Option<Scalar<AllocId>> {
7575
match *self {
76-
ConstValue::ByRef { .. } | ConstValue::Slice { .. } | ConstValue::ZST => None,
76+
ConstValue::ByRef { .. } | ConstValue::Slice { .. } | ConstValue::Zst => None,
7777
ConstValue::Scalar(val) => Some(val),
7878
}
7979
}

compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ impl<'tcx> Operand<'tcx> {
17111711
Operand::Constant(Box::new(Constant {
17121712
span,
17131713
user_ty: None,
1714-
literal: ConstantKind::Val(ConstValue::ZST, ty),
1714+
literal: ConstantKind::Val(ConstValue::Zst, ty),
17151715
}))
17161716
}
17171717

@@ -2196,7 +2196,7 @@ impl<'tcx> ConstantKind<'tcx> {
21962196

21972197
#[inline]
21982198
pub fn zero_sized(ty: Ty<'tcx>) -> Self {
2199-
let cv = ConstValue::ZST;
2199+
let cv = ConstValue::Zst;
22002200
Self::Val(cv, ty)
22012201
}
22022202

compiler/rustc_middle/src/mir/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
449449
}
450450

451451
let fmt_val = |val: &ConstValue<'tcx>| match val {
452-
ConstValue::ZST => format!("ZST"),
452+
ConstValue::Zst => format!("ZST"),
453453
ConstValue::Scalar(s) => format!("Scalar({:?})", s),
454454
ConstValue::Slice { .. } => format!("Slice(..)"),
455455
ConstValue::ByRef { .. } => format!("ByRef(..)"),
@@ -680,7 +680,7 @@ pub fn write_allocations<'tcx>(
680680
ConstValue::Scalar(interpret::Scalar::Int { .. }) => {
681681
Either::Left(Either::Right(std::iter::empty()))
682682
}
683-
ConstValue::ZST => Either::Left(Either::Right(std::iter::empty())),
683+
ConstValue::Zst => Either::Left(Either::Right(std::iter::empty())),
684684
ConstValue::ByRef { alloc, .. } | ConstValue::Slice { data: alloc, .. } => {
685685
Either::Right(alloc_ids_from_alloc(alloc))
686686
}

compiler/rustc_middle/src/thir.rs

-6
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,6 @@ pub enum ExprKind<'tcx> {
458458
},
459459
}
460460

461-
impl<'tcx> ExprKind<'tcx> {
462-
pub fn zero_sized_literal(user_ty: Option<Canonical<'tcx, UserType<'tcx>>>) -> Self {
463-
ExprKind::ZstLiteral { user_ty }
464-
}
465-
}
466-
467461
/// Represents the association of a field identifier and an expression.
468462
///
469463
/// This is used in struct constructors.

compiler/rustc_mir_build/src/build/expr/as_constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6161
inferred_ty: ty,
6262
})
6363
});
64-
let literal = ConstantKind::Val(ConstValue::ZST, ty);
64+
let literal = ConstantKind::Val(ConstValue::Zst, ty);
6565

6666
Constant { span, user_ty: user_ty, literal }
6767
}

compiler/rustc_mir_build/src/thir/cx/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl<'tcx> Cx<'tcx> {
799799
}
800800
};
801801
let ty = self.tcx().mk_fn_def(def_id, substs);
802-
Expr { temp_lifetime, ty, span, kind: ExprKind::zero_sized_literal(user_ty) }
802+
Expr { temp_lifetime, ty, span, kind: ExprKind::ZstLiteral { user_ty } }
803803
}
804804

805805
fn convert_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) -> ArmId {
@@ -828,7 +828,7 @@ impl<'tcx> Cx<'tcx> {
828828
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
829829
| Res::SelfCtor(_) => {
830830
let user_ty = self.user_substs_applied_to_res(expr.hir_id, res);
831-
ExprKind::zero_sized_literal(user_ty)
831+
ExprKind::ZstLiteral { user_ty }
832832
}
833833

834834
Res::Def(DefKind::ConstParam, def_id) => {

0 commit comments

Comments
 (0)