mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Use debug impl in rendering const eval result
This commit is contained in:
parent
4a444e768c
commit
f0ba0dbe8a
4 changed files with 106 additions and 58 deletions
|
@ -446,28 +446,6 @@ impl HirDisplay for Const {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct HexifiedConst(pub Const);
|
||||
|
||||
impl HirDisplay for HexifiedConst {
|
||||
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
||||
let data = &self.0.data(Interner);
|
||||
if let TyKind::Scalar(s) = data.ty.kind(Interner) {
|
||||
if matches!(s, Scalar::Int(_) | Scalar::Uint(_)) {
|
||||
if let ConstValue::Concrete(c) = &data.value {
|
||||
if let ConstScalar::Bytes(b, m) = &c.interned {
|
||||
let value = u128::from_le_bytes(pad16(b, false));
|
||||
if value >= 10 {
|
||||
render_const_scalar(f, &b, m, &data.ty)?;
|
||||
return write!(f, " ({:#X})", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.0.hir_fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
fn render_const_scalar(
|
||||
f: &mut HirFormatter<'_>,
|
||||
b: &[u8],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue