Skip to content

Commit 75f670d

Browse files
rustdoc: Correctly handle attribute merge if this is a glob reexport
1 parent 5bd5d21 commit 75f670d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/librustdoc/clean/mod.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
147147
)
148148
}
149149

150+
fn is_glob_import(tcx: TyCtxt<'_>, import_id: LocalDefId) -> bool {
151+
if let Some(node) = tcx.opt_hir_node_by_def_id(import_id)
152+
&& let hir::Node::Item(item) = node
153+
&& let hir::ItemKind::Use(_, use_kind) = item.kind
154+
{
155+
use_kind == hir::UseKind::Glob
156+
} else {
157+
false
158+
}
159+
}
160+
150161
fn generate_item_with_correct_attrs(
151162
cx: &mut DocContext<'_>,
152163
kind: ItemKind,
@@ -157,10 +168,17 @@ fn generate_item_with_correct_attrs(
157168
) -> Item {
158169
let target_attrs = inline::load_attrs(cx, def_id);
159170
let attrs = if let Some(import_id) = import_id {
171+
// glob reexports are treated the same as `#[doc(inline)]` items.
172+
//
173+
// For glob re-exports the item may or may not exist to be re-exported (potentially the cfgs
174+
// on the path up until the glob can be removed, and only cfgs on the globbed item itself
175+
// matter), for non-inlined re-exports see #85043.
160176
let is_inline = inline::load_attrs(cx, import_id.to_def_id())
161177
.lists(sym::doc)
162178
.get_word_attr(sym::inline)
163-
.is_some();
179+
.is_some()
180+
|| (is_glob_import(cx.tcx, import_id)
181+
&& (cx.render_options.document_hidden || !cx.tcx.is_doc_hidden(def_id)));
164182
let mut attrs = get_all_import_attributes(cx, import_id, def_id, is_inline);
165183
add_without_unwanted_attributes(&mut attrs, target_attrs, is_inline, None);
166184
attrs

0 commit comments

Comments
 (0)