diff options
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r-- | crates/hir_ty/src/lower.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index e9e4e69ad..19465b2ed 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -832,12 +832,15 @@ pub fn associated_type_shorthand_candidates<R>( | |||
832 | 832 | ||
833 | match res { | 833 | match res { |
834 | // FIXME: how to correctly handle higher-ranked bounds here? | 834 | // FIXME: how to correctly handle higher-ranked bounds here? |
835 | TypeNs::SelfType(impl_id) => { | 835 | TypeNs::SelfType(impl_id) => search( |
836 | search(db.impl_trait(impl_id)?.value.shift_bound_vars_out(DebruijnIndex::ONE)) | 836 | db.impl_trait(impl_id)? |
837 | } | 837 | .into_value_and_skipped_binders() |
838 | .0 | ||
839 | .shift_bound_vars_out(DebruijnIndex::ONE), | ||
840 | ), | ||
838 | TypeNs::GenericParam(param_id) => { | 841 | TypeNs::GenericParam(param_id) => { |
839 | let predicates = db.generic_predicates_for_param(param_id); | 842 | let predicates = db.generic_predicates_for_param(param_id); |
840 | let res = predicates.iter().find_map(|pred| match &pred.value.value { | 843 | let res = predicates.iter().find_map(|pred| match pred.skip_binders().skip_binders() { |
841 | // FIXME: how to correctly handle higher-ranked bounds here? | 844 | // FIXME: how to correctly handle higher-ranked bounds here? |
842 | WhereClause::Implemented(tr) => { | 845 | WhereClause::Implemented(tr) => { |
843 | search(tr.clone().shift_bound_vars_out(DebruijnIndex::ONE)) | 846 | search(tr.clone().shift_bound_vars_out(DebruijnIndex::ONE)) |
@@ -1088,8 +1091,8 @@ fn fn_sig_for_struct_constructor(db: &dyn HirDatabase, def: StructId) -> PolyFnS | |||
1088 | let ctx = | 1091 | let ctx = |
1089 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); | 1092 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); |
1090 | let params = fields.iter().map(|(_, field)| ctx.lower_ty(&field.type_ref)).collect::<Vec<_>>(); | 1093 | let params = fields.iter().map(|(_, field)| ctx.lower_ty(&field.type_ref)).collect::<Vec<_>>(); |
1091 | let ret = type_for_adt(db, def.into()); | 1094 | let (ret, binders) = type_for_adt(db, def.into()).into_value_and_skipped_binders(); |
1092 | Binders::new(ret.num_binders, CallableSig::from_params_and_return(params, ret.value, false)) | 1095 | Binders::new(binders, CallableSig::from_params_and_return(params, ret, false)) |
1093 | } | 1096 | } |
1094 | 1097 | ||
1095 | /// Build the type of a tuple struct constructor. | 1098 | /// Build the type of a tuple struct constructor. |
@@ -1114,8 +1117,8 @@ fn fn_sig_for_enum_variant_constructor(db: &dyn HirDatabase, def: EnumVariantId) | |||
1114 | let ctx = | 1117 | let ctx = |
1115 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); | 1118 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); |
1116 | let params = fields.iter().map(|(_, field)| ctx.lower_ty(&field.type_ref)).collect::<Vec<_>>(); | 1119 | let params = fields.iter().map(|(_, field)| ctx.lower_ty(&field.type_ref)).collect::<Vec<_>>(); |
1117 | let ret = type_for_adt(db, def.parent.into()); | 1120 | let (ret, binders) = type_for_adt(db, def.parent.into()).into_value_and_skipped_binders(); |
1118 | Binders::new(ret.num_binders, CallableSig::from_params_and_return(params, ret.value, false)) | 1121 | Binders::new(binders, CallableSig::from_params_and_return(params, ret, false)) |
1119 | } | 1122 | } |
1120 | 1123 | ||
1121 | /// Build the type of a tuple enum variant constructor. | 1124 | /// Build the type of a tuple enum variant constructor. |
@@ -1267,9 +1270,9 @@ pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option< | |||
1267 | let resolver = impl_id.resolver(db.upcast()); | 1270 | let resolver = impl_id.resolver(db.upcast()); |
1268 | let ctx = | 1271 | let ctx = |
1269 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); | 1272 | TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable); |
1270 | let self_ty = db.impl_self_ty(impl_id); | 1273 | let (self_ty, binders) = db.impl_self_ty(impl_id).into_value_and_skipped_binders(); |
1271 | let target_trait = impl_data.target_trait.as_ref()?; | 1274 | let target_trait = impl_data.target_trait.as_ref()?; |
1272 | Some(Binders::new(self_ty.num_binders, ctx.lower_trait_ref(target_trait, Some(self_ty.value))?)) | 1275 | Some(Binders::new(binders, ctx.lower_trait_ref(target_trait, Some(self_ty))?)) |
1273 | } | 1276 | } |
1274 | 1277 | ||
1275 | pub(crate) fn return_type_impl_traits( | 1278 | pub(crate) fn return_type_impl_traits( |