@@ -5,7 +5,7 @@ use std::sync::Arc;
5
5
6
6
use rustc_data_structures:: fx:: FxHashSet ;
7
7
use rustc_hir:: def:: { DefKind , Res } ;
8
- use rustc_hir:: def_id:: { DefId , DefIdSet , LocalModDefId } ;
8
+ use rustc_hir:: def_id:: { DefId , DefIdSet , LocalDefId , LocalModDefId } ;
9
9
use rustc_hir:: Mutability ;
10
10
use rustc_metadata:: creader:: { CStore , LoadedMacro } ;
11
11
use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
@@ -43,7 +43,7 @@ pub(crate) fn try_inline(
43
43
cx : & mut DocContext < ' _ > ,
44
44
res : Res ,
45
45
name : Symbol ,
46
- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
46
+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
47
47
visited : & mut DefIdSet ,
48
48
) -> Option < Vec < clean:: Item > > {
49
49
let did = res. opt_def_id ( ) ?;
@@ -152,14 +152,8 @@ pub(crate) fn try_inline(
152
152
} ;
153
153
154
154
cx. inlined . insert ( did. into ( ) ) ;
155
- let mut item = crate :: clean:: generate_item_with_correct_attrs (
156
- cx,
157
- kind,
158
- did,
159
- name,
160
- import_def_id. and_then ( |def_id| def_id. as_local ( ) ) ,
161
- None ,
162
- ) ;
155
+ let mut item =
156
+ crate :: clean:: generate_item_with_correct_attrs ( cx, kind, did, name, import_def_id, None ) ;
163
157
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
164
158
item. inline_stmt_id = import_def_id;
165
159
ret. push ( item) ;
@@ -198,7 +192,7 @@ pub(crate) fn try_inline_glob(
198
192
visited,
199
193
inlined_names,
200
194
Some ( & reexports) ,
201
- Some ( ( attrs, Some ( import. owner_id . def_id . to_def_id ( ) ) ) ) ,
195
+ Some ( ( attrs, Some ( import. owner_id . def_id ) ) ) ,
202
196
) ;
203
197
items. retain ( |item| {
204
198
if let Some ( name) = item. name {
@@ -372,7 +366,7 @@ fn build_type_alias(
372
366
pub ( crate ) fn build_impls (
373
367
cx : & mut DocContext < ' _ > ,
374
368
did : DefId ,
375
- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
369
+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
376
370
ret : & mut Vec < clean:: Item > ,
377
371
) {
378
372
let _prof_timer = cx. tcx . sess . prof . generic_activity ( "build_inherent_impls" ) ;
@@ -405,7 +399,7 @@ pub(crate) fn build_impls(
405
399
pub ( crate ) fn merge_attrs (
406
400
cx : & mut DocContext < ' _ > ,
407
401
old_attrs : & [ ast:: Attribute ] ,
408
- new_attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
402
+ new_attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
409
403
) -> ( clean:: Attributes , Option < Arc < clean:: cfg:: Cfg > > ) {
410
404
// NOTE: If we have additional attributes (from a re-export),
411
405
// always insert them first. This ensure that re-export
@@ -416,7 +410,7 @@ pub(crate) fn merge_attrs(
416
410
both. extend_from_slice ( old_attrs) ;
417
411
(
418
412
if let Some ( item_id) = item_id {
419
- Attributes :: from_ast_with_additional ( old_attrs, ( inner, item_id) )
413
+ Attributes :: from_ast_with_additional ( old_attrs, ( inner, item_id. to_def_id ( ) ) )
420
414
} else {
421
415
Attributes :: from_ast ( & both)
422
416
} ,
@@ -431,7 +425,7 @@ pub(crate) fn merge_attrs(
431
425
pub ( crate ) fn build_impl (
432
426
cx : & mut DocContext < ' _ > ,
433
427
did : DefId ,
434
- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
428
+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
435
429
ret : & mut Vec < clean:: Item > ,
436
430
) {
437
431
if !cx. inlined . insert ( did. into ( ) ) {
@@ -623,7 +617,7 @@ pub(crate) fn build_impl(
623
617
ImplKind :: Normal
624
618
} ,
625
619
} ) ) ,
626
- Box :: new ( merged_attrs) ,
620
+ merged_attrs,
627
621
cfg,
628
622
) ) ;
629
623
}
@@ -641,7 +635,7 @@ fn build_module_items(
641
635
visited : & mut DefIdSet ,
642
636
inlined_names : & mut FxHashSet < ( ItemType , Symbol ) > ,
643
637
allowed_def_ids : Option < & DefIdSet > ,
644
- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
638
+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
645
639
) -> Vec < clean:: Item > {
646
640
let mut items = Vec :: new ( ) ;
647
641
@@ -673,27 +667,29 @@ fn build_module_items(
673
667
let prim_ty = clean:: PrimitiveType :: from ( p) ;
674
668
items. push ( clean:: Item {
675
669
name : None ,
676
- attrs : Box :: default ( ) ,
677
670
// We can use the item's `DefId` directly since the only information ever used
678
671
// from it is `DefId.krate`.
679
672
item_id : ItemId :: DefId ( did) ,
680
- kind : Box :: new ( clean:: ImportItem ( clean:: Import :: new_simple (
681
- item. ident . name ,
682
- clean:: ImportSource {
683
- path : clean:: Path {
684
- res,
685
- segments : thin_vec ! [ clean:: PathSegment {
686
- name: prim_ty. as_sym( ) ,
687
- args: clean:: GenericArgs :: AngleBracketed {
688
- args: Default :: default ( ) ,
689
- constraints: ThinVec :: new( ) ,
690
- } ,
691
- } ] ,
673
+ inner : Box :: new ( clean:: ItemInner {
674
+ attrs : Default :: default ( ) ,
675
+ kind : clean:: ImportItem ( clean:: Import :: new_simple (
676
+ item. ident . name ,
677
+ clean:: ImportSource {
678
+ path : clean:: Path {
679
+ res,
680
+ segments : thin_vec ! [ clean:: PathSegment {
681
+ name: prim_ty. as_sym( ) ,
682
+ args: clean:: GenericArgs :: AngleBracketed {
683
+ args: Default :: default ( ) ,
684
+ constraints: ThinVec :: new( ) ,
685
+ } ,
686
+ } ] ,
687
+ } ,
688
+ did : None ,
692
689
} ,
693
- did : None ,
694
- } ,
695
- true ,
696
- ) ) ) ,
690
+ true ,
691
+ ) ) ,
692
+ } ) ,
697
693
cfg : None ,
698
694
inline_stmt_id : None ,
699
695
} ) ;
@@ -745,15 +741,16 @@ fn build_macro(
745
741
cx : & mut DocContext < ' _ > ,
746
742
def_id : DefId ,
747
743
name : Symbol ,
748
- import_def_id : Option < DefId > ,
744
+ import_def_id : Option < LocalDefId > ,
749
745
macro_kind : MacroKind ,
750
746
is_doc_hidden : bool ,
751
747
) -> clean:: ItemKind {
752
748
match CStore :: from_tcx ( cx. tcx ) . load_macro_untracked ( def_id, cx. tcx ) {
753
749
LoadedMacro :: MacroDef ( item_def, _) => match macro_kind {
754
750
MacroKind :: Bang => {
755
751
if let ast:: ItemKind :: MacroDef ( ref def) = item_def. kind {
756
- let vis = cx. tcx . visibility ( import_def_id. unwrap_or ( def_id) ) ;
752
+ let vis =
753
+ cx. tcx . visibility ( import_def_id. map ( |d| d. to_def_id ( ) ) . unwrap_or ( def_id) ) ;
757
754
clean:: MacroItem ( clean:: Macro {
758
755
source : utils:: display_macro_source (
759
756
cx,
0 commit comments