@@ -626,25 +626,22 @@ pub(super) fn check_opaque_for_cycles<'tcx>(
626
626
///
627
627
/// Without this check the above code is incorrectly accepted: we would ICE if
628
628
/// some tried, for example, to clone an `Option<X<&mut ()>>`.
629
- #[ instrument( skip( tcx) ) ]
629
+ #[ instrument( level = "debug" , skip( tcx) ) ]
630
630
fn check_opaque_meets_bounds < ' tcx > (
631
631
tcx : TyCtxt < ' tcx > ,
632
632
def_id : LocalDefId ,
633
633
substs : SubstsRef < ' tcx > ,
634
634
span : Span ,
635
635
origin : & hir:: OpaqueTyOrigin ,
636
636
) {
637
- match origin {
638
- // Checked when type checking the function containing them.
639
- hir:: OpaqueTyOrigin :: FnReturn ( ..) | hir:: OpaqueTyOrigin :: AsyncFn ( ..) => return ,
640
- // Can have different predicates to their defining use
641
- hir:: OpaqueTyOrigin :: TyAlias => { }
642
- }
643
-
644
637
let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
645
- let param_env = tcx. param_env ( def_id) ;
638
+ let defining_use_anchor = match * origin {
639
+ hir:: OpaqueTyOrigin :: FnReturn ( did) | hir:: OpaqueTyOrigin :: AsyncFn ( did) => did,
640
+ hir:: OpaqueTyOrigin :: TyAlias => def_id,
641
+ } ;
642
+ let param_env = tcx. param_env ( defining_use_anchor) ;
646
643
647
- tcx. infer_ctxt ( ) . with_opaque_type_inference ( def_id ) . enter ( move |infcx| {
644
+ tcx. infer_ctxt ( ) . with_opaque_type_inference ( defining_use_anchor ) . enter ( move |infcx| {
648
645
let inh = Inherited :: new ( infcx, def_id) ;
649
646
let infcx = & inh. infcx ;
650
647
let opaque_ty = tcx. mk_opaque ( def_id. to_def_id ( ) , substs) ;
@@ -678,10 +675,17 @@ fn check_opaque_meets_bounds<'tcx>(
678
675
infcx. report_fulfillment_errors ( & errors, None , false ) ;
679
676
}
680
677
681
- // Finally, resolve all regions. This catches wily misuses of
682
- // lifetime parameters.
683
- let fcx = FnCtxt :: new ( & inh, param_env, hir_id) ;
684
- fcx. regionck_item ( hir_id, span, FxHashSet :: default ( ) ) ;
678
+ match origin {
679
+ // Checked when type checking the function containing them.
680
+ hir:: OpaqueTyOrigin :: FnReturn ( ..) | hir:: OpaqueTyOrigin :: AsyncFn ( ..) => return ,
681
+ // Can have different predicates to their defining use
682
+ hir:: OpaqueTyOrigin :: TyAlias => {
683
+ // Finally, resolve all regions. This catches wily misuses of
684
+ // lifetime parameters.
685
+ let fcx = FnCtxt :: new ( & inh, param_env, hir_id) ;
686
+ fcx. regionck_item ( hir_id, span, FxHashSet :: default ( ) ) ;
687
+ }
688
+ }
685
689
} ) ;
686
690
}
687
691
0 commit comments