@@ -15,7 +15,7 @@ use rustc_attr as attr;
15
15
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap , FxIndexSet , IndexEntry } ;
16
16
use rustc_hir as hir;
17
17
use 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 } ;
19
19
use rustc_hir:: PredicateOrigin ;
20
20
use rustc_hir_analysis:: hir_ty_to_ty;
21
21
use rustc_infer:: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
@@ -116,7 +116,8 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
116
116
}
117
117
} ) ;
118
118
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)
120
121
}
121
122
122
123
fn clean_generic_bound < ' tcx > (
@@ -2067,12 +2068,12 @@ struct OneLevelVisitor<'hir> {
2067
2068
map : rustc_middle:: hir:: map:: Map < ' hir > ,
2068
2069
item : Option < & ' hir hir:: Item < ' hir > > ,
2069
2070
looking_for : Ident ,
2070
- target_hir_id : hir :: HirId ,
2071
+ target_def_id : LocalDefId ,
2071
2072
}
2072
2073
2073
2074
impl < ' 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 }
2076
2077
}
2077
2078
2078
2079
fn reset ( & mut self , looking_for : Ident ) {
@@ -2092,7 +2093,7 @@ impl<'hir> hir::intravisit::Visitor<'hir> for OneLevelVisitor<'hir> {
2092
2093
if self . item . is_none ( )
2093
2094
&& item. ident == self . looking_for
2094
2095
&& matches ! ( item. kind, hir:: ItemKind :: Use ( _, _) )
2095
- || item. hir_id ( ) == self . target_hir_id
2096
+ || item. owner_id . def_id == self . target_def_id
2096
2097
{
2097
2098
self . item = Some ( item) ;
2098
2099
}
@@ -2106,11 +2107,11 @@ impl<'hir> hir::intravisit::Visitor<'hir> for OneLevelVisitor<'hir> {
2106
2107
fn get_all_import_attributes < ' hir > (
2107
2108
mut item : & hir:: Item < ' hir > ,
2108
2109
tcx : TyCtxt < ' hir > ,
2109
- target_hir_id : hir :: HirId ,
2110
+ target_def_id : LocalDefId ,
2110
2111
attributes : & mut Vec < ast:: Attribute > ,
2111
2112
) {
2112
2113
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 ) ;
2114
2115
// If the item is an import and has at least a path with two parts, we go into it.
2115
2116
while let hir:: ItemKind :: Use ( path, _) = item. kind &&
2116
2117
path. segments . len ( ) > 1 &&
@@ -2138,7 +2139,7 @@ fn clean_maybe_renamed_item<'tcx>(
2138
2139
cx : & mut DocContext < ' tcx > ,
2139
2140
item : & hir:: Item < ' tcx > ,
2140
2141
renamed : Option < Symbol > ,
2141
- import_id : Option < hir :: HirId > ,
2142
+ import_id : Option < LocalDefId > ,
2142
2143
) -> Vec < Item > {
2143
2144
use hir:: ItemKind ;
2144
2145
@@ -2183,7 +2184,7 @@ fn clean_maybe_renamed_item<'tcx>(
2183
2184
generics : clean_generics ( generics, cx) ,
2184
2185
fields : variant_data. fields ( ) . iter ( ) . map ( |x| clean_field ( x, cx) ) . collect ( ) ,
2185
2186
} ) ,
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) ,
2187
2188
// proc macros can have a name set by attributes
2188
2189
ItemKind :: Fn ( ref sig, generics, body_id) => {
2189
2190
clean_fn_or_proc_macro ( item, sig, generics, body_id, & mut name, cx)
@@ -2218,10 +2219,10 @@ fn clean_maybe_renamed_item<'tcx>(
2218
2219
2219
2220
let mut extra_attrs = Vec :: new ( ) ;
2220
2221
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 ) )
2222
2223
{
2223
2224
// 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) ;
2225
2226
}
2226
2227
2227
2228
if !extra_attrs. is_empty ( ) {
@@ -2244,12 +2245,12 @@ fn clean_maybe_renamed_item<'tcx>(
2244
2245
2245
2246
fn clean_variant < ' tcx > ( variant : & hir:: Variant < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Item {
2246
2247
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)
2248
2249
}
2249
2250
2250
2251
fn clean_impl < ' tcx > (
2251
2252
impl_ : & hir:: Impl < ' tcx > ,
2252
- hir_id : hir :: HirId ,
2253
+ def_id : LocalDefId ,
2253
2254
cx : & mut DocContext < ' tcx > ,
2254
2255
) -> Vec < Item > {
2255
2256
let tcx = cx. tcx ;
@@ -2260,7 +2261,6 @@ fn clean_impl<'tcx>(
2260
2261
. iter ( )
2261
2262
. map ( |ii| clean_impl_item ( tcx. hir ( ) . impl_item ( ii. id ) , cx) )
2262
2263
. collect :: < Vec < _ > > ( ) ;
2263
- let def_id = tcx. hir ( ) . local_def_id ( hir_id) ;
2264
2264
2265
2265
// If this impl block is an implementation of the Deref trait, then we
2266
2266
// need to try inlining the target's inherent impl blocks as well.
@@ -2289,7 +2289,7 @@ fn clean_impl<'tcx>(
2289
2289
ImplKind :: Normal
2290
2290
} ,
2291
2291
} ) ) ;
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)
2293
2293
} ;
2294
2294
if let Some ( type_alias) = type_alias {
2295
2295
ret. push ( make_item ( trait_. clone ( ) , type_alias, items. clone ( ) ) ) ;
@@ -2510,8 +2510,8 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
2510
2510
hir:: ForeignItemKind :: Type => ForeignTypeItem ,
2511
2511
} ;
2512
2512
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 ( ) ,
2515
2515
Some ( renamed. unwrap_or ( item. ident . name ) ) ,
2516
2516
kind,
2517
2517
cx,
0 commit comments