Declarative macros: no error about duplicate trait items · Issue #71614 · rust-lang/rust (original) (raw)

I tried this code on the latest nightly:

#![feature(decl_macro)]

trait Trait { type T; }

macro trait_impl { () => { type T = (); } }

impl Trait for i32 { trait_impl!(); type T = (); }

I expected to see this happen: an error about type T being defined twice in the same impl. (This is what happens with macro_rules! trait_impl.)

Instead, this happened: the code just compiles. The same also works when considering a function rather than a type.