Skip to content

Fix doc attribute on paste! invocation - #13

Merged
Martan03 merged 1 commit into
Martan03:masterfrom
mejrs:fix-doc
Sep 30, 2026
Merged

Martan03 merged 1 commit into
Martan03:masterfrom
mejrs:fix-doc

Conversation

@mejrs

@mejrs mejrs commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Hello,

I'm opening this PR because this crate surfaced in a crater run for rust-lang/rust#160904

This crate depends on a rustc bug where doc attributes on macro invocations were not checked. As a result of fixing this bug, version 0.9.0 of this crate will stop compiling:

Error

error: attribute value must be a literal
   --> src/style/stylize.rs:77:25
    |
 77 |                   #[doc = concat!(
    |  _________________________^
 78 | |                     "Sets the background color to [`Color::",
 79 | |                     stringify!($color),
 80 | |                     "`](crate::enums::Color::",
 81 | |                     stringify!($color), ")."
 82 | |                 )]
    | |_________________^
...
197 | / generate_stylize_trait! {
198 | |     black => Black,
199 | |     dark_red => DarkRed,
200 | |     dark_green => DarkGreen,
...   |
222 | |     strike => STRIKED,
223 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `generate_stylize_trait` (in Nightly builds, run with -Z macro-backtrace for more info)


warning: unused doc comment
   --> src/style/stylize.rs:77:17
    |
 77 | /                 #[doc = concat!(
 78 | |                     "Sets the background color to [`Color::",
 79 | |                     stringify!($color),
 80 | |                     "`](crate::enums::Color::",
 81 | |                     stringify!($color), ")."
 82 | |                 )]
    | |__________________^ rustdoc does not generate documentation for macro invocations
...
197 | / generate_stylize_trait! {
198 | |     black => Black,
199 | |     dark_red => DarkRed,
200 | |     dark_green => DarkGreen,
...   |
222 | |     strike => STRIKED,
223 | | }
    | |_- in this macro invocation
    |
    = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
    = note: `#[warn(unused_doc_comments)]` (part of `#[warn(unused)]`) on by default
    = note: this warning originates in the macro `generate_stylize_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

This PR fixes that by moving the doc attribute inside of the paste! invocation. This also fixes the bug where on_* methods are undocumented.

Would you be willing to make a 0.9.1 release containing this fix?

Many thanks,
mejrs on behalf of the Rust project

@Martan03
Martan03 merged commit 9e4f8aa into Martan03:master Sep 30, 2026
3 checks passed
@Martan03

Copy link
Copy Markdown
Owner

Hello,

thank you for pointing it out and fixing it.

Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants