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.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index 3cfe78141d..1d7f6cc0c1 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -463,6 +463,9 @@ fn render_const_scalar(
memory_map: &MemoryMap,
ty: &Ty,
) -> Result<(), HirDisplayError> {
+ // FIXME: We need to get krate from the final callers of the hir display
+ // infrastructure and have it here as a field on `f`.
+ let krate = *f.db.crate_graph().crates_in_topological_order().last().unwrap();
match ty.kind(Interner) {
chalk_ir::TyKind::Scalar(s) => match s {
Scalar::Bool => write!(f, "{}", if b[0] == 0 { false } else { true }),
@@ -502,11 +505,6 @@ fn render_const_scalar(
_ => f.write_str("<ref-not-supported>"),
},
chalk_ir::TyKind::Tuple(_, subst) => {
- // FIXME: Remove this line. If the target data layout is independent
- // of the krate, the `db.target_data_layout` and its callers like `layout_of_ty` don't need
- // to get krate. Otherwise, we need to get krate from the final callers of the hir display
- // infrastructure and have it here as a field on `f`.
- let krate = *f.db.crate_graph().crates_in_topological_order().last().unwrap();
let Ok(layout) = layout_of_ty(f.db, ty, krate) else {
return f.write_str("<layout-error>");
};
@@ -532,7 +530,7 @@ fn render_const_scalar(
chalk_ir::TyKind::Adt(adt, subst) => match adt.0 {
hir_def::AdtId::StructId(s) => {
let data = f.db.struct_data(s);
- let Ok(layout) = f.db.layout_of_adt(adt.0, subst.clone()) else {
+ let Ok(layout) = f.db.layout_of_adt(adt.0, subst.clone(), krate) else {
return f.write_str("<layout-error>");
};
match data.variant_data.as_ref() {