Skip to content

const generics: cycle error due to a lack of lazy normalization #68249

Description

@JohnTitor

Consider this example:

#![feature(const_generics)]

fn foo<const N: usize, const A: [u8; N]>() {}

fn bar() {
    foo::<1, {[1]}>();
}

It causes a cycle error:

error[E0391]: cycle detected when processing `foo::A`
  --> $DIR/issue-62879.rs:4:30
   |
LL | fn foo<const N: usize, const A: [u8; N]>() {}
   |                              ^
   |
   = note: ...which again requires processing `foo::A`, completing the cycle
note: cycle used when processing `foo`
  --> $DIR/issue-62879.rs:4:1
   |
LL | fn foo<const N: usize, const A: [u8; N]>() {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It should be compiled, but cycle error occurs due to a lack of lazy normalization.
It's added to ui test as a regression test of #62879 (src/test/ui/const-generics/issue-62879.rs) in #68236, but we should still improve current behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions