Count query entries in memory usage command

This commit is contained in:
Lukas Wirth 2023-06-10 01:49:32 +02:00
parent b6fb35f20c
commit ccce893577
5 changed files with 56 additions and 18 deletions

View file

@ -553,7 +553,17 @@ fn render_const_scalar(
render_const_scalar(f, bytes, memory_map, t)
}
_ => {
let addr = usize::from_le_bytes(b.try_into().unwrap());
let addr = usize::from_le_bytes(match b.try_into() {
Ok(b) => b,
Err(_) => {
never!(
"tried rendering ty {:?} in const ref with incorrect byte count {}",
t,
b.len()
);
return f.write_str("<layout-error>");
}
});
let Ok(layout) = f.db.layout_of_ty(t.clone(), krate) else {
return f.write_str("<layout-error>");
};