gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Macro expansion of attribute-bearing statement treated as expression

Open powerboat9 opened this issue 2 years ago • 1 comments

I tried this code:

macro_rules! mac {
    () => {
        #[allow(overflowing_literals)]
        match () {_ => {}}
    }
}

pub fn foo() {
    mac!()
}

I expected to see this happen: no error

Instead, this happened:

test.rs:3:9: error: found unexpected token ‘#’ in null denotation
    3 |         #[allow(overflowing_literals)]
      |         ^

Meta

  • sha: 1b322540fa0fce561cf86e371dd7f304f1343511

powerboat9 avatar Jun 06 '23 23:06 powerboat9

@powerboat9 if you'd like to work on this, this is probably caused by a missing call to parse_outer_attributes in the macro transcribers. I'm thinking that the fix should not be too hard, but maybe I am downplaying it in my head

CohenArthur avatar Jun 07 '23 12:06 CohenArthur