blob: e06d04db804094a01dfcb3e1a73f3fd1f7a809a5 [file] [log] [blame]
Deadbeef7f6150b2024-10-02 11:42:061//@ compile-flags: -Znext-solver
Michael Goulet0b5ddf32024-10-30 18:03:442#![feature(const_trait_impl)]
Dylan MacKenzie323ff192020-02-04 22:03:373
Deadbeef1bcc26a2022-08-28 06:27:314#[const_trait]
Dylan MacKenzie323ff192020-02-04 22:03:375pub trait Plus {
6 fn plus(self, rhs: Self) -> Self;
7}
8
9impl const Plus for i32 {
10 fn plus(self, rhs: Self) -> Self {
11 self + rhs
12 }
13}
14
15impl Plus for u32 {
16 fn plus(self, rhs: Self) -> Self {
17 self + rhs
18 }
19}
20
21pub const fn add_i32(a: i32, b: i32) -> i32 {
Dylan MacKenzied6d6d252020-02-05 17:35:3222 a.plus(b) // ok
Dylan MacKenzie323ff192020-02-04 22:03:3723}
24
25pub const fn add_u32(a: u32, b: u32) -> u32 {
26 a.plus(b)
Deadbeef7f6150b2024-10-02 11:42:0627 //~^ ERROR the trait bound `u32: ~const Plus`
Dylan MacKenzie323ff192020-02-04 22:03:3728}
29
30fn main() {}