-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-coherenceArea: CoherenceArea: CoherenceA-hygieneArea: Macro hygieneArea: Macro hygieneC-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
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.
fmease
Metadata
Metadata
Assignees
Labels
A-coherenceArea: CoherenceArea: CoherenceA-hygieneArea: Macro hygieneArea: Macro hygieneC-bugCategory: This is a bug.Category: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.