Remove a function argument that is always passed with the same value.
This commit is contained in:
parent
a0eb348d38
commit
09b89efa70
3 changed files with 21 additions and 46 deletions
|
@ -106,7 +106,7 @@ impl<Prov: Provenance> std::fmt::Display for ImmTy<'_, Prov> {
|
||||||
// Just print the ptr value. `pretty_print_const_scalar_ptr` would also try to
|
// Just print the ptr value. `pretty_print_const_scalar_ptr` would also try to
|
||||||
// print what is points to, which would fail since it has no access to the local
|
// print what is points to, which would fail since it has no access to the local
|
||||||
// memory.
|
// memory.
|
||||||
cx.pretty_print_const_pointer(ptr, ty, true)
|
cx.pretty_print_const_pointer(ptr, ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2776,7 +2776,7 @@ impl<'tcx> Display for ConstantKind<'tcx> {
|
||||||
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
|
ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
|
||||||
ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt, true),
|
ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt),
|
||||||
// FIXME(valtrees): Correctly print mir constants.
|
// FIXME(valtrees): Correctly print mir constants.
|
||||||
ConstantKind::Unevaluated(..) => {
|
ConstantKind::Unevaluated(..) => {
|
||||||
fmt.write_str("_")?;
|
fmt.write_str("_")?;
|
||||||
|
@ -2815,7 +2815,7 @@ fn comma_sep<'tcx>(
|
||||||
if !first {
|
if !first {
|
||||||
fmt.write_str(", ")?;
|
fmt.write_str(", ")?;
|
||||||
}
|
}
|
||||||
pretty_print_const_value(ct, ty, fmt, true)?;
|
pretty_print_const_value(ct, ty, fmt)?;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -2826,7 +2826,6 @@ fn pretty_print_const_value<'tcx>(
|
||||||
ct: ConstValue<'tcx>,
|
ct: ConstValue<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
fmt: &mut Formatter<'_>,
|
fmt: &mut Formatter<'_>,
|
||||||
print_ty: bool,
|
|
||||||
) -> fmt::Result {
|
) -> fmt::Result {
|
||||||
use crate::ty::print::PrettyPrinter;
|
use crate::ty::print::PrettyPrinter;
|
||||||
|
|
||||||
|
@ -2935,7 +2934,7 @@ fn pretty_print_const_value<'tcx>(
|
||||||
fmt.write_str(", ")?;
|
fmt.write_str(", ")?;
|
||||||
}
|
}
|
||||||
write!(fmt, "{}: ", field_def.name)?;
|
write!(fmt, "{}: ", field_def.name)?;
|
||||||
pretty_print_const_value(ct, ty, fmt, true)?;
|
pretty_print_const_value(ct, ty, fmt)?;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
fmt.write_str(" }}")?;
|
fmt.write_str(" }}")?;
|
||||||
|
@ -2945,20 +2944,13 @@ fn pretty_print_const_value<'tcx>(
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else {
|
}
|
||||||
// Fall back to debug pretty printing for invalid constants.
|
|
||||||
fmt.write_str(&format!("{:?}", ct))?;
|
|
||||||
if print_ty {
|
|
||||||
fmt.write_str(&format!(": {}", ty))?;
|
|
||||||
}
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
(ConstValue::Scalar(scalar), _) => {
|
(ConstValue::Scalar(scalar), _) => {
|
||||||
let mut cx = FmtPrinter::new(tcx, Namespace::ValueNS);
|
let mut cx = FmtPrinter::new(tcx, Namespace::ValueNS);
|
||||||
cx.print_alloc_ids = true;
|
cx.print_alloc_ids = true;
|
||||||
let ty = tcx.lift(ty).unwrap();
|
let ty = tcx.lift(ty).unwrap();
|
||||||
cx = cx.pretty_print_const_scalar(scalar, ty, print_ty)?;
|
cx = cx.pretty_print_const_scalar(scalar, ty)?;
|
||||||
fmt.write_str(&cx.into_buffer())?;
|
fmt.write_str(&cx.into_buffer())?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -2973,12 +2965,8 @@ fn pretty_print_const_value<'tcx>(
|
||||||
// their fields instead of just dumping the memory.
|
// their fields instead of just dumping the memory.
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
// fallback
|
// Fall back to debug pretty printing for invalid constants.
|
||||||
fmt.write_str(&format!("{:?}", ct))?;
|
write!(fmt, "{ct:?}: {ty}")
|
||||||
if print_ty {
|
|
||||||
fmt.write_str(&format!(": {}", ty))?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1393,11 +1393,10 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
self,
|
self,
|
||||||
scalar: Scalar,
|
scalar: Scalar,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
print_ty: bool,
|
|
||||||
) -> Result<Self::Const, Self::Error> {
|
) -> Result<Self::Const, Self::Error> {
|
||||||
match scalar {
|
match scalar {
|
||||||
Scalar::Ptr(ptr, _size) => self.pretty_print_const_scalar_ptr(ptr, ty, print_ty),
|
Scalar::Ptr(ptr, _size) => self.pretty_print_const_scalar_ptr(ptr, ty),
|
||||||
Scalar::Int(int) => self.pretty_print_const_scalar_int(int, ty, print_ty),
|
Scalar::Int(int) => self.pretty_print_const_scalar_int(int, ty, true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,7 +1404,6 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
mut self,
|
mut self,
|
||||||
ptr: Pointer,
|
ptr: Pointer,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
print_ty: bool,
|
|
||||||
) -> Result<Self::Const, Self::Error> {
|
) -> Result<Self::Const, Self::Error> {
|
||||||
define_scoped_cx!(self);
|
define_scoped_cx!(self);
|
||||||
|
|
||||||
|
@ -1459,7 +1457,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
// Any pointer values not covered by a branch above
|
// Any pointer values not covered by a branch above
|
||||||
self = self.pretty_print_const_pointer(ptr, ty, print_ty)?;
|
self = self.pretty_print_const_pointer(ptr, ty)?;
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,24 +1525,18 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
/// This is overridden for MIR printing because we only want to hide alloc ids from users, not
|
/// This is overridden for MIR printing because we only want to hide alloc ids from users, not
|
||||||
/// from MIR where it is actually useful.
|
/// from MIR where it is actually useful.
|
||||||
fn pretty_print_const_pointer<Prov: Provenance>(
|
fn pretty_print_const_pointer<Prov: Provenance>(
|
||||||
mut self,
|
self,
|
||||||
_: Pointer<Prov>,
|
_: Pointer<Prov>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
print_ty: bool,
|
|
||||||
) -> Result<Self::Const, Self::Error> {
|
) -> Result<Self::Const, Self::Error> {
|
||||||
if print_ty {
|
self.typed_value(
|
||||||
self.typed_value(
|
|mut this| {
|
||||||
|mut this| {
|
this.write_str("&_")?;
|
||||||
this.write_str("&_")?;
|
Ok(this)
|
||||||
Ok(this)
|
},
|
||||||
},
|
|this| this.print_type(ty),
|
||||||
|this| this.print_type(ty),
|
": ",
|
||||||
": ",
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
self.write_str("&_")?;
|
|
||||||
Ok(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pretty_print_byte_str(mut self, byte_str: &'tcx [u8]) -> Result<Self::Const, Self::Error> {
|
fn pretty_print_byte_str(mut self, byte_str: &'tcx [u8]) -> Result<Self::Const, Self::Error> {
|
||||||
|
@ -2156,7 +2148,6 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
self,
|
self,
|
||||||
p: Pointer<Prov>,
|
p: Pointer<Prov>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
print_ty: bool,
|
|
||||||
) -> Result<Self::Const, Self::Error> {
|
) -> Result<Self::Const, Self::Error> {
|
||||||
let print = |mut this: Self| {
|
let print = |mut this: Self| {
|
||||||
define_scoped_cx!(this);
|
define_scoped_cx!(this);
|
||||||
|
@ -2167,11 +2158,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
Ok(this)
|
Ok(this)
|
||||||
};
|
};
|
||||||
if print_ty {
|
self.typed_value(print, |this| this.print_type(ty), ": ")
|
||||||
self.typed_value(print, |this| this.print_type(ty), ": ")
|
|
||||||
} else {
|
|
||||||
print(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue