@@ -173,38 +173,25 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
173173 ) ;
174174 }
175175
176- // Return types are a bit more complex. They may contain opaque `impl Trait` types.
176+ // Equate expected output ty with the type of the RETURN_PLACE in MIR
177177 let mir_output_ty = self . body . local_decls [ RETURN_PLACE ] . ty ;
178178 let output_span = self . body . local_decls [ RETURN_PLACE ] . source_info . span ;
179179 self . equate_normalized_input_or_output ( normalized_output_ty, mir_output_ty, output_span) ;
180180 }
181181
182182 #[ instrument( skip( self ) , level = "debug" ) ]
183183 fn equate_normalized_input_or_output ( & mut self , a : Ty < ' tcx > , b : Ty < ' tcx > , span : Span ) {
184- if let Err ( _) =
185- self . eq_types ( a, b, Locations :: All ( span) , ConstraintCategory :: BoringNoLocation )
186- {
187- // FIXME(jackh726): This is a hack. It's somewhat like
188- // `rustc_traits::normalize_after_erasing_regions`. Ideally, we'd
189- // like to normalize *before* inserting into `local_decls`, but
190- // doing so ends up causing some other trouble.
191- let b = self . normalize ( b, Locations :: All ( span) ) ;
192-
193- // Note: if we have to introduce new placeholders during normalization above, then we
194- // won't have added those universes to the universe info, which we would want in
195- // `relate_tys`.
196- if let Err ( terr) =
197- self . eq_types ( a, b, Locations :: All ( span) , ConstraintCategory :: BoringNoLocation )
198- {
199- span_mirbug ! (
200- self ,
201- Location :: START ,
202- "equate_normalized_input_or_output: `{:?}=={:?}` failed with `{:?}`" ,
203- a,
204- b,
205- terr
206- ) ;
207- }
208- }
184+ // FIXME(jackh726, BoxyUwU): This is a hack. `body.local_decls` are not necessarily
185+ // normalized in the old solver due to not deeply normalizing in writeback.
186+ //
187+ // They really should be though (and are in the new solver).
188+ let b = match self . infcx . tcx . next_trait_solver_globally ( ) {
189+ true => b,
190+ false => self . normalize ( b, Locations :: All ( span) ) ,
191+ } ;
192+
193+ debug ! ( ?b) ;
194+ self . eq_types ( a, b, Locations :: All ( span) , ConstraintCategory :: BoringNoLocation )
195+ . expect ( "equate_normalized_input_or_output unexpectedly failed" ) ;
209196 }
210197}
0 commit comments