mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 12:18:33 +00:00
39 lines
659 B
Rust
39 lines
659 B
Rust
![]() |
//@ revisions: yes no
|
||
|
//@ compile-flags: -Znext-solver
|
||
|
//@[yes] check-pass
|
||
|
|
||
|
#![feature(const_trait_impl)]
|
||
|
|
||
|
#[const_trait]
|
||
|
trait Foo {
|
||
|
fn method(&self);
|
||
|
}
|
||
|
|
||
|
impl<T: ~const Foo> const Foo for (T,) {
|
||
|
fn method(&self) {}
|
||
|
}
|
||
|
|
||
|
#[cfg(yes)]
|
||
|
impl const Foo for () {
|
||
|
fn method(&self) {}
|
||
|
}
|
||
|
|
||
|
#[cfg(no)]
|
||
|
impl Foo for () {
|
||
|
fn method(&self) {}
|
||
|
}
|
||
|
|
||
|
const fn bar<T: ~const Foo>(t: T) -> impl ~const Foo {
|
||
|
(t,)
|
||
|
}
|
||
|
|
||
|
const _: () = {
|
||
|
let opaque = bar(());
|
||
|
//[no]~^ ERROR the trait bound `(): const Foo` is not satisfied
|
||
|
opaque.method();
|
||
|
//[no]~^ ERROR the trait bound `(): const Foo` is not satisfied
|
||
|
std::mem::forget(opaque);
|
||
|
};
|
||
|
|
||
|
fn main() {}
|