@@ -1052,24 +1052,29 @@ impl<'tcx> TyCtxt<'tcx> {
1052
1052
}
1053
1053
1054
1054
/// Returns the `DefId` and the `BoundRegionKind` corresponding to the given region.
1055
- pub fn is_suitable_region ( self , region : Region < ' tcx > ) -> Option < FreeRegionInfo > {
1056
- let ( suitable_region_binding_scope, bound_region) = match * region {
1057
- ty:: ReFree ( ref free_region) => {
1058
- ( free_region. scope . expect_local ( ) , free_region. bound_region )
1055
+ pub fn is_suitable_region ( self , mut region : Region < ' tcx > ) -> Option < FreeRegionInfo > {
1056
+ let ( suitable_region_binding_scope, bound_region) = loop {
1057
+ let def_id = match region. kind ( ) {
1058
+ ty:: ReFree ( fr) => fr. bound_region . get_id ( ) ?. as_local ( ) ?,
1059
+ ty:: ReEarlyBound ( ebr) => ebr. def_id . expect_local ( ) ,
1060
+ _ => return None , // not a free region
1061
+ } ;
1062
+ let scope = self . local_parent ( def_id) ;
1063
+ if self . def_kind ( scope) == DefKind :: OpaqueTy {
1064
+ // Lifetime params of opaque types are synthetic and thus irrelevant to
1065
+ // diagnostics. Map them back to their origin!
1066
+ region = self . map_rpit_lifetime_to_fn_lifetime ( def_id) ;
1067
+ continue ;
1059
1068
}
1060
- ty:: ReEarlyBound ( ref ebr) => (
1061
- self . local_parent ( ebr. def_id . expect_local ( ) ) ,
1062
- ty:: BoundRegionKind :: BrNamed ( ebr. def_id , ebr. name ) ,
1063
- ) ,
1064
- _ => return None , // not a free region
1069
+ break ( scope, ty:: BrNamed ( def_id. into ( ) , self . item_name ( def_id. into ( ) ) ) ) ;
1065
1070
} ;
1066
1071
1067
1072
let is_impl_item = match self . hir ( ) . find_by_def_id ( suitable_region_binding_scope) {
1068
1073
Some ( Node :: Item ( ..) | Node :: TraitItem ( ..) ) => false ,
1069
1074
Some ( Node :: ImplItem ( ..) ) => {
1070
1075
self . is_bound_region_in_impl_item ( suitable_region_binding_scope)
1071
1076
}
1072
- _ => return None ,
1077
+ _ => false ,
1073
1078
} ;
1074
1079
1075
1080
Some ( FreeRegionInfo {
0 commit comments