]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs
Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor
[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 calls in constant functions are limited to constant functions
26 }
27
28 fn main() {}