2021-07-06 13:05:24 +08:00
|
|
|
#![feature(const_trait_impl)]
|
2021-07-07 11:52:40 +08:00
|
|
|
#![feature(const_fn_trait_bound)] // FIXME is this needed?
|
2021-07-06 13:05:24 +08:00
|
|
|
|
|
|
|
trait ConstDefaultFn: Sized {
|
|
|
|
fn b(self);
|
|
|
|
|
|
|
|
#[default_method_body_is_const]
|
|
|
|
fn a(self) {
|
|
|
|
self.b();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct NonConstImpl;
|
|
|
|
struct ConstImpl;
|
|
|
|
|
|
|
|
impl ConstDefaultFn for NonConstImpl {
|
|
|
|
fn b(self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl const ConstDefaultFn for ConstImpl {
|
|
|
|
fn b(self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
const fn test() {
|
|
|
|
NonConstImpl.a();
|
2021-12-10 01:10:05 +08:00
|
|
|
//~^ ERROR cannot call non-const fn
|
2021-07-06 13:05:24 +08:00
|
|
|
ConstImpl.a();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|