Use correct substs for super trait assoc types
When referring to an associated type of a super trait, we used the substs of the subtrait. That led to the #4931 crash if the subtrait had less parameters, but it could also lead to other incorrectness if just the order was different. Fixes #4931.
This commit is contained in:
committed by
Florian Diebold
parent
6654055308
commit
2745cb37c1
@@ -143,13 +143,14 @@ pub(super) fn find_super_trait_path(
|
||||
}
|
||||
|
||||
pub(super) fn associated_type_by_name_including_super_traits(
|
||||
db: &dyn DefDatabase,
|
||||
trait_: TraitId,
|
||||
db: &dyn HirDatabase,
|
||||
trait_ref: TraitRef,
|
||||
name: &Name,
|
||||
) -> Option<TypeAliasId> {
|
||||
all_super_traits(db, trait_)
|
||||
.into_iter()
|
||||
.find_map(|t| db.trait_data(t).associated_type_by_name(name))
|
||||
) -> Option<(TraitRef, TypeAliasId)> {
|
||||
all_super_trait_refs(db, trait_ref).into_iter().find_map(|t| {
|
||||
let assoc_type = db.trait_data(t.trait_).associated_type_by_name(name)?;
|
||||
Some((t, assoc_type))
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn variant_data(db: &dyn DefDatabase, var: VariantId) -> Arc<VariantData> {
|
||||
@@ -176,6 +177,7 @@ pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics {
|
||||
Generics { def, params: db.generic_params(def), parent_generics }
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Generics {
|
||||
def: GenericDefId,
|
||||
pub(crate) params: Arc<GenericParams>,
|
||||
|
||||
Reference in New Issue
Block a user