Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/display.rs')
-rw-r--r--crates/hir-ty/src/display.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index 9d5cf47da8..2e7558a7b6 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -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>");
};