]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs
Ensure const impl cannot coexist with non-const impl
[rust.git] / src / test / ui / rfc-2632-const-trait-impl / const-and-non-const-impl.rs
1 #![allow(incomplete_features)]
2 #![feature(const_trait_impl)]
3
4 pub struct Int(i32);
5
6 impl const std::ops::Add for i32 {
7     //~^ ERROR conflicting implementations of trait
8     //~| ERROR only traits defined in the current crate can be implemented for arbitrary types
9     type Output = Self;
10
11     fn add(self, rhs: Self) -> Self {
12         self + rhs
13     }
14 }
15
16 impl std::ops::Add for Int {
17     type Output = Self;
18
19     fn add(self, rhs: Self) -> Self {
20         Int(self.0 + rhs.0)
21     }
22 }
23
24 impl const std::ops::Add for Int {
25     //~^ ERROR conflicting implementations of trait
26     type Output = Self;
27
28     fn add(self, rhs: Self) -> Self {
29         Int(self.0 + rhs.0)
30     }
31 }
32
33 fn main() {}