Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4c01025
std: thread_local::register_dtor fix proposal for FreeBSD.
devnexen Jan 27, 2024
ad1e629
Make duplicate lang items fatal
Noratrieb Jan 29, 2024
a360ecd
Delete now-useless test
Noratrieb Jan 29, 2024
1f89e90
Add test for duplicate lang items
Noratrieb Jan 29, 2024
f6b21e9
Remove the `abi_amdgpu_kernel` feature
clubby789 Jan 30, 2024
0b2579a
Make `PatternColumn` generic in `Cx`
Nadrieril Jan 24, 2024
cb0e8c5
Limit the use of `PlaceCtxt`
Nadrieril Jan 24, 2024
83e88c6
Repurpose `MatchCtxt` for usefulness only
Nadrieril Jan 24, 2024
6ef8362
Make `PatternColumn` part of the public API
Nadrieril Jan 24, 2024
5903142
Separate `PlaceCtxt` from `UsefulnessCtxt`
Nadrieril Jan 24, 2024
dfbbdda
check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test
onur-ozkan Jan 21, 2024
75f670d
rustdoc: Correctly handle attribute merge if this is a glob reexport
GuillaumeGomez Jan 30, 2024
024364a
Add regression test for #120487
GuillaumeGomez Jan 30, 2024
8ebd47e
Mark "unused binding" suggestion as maybe incorrect
estebank Jan 29, 2024
6efddac
Provide more context on derived obligation error primary label
estebank Jan 29, 2024
c780fe6
document `FromIterator for Vec` allocation behaviors
the8472 Jan 25, 2024
39dc315
Apply suggestions from code review
the8472 Jan 26, 2024
f810a80
Rollup merge of #120207 - onur-ozkan:120202-fix, r=clubby789
Nadrieril Jan 31, 2024
79a6a01
Rollup merge of #120321 - Nadrieril:cleanup-cx, r=compiler-errors
Nadrieril Jan 31, 2024
2932425
Rollup merge of #120355 - the8472:doc-vec-fromiter, r=cuviper
Nadrieril Jan 31, 2024
48ca8f4
Rollup merge of #120430 - devnexen:fix_tls_dtor_fbsd, r=cuviper
Nadrieril Jan 31, 2024
ef9dd13
Rollup merge of #120469 - estebank:issue-40120, r=TaKO8Ki
Nadrieril Jan 31, 2024
df61874
Rollup merge of #120470 - estebank:issue-54196, r=compiler-errors
Nadrieril Jan 31, 2024
82ee16f
Rollup merge of #120472 - Nilstrieb:die, r=compiler-errors
Nadrieril Jan 31, 2024
6414100
Rollup merge of #120495 - clubby789:remove-amdgpu-kernel, r=oli-obk
Nadrieril Jan 31, 2024
26b411e
Rollup merge of #120501 - GuillaumeGomez:glob-reexport-attr-merge-bug…
Nadrieril Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
)
}

fn is_glob_import(tcx: TyCtxt<'_>, import_id: LocalDefId) -> bool {
if let Some(node) = tcx.opt_hir_node_by_def_id(import_id)
&& let hir::Node::Item(item) = node
&& let hir::ItemKind::Use(_, use_kind) = item.kind
{
use_kind == hir::UseKind::Glob
} else {
false
}
}

fn generate_item_with_correct_attrs(
cx: &mut DocContext<'_>,
kind: ItemKind,
Expand All @@ -158,10 +169,17 @@ fn generate_item_with_correct_attrs(
) -> Item {
let target_attrs = inline::load_attrs(cx, def_id);
let attrs = if let Some(import_id) = import_id {
// glob reexports are treated the same as `#[doc(inline)]` items.
//
// For glob re-exports the item may or may not exist to be re-exported (potentially the cfgs
// on the path up until the glob can be removed, and only cfgs on the globbed item itself
// matter), for non-inlined re-exports see #85043.
let is_inline = inline::load_attrs(cx, import_id.to_def_id())
.lists(sym::doc)
.get_word_attr(sym::inline)
.is_some();
.is_some()
|| (is_glob_import(cx.tcx, import_id)
&& (cx.render_options.document_hidden || !cx.tcx.is_doc_hidden(def_id)));
let mut attrs = get_all_import_attributes(cx, import_id, def_id, is_inline);
add_without_unwanted_attributes(&mut attrs, target_attrs, is_inline, None);
attrs
Expand Down
32 changes: 32 additions & 0 deletions tests/rustdoc/glob-reexport-attribute-merge-120487.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This test ensures that non-glob reexports don't get their attributes merge with
// the reexported item whereas glob reexports do.
// Regression test for <https://github.com/rust-lang/rust/issues/120487>.

#![crate_name = "foo"]
#![feature(doc_cfg)]

// @has 'foo/index.html'
// There are two items.
// @count - '//*[@class="item-table"]//div[@class="item-name"]' 2
// Only one of them should have an attribute.
// @count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1

mod a {
#[doc(cfg(not(feature = "a")))]
#[cfg(not(feature = "a"))]
pub struct Test1;
}

mod b {
#[doc(cfg(not(feature = "a")))]
#[cfg(not(feature = "a"))]
pub struct Test2;
}

// @has 'foo/struct.Test1.html'
// @count - '//*[@id="main-content"]/*[@class="item-info"]' 1
// @has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.'
pub use a::*;
// @has 'foo/struct.Test2.html'
// @count - '//*[@id="main-content"]/*[@class="item-info"]' 0
pub use b::Test2;