impl HirDisplay for next_solver::Ty

This commit is contained in:
jackh726 2025-08-09 23:28:48 +00:00
parent b2f107cb8b
commit eeaefa4b9d
24 changed files with 580 additions and 388 deletions

View file

@ -85,7 +85,9 @@ use hir_ty::{
layout::{Layout as TyLayout, RustcEnumVariantIdx, RustcFieldIdx, TagEncoding},
method_resolution,
mir::{MutBorrowKind, interpret_mir},
next_solver::{DbInterner, GenericArgs, SolverDefId, infer::InferCtxt},
next_solver::{
DbInterner, GenericArgs, SolverDefId, infer::InferCtxt, mapping::ChalkToNextSolver,
},
primitive::UintTy,
traits::FnTrait,
};
@ -1814,12 +1816,15 @@ impl Adt {
}
pub fn layout(self, db: &dyn HirDatabase) -> Result<Layout, LayoutError> {
db.layout_of_adt(
let env = db.trait_environment(self.into());
let interner = DbInterner::new_with(db, Some(env.krate), env.block);
db.layout_of_adt_ns(
self.into(),
TyBuilder::adt(db, self.into())
.fill_with_defaults(db, || TyKind::Error.intern(Interner))
.build_into_subst(),
db.trait_environment(self.into()),
.build_into_subst()
.to_nextsolver(interner),
env,
)
.map(|layout| Layout(layout, db.target_data_layout(self.krate(db).id).unwrap()))
}