@@ -493,7 +493,7 @@ pub struct InferenceResult {
493
493
/// ```
494
494
/// the first `rest` has implicit `ref` binding mode, but the second `rest` binding mode is `move`.
495
495
pub binding_modes : ArenaMap < PatId , BindingMode > ,
496
- pub expr_adjustments : FxHashMap < ExprId , Vec < Adjustment > > ,
496
+ pub expr_adjustments : FxHashMap < ExprId , Box < [ Adjustment ] > > ,
497
497
pub ( crate ) closure_info : FxHashMap < ClosureId , ( Vec < CapturedItem > , FnTrait ) > ,
498
498
// FIXME: remove this field
499
499
pub mutated_bindings_in_closure : FxHashSet < BindingId > ,
@@ -785,8 +785,8 @@ impl<'a> InferenceContext<'a> {
785
785
// Comment from rustc:
786
786
// Even though coercion casts provide type hints, we check casts after fallback for
787
787
// backwards compatibility. This makes fallback a stronger type hint than a cast coercion.
788
- let mut apply_adjustments = |expr, adj| {
789
- expr_adjustments. insert ( expr, adj) ;
788
+ let mut apply_adjustments = |expr, adj : Vec < _ > | {
789
+ expr_adjustments. insert ( expr, adj. into_boxed_slice ( ) ) ;
790
790
} ;
791
791
let mut set_coercion_cast = |expr| {
792
792
coercion_casts. insert ( expr) ;
@@ -808,22 +808,27 @@ impl<'a> InferenceContext<'a> {
808
808
* ty = table. resolve_completely ( ty. clone ( ) ) ;
809
809
* has_errors = * has_errors || ty. contains_unknown ( ) ;
810
810
}
811
+ type_of_expr. shrink_to_fit ( ) ;
811
812
for ty in type_of_pat. values_mut ( ) {
812
813
* ty = table. resolve_completely ( ty. clone ( ) ) ;
813
814
* has_errors = * has_errors || ty. contains_unknown ( ) ;
814
815
}
816
+ type_of_pat. shrink_to_fit ( ) ;
815
817
for ty in type_of_binding. values_mut ( ) {
816
818
* ty = table. resolve_completely ( ty. clone ( ) ) ;
817
819
* has_errors = * has_errors || ty. contains_unknown ( ) ;
818
820
}
821
+ type_of_binding. shrink_to_fit ( ) ;
819
822
for ty in type_of_rpit. values_mut ( ) {
820
823
* ty = table. resolve_completely ( ty. clone ( ) ) ;
821
824
* has_errors = * has_errors || ty. contains_unknown ( ) ;
822
825
}
826
+ type_of_rpit. shrink_to_fit ( ) ;
823
827
for ty in type_of_for_iterator. values_mut ( ) {
824
828
* ty = table. resolve_completely ( ty. clone ( ) ) ;
825
829
* has_errors = * has_errors || ty. contains_unknown ( ) ;
826
830
}
831
+ type_of_for_iterator. shrink_to_fit ( ) ;
827
832
828
833
* has_errors |= !type_mismatches. is_empty ( ) ;
829
834
@@ -838,6 +843,7 @@ impl<'a> InferenceContext<'a> {
838
843
)
839
844
. is_ok ( )
840
845
} ) ;
846
+ type_mismatches. shrink_to_fit ( ) ;
841
847
diagnostics. retain_mut ( |diagnostic| {
842
848
use InferenceDiagnostic :: * ;
843
849
match diagnostic {
@@ -866,24 +872,29 @@ impl<'a> InferenceContext<'a> {
866
872
}
867
873
true
868
874
} ) ;
875
+ diagnostics. shrink_to_fit ( ) ;
869
876
for ( _, subst) in method_resolutions. values_mut ( ) {
870
877
* subst = table. resolve_completely ( subst. clone ( ) ) ;
871
878
* has_errors =
872
879
* has_errors || subst. type_parameters ( Interner ) . any ( |ty| ty. contains_unknown ( ) ) ;
873
880
}
881
+ method_resolutions. shrink_to_fit ( ) ;
874
882
for ( _, subst) in assoc_resolutions. values_mut ( ) {
875
883
* subst = table. resolve_completely ( subst. clone ( ) ) ;
876
884
* has_errors =
877
885
* has_errors || subst. type_parameters ( Interner ) . any ( |ty| ty. contains_unknown ( ) ) ;
878
886
}
887
+ assoc_resolutions. shrink_to_fit ( ) ;
879
888
for adjustment in expr_adjustments. values_mut ( ) . flatten ( ) {
880
889
adjustment. target = table. resolve_completely ( adjustment. target . clone ( ) ) ;
881
890
* has_errors = * has_errors || adjustment. target . contains_unknown ( ) ;
882
891
}
892
+ expr_adjustments. shrink_to_fit ( ) ;
883
893
for adjustment in pat_adjustments. values_mut ( ) . flatten ( ) {
884
894
* adjustment = table. resolve_completely ( adjustment. clone ( ) ) ;
885
895
* has_errors = * has_errors || adjustment. contains_unknown ( ) ;
886
896
}
897
+ pat_adjustments. shrink_to_fit ( ) ;
887
898
result. tuple_field_access_types = tuple_field_accesses_rev
888
899
. into_iter ( )
889
900
. enumerate ( )
@@ -893,6 +904,7 @@ impl<'a> InferenceContext<'a> {
893
904
* has_errors || subst. type_parameters ( Interner ) . any ( |ty| ty. contains_unknown ( ) ) ;
894
905
} )
895
906
. collect ( ) ;
907
+ result. tuple_field_access_types . shrink_to_fit ( ) ;
896
908
897
909
result. diagnostics = diagnostics;
898
910
@@ -1261,7 +1273,7 @@ impl<'a> InferenceContext<'a> {
1261
1273
self . result . type_of_expr . insert ( expr, ty) ;
1262
1274
}
1263
1275
1264
- fn write_expr_adj ( & mut self , expr : ExprId , adjustments : Vec < Adjustment > ) {
1276
+ fn write_expr_adj ( & mut self , expr : ExprId , adjustments : Box < [ Adjustment ] > ) {
1265
1277
if adjustments. is_empty ( ) {
1266
1278
return ;
1267
1279
}
0 commit comments