From e28f0c98ba449c372ffcc450ac756f0adbdf9549 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 5 Apr 2021 18:54:31 +0200 Subject: Get rid of some walk_mut uses --- crates/hir_ty/src/lower.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/hir_ty/src/lower.rs') diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 00838b298..a3c3ef6b2 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -1011,17 +1011,19 @@ pub(crate) fn generic_defaults_query( p.default.as_ref().map_or(TyKind::Error.intern(&Interner), |t| ctx.lower_ty(t)); // Each default can only refer to previous parameters. - ty.walk_mut_binders( - &mut |ty, binders| match ty.interned_mut() { + ty = ty.fold_binders( + &mut |ty, binders| match ty.kind(&Interner) { TyKind::BoundVar(BoundVar { debruijn, index }) if *debruijn == binders => { if *index >= idx { // type variable default referring to parameter coming // after it. This is forbidden (FIXME: report // diagnostic) - *ty = TyKind::Error.intern(&Interner); + TyKind::Error.intern(&Interner) + } else { + ty } } - _ => {} + _ => ty, }, DebruijnIndex::INNERMOST, ); -- cgit v1.2.3