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