@@ -90,7 +90,7 @@ pub trait HirTyLowerer<'tcx> {
90
90
fn tcx ( & self ) -> TyCtxt < ' tcx > ;
91
91
92
92
/// Returns the [`DefId`] of the overarching item whose constituents get lowered.
93
- fn item_def_id ( & self ) -> DefId ;
93
+ fn item_def_id ( & self ) -> LocalDefId ;
94
94
95
95
/// Returns `true` if the current context allows the use of inference variables.
96
96
fn allow_infer ( & self ) -> bool ;
@@ -1477,16 +1477,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1477
1477
let def_id = self . item_def_id ( ) ;
1478
1478
debug ! ( item_def_id = ?def_id) ;
1479
1479
1480
- let parent_def_id = def_id
1481
- . as_local ( )
1482
- . map ( |def_id| tcx. local_def_id_to_hir_id ( def_id) )
1483
- . map ( |hir_id| tcx. hir ( ) . get_parent_item ( hir_id) . to_def_id ( ) ) ;
1480
+ // FIXME: document why/how this is different from `tcx.local_parent(def_id)`
1481
+ let parent_def_id =
1482
+ tcx. hir ( ) . get_parent_item ( tcx. local_def_id_to_hir_id ( def_id) ) . to_def_id ( ) ;
1484
1483
debug ! ( ?parent_def_id) ;
1485
1484
1486
1485
// If the trait in segment is the same as the trait defining the item,
1487
1486
// use the `<Self as ..>` syntax in the error.
1488
- let is_part_of_self_trait_constraints = def_id == trait_def_id;
1489
- let is_part_of_fn_in_self_trait = parent_def_id == Some ( trait_def_id) ;
1487
+ let is_part_of_self_trait_constraints = def_id. to_def_id ( ) == trait_def_id;
1488
+ let is_part_of_fn_in_self_trait = parent_def_id == trait_def_id;
1490
1489
1491
1490
let type_names = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
1492
1491
vec ! [ "Self" . to_string( ) ]
@@ -1967,7 +1966,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1967
1966
}
1968
1967
1969
1968
let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
1970
- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
1969
+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
1971
1970
let parent_generics = self . tcx ( ) . generics_of ( parent) ;
1972
1971
1973
1972
let parent_is_trait = ( self . tcx ( ) . def_kind ( parent) == DefKind :: Trait ) as usize ;
@@ -2006,7 +2005,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2006
2005
let sig = self . tcx ( ) . fn_sig ( sig_id) ;
2007
2006
let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
2008
2007
2009
- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
2008
+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
2010
2009
let parent_def_kind = self . tcx ( ) . def_kind ( parent) ;
2011
2010
2012
2011
let sig = if let DefKind :: Impl { .. } = parent_def_kind
0 commit comments