aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/code_model.rs10
-rw-r--r--crates/ra_hir_def/src/generics.rs17
-rw-r--r--crates/ra_hir_def/src/type_ref.rs4
-rw-r--r--crates/ra_hir_ty/src/db.rs7
-rw-r--r--crates/ra_hir_ty/src/infer.rs9
-rw-r--r--crates/ra_hir_ty/src/infer/coerce.rs8
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs4
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs5
-rw-r--r--crates/ra_hir_ty/src/lib.rs5
-rw-r--r--crates/ra_hir_ty/src/lower.rs8
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs11
-rw-r--r--crates/ra_hir_ty/src/utils.rs63
12 files changed, 98 insertions, 53 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 63c85ca34..4d9641728 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -10,10 +10,9 @@ use hir_def::{
10 per_ns::PerNs, 10 per_ns::PerNs,
11 resolver::HasResolver, 11 resolver::HasResolver,
12 type_ref::{Mutability, TypeRef}, 12 type_ref::{Mutability, TypeRef},
13 AdtId, ConstId, DefWithBodyId, EnumId, FunctionId, HasModule, ImplId, LocalEnumVariantId, 13 AdtId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId,
14 LocalModuleId, LocalStructFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, 14 LocalEnumVariantId, LocalModuleId, LocalStructFieldId, Lookup, ModuleId, StaticId, StructId,
15 TypeParamId, UnionId, 15 TraitId, TypeAliasId, TypeParamId, UnionId,
16 GenericDefId
17}; 16};
18use hir_expand::{ 17use hir_expand::{
19 diagnostics::DiagnosticSink, 18 diagnostics::DiagnosticSink,
@@ -22,8 +21,7 @@ use hir_expand::{
22}; 21};
23use hir_ty::{ 22use hir_ty::{
24 autoderef, display::HirFormatter, expr::ExprValidator, method_resolution, ApplicationTy, 23 autoderef, display::HirFormatter, expr::ExprValidator, method_resolution, ApplicationTy,
25 Canonical, InEnvironment, TraitEnvironment, Ty, TyDefId, TypeCtor, 24 Canonical, InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor,
26 Substs
27}; 25};
28use ra_db::{CrateId, Edition, FileId}; 26use ra_db::{CrateId, Edition, FileId};
29use ra_prof::profile; 27use ra_prof::profile;
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index e4e616519..f765e6edc 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -61,7 +61,7 @@ pub struct WherePredicate {
61pub enum WherePredicateTarget { 61pub enum WherePredicateTarget {
62 TypeRef(TypeRef), 62 TypeRef(TypeRef),
63 /// For desugared where predicates that can directly refer to a type param. 63 /// For desugared where predicates that can directly refer to a type param.
64 TypeParam(LocalTypeParamId) 64 TypeParam(LocalTypeParamId),
65} 65}
66 66
67type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; 67type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>;
@@ -197,7 +197,8 @@ impl GenericParams {
197 return; 197 return;
198 } 198 }
199 let bound = TypeBound::from_ast(bound); 199 let bound = TypeBound::from_ast(bound);
200 self.where_predicates.push(WherePredicate { target: WherePredicateTarget::TypeRef(type_ref), bound }); 200 self.where_predicates
201 .push(WherePredicate { target: WherePredicateTarget::TypeRef(type_ref), bound });
201 } 202 }
202 203
203 fn fill_implicit_impl_trait_args(&mut self, type_ref: &TypeRef) { 204 fn fill_implicit_impl_trait_args(&mut self, type_ref: &TypeRef) {
@@ -212,7 +213,7 @@ impl GenericParams {
212 for bound in bounds { 213 for bound in bounds {
213 self.where_predicates.push(WherePredicate { 214 self.where_predicates.push(WherePredicate {
214 target: WherePredicateTarget::TypeParam(param_id), 215 target: WherePredicateTarget::TypeParam(param_id),
215 bound: bound.clone() 216 bound: bound.clone(),
216 }); 217 });
217 } 218 }
218 } 219 }
@@ -226,9 +227,13 @@ impl GenericParams {
226 } 227 }
227 228
228 pub fn find_trait_self_param(&self) -> Option<LocalTypeParamId> { 229 pub fn find_trait_self_param(&self) -> Option<LocalTypeParamId> {
229 self.types 230 self.types.iter().find_map(|(id, p)| {
230 .iter() 231 if p.provenance == TypeParamProvenance::TraitSelf {
231 .find_map(|(id, p)| if p.provenance == TypeParamProvenance::TraitSelf { Some(id) } else { None }) 232 Some(id)
233 } else {
234 None
235 }
236 })
232 } 237 }
233} 238}
234 239
diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs
index 109414770..102fdb13d 100644
--- a/crates/ra_hir_def/src/type_ref.rs
+++ b/crates/ra_hir_def/src/type_ref.rs
@@ -131,9 +131,7 @@ impl TypeRef {
131 fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) { 131 fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) {
132 f(type_ref); 132 f(type_ref);
133 match type_ref { 133 match type_ref {
134 TypeRef::Fn(types) | TypeRef::Tuple(types) => { 134 TypeRef::Fn(types) | TypeRef::Tuple(types) => types.iter().for_each(|t| go(t, f)),
135 types.iter().for_each(|t| go(t, f))
136 }
137 TypeRef::RawPtr(type_ref, _) 135 TypeRef::RawPtr(type_ref, _)
138 | TypeRef::Reference(type_ref, _) 136 | TypeRef::Reference(type_ref, _)
139 | TypeRef::Array(type_ref) 137 | TypeRef::Array(type_ref)
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index 21ab22fa9..e9bfcfa17 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -3,7 +3,8 @@
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::{ 5use hir_def::{
6 db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, VariantId, TypeParamId, 6 db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, TypeParamId,
7 VariantId,
7}; 8};
8use ra_arena::map::ArenaMap; 9use ra_arena::map::ArenaMap;
9use ra_db::{impl_intern_key, salsa, CrateId}; 10use ra_db::{impl_intern_key, salsa, CrateId};
@@ -12,8 +13,8 @@ use ra_prof::profile;
12use crate::{ 13use crate::{
13 method_resolution::CrateImplBlocks, 14 method_resolution::CrateImplBlocks,
14 traits::{chalk, AssocTyValue, Impl}, 15 traits::{chalk, AssocTyValue, Impl},
15 CallableDef, PolyFnSig, GenericPredicate, InferenceResult, Substs, TraitRef, Ty, TyDefId, TypeCtor, 16 Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty,
16 ValueTyDefId, Binders, 17 TyDefId, TypeCtor, ValueTyDefId,
17}; 18};
18 19
19#[salsa::query_group(HirDatabaseStorage)] 20#[salsa::query_group(HirDatabaseStorage)]
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index dec6bd84c..a9d958c8b 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -278,7 +278,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
278 impl_trait_mode: ImplTraitLoweringMode, 278 impl_trait_mode: ImplTraitLoweringMode,
279 ) -> Ty { 279 ) -> Ty {
280 // FIXME use right resolver for block 280 // FIXME use right resolver for block
281 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver).with_impl_trait_mode(impl_trait_mode); 281 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver)
282 .with_impl_trait_mode(impl_trait_mode);
282 let ty = Ty::from_hir(&ctx, type_ref); 283 let ty = Ty::from_hir(&ctx, type_ref);
283 let ty = self.insert_type_vars(ty); 284 let ty = self.insert_type_vars(ty);
284 self.normalize_associated_types_in(ty) 285 self.normalize_associated_types_in(ty)
@@ -455,8 +456,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
455 456
456 fn collect_fn(&mut self, data: &FunctionData) { 457 fn collect_fn(&mut self, data: &FunctionData) {
457 let body = Arc::clone(&self.body); // avoid borrow checker problem 458 let body = Arc::clone(&self.body); // avoid borrow checker problem
458 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver).with_impl_trait_mode(ImplTraitLoweringMode::Param); 459 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver)
459 let param_tys = data.params.iter().map(|type_ref| Ty::from_hir(&ctx, type_ref)).collect::<Vec<_>>(); 460 .with_impl_trait_mode(ImplTraitLoweringMode::Param);
461 let param_tys =
462 data.params.iter().map(|type_ref| Ty::from_hir(&ctx, type_ref)).collect::<Vec<_>>();
460 for (ty, pat) in param_tys.into_iter().zip(body.params.iter()) { 463 for (ty, pat) in param_tys.into_iter().zip(body.params.iter()) {
461 let ty = self.insert_type_vars(ty); 464 let ty = self.insert_type_vars(ty);
462 let ty = self.normalize_associated_types_in(ty); 465 let ty = self.normalize_associated_types_in(ty);
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs
index 2a9567898..f68a1439f 100644
--- a/crates/ra_hir_ty/src/infer/coerce.rs
+++ b/crates/ra_hir_ty/src/infer/coerce.rs
@@ -66,9 +66,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
66 // This works for smart-pointer-like coercion, which covers all impls from std. 66 // This works for smart-pointer-like coercion, which covers all impls from std.
67 st1.iter().zip(st2.iter()).enumerate().find_map(|(i, (ty1, ty2))| { 67 st1.iter().zip(st2.iter()).enumerate().find_map(|(i, (ty1, ty2))| {
68 match (ty1, ty2) { 68 match (ty1, ty2) {
69 (Ty::Bound(idx1), Ty::Bound(idx2)) 69 (Ty::Bound(idx1), Ty::Bound(idx2)) if idx1 != idx2 => {
70 if idx1 != idx2 =>
71 {
72 Some(((*ctor1, *ctor2), i)) 70 Some(((*ctor1, *ctor2), i))
73 } 71 }
74 _ => None, 72 _ => None,
@@ -277,9 +275,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
277 let mut multiple_used = false; 275 let mut multiple_used = false;
278 fields.for_each(|(field_id, _data)| { 276 fields.for_each(|(field_id, _data)| {
279 field_tys[field_id].value.walk(&mut |ty| match ty { 277 field_tys[field_id].value.walk(&mut |ty| match ty {
280 &Ty::Bound(idx) if idx == unsize_generic_index => { 278 &Ty::Bound(idx) if idx == unsize_generic_index => multiple_used = true,
281 multiple_used = true
282 }
283 _ => {} 279 _ => {}
284 }) 280 })
285 }); 281 });
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 6222bd90e..8c360bcad 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -19,8 +19,8 @@ use crate::{
19 method_resolution, op, 19 method_resolution, op,
20 traits::InEnvironment, 20 traits::InEnvironment,
21 utils::{generics, variant_data, Generics}, 21 utils::{generics, variant_data, Generics},
22 ApplicationTy, CallableDef, InferTy, IntTy, Mutability, Obligation, Substs, TraitRef, Ty, 22 ApplicationTy, Binders, CallableDef, InferTy, IntTy, Mutability, Obligation, Substs, TraitRef,
23 TypeCtor, Uncertain, Binders, 23 Ty, TypeCtor, Uncertain,
24}; 24};
25 25
26use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch}; 26use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch};
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index fcf13b0b3..686ce7a21 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -9,10 +9,7 @@ use hir_def::{
9}; 9};
10use hir_expand::name::Name; 10use hir_expand::name::Name;
11 11
12use crate::{ 12use crate::{db::HirDatabase, method_resolution, Substs, Ty, ValueTyDefId};
13 db::HirDatabase, method_resolution, Substs, Ty,
14 ValueTyDefId
15};
16 13
17use super::{ExprOrPatId, InferenceContext, TraitRef}; 14use super::{ExprOrPatId, InferenceContext, TraitRef};
18 15
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 314be17b8..60c7fd0e5 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -1033,7 +1033,10 @@ impl HirDisplay for Ty {
1033 write!(f, "impl ")?; 1033 write!(f, "impl ")?;
1034 let bounds = f.db.generic_predicates_for_param(*id); 1034 let bounds = f.db.generic_predicates_for_param(*id);
1035 let substs = Substs::type_params_for_generics(&generics); 1035 let substs = Substs::type_params_for_generics(&generics);
1036 write_bounds_like_dyn_trait(&bounds.iter().map(|b| b.clone().subst(&substs)).collect::<Vec<_>>(), f)?; 1036 write_bounds_like_dyn_trait(
1037 &bounds.iter().map(|b| b.clone().subst(&substs)).collect::<Vec<_>>(),
1038 f,
1039 )?;
1037 } 1040 }
1038 } 1041 }
1039 } 1042 }
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 0d4c075af..4168e7509 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -276,7 +276,9 @@ impl Ty {
276 TypeNs::SelfType(impl_id) => { 276 TypeNs::SelfType(impl_id) => {
277 let generics = generics(ctx.db, impl_id.into()); 277 let generics = generics(ctx.db, impl_id.into());
278 let substs = match ctx.type_param_mode { 278 let substs = match ctx.type_param_mode {
279 TypeParamLoweringMode::Placeholder => Substs::type_params_for_generics(&generics), 279 TypeParamLoweringMode::Placeholder => {
280 Substs::type_params_for_generics(&generics)
281 }
280 TypeParamLoweringMode::Variable => Substs::bound_vars(&generics), 282 TypeParamLoweringMode::Variable => Substs::bound_vars(&generics),
281 }; 283 };
282 ctx.db.impl_self_ty(impl_id).subst(&substs) 284 ctx.db.impl_self_ty(impl_id).subst(&substs)
@@ -284,7 +286,9 @@ impl Ty {
284 TypeNs::AdtSelfType(adt) => { 286 TypeNs::AdtSelfType(adt) => {
285 let generics = generics(ctx.db, adt.into()); 287 let generics = generics(ctx.db, adt.into());
286 let substs = match ctx.type_param_mode { 288 let substs = match ctx.type_param_mode {
287 TypeParamLoweringMode::Placeholder => Substs::type_params_for_generics(&generics), 289 TypeParamLoweringMode::Placeholder => {
290 Substs::type_params_for_generics(&generics)
291 }
288 TypeParamLoweringMode::Variable => Substs::bound_vars(&generics), 292 TypeParamLoweringMode::Variable => Substs::bound_vars(&generics),
289 }; 293 };
290 ctx.db.ty(adt.into()).subst(&substs) 294 ctx.db.ty(adt.into()).subst(&substs)
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 8260bd157..4974c565b 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -144,8 +144,11 @@ impl ToChalk for Ty {
144 } 144 }
145 Ty::Param(id) => { 145 Ty::Param(id) => {
146 let interned_id = db.intern_type_param_id(id); 146 let interned_id = db.intern_type_param_id(id);
147 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: interned_id.as_intern_id().as_usize() } 147 PlaceholderIndex {
148 .to_ty::<TypeFamily>() 148 ui: UniverseIndex::ROOT,
149 idx: interned_id.as_intern_id().as_usize(),
150 }
151 .to_ty::<TypeFamily>()
149 } 152 }
150 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(), 153 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(),
151 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), 154 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
@@ -178,7 +181,9 @@ impl ToChalk for Ty {
178 }, 181 },
179 chalk_ir::TyData::Placeholder(idx) => { 182 chalk_ir::TyData::Placeholder(idx) => {
180 assert_eq!(idx.ui, UniverseIndex::ROOT); 183 assert_eq!(idx.ui, UniverseIndex::ROOT);
181 let interned_id = crate::db::GlobalTypeParamId::from_intern_id(crate::salsa::InternId::from(idx.idx)); 184 let interned_id = crate::db::GlobalTypeParamId::from_intern_id(
185 crate::salsa::InternId::from(idx.idx),
186 );
182 Ty::Param(db.lookup_intern_type_param_id(interned_id)) 187 Ty::Param(db.lookup_intern_type_param_id(interned_id))
183 } 188 }
184 chalk_ir::TyData::Alias(proj) => { 189 chalk_ir::TyData::Alias(proj) => {
diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/ra_hir_ty/src/utils.rs
index 8fa1838bd..e307d958d 100644
--- a/crates/ra_hir_ty/src/utils.rs
+++ b/crates/ra_hir_ty/src/utils.rs
@@ -2,6 +2,7 @@
2//! query, but can't be computed directly from `*Data` (ie, which need a `db`). 2//! query, but can't be computed directly from `*Data` (ie, which need a `db`).
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::generics::WherePredicateTarget;
5use hir_def::{ 6use hir_def::{
6 adt::VariantData, 7 adt::VariantData,
7 db::DefDatabase, 8 db::DefDatabase,
@@ -12,7 +13,6 @@ use hir_def::{
12 AssocContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId, VariantId, 13 AssocContainerId, GenericDefId, Lookup, TraitId, TypeAliasId, TypeParamId, VariantId,
13}; 14};
14use hir_expand::name::{name, Name}; 15use hir_expand::name::{name, Name};
15use hir_def::generics::WherePredicateTarget;
16 16
17fn direct_super_traits(db: &impl DefDatabase, trait_: TraitId) -> Vec<TraitId> { 17fn direct_super_traits(db: &impl DefDatabase, trait_: TraitId) -> Vec<TraitId> {
18 let resolver = trait_.resolver(db); 18 let resolver = trait_.resolver(db);
@@ -26,8 +26,12 @@ fn direct_super_traits(db: &impl DefDatabase, trait_: TraitId) -> Vec<TraitId> {
26 .where_predicates 26 .where_predicates
27 .iter() 27 .iter()
28 .filter_map(|pred| match &pred.target { 28 .filter_map(|pred| match &pred.target {
29 WherePredicateTarget::TypeRef(TypeRef::Path(p)) if p == &Path::from(name![Self]) => pred.bound.as_path(), 29 WherePredicateTarget::TypeRef(TypeRef::Path(p)) if p == &Path::from(name![Self]) => {
30 WherePredicateTarget::TypeParam(local_id) if Some(*local_id) == trait_self => pred.bound.as_path(), 30 pred.bound.as_path()
31 }
32 WherePredicateTarget::TypeParam(local_id) if Some(*local_id) == trait_self => {
33 pred.bound.as_path()
34 }
31 _ => None, 35 _ => None,
32 }) 36 })
33 .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) { 37 .filter_map(|path| match resolver.resolve_path_in_type_ns_fully(db, path.mod_path()) {
@@ -99,19 +103,35 @@ pub(crate) struct Generics {
99} 103}
100 104
101impl Generics { 105impl Generics {
102 pub(crate) fn iter<'a>(&'a self) -> impl Iterator<Item = (TypeParamId, &'a TypeParamData)> + 'a { 106 pub(crate) fn iter<'a>(
107 &'a self,
108 ) -> impl Iterator<Item = (TypeParamId, &'a TypeParamData)> + 'a {
103 self.parent_generics 109 self.parent_generics
104 .as_ref() 110 .as_ref()
105 .into_iter() 111 .into_iter()
106 .flat_map(|it| it.params.types.iter().map(move |(local_id, p)| (TypeParamId { parent: it.def, local_id }, p))) 112 .flat_map(|it| {
107 .chain(self.params.types.iter().map(move |(local_id, p)| (TypeParamId { parent: self.def, local_id }, p))) 113 it.params
114 .types
115 .iter()
116 .map(move |(local_id, p)| (TypeParamId { parent: it.def, local_id }, p))
117 })
118 .chain(
119 self.params
120 .types
121 .iter()
122 .map(move |(local_id, p)| (TypeParamId { parent: self.def, local_id }, p)),
123 )
108 } 124 }
109 125
110 pub(crate) fn iter_parent<'a>(&'a self) -> impl Iterator<Item = (TypeParamId, &'a TypeParamData)> + 'a { 126 pub(crate) fn iter_parent<'a>(
111 self.parent_generics 127 &'a self,
112 .as_ref() 128 ) -> impl Iterator<Item = (TypeParamId, &'a TypeParamData)> + 'a {
113 .into_iter() 129 self.parent_generics.as_ref().into_iter().flat_map(|it| {
114 .flat_map(|it| it.params.types.iter().map(move |(local_id, p)| (TypeParamId { parent: it.def, local_id }, p))) 130 it.params
131 .types
132 .iter()
133 .map(move |(local_id, p)| (TypeParamId { parent: it.def, local_id }, p))
134 })
115 } 135 }
116 136
117 pub(crate) fn len(&self) -> usize { 137 pub(crate) fn len(&self) -> usize {
@@ -127,9 +147,24 @@ impl Generics {
127 147
128 /// (self, type param list, impl trait) 148 /// (self, type param list, impl trait)
129 pub(crate) fn provenance_split(&self) -> (usize, usize, usize) { 149 pub(crate) fn provenance_split(&self) -> (usize, usize, usize) {
130 let self_params = self.params.types.iter().filter(|(_, p)| p.provenance == TypeParamProvenance::TraitSelf).count(); 150 let self_params = self
131 let list_params = self.params.types.iter().filter(|(_, p)| p.provenance == TypeParamProvenance::TypeParamList).count(); 151 .params
132 let impl_trait_params = self.params.types.iter().filter(|(_, p)| p.provenance == TypeParamProvenance::ArgumentImplTrait).count(); 152 .types
153 .iter()
154 .filter(|(_, p)| p.provenance == TypeParamProvenance::TraitSelf)
155 .count();
156 let list_params = self
157 .params
158 .types
159 .iter()
160 .filter(|(_, p)| p.provenance == TypeParamProvenance::TypeParamList)
161 .count();
162 let impl_trait_params = self
163 .params
164 .types
165 .iter()
166 .filter(|(_, p)| p.provenance == TypeParamProvenance::ArgumentImplTrait)
167 .count();
133 (self_params, list_params, impl_trait_params) 168 (self_params, list_params, impl_trait_params)
134 } 169 }
135 170