@@ -579,9 +579,31 @@ impl<'a> InferenceContext<'a> {
579
579
// used this function for another workaround, mention it here. If you really need this function and believe that
580
580
// there is no problem in it being `pub(crate)`, remove this comment.
581
581
pub ( crate ) fn resolve_all ( self ) -> InferenceResult {
582
- // NOTE: `InferenceResult::closure_info` is `resolve_completely()`'d during
583
- // `InferenceContext::infer_closures()` (in `HirPlace::ty()` specifically).
584
582
let InferenceContext { mut table, mut result, .. } = self ;
583
+ // Destructure every single field so whenever new fields are added to `InferenceResult` we
584
+ // don't forget to handle them here.
585
+ let InferenceResult {
586
+ method_resolutions,
587
+ field_resolutions : _,
588
+ variant_resolutions : _,
589
+ assoc_resolutions,
590
+ diagnostics,
591
+ type_of_expr,
592
+ type_of_pat,
593
+ type_of_binding,
594
+ type_of_rpit,
595
+ type_of_for_iterator,
596
+ type_mismatches,
597
+ standard_types : _,
598
+ pat_adjustments,
599
+ binding_modes : _,
600
+ expr_adjustments,
601
+ // Types in `closure_info` have already been `resolve_completely()`'d during
602
+ // `InferenceContext::infer_closures()` (in `HirPlace::ty()` specifically), so no need
603
+ // to resolve them here.
604
+ closure_info : _,
605
+ mutated_bindings_in_closure : _,
606
+ } = & mut result;
585
607
586
608
table. fallback_if_possible ( ) ;
587
609
@@ -590,26 +612,26 @@ impl<'a> InferenceContext<'a> {
590
612
591
613
// make sure diverging type variables are marked as such
592
614
table. propagate_diverging_flag ( ) ;
593
- for ty in result . type_of_expr . values_mut ( ) {
615
+ for ty in type_of_expr. values_mut ( ) {
594
616
* ty = table. resolve_completely ( ty. clone ( ) ) ;
595
617
}
596
- for ty in result . type_of_pat . values_mut ( ) {
618
+ for ty in type_of_pat. values_mut ( ) {
597
619
* ty = table. resolve_completely ( ty. clone ( ) ) ;
598
620
}
599
- for ty in result . type_of_binding . values_mut ( ) {
621
+ for ty in type_of_binding. values_mut ( ) {
600
622
* ty = table. resolve_completely ( ty. clone ( ) ) ;
601
623
}
602
- for ty in result . type_of_rpit . values_mut ( ) {
624
+ for ty in type_of_rpit. values_mut ( ) {
603
625
* ty = table. resolve_completely ( ty. clone ( ) ) ;
604
626
}
605
- for ty in result . type_of_for_iterator . values_mut ( ) {
627
+ for ty in type_of_for_iterator. values_mut ( ) {
606
628
* ty = table. resolve_completely ( ty. clone ( ) ) ;
607
629
}
608
- for mismatch in result . type_mismatches . values_mut ( ) {
630
+ for mismatch in type_mismatches. values_mut ( ) {
609
631
mismatch. expected = table. resolve_completely ( mismatch. expected . clone ( ) ) ;
610
632
mismatch. actual = table. resolve_completely ( mismatch. actual . clone ( ) ) ;
611
633
}
612
- result . diagnostics . retain_mut ( |diagnostic| {
634
+ diagnostics. retain_mut ( |diagnostic| {
613
635
use InferenceDiagnostic :: * ;
614
636
match diagnostic {
615
637
ExpectedFunction { found : ty, .. }
@@ -637,16 +659,16 @@ impl<'a> InferenceContext<'a> {
637
659
}
638
660
true
639
661
} ) ;
640
- for ( _, subst) in result . method_resolutions . values_mut ( ) {
662
+ for ( _, subst) in method_resolutions. values_mut ( ) {
641
663
* subst = table. resolve_completely ( subst. clone ( ) ) ;
642
664
}
643
- for ( _, subst) in result . assoc_resolutions . values_mut ( ) {
665
+ for ( _, subst) in assoc_resolutions. values_mut ( ) {
644
666
* subst = table. resolve_completely ( subst. clone ( ) ) ;
645
667
}
646
- for adjustment in result . expr_adjustments . values_mut ( ) . flatten ( ) {
668
+ for adjustment in expr_adjustments. values_mut ( ) . flatten ( ) {
647
669
adjustment. target = table. resolve_completely ( adjustment. target . clone ( ) ) ;
648
670
}
649
- for adjustment in result . pat_adjustments . values_mut ( ) . flatten ( ) {
671
+ for adjustment in pat_adjustments. values_mut ( ) . flatten ( ) {
650
672
* adjustment = table. resolve_completely ( adjustment. clone ( ) ) ;
651
673
}
652
674
result
0 commit comments