Skip to content

Item macros do neither support import lines nor inner attributes #10716

Closed
@Kimundi

Description

@Kimundi

I'm trying to switch a few of the libstd macros from generated module to multi item macros, and I've run in a few issues:

Import lines are not supported:

#[feature(macro_rules)];

macro_rules! items(
    () => (
        use std::option::Option;
    )
)

items!()
multi_item_macro_bugs.rs:5:31: 5:32 error: view items are not allowed here
multi_item_macro_bugs.rs:5         use std::option::Option;
                                                          ^

Inner attributes are not supported:

#[feature(macro_rules)];

macro_rules! items(
    () => (
        #[feature(globs)];
    )
)

items!()
multi_item_macro_bugs.rs:5:25: 5:26 error: macro expansion ignores token `;` and any following
multi_item_macro_bugs.rs:5         #[feature(globs)];
                                                    ^

I'm not sure if those two are intentional limitations or not, but if they are, then not all use cases for macros-expanding-to-generated-modules can be replaced with item macros. (See std::num::uint_macros for a big example)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions