@@ -5,7 +5,7 @@ use std::sync::Arc;
55
66use rustc_data_structures:: fx:: FxHashSet ;
77use rustc_hir:: def:: { DefKind , Res } ;
8- use rustc_hir:: def_id:: { DefId , DefIdSet , LocalModDefId } ;
8+ use rustc_hir:: def_id:: { DefId , DefIdSet , LocalDefId , LocalModDefId } ;
99use rustc_hir:: Mutability ;
1010use rustc_metadata:: creader:: { CStore , LoadedMacro } ;
1111use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
@@ -43,7 +43,7 @@ pub(crate) fn try_inline(
4343 cx : & mut DocContext < ' _ > ,
4444 res : Res ,
4545 name : Symbol ,
46- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
46+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
4747 visited : & mut DefIdSet ,
4848) -> Option < Vec < clean:: Item > > {
4949 let did = res. opt_def_id ( ) ?;
@@ -152,14 +152,8 @@ pub(crate) fn try_inline(
152152 } ;
153153
154154 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 ) ;
163157 // The visibility needs to reflect the one from the reexport and not from the "source" DefId.
164158 item. inline_stmt_id = import_def_id;
165159 ret. push ( item) ;
@@ -198,7 +192,7 @@ pub(crate) fn try_inline_glob(
198192 visited,
199193 inlined_names,
200194 Some ( & reexports) ,
201- Some ( ( attrs, Some ( import. owner_id . def_id . to_def_id ( ) ) ) ) ,
195+ Some ( ( attrs, Some ( import. owner_id . def_id ) ) ) ,
202196 ) ;
203197 items. retain ( |item| {
204198 if let Some ( name) = item. name {
@@ -372,7 +366,7 @@ fn build_type_alias(
372366pub ( crate ) fn build_impls (
373367 cx : & mut DocContext < ' _ > ,
374368 did : DefId ,
375- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
369+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
376370 ret : & mut Vec < clean:: Item > ,
377371) {
378372 let _prof_timer = cx. tcx . sess . prof . generic_activity ( "build_inherent_impls" ) ;
@@ -405,7 +399,7 @@ pub(crate) fn build_impls(
405399pub ( crate ) fn merge_attrs (
406400 cx : & mut DocContext < ' _ > ,
407401 old_attrs : & [ ast:: Attribute ] ,
408- new_attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
402+ new_attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
409403) -> ( clean:: Attributes , Option < Arc < clean:: cfg:: Cfg > > ) {
410404 // NOTE: If we have additional attributes (from a re-export),
411405 // always insert them first. This ensure that re-export
@@ -416,7 +410,7 @@ pub(crate) fn merge_attrs(
416410 both. extend_from_slice ( old_attrs) ;
417411 (
418412 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 ( ) ) )
420414 } else {
421415 Attributes :: from_ast ( & both)
422416 } ,
@@ -431,7 +425,7 @@ pub(crate) fn merge_attrs(
431425pub ( crate ) fn build_impl (
432426 cx : & mut DocContext < ' _ > ,
433427 did : DefId ,
434- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
428+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
435429 ret : & mut Vec < clean:: Item > ,
436430) {
437431 if !cx. inlined . insert ( did. into ( ) ) {
@@ -623,7 +617,7 @@ pub(crate) fn build_impl(
623617 ImplKind :: Normal
624618 } ,
625619 } ) ) ,
626- Box :: new ( merged_attrs) ,
620+ merged_attrs,
627621 cfg,
628622 ) ) ;
629623}
@@ -641,7 +635,7 @@ fn build_module_items(
641635 visited : & mut DefIdSet ,
642636 inlined_names : & mut FxHashSet < ( ItemType , Symbol ) > ,
643637 allowed_def_ids : Option < & DefIdSet > ,
644- attrs : Option < ( & [ ast:: Attribute ] , Option < DefId > ) > ,
638+ attrs : Option < ( & [ ast:: Attribute ] , Option < LocalDefId > ) > ,
645639) -> Vec < clean:: Item > {
646640 let mut items = Vec :: new ( ) ;
647641
@@ -673,27 +667,29 @@ fn build_module_items(
673667 let prim_ty = clean:: PrimitiveType :: from ( p) ;
674668 items. push ( clean:: Item {
675669 name : None ,
676- attrs : Box :: default ( ) ,
677670 // We can use the item's `DefId` directly since the only information ever used
678671 // from it is `DefId.krate`.
679672 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 ,
692689 } ,
693- did : None ,
694- } ,
695- true ,
696- ) ) ) ,
690+ true ,
691+ ) ) ,
692+ } ) ,
697693 cfg : None ,
698694 inline_stmt_id : None ,
699695 } ) ;
@@ -745,15 +741,16 @@ fn build_macro(
745741 cx : & mut DocContext < ' _ > ,
746742 def_id : DefId ,
747743 name : Symbol ,
748- import_def_id : Option < DefId > ,
744+ import_def_id : Option < LocalDefId > ,
749745 macro_kind : MacroKind ,
750746 is_doc_hidden : bool ,
751747) -> clean:: ItemKind {
752748 match CStore :: from_tcx ( cx. tcx ) . load_macro_untracked ( def_id, cx. tcx ) {
753749 LoadedMacro :: MacroDef ( item_def, _) => match macro_kind {
754750 MacroKind :: Bang => {
755751 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) ) ;
757754 clean:: MacroItem ( clean:: Macro {
758755 source : utils:: display_macro_source (
759756 cx,
0 commit comments