Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycle E0391 error with polymorphize #85318

Closed
leonardo-m opened this issue May 15, 2021 · 1 comment
Closed

Cycle E0391 error with polymorphize #85318

leonardo-m opened this issue May 15, 2021 · 1 comment
Labels
-Zpolymorphize Unstable option: Polymorphization. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

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.

@leonardo-m leonardo-m added the C-bug Category: This is a bug. label May 15, 2021
@jonas-schievink jonas-schievink added the -Zpolymorphize Unstable option: Polymorphization. label May 15, 2021
@estebank estebank added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 18, 2021
@tgnottingham
Copy link
Contributor

This can be closed. Works as of nightly-2021-10-18 (well, with updates to changed feature names). Most likely fixed by #89514.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zpolymorphize Unstable option: Polymorphization. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants