-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
rustdoc: Inherit inline attributes for declarative macros #154902
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
Merged
rust-bors
merged 1 commit into
rust-lang:main
from
shivendra02467:fix-rustdoc-macro-inline
Apr 8, 2026
+175
−6
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| // Regression test for <https://github.com/rust-lang/rust/issues/154694>. | ||
| // The goal is to ensure that declarative macros re-exported by name | ||
| // inherit the `#[doc(inline)]` attribute from intermediate re-exports, | ||
| // matching the behavior of glob re-exports. | ||
|
|
||
| #![crate_name = "foo"] | ||
|
|
||
| #[macro_use] | ||
| mod macros { | ||
| #[macro_export] | ||
| #[doc(hidden)] | ||
| macro_rules! explicit_macro { | ||
| () => {}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| #[doc(hidden)] | ||
| macro_rules! wild_macro { | ||
| () => {}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| #[doc(hidden)] | ||
| macro_rules! actually_hidden_macro { | ||
| () => {}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| #[doc(hidden)] | ||
| macro_rules! actually_hidden_wild_macro { | ||
| () => {}; | ||
| } | ||
|
|
||
| #[macro_export] | ||
| #[doc(hidden)] | ||
| macro_rules! actually_hidden_indirect_macro { | ||
| () => {}; | ||
| } | ||
| } | ||
|
|
||
| // Standard items (like structs) are provided as control cases to ensure | ||
| // macro inlining behavior maintains parity. | ||
| #[doc(hidden)] | ||
| pub struct HiddenStruct; | ||
|
|
||
| #[doc(hidden)] | ||
| pub struct IndirectlyHiddenStruct; | ||
|
|
||
| pub mod bar { | ||
| mod hidden_explicit { | ||
| #[doc(inline)] | ||
| pub use crate::explicit_macro; | ||
| } | ||
|
|
||
| mod hidden_wild { | ||
| #[doc(inline)] | ||
| pub use crate::wild_macro; | ||
| } | ||
|
|
||
| mod actually_hidden { | ||
| // BUG: as demonstrated by the `actually_hidden_struct` module, when both | ||
| // `doc(hidden)` and `doc(inline)` are specified, `doc(hidden)` | ||
| // should take priority. | ||
| #[doc(hidden)] | ||
| #[doc(inline)] | ||
| pub use crate::actually_hidden_macro; | ||
| } | ||
|
|
||
| mod actually_hidden_indirect_inner { | ||
| #[doc(inline)] | ||
| pub use crate::actually_hidden_indirect_macro; | ||
| } | ||
|
|
||
| mod actually_hidden_indirect { | ||
| // BUG: when there is a chain of imports, we should stop looking as soon as soon as we hit | ||
| // something with `doc(hidden)`. | ||
| #[doc(hidden)] | ||
| pub use super::actually_hidden_indirect_inner::actually_hidden_indirect_macro; | ||
| } | ||
|
|
||
| mod actually_hidden_indirect_struct_inner { | ||
| #[doc(inline)] | ||
| pub use crate::IndirectlyHiddenStruct; | ||
| } | ||
|
|
||
| mod actually_hidden_indirect_struct { | ||
| #[doc(hidden)] | ||
| pub use super::actually_hidden_indirect_struct_inner::IndirectlyHiddenStruct; | ||
| } | ||
|
|
||
| mod actually_hidden_wild { | ||
| #[doc(hidden)] | ||
| #[doc(inline)] | ||
| pub use crate::actually_hidden_wild_macro; | ||
| } | ||
|
|
||
| mod actually_hidden_struct { | ||
| #[doc(inline)] | ||
| #[doc(hidden)] | ||
| pub use crate::HiddenStruct; | ||
| } | ||
|
|
||
| // First, we check that the explicitly named macro inherits the inline attribute | ||
| // from `hidden_explicit` and is successfully rendered. | ||
| //@ has 'foo/bar/macro.explicit_macro.html' | ||
| //@ has 'foo/bar/index.html' '//a[@href="macro.explicit_macro.html"]' 'explicit_macro' | ||
| pub use self::hidden_explicit::explicit_macro; | ||
|
|
||
| // Next, we ensure that the glob-imported macro continues to render correctly | ||
| // as a control case. | ||
| //@ has 'foo/bar/macro.wild_macro.html' | ||
| //@ has 'foo/bar/index.html' '//a[@href="macro.wild_macro.html"]' 'wild_macro' | ||
| pub use self::hidden_wild::*; | ||
|
|
||
| //@ !has 'foo/bar/macro.actually_hidden_macro.html' | ||
| pub use self::actually_hidden::actually_hidden_macro; | ||
|
|
||
| //@ !has 'foo/bar/macro.actually_hidden_wild_macro.html' | ||
| pub use self::actually_hidden_wild::*; | ||
|
|
||
| //@ !has 'foo/bar/struct.HiddenStruct.html' | ||
| pub use self::actually_hidden_struct::HiddenStruct; | ||
|
|
||
| //@ !has 'foo/bar/macro.actually_hidden_indirect_macro.html' | ||
| pub use self::actually_hidden_indirect::actually_hidden_indirect_macro; | ||
|
|
||
| //@ !has 'foo/bar/struct.IndirectlyHiddenStruct.html' | ||
| pub use self::actually_hidden_indirect_struct::IndirectlyHiddenStruct; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.