Skip to content

Doc feature banners won't show up when re-exporting items with wildcard #113982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rodrigocfd opened this issue Jul 23, 2023 · 5 comments · Fixed by #114012
Closed

Doc feature banners won't show up when re-exporting items with wildcard #113982

rodrigocfd opened this issue Jul 23, 2023 · 5 comments · Fixed by #114012
Labels
C-bug Category: This is a bug. F-doc_auto_cfg `#![feature(doc_auto_cfg)]` F-doc_cfg `#![feature(doc_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@rodrigocfd
Copy link

rodrigocfd commented Jul 23, 2023

Problem

I'm building a big library crate, composed of multiple sub-crates. These sub-crates are gated through Cargo features, so the user can choose what to import.

My goal is to have "fruits" and "colors" feature banners in the docs, for each item, like this:

banners

However, I'm only achieving this by manually declaring each member of each sub-crate:

#[cfg(feature = "colors")]
pub use colors::{
    blue,
    red,
    white,
};

#[cfg(feature = "fruits")]
pub use fruits::{
    banana,
    grape,
};

There will be hundreds of declarations, so this is very error-prone. When using wildcards to the declare the members, the feature banners won't show up:

no-banners

#[cfg(feature = "colors")]
pub use colors::*;

#[cfg(feature = "fruits")]
pub use fruits::*;

Is this a bug or am I missing something?

Minimal reproducible example:

Steps

  1. Generate the docs with:
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps -p big-lib

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.71.0 (cfd3bbd8f 2023-06-08)
release: 1.71.0
commit-hash: cfd3bbd8fe4fd92074dfad04b7eb9a923646839f
commit-date: 2023-06-08
host: x86_64-pc-windows-msvc
libgit2: 1.6.4 (sys:0.17.1 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:Schannel)
os: Windows 10.0.19045 (Windows 10 Pro) [64-bit]
@rodrigocfd rodrigocfd added the C-bug Category: This is a bug. label Jul 23, 2023
@rodrigocfd rodrigocfd changed the title Feature banners won't show up when re-exporting items with wildcard Doc feature banners won't show up when re-exporting items with wildcard Jul 23, 2023
@ehuss ehuss transferred this issue from rust-lang/cargo Jul 23, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 23, 2023
@ehuss
Copy link
Contributor

ehuss commented Jul 23, 2023

Transferred to rust-lang/rust, since this is likely an issue for rustdoc, which is tracked here.

@ehuss ehuss added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. F-doc_cfg `#![feature(doc_cfg)]` F-doc_auto_cfg `#![feature(doc_auto_cfg)]` labels Jul 23, 2023
@GuillaumeGomez
Copy link
Member

I confirm this is a bug. Working on a fix.

@GuillaumeGomez
Copy link
Member

One question though. Why did you put both cfg and cfg_attr for the same cfg:

#[cfg(feature = "colors")]
#[cfg_attr(docsrs, cfg(feature = "colors"))]
pub use colors::*;

Unless I'm missing something, it's supposed to be exactly the same so with --cfg docsrs you will have cfg(feature = "colors") twice.

@rodrigocfd
Copy link
Author

One question though. Why did you put both cfg and cfg_attr for the same cfg

You're right, it's redundant. It's a leftover from all the combinations I tried (I really tried everything possible).

Fixed.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 24, 2023
@bors bors closed this as completed in 6908c73 Jul 26, 2023
RalfJung pushed a commit to RalfJung/miri that referenced this issue Jul 27, 2023
Fix missing attribute merge on glob foreign re-exports

Fixes rust-lang/rust#113982.

The attributes were not merged with the import's in case of glob re-export of foreign items.

r? `@notriddle`
@rodrigocfd
Copy link
Author

Confirmed working in nightly.

Thank you, @GuillaumeGomez.

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2023
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
Fix missing attribute merge on glob foreign re-exports

Fixes rust-lang/rust#113982.

The attributes were not merged with the import's in case of glob re-export of foreign items.

r? `@notriddle`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Fix missing attribute merge on glob foreign re-exports

Fixes rust-lang/rust#113982.

The attributes were not merged with the import's in case of glob re-export of foreign items.

r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-doc_auto_cfg `#![feature(doc_auto_cfg)]` F-doc_cfg `#![feature(doc_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants