Fix lifetime parameters moving paramter defaults

This commit is contained in:
Lukas Wirth 2024-07-02 10:13:02 +02:00
parent 1b283db47f
commit 1a929d6485
5 changed files with 113 additions and 68 deletions

View file

@ -20,6 +20,7 @@ use hir_def::{
LocalLifetimeParamId, LocalTypeOrConstParamId, Lookup, TypeOrConstParamId, TypeParamId,
};
use intern::Interned;
use stdx::TupleExt;
use crate::{db::HirDatabase, lt_to_placeholder_idx, to_placeholder_idx, Interner, Substitution};
@ -57,7 +58,7 @@ impl Generics {
self.iter_self().map(|(id, _)| id)
}
fn iter_parent_id(&self) -> impl Iterator<Item = GenericParamId> + '_ {
pub(crate) fn iter_parent_id(&self) -> impl Iterator<Item = GenericParamId> + '_ {
self.iter_parent().map(|(id, _)| id)
}
@ -67,6 +68,16 @@ impl Generics {
self.params.iter_type_or_consts()
}
pub(crate) fn iter_self_type_or_consts_id(
&self,
) -> impl DoubleEndedIterator<Item = GenericParamId> + '_ {
self.params.iter_type_or_consts().map(from_toc_id(self)).map(TupleExt::head)
}
pub(crate) fn iter_self_lt_id(&self) -> impl DoubleEndedIterator<Item = GenericParamId> + '_ {
self.params.iter_lt().map(from_lt_id(self)).map(TupleExt::head)
}
/// Iterate over the params followed by the parent params.
pub(crate) fn iter(
&self,