@@ -28,13 +28,9 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
2828 pub ( super ) fn try_handle_opaque_type_uses_next ( & mut self ) {
2929 // We clone the opaques instead of stealing them here as we still need
3030 // to use them after fallback.
31- let mut opaque_types: Vec < _ > = self . infcx . clone_opaque_types ( ) ;
32- for entry in & mut opaque_types {
33- * entry = self . resolve_vars_if_possible ( * entry) ;
34- }
35- debug ! ( ?opaque_types) ;
31+ let opaque_types: Vec < _ > = self . infcx . clone_opaque_types ( ) ;
3632
37- self . compute_definition_site_hidden_types ( & opaque_types, false ) ;
33+ self . compute_definition_site_hidden_types ( opaque_types, false ) ;
3834 }
3935
4036 /// This takes all the opaque type uses during HIR typeck. It first computes
@@ -49,16 +45,12 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
4945 pub ( super ) fn handle_opaque_type_uses_next ( & mut self ) {
5046 // We clone the opaques instead of stealing them here as they are still used for
5147 // normalization in the next generation trait solver.
52- let mut opaque_types: Vec < _ > = self . infcx . clone_opaque_types ( ) ;
48+ let opaque_types: Vec < _ > = self . infcx . clone_opaque_types ( ) ;
5349 let num_entries = self . inner . borrow_mut ( ) . opaque_types ( ) . num_entries ( ) ;
5450 let prev = self . checked_opaque_types_storage_entries . replace ( Some ( num_entries) ) ;
5551 debug_assert_eq ! ( prev, None ) ;
56- for entry in & mut opaque_types {
57- * entry = self . resolve_vars_if_possible ( * entry) ;
58- }
59- debug ! ( ?opaque_types) ;
6052
61- self . compute_definition_site_hidden_types ( & opaque_types, true ) ;
53+ self . compute_definition_site_hidden_types ( opaque_types, true ) ;
6254 }
6355}
6456
@@ -96,9 +88,14 @@ impl<'tcx> UsageKind<'tcx> {
9688impl < ' tcx > FnCtxt < ' _ , ' tcx > {
9789 fn compute_definition_site_hidden_types (
9890 & mut self ,
99- opaque_types : & [ ( OpaqueTypeKey < ' tcx > , OpaqueHiddenType < ' tcx > ) ] ,
91+ mut opaque_types : Vec < ( OpaqueTypeKey < ' tcx > , OpaqueHiddenType < ' tcx > ) > ,
10092 error_on_missing_defining_use : bool ,
10193 ) {
94+ for entry in opaque_types. iter_mut ( ) {
95+ * entry = self . resolve_vars_if_possible ( * entry) ;
96+ }
97+ debug ! ( ?opaque_types) ;
98+
10299 let tcx = self . tcx ;
103100 let TypingMode :: Analysis { defining_opaque_types_and_generators } = self . typing_mode ( )
104101 else {
@@ -116,7 +113,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
116113 // store this), because we can go from `UnconstrainedHiddenType` to
117114 // `HasDefiningUse` (because of fallback)
118115 let mut usage_kind = UsageKind :: None ;
119- for & ( opaque_type_key, hidden_type) in opaque_types {
116+ for & ( opaque_type_key, hidden_type) in & opaque_types {
120117 if opaque_type_key. def_id != def_id {
121118 continue ;
122119 }
@@ -129,7 +126,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
129126 }
130127
131128 if let UsageKind :: HasDefiningUse ( ty) = usage_kind {
132- for & ( opaque_type_key, hidden_type) in opaque_types {
129+ for & ( opaque_type_key, hidden_type) in & opaque_types {
133130 if opaque_type_key. def_id != def_id {
134131 continue ;
135132 }
@@ -145,8 +142,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
145142 let _ = self . typeck_results . borrow_mut ( ) . hidden_types . insert ( def_id, ty) ;
146143 }
147144
148- // If this the first pass (` try_handle_opaque_type_uses_next`),
149- // then do not report any errors.
145+ // If we're in `fn try_handle_opaque_type_uses_next` then do not
146+ // report any errors.
150147 if !error_on_missing_defining_use {
151148 continue ;
152149 }
0 commit comments