Files
rust/tests/ui/traits/const-traits/const-default-method-bodies.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
495 B
Rust
Raw Normal View History

//@ compile-flags: -Znext-solver
2024-10-30 18:03:44 +00:00
#![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();
//~^ ERROR the trait bound `NonConstImpl: [const] ConstDefaultFn` is not satisfied
ConstImpl.a();
}
fn main() {}