Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/interner.rs')
| -rw-r--r-- | crates/hir-ty/src/next_solver/interner.rs | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs index 2e52dcea6c..8b24a20a5b 100644 --- a/crates/hir-ty/src/next_solver/interner.rs +++ b/crates/hir-ty/src/next_solver/interner.rs @@ -690,15 +690,10 @@ impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef { interner: DbInterner<'db>, sizedness: SizedTraitKind, ) -> Option<EarlyBinder<DbInterner<'db>, Ty<'db>>> { - if self.is_struct() { - let tail_ty = self.all_field_tys(interner).skip_binder().into_iter().last()?; - - let constraint_ty = sizedness_constraint_for_ty(interner, sizedness, tail_ty)?; - - Some(EarlyBinder::bind(constraint_ty)) - } else { - None - } + let tail_ty = self.struct_tail_ty(interner)?; + tail_ty + .map_bound(|tail_ty| sizedness_constraint_for_ty(interner, sizedness, tail_ty)) + .transpose() } fn destructor( @@ -1109,14 +1104,7 @@ impl<'db> Interner for DbInterner<'db> { fn type_of(self, def_id: Self::DefId) -> EarlyBinder<Self, Self::Ty> { match def_id { - SolverDefId::TypeAliasId(id) => { - use hir_def::Lookup; - match id.lookup(self.db()).container { - ItemContainerId::ImplId(it) => it, - _ => panic!("assoc ty value should be in impl"), - }; - self.db().ty(id.into()) - } + SolverDefId::TypeAliasId(id) => self.db().ty(id.into()), SolverDefId::AdtId(id) => self.db().ty(id.into()), // FIXME(next-solver): This uses the types of `query mir_borrowck` in rustc. // @@ -1694,7 +1682,7 @@ impl<'db> Interner for DbInterner<'db> { mut f: impl FnMut(Self::ImplId), ) { let krate = self.krate.expect("trait solving requires setting `DbInterner::krate`"); - let trait_block = trait_def_id.0.loc(self.db).container.containing_block(); + let trait_block = trait_def_id.0.loc(self.db).container.block(self.db); let mut consider_impls_for_simplified_type = |simp: SimplifiedType| { let type_block = simp.def().and_then(|def_id| { let module = match def_id { @@ -1713,7 +1701,7 @@ impl<'db> Interner for DbInterner<'db> { | SolverDefId::EnumVariantId(_) | SolverDefId::Ctor(_) => return None, }; - module.containing_block() + module.block(self.db) }); TraitImpls::for_each_crate_and_block_trait_and_type( self.db, @@ -1828,7 +1816,7 @@ impl<'db> Interner for DbInterner<'db> { fn for_each_blanket_impl(self, trait_def_id: Self::TraitId, mut f: impl FnMut(Self::ImplId)) { let Some(krate) = self.krate else { return }; - let block = trait_def_id.0.loc(self.db).container.containing_block(); + let block = trait_def_id.0.loc(self.db).container.block(self.db); TraitImpls::for_each_crate_and_block(self.db, krate, block, &mut |impls| { for &impl_ in impls.blanket_impls(trait_def_id.0) { |