@@ -38,9 +38,18 @@ pub(crate) struct Module<'hir> {
3838 ( LocalDefId , Option < Symbol > ) ,
3939 ( & ' hir hir:: Item < ' hir > , Option < Symbol > , Option < LocalDefId > ) ,
4040 > ,
41- /// Same as for `items`.
41+
42+ /// (def_id, renamed) -> (res, local_import_id)
43+ ///
44+ /// `inlined_foreigns` only contains `extern` items
45+ /// that are cross-crate inlined.
46+ ///
47+ /// Locally inlined `extern` items are
48+ /// stored in `foreigns` with the `import_id` set,
49+ /// analogous to how `items` is.
4250 pub ( crate ) inlined_foreigns : FxIndexMap < ( DefId , Option < Symbol > ) , ( Res , LocalDefId ) > ,
43- pub ( crate ) foreigns : Vec < ( & ' hir hir:: ForeignItem < ' hir > , Option < Symbol > ) > ,
51+ /// (item, renamed, import_id)
52+ pub ( crate ) foreigns : Vec < ( & ' hir hir:: ForeignItem < ' hir > , Option < Symbol > , Option < LocalDefId > ) > ,
4453}
4554
4655impl Module < ' _ > {
@@ -327,7 +336,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
327336 }
328337 Node :: ForeignItem ( it) if !glob => {
329338 let prev = mem:: replace ( & mut self . inlining , true ) ;
330- self . visit_foreign_item_inner ( it, renamed) ;
339+ self . visit_foreign_item_inner ( it, renamed, Some ( def_id ) ) ;
331340 self . inlining = prev;
332341 true
333342 }
@@ -432,7 +441,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
432441 hir:: ItemKind :: ForeignMod { items, .. } => {
433442 for item in items {
434443 let item = tcx. hir_foreign_item ( item. id ) ;
435- self . visit_foreign_item_inner ( item, None ) ;
444+ self . visit_foreign_item_inner ( item, None , None ) ;
436445 }
437446 }
438447 // If we're inlining, skip private items.
@@ -527,10 +536,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
527536 & mut self ,
528537 item : & ' tcx hir:: ForeignItem < ' _ > ,
529538 renamed : Option < Symbol > ,
539+ import_id : Option < LocalDefId > ,
530540 ) {
531541 // If inlining we only want to include public functions.
532542 if !self . inlining || self . cx . tcx . visibility ( item. owner_id ) . is_public ( ) {
533- self . modules . last_mut ( ) . unwrap ( ) . foreigns . push ( ( item, renamed) ) ;
543+ self . modules . last_mut ( ) . unwrap ( ) . foreigns . push ( ( item, renamed, import_id ) ) ;
534544 }
535545 }
536546
0 commit comments