mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Fix layout for hir_ty::Ty
and friends
This commit is contained in:
parent
0a806fe7ad
commit
261047d019
9 changed files with 89 additions and 30 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue