summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.rs
blob: 3f1a9d12b44f91f1a5f8fdf41aafbd64f5f1da5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#![feature(type_alias_impl_trait)]

trait Foo {}
impl Foo for () {}
impl Foo for i32 {}

type Bar<T: Foo> = impl std::fmt::Debug;
fn defining_use<T: Foo>() -> Bar<T> {
    42
}

trait Bop {}

impl Bop for Bar<()> {}

// If the hidden type is the same, this is effectively a second impl for the same type.
impl Bop for Bar<i32> {}
//~^ ERROR conflicting implementations

type Barr = impl std::fmt::Debug;
fn defining_use2() -> Barr {
    42
}

// Even completely different opaque types must conflict.
impl Bop for Barr {}
//~^ ERROR conflicting implementations

// And obviously the hidden type must conflict, too.
impl Bop for i32 {}
//~^ ERROR conflicting implementations

fn main() {}