@@ -89,8 +89,8 @@ pub enum PredicateFilter {
89
89
pub trait HirTyLowerer < ' tcx > {
90
90
fn tcx ( & self ) -> TyCtxt < ' tcx > ;
91
91
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 ;
94
94
95
95
/// Returns `true` if the current context allows the use of inference variables.
96
96
fn allow_infer ( & self ) -> bool ;
@@ -1493,16 +1493,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1493
1493
let def_id = self . item_def_id ( ) ;
1494
1494
debug ! ( item_def_id = ?def_id) ;
1495
1495
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 ( ) ;
1500
1499
debug ! ( ?parent_def_id) ;
1501
1500
1502
1501
// If the trait in segment is the same as the trait defining the item,
1503
1502
// 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;
1506
1505
1507
1506
let type_names = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
1508
1507
vec ! [ "Self" . to_string( ) ]
@@ -1983,7 +1982,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1983
1982
}
1984
1983
1985
1984
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 ( ) ) ;
1987
1986
let parent_generics = self . tcx ( ) . generics_of ( parent) ;
1988
1987
1989
1988
let parent_is_trait = ( self . tcx ( ) . def_kind ( parent) == DefKind :: Trait ) as usize ;
@@ -2022,7 +2021,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2022
2021
let sig = self . tcx ( ) . fn_sig ( sig_id) ;
2023
2022
let sig_generics = self . tcx ( ) . generics_of ( sig_id) ;
2024
2023
2025
- let parent = self . tcx ( ) . parent ( self . item_def_id ( ) ) ;
2024
+ let parent = self . tcx ( ) . local_parent ( self . item_def_id ( ) ) ;
2026
2025
let parent_def_kind = self . tcx ( ) . def_kind ( parent) ;
2027
2026
2028
2027
let sig = if let DefKind :: Impl { .. } = parent_def_kind
0 commit comments