It is not working is this a bug?

here is the code i wrote

macro_rules! mymacro {
    ($b:block) => {
        $b
    };
}

fn main() {
    mymacro!({
        #![allow(dead_code)]
        //#![warn(unused_variables)]
        let x = 10;
        println!("{}", x);
    });
}

and here what the rust doc says

Block expressions
[expr.block.syntax]

Syntax
BlockExpression →
    {
        InnerAttribute*
        Statements?
    }

Statements →
      Statement+
    | Statement+ ExpressionWithoutBlock
    | ExpressionWithoutBlock

link : Block expressions - The Rust Reference

I don't know the rules surrounding the expansion of block expressions in declarative macros and why inner attributes are problematic in that context. But as a workaround you can use inner attributes in a block expression wrapped in another block expression passed to the macro:

mymacro!({{
    #![allow(dead_code)]
    //#![warn(unused_variables)]
    let x = 10;
    println!("{}", x);
}});

Playground.

Note that it doesn't work if you wrap the block in another block inside of your macro. I.e. this doesn't work:

macro_rules! mymacro {
    ($b:block) => {
        {
            $b
        }
    };
}