aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lower.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r--crates/hir_ty/src/lower.rs26
1 files changed, 10 insertions, 16 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index b45e811fa..109157a5e 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -1016,22 +1016,16 @@ pub(crate) fn generic_defaults_query(
1016 p.default.as_ref().map_or(TyKind::Error.intern(&Interner), |t| ctx.lower_ty(t)); 1016 p.default.as_ref().map_or(TyKind::Error.intern(&Interner), |t| ctx.lower_ty(t));
1017 1017
1018 // Each default can only refer to previous parameters. 1018 // Each default can only refer to previous parameters.
1019 ty = ty.fold_binders( 1019 ty = crate::fold_free_vars(ty, |bound, binders| {
1020 &mut |ty, binders| match ty.kind(&Interner) { 1020 if bound.index >= idx && bound.debruijn == DebruijnIndex::INNERMOST {
1021 TyKind::BoundVar(BoundVar { debruijn, index }) if *debruijn == binders => { 1021 // type variable default referring to parameter coming
1022 if *index >= idx { 1022 // after it. This is forbidden (FIXME: report
1023 // type variable default referring to parameter coming 1023 // diagnostic)
1024 // after it. This is forbidden (FIXME: report 1024 TyKind::Error.intern(&Interner)
1025 // diagnostic) 1025 } else {
1026 TyKind::Error.intern(&Interner) 1026 bound.shifted_in_from(binders).to_ty(&Interner)
1027 } else { 1027 }
1028 ty 1028 });
1029 }
1030 }
1031 _ => ty,
1032 },
1033 DebruijnIndex::INNERMOST,
1034 );
1035 1029
1036 crate::make_only_type_binders(idx, ty) 1030 crate::make_only_type_binders(idx, ty)
1037 }) 1031 })