@@ -456,38 +456,38 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
456456 fn visit_local_decl ( & mut self , local : Local , local_decl : & LocalDecl < ' tcx > ) {
457457 self . super_local_decl ( local, local_decl) ;
458458
459- if let Some ( user_ty) = & local_decl. user_ty {
460- for ( user_ty, span) in user_ty. projections_and_spans ( ) {
461- let ty = if !local_decl. is_nonref_binding ( ) {
462- // If we have a binding of the form `let ref x: T = ..`
463- // then remove the outermost reference so we can check the
464- // type annotation for the remaining type.
465- if let ty:: Ref ( _, rty, _) = local_decl. ty . kind ( ) {
466- * rty
467- } else {
468- bug ! ( "{:?} with ref binding has wrong type {}" , local, local_decl. ty) ;
469- }
470- } else {
471- local_decl. ty
472- } ;
459+ for user_ty in
460+ local_decl. user_ty . as_deref ( ) . into_iter ( ) . flat_map ( UserTypeProjections :: projections)
461+ {
462+ let span = self . typeck . user_type_annotations [ user_ty. base ] . span ;
463+
464+ let ty = if local_decl. is_nonref_binding ( ) {
465+ local_decl. ty
466+ } else if let & ty:: Ref ( _, rty, _) = local_decl. ty . kind ( ) {
467+ // If we have a binding of the form `let ref x: T = ..`
468+ // then remove the outermost reference so we can check the
469+ // type annotation for the remaining type.
470+ rty
471+ } else {
472+ bug ! ( "{:?} with ref binding has wrong type {}" , local, local_decl. ty) ;
473+ } ;
473474
474- if let Err ( terr) = self . typeck . relate_type_and_user_type (
475- ty,
476- ty:: Invariant ,
477- user_ty,
478- Locations :: All ( * span) ,
479- ConstraintCategory :: TypeAnnotation ( AnnotationSource :: Declaration ) ,
480- ) {
481- span_mirbug ! (
482- self ,
483- local,
484- "bad user type on variable {:?}: {:?} != {:?} ({:?})" ,
485- local,
486- local_decl. ty,
487- local_decl. user_ty,
488- terr,
489- ) ;
490- }
475+ if let Err ( terr) = self . typeck . relate_type_and_user_type (
476+ ty,
477+ ty:: Invariant ,
478+ user_ty,
479+ Locations :: All ( span) ,
480+ ConstraintCategory :: TypeAnnotation ( AnnotationSource :: Declaration ) ,
481+ ) {
482+ span_mirbug ! (
483+ self ,
484+ local,
485+ "bad user type on variable {:?}: {:?} != {:?} ({:?})" ,
486+ local,
487+ local_decl. ty,
488+ local_decl. user_ty,
489+ terr,
490+ ) ;
491491 }
492492 }
493493 }
0 commit comments