@@ -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 ;
@@ -1472,16 +1472,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1472
1472
let def_id = self . item_def_id ( ) ;
1473
1473
debug ! ( item_def_id = ?def_id) ;
1474
1474
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 ( ) ;
1479
1478
debug ! ( ?parent_def_id) ;
1480
1479
1481
1480
// If the trait in segment is the same as the trait defining the item,
1482
1481
// 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;
1485
1484
1486
1485
let type_names = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
1487
1486
vec ! [ "Self" . to_string( ) ]
@@ -1962,7 +1961,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1962
1961
}
1963
1962
1964
1963
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 ( ) ) ;
1966
1965
let parent_generics = self . tcx ( ) . generics_of ( parent) ;
1967
1966
1968
1967
let parent_is_trait = ( self . tcx ( ) . def_kind ( parent) == DefKind :: Trait ) as usize ;
@@ -2001,7 +2000,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2001
2000
let sig = self . tcx ( ) . fn_sig ( sig_id) ;
2002
2001
let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
2003
2002
2004
- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
2003
+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
2005
2004
let parent_def_kind = self . tcx ( ) . def_kind ( parent) ;
2006
2005
2007
2006
let sig = if let DefKind :: Impl { .. } = parent_def_kind
0 commit comments