about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-06-12 14:40:37 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-06-12 14:40:37 +0200
commit7a0ab1358c21a6414c29111f154eff2efae10d4d (patch)
tree8dcf4c20d54746281a553446133a60002805a8d1
parentad109f7f0ab2ae1ad05fc18d9293a158a2b5ecd1 (diff)
downloadrust-7a0ab1358c21a6414c29111f154eff2efae10d4d.tar.gz
rust-7a0ab1358c21a6414c29111f154eff2efae10d4d.zip
internal: Remove `Generics::type_iter` in favor of `Generics::iter`
-rw-r--r--crates/hir-def/src/generics.rs8
-rw-r--r--crates/hir-ty/src/lower.rs8
-rw-r--r--crates/hir-ty/src/utils.rs21
3 files changed, 7 insertions, 30 deletions
diff --git a/crates/hir-def/src/generics.rs b/crates/hir-def/src/generics.rs
index 04b77894ae9..f54f084ec3f 100644
--- a/crates/hir-def/src/generics.rs
+++ b/crates/hir-def/src/generics.rs
@@ -133,14 +133,6 @@ pub enum WherePredicateTypeTarget {
 }
 
 impl GenericParams {
-    // FIXME: almost every usecase of this function is wrong. every one should check
-    // const generics
-    pub fn type_iter<'a>(
-        &'a self,
-    ) -> impl Iterator<Item = (Idx<TypeOrConstParamData>, &TypeParamData)> {
-        self.type_or_consts.iter().filter_map(|x| x.1.type_param().map(|y| (x.0, y)))
-    }
-
     /// Iterator of type_or_consts field
     pub fn iter<'a>(
         &'a self,
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index a3787728eac..f64027c2183 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -292,9 +292,13 @@ impl<'a> TyLoweringContext<'a> {
                         if let Some(def) = self.resolver.generic_def() {
                             let generics = generics(self.db.upcast(), def);
                             let param = generics
-                                .type_iter()
+                                .iter()
                                 .filter(|(_, data)| {
-                                    data.provenance == TypeParamProvenance::ArgumentImplTrait
+                                    matches!(
+                                        data,
+                                        TypeOrConstParamData::TypeParamData(data)
+                                        if data.provenance == TypeParamProvenance::ArgumentImplTrait
+                                    )
                                 })
                                 .nth(idx as usize)
                                 .map_or(TyKind::Error, |(id, _)| {
diff --git a/crates/hir-ty/src/utils.rs b/crates/hir-ty/src/utils.rs
index bdb7677f5d7..fb39e6095c0 100644
--- a/crates/hir-ty/src/utils.rs
+++ b/crates/hir-ty/src/utils.rs
@@ -8,7 +8,7 @@ use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex};
 use hir_def::{
     db::DefDatabase,
     generics::{
-        GenericParams, TypeOrConstParamData, TypeParamData, TypeParamProvenance, WherePredicate,
+        GenericParams, TypeOrConstParamData, TypeParamProvenance, WherePredicate,
         WherePredicateTypeTarget,
     },
     intern::Interned,
@@ -204,25 +204,6 @@ pub(crate) struct Generics {
 }
 
 impl Generics {
-    // FIXME: we should drop this and handle const and type generics at the same time
-    pub(crate) fn type_iter<'a>(
-        &'a self,
-    ) -> impl Iterator<Item = (TypeOrConstParamId, &'a TypeParamData)> + 'a {
-        self.parent_generics
-            .as_ref()
-            .into_iter()
-            .flat_map(|it| {
-                it.params
-                    .type_iter()
-                    .map(move |(local_id, p)| (TypeOrConstParamId { parent: it.def, local_id }, p))
-            })
-            .chain(
-                self.params.type_iter().map(move |(local_id, p)| {
-                    (TypeOrConstParamId { parent: self.def, local_id }, p)
-                }),
-            )
-    }
-
     pub(crate) fn iter_id<'a>(
         &'a self,
     ) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + 'a {