Skip to content

Commit ba27564

Browse files
Keep the original import DefId when inlining items through multiple reexports
1 parent 6f644d8 commit ba27564

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/librustdoc/visit_ast.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
244244
res: Res,
245245
renamed: Option<Symbol>,
246246
please_inline: bool,
247+
import_id: Option<LocalDefId>,
247248
) -> bool {
248249
debug!("maybe_inline_local (renamed: {renamed:?}) res: {res:?}");
249250

@@ -338,20 +339,20 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
338339
let prev = mem::replace(&mut self.inlining, true);
339340
for &i in m.item_ids {
340341
let i = tcx.hir_item(i);
341-
self.visit_item_inner(i, None, Some(def_id));
342+
self.visit_item_inner(i, None, Some(import_id.unwrap_or(def_id)));
342343
}
343344
self.inlining = prev;
344345
true
345346
}
346347
Node::Item(it) if !is_glob => {
347348
let prev = mem::replace(&mut self.inlining, true);
348-
self.visit_item_inner(it, renamed, Some(def_id));
349+
self.visit_item_inner(it, renamed, Some(import_id.unwrap_or(def_id)));
349350
self.inlining = prev;
350351
true
351352
}
352353
Node::ForeignItem(it) if !is_glob => {
353354
let prev = mem::replace(&mut self.inlining, true);
354-
self.visit_foreign_item_inner(it, renamed, Some(def_id));
355+
self.visit_foreign_item_inner(it, renamed, Some(import_id.unwrap_or(def_id)));
355356
self.inlining = prev;
356357
true
357358
}
@@ -519,8 +520,13 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
519520
hir::UseKind::Glob => None,
520521
hir::UseKind::ListStem => unreachable!(),
521522
};
522-
if self.maybe_inline_local(item.owner_id.def_id, res, ident, please_inline)
523-
{
523+
if self.maybe_inline_local(
524+
item.owner_id.def_id,
525+
res,
526+
ident,
527+
please_inline,
528+
import_id,
529+
) {
524530
debug!("Inlining {:?}", item.owner_id.def_id);
525531
continue;
526532
}

tests/rustdoc-html/doc-cfg/reexports.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature banana and non-crate feature yoyo only.'
1111

1212
//@has 'foo/struct.SubBanana.html'
13-
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
14-
15-
//@has 'foo/struct.Yolo.html'
16-
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
13+
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana and non-crate feature yoyo only.'
1714

1815
#[cfg(not(feature = "yoyo"))]
1916
pub use self::banana::*;
17+
18+
//@has 'foo/struct.Yolo.html'
19+
//@has - '//*[@class="item-info"]/*[@class="stab portability"]' 'Available on non-crate feature ananas and non-crate feature banana only.'
2020
pub use self::banana::SubBanana as Yolo;
2121

2222
#[cfg(not(feature = "banana"))]

0 commit comments

Comments
 (0)