]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs
Rollup merge of #100691 - compiler-errors:issue-100690, r=estebank
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / assoc-type.rs
1 #![feature(const_trait_impl)]
2
3 struct NonConstAdd(i32);
4
5 impl std::ops::Add for NonConstAdd {
6     type Output = Self;
7
8     fn add(self, rhs: Self) -> Self {
9         NonConstAdd(self.0 + rhs.0)
10     }
11 }
12
13 trait Foo {
14     type Bar: ~const std::ops::Add;
15 }
16
17 impl const Foo for NonConstAdd {
18     type Bar = NonConstAdd;
19     //~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts
20 }
21
22 trait Baz {
23     type Qux: std::ops::Add;
24 }
25
26 impl const Baz for NonConstAdd {
27     type Qux = NonConstAdd; // OK
28 }
29
30 fn main() {}