@@ -15,7 +15,7 @@ use rustc_attr as attr;
1515use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap , FxIndexSet , IndexEntry } ;
1616use rustc_hir as hir;
1717use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
18- use rustc_hir:: def_id:: { DefId , DefIdMap , DefIdSet , LOCAL_CRATE } ;
18+ use rustc_hir:: def_id:: { DefId , DefIdMap , DefIdSet , LocalDefId , LOCAL_CRATE } ;
1919use rustc_hir:: PredicateOrigin ;
2020use rustc_hir_analysis:: hir_ty_to_ty;
2121use rustc_infer:: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
@@ -116,7 +116,8 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
116116 }
117117 } ) ;
118118
119- Item :: from_hir_id_and_parts ( doc. id , Some ( doc. name ) , ModuleItem ( Module { items, span } ) , cx)
119+ let kind = ModuleItem ( Module { items, span } ) ;
120+ Item :: from_def_id_and_parts ( doc. def_id . to_def_id ( ) , Some ( doc. name ) , kind, cx)
120121}
121122
122123fn clean_generic_bound < ' tcx > (
@@ -2067,12 +2068,12 @@ struct OneLevelVisitor<'hir> {
20672068 map : rustc_middle:: hir:: map:: Map < ' hir > ,
20682069 item : Option < & ' hir hir:: Item < ' hir > > ,
20692070 looking_for : Ident ,
2070- target_hir_id : hir :: HirId ,
2071+ target_def_id : LocalDefId ,
20712072}
20722073
20732074impl < ' hir > OneLevelVisitor < ' hir > {
2074- fn new ( map : rustc_middle:: hir:: map:: Map < ' hir > , target_hir_id : hir :: HirId ) -> Self {
2075- Self { map, item : None , looking_for : Ident :: empty ( ) , target_hir_id }
2075+ fn new ( map : rustc_middle:: hir:: map:: Map < ' hir > , target_def_id : LocalDefId ) -> Self {
2076+ Self { map, item : None , looking_for : Ident :: empty ( ) , target_def_id }
20762077 }
20772078
20782079 fn reset ( & mut self , looking_for : Ident ) {
@@ -2092,7 +2093,7 @@ impl<'hir> hir::intravisit::Visitor<'hir> for OneLevelVisitor<'hir> {
20922093 if self . item . is_none ( )
20932094 && item. ident == self . looking_for
20942095 && matches ! ( item. kind, hir:: ItemKind :: Use ( _, _) )
2095- || item. hir_id ( ) == self . target_hir_id
2096+ || item. owner_id . def_id == self . target_def_id
20962097 {
20972098 self . item = Some ( item) ;
20982099 }
@@ -2106,11 +2107,11 @@ impl<'hir> hir::intravisit::Visitor<'hir> for OneLevelVisitor<'hir> {
21062107fn get_all_import_attributes < ' hir > (
21072108 mut item : & hir:: Item < ' hir > ,
21082109 tcx : TyCtxt < ' hir > ,
2109- target_hir_id : hir :: HirId ,
2110+ target_def_id : LocalDefId ,
21102111 attributes : & mut Vec < ast:: Attribute > ,
21112112) {
21122113 let hir_map = tcx. hir ( ) ;
2113- let mut visitor = OneLevelVisitor :: new ( hir_map, target_hir_id ) ;
2114+ let mut visitor = OneLevelVisitor :: new ( hir_map, target_def_id ) ;
21142115 // If the item is an import and has at least a path with two parts, we go into it.
21152116 while let hir:: ItemKind :: Use ( path, _) = item. kind &&
21162117 path. segments . len ( ) > 1 &&
@@ -2138,7 +2139,7 @@ fn clean_maybe_renamed_item<'tcx>(
21382139 cx : & mut DocContext < ' tcx > ,
21392140 item : & hir:: Item < ' tcx > ,
21402141 renamed : Option < Symbol > ,
2141- import_id : Option < hir :: HirId > ,
2142+ import_id : Option < LocalDefId > ,
21422143) -> Vec < Item > {
21432144 use hir:: ItemKind ;
21442145
@@ -2183,7 +2184,7 @@ fn clean_maybe_renamed_item<'tcx>(
21832184 generics : clean_generics ( generics, cx) ,
21842185 fields : variant_data. fields ( ) . iter ( ) . map ( |x| clean_field ( x, cx) ) . collect ( ) ,
21852186 } ) ,
2186- ItemKind :: Impl ( impl_) => return clean_impl ( impl_, item. hir_id ( ) , cx) ,
2187+ ItemKind :: Impl ( impl_) => return clean_impl ( impl_, item. owner_id . def_id , cx) ,
21872188 // proc macros can have a name set by attributes
21882189 ItemKind :: Fn ( ref sig, generics, body_id) => {
21892190 clean_fn_or_proc_macro ( item, sig, generics, body_id, & mut name, cx)
@@ -2218,10 +2219,10 @@ fn clean_maybe_renamed_item<'tcx>(
22182219
22192220 let mut extra_attrs = Vec :: new ( ) ;
22202221 if let Some ( hir:: Node :: Item ( use_node) ) =
2221- import_id. and_then ( |hir_id | cx. tcx . hir ( ) . find ( hir_id ) )
2222+ import_id. and_then ( |def_id | cx. tcx . hir ( ) . find_by_def_id ( def_id ) )
22222223 {
22232224 // We get all the various imports' attributes.
2224- get_all_import_attributes ( use_node, cx. tcx , item. hir_id ( ) , & mut extra_attrs) ;
2225+ get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut extra_attrs) ;
22252226 }
22262227
22272228 if !extra_attrs. is_empty ( ) {
@@ -2244,12 +2245,12 @@ fn clean_maybe_renamed_item<'tcx>(
22442245
22452246fn clean_variant < ' tcx > ( variant : & hir:: Variant < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Item {
22462247 let kind = VariantItem ( clean_variant_data ( & variant. data , & variant. disr_expr , cx) ) ;
2247- Item :: from_hir_id_and_parts ( variant. hir_id , Some ( variant. ident . name ) , kind, cx)
2248+ Item :: from_def_id_and_parts ( variant. def_id . to_def_id ( ) , Some ( variant. ident . name ) , kind, cx)
22482249}
22492250
22502251fn clean_impl < ' tcx > (
22512252 impl_ : & hir:: Impl < ' tcx > ,
2252- hir_id : hir :: HirId ,
2253+ def_id : LocalDefId ,
22532254 cx : & mut DocContext < ' tcx > ,
22542255) -> Vec < Item > {
22552256 let tcx = cx. tcx ;
@@ -2260,7 +2261,6 @@ fn clean_impl<'tcx>(
22602261 . iter ( )
22612262 . map ( |ii| clean_impl_item ( tcx. hir ( ) . impl_item ( ii. id ) , cx) )
22622263 . collect :: < Vec < _ > > ( ) ;
2263- let def_id = tcx. hir ( ) . local_def_id ( hir_id) ;
22642264
22652265 // If this impl block is an implementation of the Deref trait, then we
22662266 // need to try inlining the target's inherent impl blocks as well.
@@ -2289,7 +2289,7 @@ fn clean_impl<'tcx>(
22892289 ImplKind :: Normal
22902290 } ,
22912291 } ) ) ;
2292- Item :: from_hir_id_and_parts ( hir_id , None , kind, cx)
2292+ Item :: from_def_id_and_parts ( def_id . to_def_id ( ) , None , kind, cx)
22932293 } ;
22942294 if let Some ( type_alias) = type_alias {
22952295 ret. push ( make_item ( trait_. clone ( ) , type_alias, items. clone ( ) ) ) ;
@@ -2510,8 +2510,8 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
25102510 hir:: ForeignItemKind :: Type => ForeignTypeItem ,
25112511 } ;
25122512
2513- Item :: from_hir_id_and_parts (
2514- item. hir_id ( ) ,
2513+ Item :: from_def_id_and_parts (
2514+ item. owner_id . def_id . to_def_id ( ) ,
25152515 Some ( renamed. unwrap_or ( item. ident . name ) ) ,
25162516 kind,
25172517 cx,
0 commit comments