Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ fn generate_item_with_correct_attrs(
) || (is_glob_import(tcx, import_id)
&& (cx.document_hidden() || !tcx.is_doc_hidden(def_id)))
|| macro_reexport_is_inline(tcx, import_id, def_id);
attrs.extend(get_all_import_attributes(cx, import_id, def_id, is_inline));
is_inline = is_inline || import_is_inline;
attrs.extend(get_all_import_attributes(cx, import_id, def_id, is_inline));
}
let keep_target_cfg = is_inline || matches!(kind, ItemKind::TypeAliasItem(..));
add_without_unwanted_attributes(&mut attrs, target_attrs, keep_target_cfg, None);
Expand Down
57 changes: 57 additions & 0 deletions tests/rustdoc-html/reexport/glob-reexport-feature-combination.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//@ compile-flags: --cfg feature="foo" --cfg feature="bar" --cfg feature="baz"
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little tip: to avoid using compile-flags, it's better to wrap the cfg attributes inside not().

View changes since the review


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

Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add the check for the index.html page.

View changes since the review

//==================================================================================================
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove that comment.

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, the idea was just to more easily separate the test cases visually.

//@ has 'foo/struct.A.html'
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
// 'Available on crate features foo and bar only.'

mod a {
mod inner {
pub struct A {}
}
#[cfg(feature = "bar")]
pub use self::inner::A;
}
#[cfg(feature = "foo")]
pub use a::*;

//==================================================================================================
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this comment.

View changes since the review

//@ has 'foo/struct.B.html'
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
// 'Available on crate features foo and bar and baz only.'

mod b {
mod inner {
mod innermost {
pub struct B {}
}
#[cfg(feature = "baz")]
pub use self::innermost::B;
}
#[cfg(feature = "bar")]
pub use self::inner::*;
}
#[cfg(feature = "foo")]
pub use b::*;

//==================================================================================================
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//@ has 'foo/struct.C.html'
//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
// 'Available on crate features foo and bar and baz only.'

mod c {
mod inner {
mod innermost {
#[cfg(feature = "baz")]
pub struct C {}
}
pub use self::innermost::*;
}
#[cfg(feature = "bar")]
pub use self::inner::*;
}
#[cfg(feature = "foo")]
pub use c::*;
Loading