Add tests for calling trait methods on concrete types

This commit is contained in:
Dylan MacKenzie 2020-02-04 14:03:37 -08:00
parent 7a019b1bd2
commit 323ff193b8
9 changed files with 78 additions and 38 deletions

View file

@ -0,0 +1,30 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(const_fn)]
pub trait Plus {
fn plus(self, rhs: Self) -> Self;
}
impl const Plus for i32 {
fn plus(self, rhs: Self) -> Self {
self + rhs
}
}
impl Plus for u32 {
fn plus(self, rhs: Self) -> Self {
self + rhs
}
}
pub const fn add_i32(a: i32, b: i32) -> i32 {
a.plus(b)
}
pub const fn add_u32(a: u32, b: u32) -> u32 {
a.plus(b)
//~^ ERROR calls in constant functions are limited to constant functions
}
fn main() {}