summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs
blob: 7d9dae52cf10e0b234904f528106809eaef00234 (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
#![feature(const_trait_impl)]

struct NonConstAdd(i32);

impl std::ops::Add for NonConstAdd {
    type Output = Self;

    fn add(self, rhs: Self) -> Self {
        NonConstAdd(self.0 + rhs.0)
    }
}

#[const_trait]
trait Foo {
    type Bar: ~const std::ops::Add;
}

impl const Foo for NonConstAdd {
    type Bar = NonConstAdd;
    //~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts
}

#[const_trait]
trait Baz {
    type Qux: std::ops::Add;
}

impl const Baz for NonConstAdd {
    type Qux = NonConstAdd; // OK
}

fn main() {}