diff options
author | Florian Diebold <[email protected]> | 2021-04-05 17:54:31 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 18:21:03 +0100 |
commit | e28f0c98ba449c372ffcc450ac756f0adbdf9549 (patch) | |
tree | 7a5ee320a6ac5615fb8270e3a9fae3b4bd9c0419 /crates/hir_ty/src/lower.rs | |
parent | 30a339e038bfd94d8c91f79287be9b7db4f0cb4e (diff) |
Get rid of some walk_mut uses
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r-- | crates/hir_ty/src/lower.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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( | |||
1011 | p.default.as_ref().map_or(TyKind::Error.intern(&Interner), |t| ctx.lower_ty(t)); | 1011 | p.default.as_ref().map_or(TyKind::Error.intern(&Interner), |t| ctx.lower_ty(t)); |
1012 | 1012 | ||
1013 | // Each default can only refer to previous parameters. | 1013 | // Each default can only refer to previous parameters. |
1014 | ty.walk_mut_binders( | 1014 | ty = ty.fold_binders( |
1015 | &mut |ty, binders| match ty.interned_mut() { | 1015 | &mut |ty, binders| match ty.kind(&Interner) { |
1016 | TyKind::BoundVar(BoundVar { debruijn, index }) if *debruijn == binders => { | 1016 | TyKind::BoundVar(BoundVar { debruijn, index }) if *debruijn == binders => { |
1017 | if *index >= idx { | 1017 | if *index >= idx { |
1018 | // type variable default referring to parameter coming | 1018 | // type variable default referring to parameter coming |
1019 | // after it. This is forbidden (FIXME: report | 1019 | // after it. This is forbidden (FIXME: report |
1020 | // diagnostic) | 1020 | // diagnostic) |
1021 | *ty = TyKind::Error.intern(&Interner); | 1021 | TyKind::Error.intern(&Interner) |
1022 | } else { | ||
1023 | ty | ||
1022 | } | 1024 | } |
1023 | } | 1025 | } |
1024 | _ => {} | 1026 | _ => ty, |
1025 | }, | 1027 | }, |
1026 | DebruijnIndex::INNERMOST, | 1028 | DebruijnIndex::INNERMOST, |
1027 | ); | 1029 | ); |