aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lower.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-29 19:00:43 +0100
committerFlorian Diebold <[email protected]>2021-04-29 19:00:43 +0100
commitb384cfcb81ae0db541cfe02213e9d95041b77362 (patch)
tree55db70978182a043187a7ded8b2fad39dfd8cabd /crates/hir_ty/src/lower.rs
parent184a0d7c1eb110571dc773c44a87206261fcf9ce (diff)
Handle cycles in generic_defaults more gracefully
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r--crates/hir_ty/src/lower.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 7fd46becd..d01933e6b 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -1089,6 +1089,27 @@ pub(crate) fn generic_defaults_query(
1089 defaults 1089 defaults
1090} 1090}
1091 1091
1092pub(crate) fn generic_defaults_recover(
1093 db: &dyn HirDatabase,
1094 _cycle: &[String],
1095 def: &GenericDefId,
1096) -> Arc<[Binders<Ty>]> {
1097 let generic_params = generics(db.upcast(), *def);
1098
1099 // we still need one default per parameter
1100 let defaults = generic_params
1101 .iter()
1102 .enumerate()
1103 .map(|(idx, _)| {
1104 let ty = TyKind::Error.intern(&Interner);
1105
1106 crate::make_only_type_binders(idx, ty)
1107 })
1108 .collect();
1109
1110 defaults
1111}
1112
1092fn fn_sig_for_fn(db: &dyn HirDatabase, def: FunctionId) -> PolyFnSig { 1113fn fn_sig_for_fn(db: &dyn HirDatabase, def: FunctionId) -> PolyFnSig {
1093 let data = db.function_data(def); 1114 let data = db.function_data(def);
1094 let resolver = def.resolver(db.upcast()); 1115 let resolver = def.resolver(db.upcast());