@@ -873,8 +873,8 @@ impl<'tcx> CommonConsts<'tcx> {
873
873
// conflict.
874
874
#[ derive( Debug ) ]
875
875
pub struct FreeRegionInfo {
876
- // def id corresponding to FreeRegion
877
- pub def_id : DefId ,
876
+ // `LocalDefId` corresponding to FreeRegion
877
+ pub def_id : LocalDefId ,
878
878
// the bound region corresponding to FreeRegion
879
879
pub boundregion : ty:: BoundRegion ,
880
880
// checks if bound region is in Impl Item
@@ -1412,14 +1412,17 @@ impl<'tcx> TyCtxt<'tcx> {
1412
1412
// Returns the `DefId` and the `BoundRegion` corresponding to the given region.
1413
1413
pub fn is_suitable_region ( & self , region : Region < ' tcx > ) -> Option < FreeRegionInfo > {
1414
1414
let ( suitable_region_binding_scope, bound_region) = match * region {
1415
- ty:: ReFree ( ref free_region) => ( free_region. scope , free_region. bound_region ) ,
1416
- ty:: ReEarlyBound ( ref ebr) => {
1417
- ( self . parent ( ebr. def_id ) . unwrap ( ) , ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) )
1415
+ ty:: ReFree ( ref free_region) => {
1416
+ ( free_region. scope . expect_local ( ) , free_region. bound_region )
1418
1417
}
1418
+ ty:: ReEarlyBound ( ref ebr) => (
1419
+ self . parent ( ebr. def_id ) . unwrap ( ) . expect_local ( ) ,
1420
+ ty:: BoundRegion :: BrNamed ( ebr. def_id , ebr. name ) ,
1421
+ ) ,
1419
1422
_ => return None , // not a free region
1420
1423
} ;
1421
1424
1422
- let hir_id = self . hir ( ) . as_local_hir_id ( suitable_region_binding_scope. expect_local ( ) ) ;
1425
+ let hir_id = self . hir ( ) . as_local_hir_id ( suitable_region_binding_scope) ;
1423
1426
let is_impl_item = match self . hir ( ) . find ( hir_id) {
1424
1427
Some ( Node :: Item ( ..) | Node :: TraitItem ( ..) ) => false ,
1425
1428
Some ( Node :: ImplItem ( ..) ) => {
@@ -1436,8 +1439,11 @@ impl<'tcx> TyCtxt<'tcx> {
1436
1439
}
1437
1440
1438
1441
/// Given a `DefId` for an `fn`, return all the `dyn` and `impl` traits in its return type.
1439
- pub fn return_type_impl_or_dyn_traits ( & self , scope_def_id : DefId ) -> Vec < & ' tcx hir:: Ty < ' tcx > > {
1440
- let hir_id = self . hir ( ) . as_local_hir_id ( scope_def_id. expect_local ( ) ) ;
1442
+ pub fn return_type_impl_or_dyn_traits (
1443
+ & self ,
1444
+ scope_def_id : LocalDefId ,
1445
+ ) -> Vec < & ' tcx hir:: Ty < ' tcx > > {
1446
+ let hir_id = self . hir ( ) . as_local_hir_id ( scope_def_id) ;
1441
1447
let hir_output = match self . hir ( ) . get ( hir_id) {
1442
1448
Node :: Item ( hir:: Item {
1443
1449
kind :
@@ -1480,9 +1486,9 @@ impl<'tcx> TyCtxt<'tcx> {
1480
1486
v. 0
1481
1487
}
1482
1488
1483
- pub fn return_type_impl_trait ( & self , scope_def_id : DefId ) -> Option < ( Ty < ' tcx > , Span ) > {
1489
+ pub fn return_type_impl_trait ( & self , scope_def_id : LocalDefId ) -> Option < ( Ty < ' tcx > , Span ) > {
1484
1490
// HACK: `type_of_def_id()` will fail on these (#55796), so return `None`.
1485
- let hir_id = self . hir ( ) . as_local_hir_id ( scope_def_id. expect_local ( ) ) ;
1491
+ let hir_id = self . hir ( ) . as_local_hir_id ( scope_def_id) ;
1486
1492
match self . hir ( ) . get ( hir_id) {
1487
1493
Node :: Item ( item) => {
1488
1494
match item. kind {
@@ -1512,8 +1518,9 @@ impl<'tcx> TyCtxt<'tcx> {
1512
1518
}
1513
1519
1514
1520
// Checks if the bound region is in Impl Item.
1515
- pub fn is_bound_region_in_impl_item ( & self , suitable_region_binding_scope : DefId ) -> bool {
1516
- let container_id = self . associated_item ( suitable_region_binding_scope) . container . id ( ) ;
1521
+ pub fn is_bound_region_in_impl_item ( & self , suitable_region_binding_scope : LocalDefId ) -> bool {
1522
+ let container_id =
1523
+ self . associated_item ( suitable_region_binding_scope. to_def_id ( ) ) . container . id ( ) ;
1517
1524
if self . impl_trait_ref ( container_id) . is_some ( ) {
1518
1525
// For now, we do not try to target impls of traits. This is
1519
1526
// because this message is going to suggest that the user
0 commit comments