Files
rust/compiler/rustc_parse/src
Jacob Pratt 0a72846a4d Rollup merge of #159695 - Dnreikronos:proc_macro/cfg_attr_file_mod_inner_attr, r=nnethercote,petrochenkov
proc_macro: Fix cfg_attr inner attrs in file modules

Fixes rust-lang/rust#159648

Inner proc-macro attrs produced by `cfg_attr` only carry the nested attr span. Splitting source around that span tries to lex two unmatched halves, so file modules fail with an unclosed delimiter.

Lex the complete module body first, then remove the expanded attr from its nested token stream. Sibling attrs stay in place, and empty `cfg_attr` wrappers use their trace span and disappear. imo this is cleaner than teaching source slicing about every nested shape.

Tests exercise sibling attrs on either side of the proc macro, then cover the single-attr case. fyi, denied lints make sibling preservation observable; ltm if another nested case should live here.
2026-07-26 00:21:54 -04:00
..