Open
Description
I tried this code:
#![feature(type_alias_impl_trait)]
use std::any::TypeId;
pub trait Trait {}
impl<T: ?Sized> Trait for T {}
pub trait Other {}
macro_rules! mymac {
() => {{
struct S;
type Foo = impl Trait;
let x: Foo = S;
println!("{:?}", TypeId::of::<Foo>());
impl Foo {
fn foo() -> () {}
}
impl Other for Foo {}
}};
}
fn main() {
mymac!();
mymac!();
}
I expected to see this happen: compiles without error
Instead, this happened:
error[E0119]: conflicting implementations of trait `Other` for type `main::Foo`
--> src/main.rs:19:9
|
19 | impl Other for Foo {}
| ^^^^^^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `main::Foo`
...
25 | mymac!();
| -------- in this macro invocation
|
= note: this error originates in the macro `mymac` (in Nightly builds, run with -Z macro-backtrace for more info)
Meta
Rust nightly version on the playground as of 9th of April 2025.