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