Skip to content

Proc-macro definition attributes are accepted in arbitrary non-item positions #52329

@petrochenkov

Description

@petrochenkov

For example,

#![feature(proc_macro)]

fn main() {
    #[proc_macro]
    let x = 10;
    #[proc_macro_attribute]
    let x = 11;
    #[proc_macro_derive]
    let x = 12;
}

A lot of stable built-in attributes have this issue as well, but if we can fix it in this specific case, then why not.
I think these kinds of checks are usually performed in librustc/hir/check_attr.rs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-decl-macros-1-2Area: Declarative macros 1.2A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions