Skip to content

Commit d513f65

Browse files
committed
Auto merge of rust-lang#12509 - Veykril:ty-utils, r=Veykril
internal: Remove `Generics::type_iter` in favor of `Generics::iter`
2 parents eacade2 + 7a0ab13 commit d513f65

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

crates/hir-def/src/generics.rs

-8
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ pub enum WherePredicateTypeTarget {
133133
}
134134

135135
impl GenericParams {
136-
// FIXME: almost every usecase of this function is wrong. every one should check
137-
// const generics
138-
pub fn type_iter<'a>(
139-
&'a self,
140-
) -> impl Iterator<Item = (Idx<TypeOrConstParamData>, &TypeParamData)> {
141-
self.type_or_consts.iter().filter_map(|x| x.1.type_param().map(|y| (x.0, y)))
142-
}
143-
144136
/// Iterator of type_or_consts field
145137
pub fn iter<'a>(
146138
&'a self,

crates/hir-ty/src/lower.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,13 @@ impl<'a> TyLoweringContext<'a> {
292292
if let Some(def) = self.resolver.generic_def() {
293293
let generics = generics(self.db.upcast(), def);
294294
let param = generics
295-
.type_iter()
295+
.iter()
296296
.filter(|(_, data)| {
297-
data.provenance == TypeParamProvenance::ArgumentImplTrait
297+
matches!(
298+
data,
299+
TypeOrConstParamData::TypeParamData(data)
300+
if data.provenance == TypeParamProvenance::ArgumentImplTrait
301+
)
298302
})
299303
.nth(idx as usize)
300304
.map_or(TyKind::Error, |(id, _)| {

crates/hir-ty/src/utils.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex};
88
use hir_def::{
99
db::DefDatabase,
1010
generics::{
11-
GenericParams, TypeOrConstParamData, TypeParamData, TypeParamProvenance, WherePredicate,
11+
GenericParams, TypeOrConstParamData, TypeParamProvenance, WherePredicate,
1212
WherePredicateTypeTarget,
1313
},
1414
intern::Interned,
@@ -204,25 +204,6 @@ pub(crate) struct Generics {
204204
}
205205

206206
impl Generics {
207-
// FIXME: we should drop this and handle const and type generics at the same time
208-
pub(crate) fn type_iter<'a>(
209-
&'a self,
210-
) -> impl Iterator<Item = (TypeOrConstParamId, &'a TypeParamData)> + 'a {
211-
self.parent_generics
212-
.as_ref()
213-
.into_iter()
214-
.flat_map(|it| {
215-
it.params
216-
.type_iter()
217-
.map(move |(local_id, p)| (TypeOrConstParamId { parent: it.def, local_id }, p))
218-
})
219-
.chain(
220-
self.params.type_iter().map(move |(local_id, p)| {
221-
(TypeOrConstParamId { parent: self.def, local_id }, p)
222-
}),
223-
)
224-
}
225-
226207
pub(crate) fn iter_id<'a>(
227208
&'a self,
228209
) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + 'a {

0 commit comments

Comments
 (0)