Closed
Description
rustc (v.1.54.0-nightly 1025db84a 2021-05-14
) compiles this code normally, even with optimizations:
#![feature(const_generics, const_evaluatable_checked, const_option)]
#![allow(incomplete_features, dead_code)]
struct Collection<T, const N: usize>
where [(); N.checked_next_power_of_two().unwrap()]: {
arr: [T; N.checked_next_power_of_two().unwrap()],
start: usize,
}
impl<T: Copy + Default, const N: usize> Collection<T, N>
where [(); N.checked_next_power_of_two().unwrap()]: {
fn new() -> Self {
Self {
arr: [T::default(); N.checked_next_power_of_two().unwrap()],
start: 0,
}
}
}
fn main() {
let _ = Collection::<u32, 52>::new();
}
If I compile it with rustc -Z polymorphize=y
, it raises errors:
error[E0391]: cycle detected when determining which generic parameters are unused by `<impl at test.rs:10:1: 18:2>::{constant#0}`
--> test.rs:11:12
|
11 | where [(); N.checked_next_power_of_two().unwrap()]: {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which again requires determining which generic parameters are unused by `<impl at test.rs:10:1: 18:2>::{constant#0}`, completing the cycle
note: cycle used when determining which generic parameters are unused by `<impl at test.rs:10:1: 18:2>::new::{constant#0}`
--> test.rs:14:33
|
14 | arr: [T::default(); N.checked_next_power_of_two().unwrap()],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
I don't know much about that polymorphize option, so I am not sure if this is a compiler problem.