Skip to content

Declarative macros: no error about duplicate trait items #71614

Closed
@RalfJung

Description

@RalfJung

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)A-trait-systemArea: Trait systemC-bugCategory: This is a bug.F-decl_macro`#![feature(decl_macro)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions