Auto merge of #17845 - ShoyuVanilla:tait, r=Veykril

feat: Implement TAIT and fix ATPIT a bit

Closes #16296 (Commented on the issue)

In #16852, I implemented ATPIT, but as I didn't discern ATPIT and other non-assoc TAIT, I guess that it has been working for some TAITs.

As the definining usage of TAIT requires it should be appear in the Def body's type(const blocks' type annotations or functions' signatures), this can be done in simlilar way with ATPIT

And this PR also corrects some defining-usage resolution for ATPIT
This commit is contained in:
bors 2024-08-12 08:08:40 +00:00
commit 6d9af33b31
14 changed files with 291 additions and 191 deletions

View file

@ -1152,11 +1152,10 @@ impl HirDisplay for Ty {
)?;
// FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution
}
ImplTraitId::AssociatedTypeImplTrait(alias, idx) => {
ImplTraitId::TypeAliasImplTrait(alias, idx) => {
let datas =
db.type_alias_impl_traits(alias).expect("impl trait id without data");
let data =
(*datas).as_ref().map(|rpit| rpit.impl_traits[idx].bounds.clone());
let data = (*datas).as_ref().map(|it| it.impl_traits[idx].bounds.clone());
let bounds = data.substitute(Interner, &parameters);
let krate = alias.krate(db.upcast());
write_bounds_like_dyn_trait_with_prefix(
@ -1339,7 +1338,7 @@ impl HirDisplay for Ty {
SizedByDefault::Sized { anchor: krate },
)?;
}
ImplTraitId::AssociatedTypeImplTrait(alias, idx) => {
ImplTraitId::TypeAliasImplTrait(alias, idx) => {
let datas =
db.type_alias_impl_traits(alias).expect("impl trait id without data");
let data =