@@ -89,8 +89,8 @@ pub enum PredicateFilter {
8989pub trait HirTyLowerer < ' tcx > {
9090 fn tcx ( & self ) -> TyCtxt < ' tcx > ;
9191
92- /// Returns the [`DefId `] of the overarching item whose constituents get lowered.
93- fn item_def_id ( & self ) -> DefId ;
92+ /// Returns the [`LocalDefId `] of the overarching item whose constituents get lowered.
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 ;
@@ -1493,16 +1493,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
14931493 let def_id = self . item_def_id ( ) ;
14941494 debug ! ( item_def_id = ?def_id) ;
14951495
1496- let parent_def_id = def_id
1497- . as_local ( )
1498- . map ( |def_id| tcx. local_def_id_to_hir_id ( def_id) )
1499- . map ( |hir_id| tcx. hir ( ) . get_parent_item ( hir_id) . to_def_id ( ) ) ;
1496+ // FIXME: document why/how this is different from `tcx.local_parent(def_id)`
1497+ let parent_def_id =
1498+ tcx. hir ( ) . get_parent_item ( tcx. local_def_id_to_hir_id ( def_id) ) . to_def_id ( ) ;
15001499 debug ! ( ?parent_def_id) ;
15011500
15021501 // If the trait in segment is the same as the trait defining the item,
15031502 // use the `<Self as ..>` syntax in the error.
1504- let is_part_of_self_trait_constraints = def_id == trait_def_id;
1505- let is_part_of_fn_in_self_trait = parent_def_id == Some ( trait_def_id) ;
1503+ let is_part_of_self_trait_constraints = def_id. to_def_id ( ) == trait_def_id;
1504+ let is_part_of_fn_in_self_trait = parent_def_id == trait_def_id;
15061505
15071506 let type_names = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
15081507 vec ! [ "Self" . to_string( ) ]
@@ -1983,7 +1982,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
19831982 }
19841983
19851984 let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
1986- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
1985+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
19871986 let parent_generics = self . tcx ( ) . generics_of ( parent) ;
19881987
19891988 let parent_is_trait = ( self . tcx ( ) . def_kind ( parent) == DefKind :: Trait ) as usize ;
@@ -2022,7 +2021,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20222021 let sig = self . tcx ( ) . fn_sig ( sig_id) ;
20232022 let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
20242023
2025- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
2024+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
20262025 let parent_def_kind = self . tcx ( ) . def_kind ( parent) ;
20272026
20282027 let sig = if let DefKind :: Impl { .. } = parent_def_kind
0 commit comments