2024-10-02 11:42:06 +00:00
|
|
|
//@ compile-flags: -Znext-solver
|
|
|
|
#![allow(incomplete_features)]
|
|
|
|
#![feature(const_trait_impl, effects)]
|
2020-11-22 03:19:46 +00:00
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
2022-10-03 17:08:42 +00:00
|
|
|
#[const_trait]
|
|
|
|
trait Foo {
|
|
|
|
fn eq(&self, _: &Self) -> bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for S {
|
2020-11-22 03:19:46 +00:00
|
|
|
fn eq(&self, _: &S) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-03 17:08:42 +00:00
|
|
|
const fn equals_self<T: ~const Foo>(t: &T) -> bool {
|
2020-11-22 03:19:46 +00:00
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calling `equals_self` with something that has a non-const impl should throw an error, despite
|
|
|
|
// it not using the impl.
|
|
|
|
|
|
|
|
pub const EQ: bool = equals_self(&S);
|
2024-10-02 11:42:06 +00:00
|
|
|
//~^ ERROR: the trait bound `S: const Foo` is not satisfied
|
2020-11-22 03:19:46 +00:00
|
|
|
|
|
|
|
fn main() {}
|