1
Fork 0

added tests

This commit is contained in:
Deadbeef 2022-09-24 20:15:19 +00:00 committed by fee1-dead
parent a480ab6839
commit 36e8c113f6
4 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,31 @@
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
#[rustc_specialization_trait]
#[const_trait]
pub trait Sup {}
impl const Sup for () {}
#[const_trait]
pub trait A {
fn a() -> u32;
}
impl<T: Default> A for T {
default fn a() -> u32 {
2
}
}
impl<T: Default + ~const Sup> const A for T {
fn a() -> u32 {
3
}
}
const fn generic<T: Default>() {
<T as A>::a();
//~^ ERROR: the trait bound `T: ~const Sup` is not satisfied
}
fn main() {}

View file

@ -0,0 +1,19 @@
error[E0277]: the trait bound `T: ~const Sup` is not satisfied
--> $DIR/specializing-constness-2.rs:27:5
|
LL | <T as A>::a();
| ^^^^^^^^^^^^^ the trait `~const Sup` is not implemented for `T`
|
note: required for `T` to implement `~const A`
--> $DIR/specializing-constness-2.rs:20:37
|
LL | impl<T: Default + ~const Sup> const A for T {
| ^ ^
help: consider further restricting this bound
|
LL | const fn generic<T: Default + ~const Sup>() {
| ++++++++++++
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,26 @@
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
#[rustc_specialization_trait]
#[const_trait]
pub trait Sup {}
impl const Sup for () {}
#[const_trait]
pub trait A {
fn a() -> u32;
}
impl<T: ~const Default> const A for T {
default fn a() -> u32 {
2
}
}
impl<T: Default + Sup> A for T { //~ ERROR: cannot specialize
fn a() -> u32 {
3
}
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: cannot specialize on trait `Default`
--> $DIR/specializing-constness.rs:20:9
|
LL | impl<T: Default + Sup> A for T {
| ^^^^^^^
error: aborting due to previous error