]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs
Rollup merge of #106739 - WaffleLapkin:astconv, r=estebank
[rust.git] / tests / ui / rfc-2632-const-trait-impl / call-const-trait-method-fail.rs
1 #![feature(const_trait_impl)]
2
3 #[const_trait]
4 pub trait Plus {
5     fn plus(self, rhs: Self) -> Self;
6 }
7
8 impl const Plus for i32 {
9     fn plus(self, rhs: Self) -> Self {
10         self + rhs
11     }
12 }
13
14 impl Plus for u32 {
15     fn plus(self, rhs: Self) -> Self {
16         self + rhs
17     }
18 }
19
20 pub const fn add_i32(a: i32, b: i32) -> i32 {
21     a.plus(b) // ok
22 }
23
24 pub const fn add_u32(a: u32, b: u32) -> u32 {
25     a.plus(b)
26     //~^ ERROR the trait bound
27 }
28
29 fn main() {}