-
-
Notifications
You must be signed in to change notification settings - Fork 16k
Regression: proc-macro inner attribute via cfg_attr on out-of-line module fails with "unclosed delimiter" #159648
Copy link
Copy link
Closed
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTA-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.F-custom_inner_attributes`#![feature(custom_inner_attributes)]``#![feature(custom_inner_attributes)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTA-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.F-custom_inner_attributes`#![feature(custom_inner_attributes)]``#![feature(custom_inner_attributes)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Code
I tried this code:
A proc-macro attribute used as an inner attribute on an out-of-line (file) module, gated behind
cfg_attr, fails to parse when thecfgis active.macros/src/lib.rs(proc-macro crate):Cargo.toml:src/lib.rs:src/demo.rs:Build with the
cfgactive:RUSTFLAGS='--cfg enabled' cargo +nightly buildI expected to see this happen: the crate compiles, exactly as it does on
nightly-2026-07-19(and as it still does when thecfgis inactive so the attribute is stripped).Instead, this happened: the file fails to parse.
The failure is specific to the
cfg_attr-wrapped proc-macro inner attribute on an out-of-line module. These all still work:#mod demo { #![cfg_attr(enabled, macros::identity)] /* … */ }#[cfg_attr(enabled, macros::identity)] pub mod demo;cfginactive (attribute stripped)Fails on both
cargo buildandcargo doc.Real-world impact: broke
esp-halnightly CI, which uses#![cfg_attr(docsrs, procmacros::doc_replace)]on ~45 module files.Version it worked on
It most recently worked on:
nightly-2026-07-19(rustceff8269f7 2026-07-18)Version with regression
rustc --version --verbose:Backtrace
Backtrace
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged +A-proc-macros +A-parser +F-custom_inner_attributes