@@ -362,44 +362,43 @@ fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
362362 DefinitionSiteHiddenType :: new_error ( tcx, guar)
363363 } ) ;
364364
365- // Sometimes, when the hidden type is an inference variable, it can happen that
366- // the hidden type becomes the opaque type itself. In this case, this was an opaque
367- // usage of the opaque type and we can ignore it. This check is mirrored in typeck's
368- // writeback.
369365 if !rcx. infcx . tcx . use_typing_mode_post_typeck_until_borrowck ( ) {
366+ // Sometimes, when the hidden type is an inference variable, it can happen that
367+ // the hidden type becomes the opaque type itself. In this case, this was an opaque
368+ // usage of the opaque type and we can ignore it. This check is mirrored in typeck's
369+ // writeback.
370370 if let & ty:: Alias ( _, ty:: AliasTy { kind : ty:: Opaque { def_id } , args, .. } ) =
371371 hidden_type. ty . skip_binder ( ) . kind ( )
372372 && def_id == opaque_type_key. def_id . to_def_id ( )
373373 && args == opaque_type_key. args
374374 {
375375 continue ;
376376 }
377- }
378377
379- // Check that all opaque types have the same region parameters if they have the same
380- // non-region parameters. This is necessary because within the new solver we perform
381- // various query operations modulo regions, and thus could unsoundly select some impls
382- // that don't hold.
383- //
384- // FIXME(-Znext-solver): This isn't necessary after all. We can remove this check again.
385- if let Some ( ( prev_decl_key, prev_span) ) = decls_modulo_regions. insert (
386- rcx. infcx . tcx . erase_and_anonymize_regions ( opaque_type_key) ,
387- ( opaque_type_key, hidden_type. span ) ,
388- ) && let Some ( ( arg1, arg2) ) = std:: iter:: zip (
389- prev_decl_key. iter_captured_args ( infcx. tcx ) . map ( |( _, arg) | arg) ,
390- opaque_type_key. iter_captured_args ( infcx. tcx ) . map ( |( _, arg) | arg) ,
391- )
392- . find ( |( arg1, arg2) | arg1 != arg2)
393- {
394- errors. push ( DeferredOpaqueTypeError :: LifetimeMismatchOpaqueParam (
395- LifetimeMismatchOpaqueParam {
396- arg : arg1,
397- prev : arg2,
398- span : prev_span,
399- prev_span : hidden_type. span ,
400- } ,
401- ) ) ;
378+ // Check that all opaque types have the same region parameters if they have the same
379+ // non-region parameters. This is necessary because within the new solver we perform
380+ // various query operations modulo regions, and thus could unsoundly select some impls
381+ // that don't hold.
382+ if let Some ( ( prev_decl_key, prev_span) ) = decls_modulo_regions. insert (
383+ rcx. infcx . tcx . erase_and_anonymize_regions ( opaque_type_key) ,
384+ ( opaque_type_key, hidden_type. span ) ,
385+ ) && let Some ( ( arg1, arg2) ) = std:: iter:: zip (
386+ prev_decl_key. iter_captured_args ( infcx. tcx ) . map ( |( _, arg) | arg) ,
387+ opaque_type_key. iter_captured_args ( infcx. tcx ) . map ( |( _, arg) | arg) ,
388+ )
389+ . find ( |( arg1, arg2) | arg1 != arg2)
390+ {
391+ errors. push ( DeferredOpaqueTypeError :: LifetimeMismatchOpaqueParam (
392+ LifetimeMismatchOpaqueParam {
393+ arg : arg1,
394+ prev : arg2,
395+ span : prev_span,
396+ prev_span : hidden_type. span ,
397+ } ,
398+ ) ) ;
399+ }
402400 }
401+
403402 add_hidden_type ( tcx, hidden_types, opaque_type_key. def_id , hidden_type) ;
404403 }
405404}
0 commit comments