@@ -38,9 +38,18 @@ pub(crate) struct Module<'hir> {
38
38
( LocalDefId , Option < Symbol > ) ,
39
39
( & ' hir hir:: Item < ' hir > , Option < Symbol > , Option < LocalDefId > ) ,
40
40
> ,
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.
42
50
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 > ) > ,
44
53
}
45
54
46
55
impl Module < ' _ > {
@@ -327,7 +336,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
327
336
}
328
337
Node :: ForeignItem ( it) if !glob => {
329
338
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 ) ) ;
331
340
self . inlining = prev;
332
341
true
333
342
}
@@ -432,7 +441,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
432
441
hir:: ItemKind :: ForeignMod { items, .. } => {
433
442
for item in items {
434
443
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 ) ;
436
445
}
437
446
}
438
447
// If we're inlining, skip private items.
@@ -527,10 +536,11 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
527
536
& mut self ,
528
537
item : & ' tcx hir:: ForeignItem < ' _ > ,
529
538
renamed : Option < Symbol > ,
539
+ import_id : Option < LocalDefId > ,
530
540
) {
531
541
// If inlining we only want to include public functions.
532
542
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 ) ) ;
534
544
}
535
545
}
536
546
0 commit comments