@@ -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 ;
@@ -1472,16 +1472,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
14721472 let def_id = self . item_def_id ( ) ;
14731473 debug ! ( item_def_id = ?def_id) ;
14741474
1475- let parent_def_id = def_id
1476- . as_local ( )
1477- . map ( |def_id| tcx. local_def_id_to_hir_id ( def_id) )
1478- . map ( |hir_id| tcx. hir ( ) . get_parent_item ( hir_id) . to_def_id ( ) ) ;
1475+ // FIXME: document why/how this is different from `tcx.local_parent(def_id)`
1476+ let parent_def_id =
1477+ tcx. hir ( ) . get_parent_item ( tcx. local_def_id_to_hir_id ( def_id) ) . to_def_id ( ) ;
14791478 debug ! ( ?parent_def_id) ;
14801479
14811480 // If the trait in segment is the same as the trait defining the item,
14821481 // use the `<Self as ..>` syntax in the error.
1483- let is_part_of_self_trait_constraints = def_id == trait_def_id;
1484- let is_part_of_fn_in_self_trait = parent_def_id == Some ( trait_def_id) ;
1482+ let is_part_of_self_trait_constraints = def_id. to_def_id ( ) == trait_def_id;
1483+ let is_part_of_fn_in_self_trait = parent_def_id == trait_def_id;
14851484
14861485 let type_names = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
14871486 vec ! [ "Self" . to_string( ) ]
@@ -1962,7 +1961,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
19621961 }
19631962
19641963 let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
1965- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
1964+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
19661965 let parent_generics = self . tcx ( ) . generics_of ( parent) ;
19671966
19681967 let parent_is_trait = ( self . tcx ( ) . def_kind ( parent) == DefKind :: Trait ) as usize ;
@@ -2001,7 +2000,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20012000 let sig = self . tcx ( ) . fn_sig ( sig_id) ;
20022001 let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
20032002
2004- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
2003+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
20052004 let parent_def_kind = self . tcx ( ) . def_kind ( parent) ;
20062005
20072006 let sig = if let DefKind :: Impl { .. } = parent_def_kind
0 commit comments