tweak names and output and bless
This commit is contained in:
parent
ac265cdc19
commit
4e7aaf1f44
124 changed files with 241 additions and 231 deletions
|
@ -35,7 +35,7 @@ pub enum ConstValue<'tcx> {
|
|||
Scalar(Scalar),
|
||||
|
||||
/// Only used for ZSTs.
|
||||
Zst,
|
||||
ZeroSized,
|
||||
|
||||
/// 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::ZeroSized => ConstValue::ZeroSized,
|
||||
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::ZeroSized => 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::ZeroSized, 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::ZeroSized;
|
||||
Self::Val(cv, ty)
|
||||
}
|
||||
|
||||
|
@ -2772,6 +2772,13 @@ fn pretty_print_const_value<'tcx>(
|
|||
fmt.write_str(&cx.into_buffer())?;
|
||||
return Ok(());
|
||||
}
|
||||
(ConstValue::ZeroSized, ty::FnDef(d, s)) => {
|
||||
let mut cx = FmtPrinter::new(tcx, Namespace::ValueNS);
|
||||
cx.print_alloc_ids = true;
|
||||
let cx = cx.print_value_path(*d, s)?;
|
||||
fmt.write_str(&cx.into_buffer())?;
|
||||
return Ok(());
|
||||
}
|
||||
// FIXME(oli-obk): also pretty print arrays and other aggregate constants by reading
|
||||
// their fields instead of just dumping the memory.
|
||||
_ => {}
|
||||
|
|
|
@ -448,8 +448,9 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
|||
self.push(&format!("+ user_ty: {:?}", user_ty));
|
||||
}
|
||||
|
||||
// FIXME: this is a poor version of `pretty_print_const_value`.
|
||||
let fmt_val = |val: &ConstValue<'tcx>| match val {
|
||||
ConstValue::Zst => format!("ZST"),
|
||||
ConstValue::ZeroSized => format!("<ZST>"),
|
||||
ConstValue::Scalar(s) => format!("Scalar({:?})", s),
|
||||
ConstValue::Slice { .. } => format!("Slice(..)"),
|
||||
ConstValue::ByRef { .. } => format!("ByRef(..)"),
|
||||
|
@ -680,7 +681,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::ZeroSized => Either::Left(Either::Right(std::iter::empty())),
|
||||
ConstValue::ByRef { alloc, .. } | ConstValue::Slice { data: alloc, .. } => {
|
||||
Either::Right(alloc_ids_from_alloc(alloc))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue