@@ -509,11 +509,10 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
509
509
}
510
510
}
511
511
512
+ #[ instrument( skip( tcx) , level = "debug" ) ]
512
513
fn find_opaque_ty_constraints ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Ty < ' _ > {
513
514
use rustc_hir:: { Expr , ImplItem , Item , TraitItem } ;
514
515
515
- debug ! ( "find_opaque_ty_constraints({:?})" , def_id) ;
516
-
517
516
struct ConstraintLocator < ' tcx > {
518
517
tcx : TyCtxt < ' tcx > ,
519
518
def_id : DefId ,
@@ -522,13 +521,11 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
522
521
}
523
522
524
523
impl ConstraintLocator < ' _ > {
524
+ #[ instrument( skip( self ) , level = "debug" ) ]
525
525
fn check ( & mut self , def_id : LocalDefId ) {
526
526
// Don't try to check items that cannot possibly constrain the type.
527
527
if !self . tcx . has_typeck_results ( def_id) {
528
- debug ! (
529
- "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`: no typeck results" ,
530
- self . def_id, def_id,
531
- ) ;
528
+ debug ! ( "no constraint: no typeck results" ) ;
532
529
return ;
533
530
}
534
531
// Calling `mir_borrowck` can lead to cycle errors through
@@ -540,21 +537,19 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
540
537
. get_by ( |( key, _) | key. def_id == self . def_id )
541
538
. is_none ( )
542
539
{
543
- debug ! (
544
- "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`" ,
545
- self . def_id, def_id,
546
- ) ;
540
+ debug ! ( "no constraints in typeck results" ) ;
547
541
return ;
548
542
}
549
543
// Use borrowck to get the type with unerased regions.
550
544
let concrete_opaque_types = & self . tcx . mir_borrowck ( def_id) . concrete_opaque_types ;
551
- if let Some ( ( opaque_type_key, concrete_type) ) =
552
- concrete_opaque_types. iter ( ) . find ( |( key, _) | key. def_id == self . def_id )
553
- {
554
- debug ! (
555
- "find_opaque_ty_constraints: found constraint for `{:?}` at `{:?}`: {:?}" ,
556
- self . def_id, def_id, concrete_type,
557
- ) ;
545
+ debug ! ( ?concrete_opaque_types) ;
546
+ for ( opaque_type_key, concrete_type) in concrete_opaque_types {
547
+ if opaque_type_key. def_id != self . def_id {
548
+ // Ignore constraints for other opaque types.
549
+ continue ;
550
+ }
551
+
552
+ debug ! ( ?concrete_type, ?opaque_type_key. substs, "found constraint" ) ;
558
553
559
554
// FIXME(oli-obk): trace the actual span from inference to improve errors.
560
555
let span = self . tcx . def_span ( def_id) ;
@@ -603,7 +598,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
603
598
604
599
if let Some ( ( prev_span, prev_ty) ) = self . found {
605
600
if * concrete_type != prev_ty {
606
- debug ! ( "find_opaque_ty_constraints: span={:?}" , span) ;
601
+ debug ! ( ? span) ;
607
602
// Found different concrete types for the opaque type.
608
603
let mut err = self . tcx . sess . struct_span_err (
609
604
span,
@@ -619,11 +614,6 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
619
614
} else {
620
615
self . found = Some ( ( span, concrete_type) ) ;
621
616
}
622
- } else {
623
- debug ! (
624
- "find_opaque_ty_constraints: no constraint for `{:?}` at `{:?}`" ,
625
- self . def_id, def_id,
626
- ) ;
627
617
}
628
618
}
629
619
}
0 commit comments