Skip to content
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

Expand doc comments to attributes before macro expansion #14197

Closed
brendanzab opened this issue May 14, 2014 · 0 comments · Fixed by #17830
Closed

Expand doc comments to attributes before macro expansion #14197

brendanzab opened this issue May 14, 2014 · 0 comments · Fixed by #17830
Labels
A-parser Area: The parsing of Rust source code to an AST A-syntaxext Area: Syntax extensions I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@brendanzab
Copy link
Member

This would allow doc comments to parse them as $_:meta elements in macro invocations. This is useful for example with bitflags!:

bitflags! {
    #[doc = "Some flags"]
    #[doc = ""]
    #[doc = "A new line"]
    #[deriving(Show)]
    flags Flags: u32 {
        #[doc = "Flag A"]
        static FlagA = 0x00000001,
        #[doc = "Flag B"]
        static FlagB = 0x00000010
    }
}

vs:

bitflags! {
    /// Some flags
    ///
    /// A new line
    #[deriving(Show)]
    flags Flags: u32 {
        /// Flag A
        static FlagA = 0x00000001,
        /// Flag B
        static FlagB = 0x00000010
    }
}

Where the bitflags! match rule is defined as:

($(#[$attr:meta])* flags $BitFlags:ident: $T:ty {
    $($(#[$Flag_attr:meta])* static $Flag:ident = $value:expr),+
})
bors added a commit that referenced this issue Nov 7, 2014
Closes #14197

Removes the `matchers` nonterminal.

If you're using `$foo:matchers` in a macro, write `$foo:tt` instead.

[breaking-change]
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 20, 2025
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.

Close rust-lang#14195

changelog: [`mem_replace_option_with_some`]: new lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST A-syntaxext Area: Syntax extensions I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant