rust/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs

30 lines
402 B
Rust
Raw Normal View History

#![feature(const_trait_impl)]
#[const_trait]
trait ConstDefaultFn: Sized {
fn b(self);
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();
2023-07-27 10:51:02 -05:00
//~^ ERROR cannot call
ConstImpl.a();
}
fn main() {}