1
Fork 0

Partly flatten the user-type loop in TypeVerifier::visit_local_decl

This commit is contained in:
Zalathar 2025-02-16 21:19:44 +11:00
parent 6d3c050de8
commit 849b0920b1

View file

@ -456,8 +456,12 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) { fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) {
self.super_local_decl(local, local_decl); self.super_local_decl(local, local_decl);
if let Some(user_ty) = &local_decl.user_ty { for (user_ty, span) in local_decl
for (user_ty, span) in user_ty.projections_and_spans() { .user_ty
.as_deref()
.into_iter()
.flat_map(UserTypeProjections::projections_and_spans)
{
let ty = if !local_decl.is_nonref_binding() { let ty = if !local_decl.is_nonref_binding() {
// If we have a binding of the form `let ref x: T = ..` // If we have a binding of the form `let ref x: T = ..`
// then remove the outermost reference so we can check the // then remove the outermost reference so we can check the
@ -490,7 +494,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
} }
} }
} }
}
fn visit_body(&mut self, body: &Body<'tcx>) { fn visit_body(&mut self, body: &Body<'tcx>) {
// The types of local_decls are checked above which is called in super_body. // The types of local_decls are checked above which is called in super_body.