]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2632-const-trait-impl/assoc-type.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / 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 #[const_trait]
14 trait Foo {
15     type Bar: ~const std::ops::Add;
16 }
17
18 impl const Foo for NonConstAdd {
19     type Bar = NonConstAdd;
20     //~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts
21 }
22
23 #[const_trait]
24 trait Baz {
25     type Qux: std::ops::Add;
26 }
27
28 impl const Baz for NonConstAdd {
29     type Qux = NonConstAdd; // OK
30 }
31
32 fn main() {}