You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rustdoc: Various #[doc] attributes are not fully validated (e.g., #[doc(hidden)], #[doc(no_inline)]) #146346
A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
This is most definitely a bug (it's not tested or documented anywhere). In the early days, rustc used to perform none or only minimal validation for attributes (where they're placed, what shape they have) and over the years we've slowly gotten more principled in this area.
Due to the somewhat "widespread" usage of this specific form and just to be safe, this needs to start out as a lint warning of invalid_doc_attributes (hopefully we'll turn this lint into a future-incompatibility one at some point and in the far future make it a hard error).
#[doc(hidden = "…")] isn't the only form we don't warn / error on, there's a whole class of them:
changed the title [-]You can pass a string literal to `#[doc(hidden = "foo")]`. Is this intended?[/-][+]rustdoc: Various `#[doc]` attributes are not fully validated (e.g., `#[doc(hidden)]`, `#[doc(no_inline)]`)[/+]on Oct 10, 2025
However, I want to block anyone from blindly rushing in and addressing this; this should be done as part of the attribute rewrite (#131229) and Jana already claimed all #[doc] attrs (we already have a very early draft PR here: #147097, but that might not end up as the actual one that we'll merge).
A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
Activity
zachs18 commentedon Sep 9, 2025
Note that this string does not show up in the rendered documentation when using the (unstable)
--document-hidden-items:cargo new --lib doc-priv && cd doc-privRUSTDOCFLAGS="-Zunstable-options --document-hidden-items" cargo +nightly doc --openfmease commentedon Oct 10, 2025
This is most definitely a bug (it's not tested or documented anywhere). In the early days, rustc used to perform none or only minimal validation for attributes (where they're placed, what shape they have) and over the years we've slowly gotten more principled in this area.
Due to the somewhat "widespread" usage of this specific form and just to be safe, this needs to start out as a lint warning of
invalid_doc_attributes(hopefully we'll turn this lint into a future-incompatibility one at some point and in the far future make it a hard error).#[doc(hidden = "…")]isn't the only form we don't warn / error on, there's a whole class of them:#[doc(hidden = 0)]#[doc(hidden(something))]#[doc(no_inline(var = 1))][-]You can pass a string literal to `#[doc(hidden = "foo")]`. Is this intended?[/-][+]rustdoc: Various `#[doc]` attributes are not fully validated (e.g., `#[doc(hidden)]`, `#[doc(no_inline)]`)[/+]fmease commentedon Oct 10, 2025
However, I want to block anyone from blindly rushing in and addressing this; this should be done as part of the attribute rewrite (#131229) and Jana already claimed all
#[doc]attrs (we already have a very early draft PR here: #147097, but that might not end up as the actual one that we'll merge).Rollup merge of rust-lang#166246 - GuillaumeGomez:malformed-doc-attrs…
Rollup merge of rust-lang#166246 - GuillaumeGomez:malformed-doc-attrs…
Unrolled build for #166246 in rollup 166254
Rollup merge of #166246 - GuillaumeGomez:malformed-doc-attrs, r=fmease