rust/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs

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

31 lines
532 B
Rust
Raw Normal View History

2024-10-21 19:37:48 +00:00
//@ compile-flags: -Znext-solver
2024-10-30 18:03:44 +00:00
#![feature(const_trait_impl)]
#[const_trait]
trait MyTrait {
fn do_something(&self);
}
trait OtherTrait {
fn do_something_else() where Self: ~const MyTrait;
//~^ ERROR `~const` is not allowed here
}
struct MyStruct<T>(T);
impl const MyTrait for u32 {
fn do_something(&self) {}
}
impl<T> MyStruct<T> {
pub fn foo(&self) where T: ~const MyTrait {
//~^ ERROR `~const` is not allowed here
self.0.do_something();
}
}
fn main() {
MyStruct(0u32).foo();
}