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
Creating a doc attribute from stringify! or concat! in a macro works in some situations but not others #52607
For anyone else coming across this, I've found the following macro to work well as a workaround:
/// Declares an item with a doc attribute computed by some macro expression./// This allows documentation to be dynamically generated based on input./// Necessary to work around https://github.com/rust-lang/rust/issues/52607.macro_rules! calculated_doc {(
$(
#[doc = $doc:expr]
$thing:item
)*) => (
$(
#[doc = $doc]
$thing
)*);}
This is definitely exploiting compiler behavior, but I'd at least like to believe that the behavior is caused by some fixed macro expansion order which won't change backwards-incompatibly.
Reacted by Stephen Checkoway, Rahul Butani and Jonas Platte
I've got a macro that automates the writing of getters and setters for an entity's components in an ECS-style system, and being able to give them the equivalent of /// Gets a reference to the [`Window`]'s [`Viewport`] component. would be awesome.
Activity
daboross commentedon Jul 23, 2019
For anyone else coming across this, I've found the following macro to work well as a workaround:
This is definitely exploiting compiler behavior, but I'd at least like to believe that the behavior is caused by some fixed macro expansion order which won't change backwards-incompatibly.
Michael-F-Bryan commentedon Jan 9, 2020
Has there been any progress on this?
I've got a macro that automates the writing of getters and setters for an entity's components in an ECS-style system, and being able to give them the equivalent of
/// Gets a reference to the [`Window`]'s [`Viewport`] component.would be awesome.petrochenkov commentedon Jan 9, 2020
cc #67121 "[experiment] Expand macros in inert key-value attributes"
Auto merge of rust-lang#78837 - petrochenkov:keyvalexpr, r=davidtwco