2022-11-06 01:07:06 -05:00
|
|
|
// Tests that `T: ~const Foo` in a specializing impl is treated as equivalent to
|
|
|
|
// `T: Foo` in the default impl for the purposes of specialization (i.e., it
|
|
|
|
// does not think that the user is attempting to specialize on trait `Foo`).
|
2022-03-24 19:24:40 -05:00
|
|
|
|
|
|
|
// check-pass
|
|
|
|
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![feature(min_specialization)]
|
|
|
|
#![feature(const_trait_impl)]
|
|
|
|
|
|
|
|
#[rustc_specialization_trait]
|
|
|
|
trait Specialize {}
|
|
|
|
|
2022-11-05 23:12:57 -05:00
|
|
|
#[const_trait]
|
2022-03-24 19:24:40 -05:00
|
|
|
trait Foo {}
|
|
|
|
|
2022-11-05 23:12:57 -05:00
|
|
|
#[const_trait]
|
2023-05-05 06:54:58 -05:00
|
|
|
trait Bar {
|
|
|
|
fn bar();
|
|
|
|
}
|
2022-03-24 19:24:40 -05:00
|
|
|
|
2022-09-13 22:18:14 -05:00
|
|
|
impl<T> Bar for T
|
2022-03-24 19:24:40 -05:00
|
|
|
where
|
2022-09-13 22:18:14 -05:00
|
|
|
T: Foo,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
default fn bar() {}
|
|
|
|
}
|
2022-03-24 19:24:40 -05:00
|
|
|
|
2022-09-13 22:18:14 -05:00
|
|
|
impl<T> const Bar for T
|
2022-03-24 19:24:40 -05:00
|
|
|
where
|
2022-09-13 22:18:14 -05:00
|
|
|
T: ~const Foo,
|
2022-03-24 19:24:40 -05:00
|
|
|
T: Specialize,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
fn bar() {}
|
|
|
|
}
|
2022-03-24 19:24:40 -05:00
|
|
|
|
2022-11-06 01:07:06 -05:00
|
|
|
#[const_trait]
|
2023-05-05 06:54:58 -05:00
|
|
|
trait Baz {
|
|
|
|
fn baz();
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
|
|
|
impl<T> const Baz for T
|
|
|
|
where
|
|
|
|
T: Foo,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
default fn baz() {}
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
|
|
|
impl<T> const Baz for T
|
|
|
|
where
|
|
|
|
T: ~const Foo,
|
|
|
|
T: Specialize,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
fn baz() {}
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
2022-03-24 19:24:40 -05:00
|
|
|
fn main() {}
|