Skip to content

Commit 4e7aaf1

Browse files
committed
tweak names and output and bless
1 parent ac265cd commit 4e7aaf1

File tree

124 files changed

+241
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+241
-231
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
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::ZeroSized => 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

Lines changed: 1 addition & 1 deletion
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::ZeroSized => {
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

Lines changed: 1 addition & 1 deletion
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::ZeroSized
161161
}
162162
}
163163
};

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 1 addition & 1 deletion
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::ZeroSized
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

Lines changed: 1 addition & 1 deletion
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::ZeroSized => 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

Lines changed: 3 additions & 3 deletions
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+
ZeroSized,
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::ZeroSized => ConstValue::ZeroSized,
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::ZeroSized => None,
7777
ConstValue::Scalar(val) => Some(val),
7878
}
7979
}

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 9 additions & 2 deletions
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::ZeroSized, 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::ZeroSized;
22002200
Self::Val(cv, ty)
22012201
}
22022202

@@ -2772,6 +2772,13 @@ fn pretty_print_const_value<'tcx>(
27722772
fmt.write_str(&cx.into_buffer())?;
27732773
return Ok(());
27742774
}
2775+
(ConstValue::ZeroSized, ty::FnDef(d, s)) => {
2776+
let mut cx = FmtPrinter::new(tcx, Namespace::ValueNS);
2777+
cx.print_alloc_ids = true;
2778+
let cx = cx.print_value_path(*d, s)?;
2779+
fmt.write_str(&cx.into_buffer())?;
2780+
return Ok(());
2781+
}
27752782
// FIXME(oli-obk): also pretty print arrays and other aggregate constants by reading
27762783
// their fields instead of just dumping the memory.
27772784
_ => {}

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
448448
self.push(&format!("+ user_ty: {:?}", user_ty));
449449
}
450450

451+
// FIXME: this is a poor version of `pretty_print_const_value`.
451452
let fmt_val = |val: &ConstValue<'tcx>| match val {
452-
ConstValue::Zst => format!("ZST"),
453+
ConstValue::ZeroSized => format!("<ZST>"),
453454
ConstValue::Scalar(s) => format!("Scalar({:?})", s),
454455
ConstValue::Slice { .. } => format!("Slice(..)"),
455456
ConstValue::ByRef { .. } => format!("ByRef(..)"),
@@ -680,7 +681,7 @@ pub fn write_allocations<'tcx>(
680681
ConstValue::Scalar(interpret::Scalar::Int { .. }) => {
681682
Either::Left(Either::Right(std::iter::empty()))
682683
}
683-
ConstValue::Zst => Either::Left(Either::Right(std::iter::empty())),
684+
ConstValue::ZeroSized => Either::Left(Either::Right(std::iter::empty())),
684685
ConstValue::ByRef { alloc, .. } | ConstValue::Slice { data: alloc, .. } => {
685686
Either::Right(alloc_ids_from_alloc(alloc))
686687
}

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

Lines changed: 1 addition & 1 deletion
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::ZeroSized, ty);
6565

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

src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.32bit.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn main() -> () {
3939
_5 = foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
4040
// mir::Constant
4141
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
42-
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
42+
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(<ZST>) }
4343
}
4444

4545
bb1: {

0 commit comments

Comments
 (0)