2022-11-06 01:07:06 -05:00
|
|
|
// Tests that trait bounds on specializing trait impls must be `~const` if the
|
|
|
|
// same bound is present on the default impl and is `~const` there.
|
2023-07-27 10:51:02 -05:00
|
|
|
// known-bug: #110395
|
2022-11-06 01:07:06 -05:00
|
|
|
|
|
|
|
#![feature(const_trait_impl)]
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![feature(min_specialization)]
|
|
|
|
|
|
|
|
#[rustc_specialization_trait]
|
|
|
|
trait Specialize {}
|
|
|
|
|
|
|
|
#[const_trait]
|
|
|
|
trait Foo {}
|
|
|
|
|
|
|
|
#[const_trait]
|
2023-05-05 06:54:58 -05:00
|
|
|
trait Bar {
|
|
|
|
fn bar();
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
|
|
|
// bgr360: I was only able to exercise the code path that raises the
|
|
|
|
// "missing ~const qualifier" error by making this base impl non-const, even
|
|
|
|
// though that doesn't really make sense to do. As seen below, if the base impl
|
|
|
|
// is made const, rustc fails earlier with an overlapping impl failure.
|
|
|
|
impl<T> Bar for T
|
|
|
|
where
|
|
|
|
T: ~const Foo,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
default fn bar() {}
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
|
|
|
impl<T> Bar for T
|
|
|
|
where
|
2023-07-27 10:51:02 -05:00
|
|
|
T: Foo, //FIXME ~ ERROR missing `~const` qualifier
|
2022-11-06 01:07:06 -05:00
|
|
|
T: Specialize,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
fn bar() {}
|
|
|
|
}
|
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: ~const Foo,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
default fn baz() {}
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
2023-07-27 10:51:02 -05:00
|
|
|
impl<T> const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz`
|
2022-11-06 01:07:06 -05:00
|
|
|
where
|
|
|
|
T: Foo,
|
|
|
|
T: Specialize,
|
2023-05-05 06:54:58 -05:00
|
|
|
{
|
|
|
|
fn baz() {}
|
|
|
|
}
|
2022-11-06 01:07:06 -05:00
|
|
|
|
|
|
|
fn main() {}
|