2020-02-05 11:40:47 -06:00
|
|
|
#![feature(const_trait_impl)]
|
|
|
|
|
|
|
|
pub struct Int(i32);
|
|
|
|
|
2021-10-21 08:36:35 -05:00
|
|
|
impl const std::ops::Add for i32 { //~ ERROR type annotations needed
|
|
|
|
//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
|
2020-02-05 11:40:47 -06:00
|
|
|
type Output = Self;
|
|
|
|
|
|
|
|
fn add(self, rhs: Self) -> Self {
|
|
|
|
self + rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 08:36:35 -05:00
|
|
|
impl std::ops::Add for Int { //~ ERROR type annotations needed
|
2020-02-05 11:40:47 -06:00
|
|
|
type Output = Self;
|
|
|
|
|
|
|
|
fn add(self, rhs: Self) -> Self {
|
|
|
|
Int(self.0 + rhs.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 08:36:35 -05:00
|
|
|
impl const std::ops::Add for Int { //~ ERROR type annotations needed
|
2020-02-05 11:40:47 -06:00
|
|
|
//~^ ERROR conflicting implementations of trait
|
|
|
|
type Output = Self;
|
|
|
|
|
|
|
|
fn add(self, rhs: Self) -> Self {
|
|
|
|
Int(self.0 + rhs.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|