@@ -538,9 +538,9 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
538
538
539
539
impl ConstraintLocator < ' _ > {
540
540
#[ instrument( skip( self ) , level = "debug" ) ]
541
- fn check ( & mut self , def_id : LocalDefId ) {
541
+ fn check ( & mut self , item_def_id : LocalDefId ) {
542
542
// Don't try to check items that cannot possibly constrain the type.
543
- if !self . tcx . has_typeck_results ( def_id ) {
543
+ if !self . tcx . has_typeck_results ( item_def_id ) {
544
544
debug ! ( "no constraint: no typeck results" ) ;
545
545
return ;
546
546
}
@@ -555,26 +555,20 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
555
555
// // because we again need to reveal `Foo` so we can check whether the
556
556
// // constant does not contain interior mutability.
557
557
// ```
558
- let tables = self . tcx . typeck ( def_id ) ;
558
+ let tables = self . tcx . typeck ( item_def_id ) ;
559
559
if let Some ( _) = tables. tainted_by_errors {
560
560
self . found = Some ( ty:: OpaqueHiddenType { span : DUMMY_SP , ty : self . tcx . ty_error ( ) } ) ;
561
561
return ;
562
562
}
563
- if tables. concrete_opaque_types . get ( & self . def_id ) . is_none ( ) {
563
+ if ! tables. concrete_opaque_types . contains_key ( & self . def_id ) {
564
564
debug ! ( "no constraints in typeck results" ) ;
565
565
return ;
566
566
}
567
567
// Use borrowck to get the type with unerased regions.
568
- let concrete_opaque_types = & self . tcx . mir_borrowck ( def_id ) . concrete_opaque_types ;
568
+ let concrete_opaque_types = & self . tcx . mir_borrowck ( item_def_id ) . concrete_opaque_types ;
569
569
debug ! ( ?concrete_opaque_types) ;
570
- for & ( def_id, concrete_type) in concrete_opaque_types {
571
- if def_id != self . def_id {
572
- // Ignore constraints for other opaque types.
573
- continue ;
574
- }
575
-
570
+ if let Some ( & concrete_type) = concrete_opaque_types. get ( & self . def_id ) {
576
571
debug ! ( ?concrete_type, "found constraint" ) ;
577
-
578
572
if let Some ( prev) = self . found {
579
573
if concrete_type. ty != prev. ty && !( concrete_type, prev) . references_error ( ) {
580
574
prev. report_mismatch ( & concrete_type, self . tcx ) ;
0 commit comments