Closed
Description
Given the following code:
#![feature(const_generics)]
#![feature(const_evaluatable_checked)]
struct A<const M: usize> where [(); M * 2]: {
arr: [i32; M*2],
}
trait F {
fn f(&mut self);
}
impl<const M: usize> F for A<M> where [(); M * 2]: {
fn f(&mut self) {
println!("f");
}
}
impl<const M: usize> Drop for A<M> where [(); M * 2]: {
fn drop(&mut self) {
println!("drop");
}
}
fn main() {
}
The current output is:
E0367
error[E0367]: `Drop` impl requires `[(); _]: '<empty>` but the struct it is implemented for does not
--> src/main.rs:18:42
|
18 | impl<const M: usize> Drop for A<M> where [(); M * 2]: {
| ^^^^^^^^^^^
|
note: the implementor must specify the same requirement
--> src/main.rs:4:1
|
4 | / struct A<const M: usize> where [(); M * 2]: {
5 | | arr: [i32; M*2],
6 | | }
| |_^
error[E0367]: `Drop` impl requires `the constant `<A<M> as Drop>::{constant#0}` can be evaluated` but the struct it is implemented for does not
--> src/main.rs:18:47
|
18 | impl<const M: usize> Drop for A<M> where [(); M * 2]: {
| ^^^^^
|
note: the implementor must specify the same requirement
--> src/main.rs:4:1
|
4 | / struct A<const M: usize> where [(); M * 2]: {
5 | | arr: [i32; M*2],
6 | | }
| |_^
For more information about this error, try `rustc --explain E0367`.
error: could not compile `playground` due to 2 previous errors; 2 warnings emitted
Ideally the output should look like:
compile pass.
where [(); M * 2]:
is a necessary constait for A, this is not a subset specialization.