It is not working is this a bug?

⚓ Rust    📅 2026-03-20    👤 surdeus    👁️ 1      

surdeus

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

2 posts - 2 participants

Read full topic

🏷️ Rust_feed