@@ -90,7 +90,7 @@ pub trait HirTyLowerer<'tcx> {
9090 fn tcx ( & self ) -> TyCtxt < ' tcx > ;
9191
9292 /// 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 ;
9494
9595 /// Returns `true` if the current context allows the use of inference variables.
9696 fn allow_infer ( & self ) -> bool ;
@@ -1477,16 +1477,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
14771477 let def_id = self . item_def_id ( ) ;
14781478 debug ! ( item_def_id = ?def_id) ;
14791479
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 ( ) ;
14841483 debug ! ( ?parent_def_id) ;
14851484
14861485 // If the trait in segment is the same as the trait defining the item,
14871486 // 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;
14901489
14911490 let type_names = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
14921491 vec ! [ "Self" . to_string( ) ]
@@ -1967,7 +1966,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
19671966 }
19681967
19691968 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 ( ) ) ;
19711970 let parent_generics = self . tcx ( ) . generics_of ( parent) ;
19721971
19731972 let parent_is_trait = ( self . tcx ( ) . def_kind ( parent) == DefKind :: Trait ) as usize ;
@@ -2006,7 +2005,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20062005 let sig = self . tcx ( ) . fn_sig ( sig_id) ;
20072006 let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
20082007
2009- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
2008+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
20102009 let parent_def_kind = self . tcx ( ) . def_kind ( parent) ;
20112010
20122011 let sig = if let DefKind :: Impl { .. } = parent_def_kind
0 commit comments