@@ -626,6 +626,7 @@ 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
630
fn check_opaque_meets_bounds < ' tcx > (
630
631
tcx : TyCtxt < ' tcx > ,
631
632
def_id : LocalDefId ,
@@ -643,7 +644,7 @@ fn check_opaque_meets_bounds<'tcx>(
643
644
let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
644
645
let param_env = tcx. param_env ( def_id) ;
645
646
646
- tcx. infer_ctxt ( ) . enter ( move |infcx| {
647
+ tcx. infer_ctxt ( ) . with_opaque_type_inference ( def_id ) . enter ( move |infcx| {
647
648
let inh = Inherited :: new ( infcx, def_id) ;
648
649
let infcx = & inh. infcx ;
649
650
let opaque_ty = tcx. mk_opaque ( def_id. to_def_id ( ) , substs) ;
@@ -656,16 +657,15 @@ fn check_opaque_meets_bounds<'tcx>(
656
657
657
658
let opaque_type_map = infcx. inner . borrow ( ) . opaque_types . clone ( ) ;
658
659
for ( OpaqueTypeKey { def_id, substs } , opaque_defn) in opaque_type_map {
659
- match infcx
660
- . at ( & misc_cause, param_env)
661
- . eq ( opaque_defn. concrete_ty , tcx. type_of ( def_id) . subst ( tcx, substs) )
662
- {
660
+ let hidden_type = tcx. type_of ( def_id) . subst ( tcx, substs) ;
661
+ trace ! ( ?hidden_type) ;
662
+ match infcx. at ( & misc_cause, param_env) . eq ( opaque_defn. concrete_ty , hidden_type) {
663
663
Ok ( infer_ok) => inh. register_infer_ok_obligations ( infer_ok) ,
664
664
Err ( ty_err) => tcx. sess . delay_span_bug (
665
- opaque_defn . definition_span ,
665
+ span ,
666
666
& format ! (
667
- "could not unify `{}` with revealed type:\n {}" ,
668
- opaque_defn . concrete_ty , ty_err,
667
+ "could not check bounds on revealed type `{}` :\n {}" ,
668
+ hidden_type , ty_err,
669
669
) ,
670
670
) ,
671
671
}
0 commit comments