Skip to content

Invalid value accepted for #[macro_export(local_inner_macros)] #154977

@theemathas

Description

@theemathas

The reference seems to indicate that #[macro_export(local_inner_macros)] does not accept additional values for local_inner_macros. However, the following code currently compiles without errors.

#[macro_export(local_inner_macros(false))]
macro_rules! foo {
    () => {};
}

#[macro_export(local_inner_macros = false)]
macro_rules! bar {
    () => {};
}

As far as I can tell, the false value is entirely ignored, making the attributes equivalent to just #[macro_export(local_inner_macros)]. (The same is true when using string literals and numerical literals instead of false.)

I think this code should probably be rejected.

The parsing of this attribute was ported to the new attribute parsing infrastructure in #143857.

cc @JonathanBrouwer @jdonszelmann @Periodic1911

Meta

Reproducible on the playground with version 1.96.0-nightly (2026-04-07 c756124775121dea0e64)

Metadata

Metadata

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions