Skip to content

In a formal non-type generic parameter, referring to a const item causes a false "cycle detected" error #73491

Closed
@yvt

Description

@yvt

I tried this code: (Playground Link)

#![feature(const_generics)]

const LEN: usize = 1024;

fn hoge<const IN: [u32; LEN]>() {}

I expected to see this happen: Successful compilation.

Instead, this happened:

error[E0391]: cycle detected when computing type of `hoge::IN`
 --> src/lib.rs:5:15
  |
5 | fn hoge<const IN: [u32; LEN]>() {}
  |               ^^
  |
  = note: ...which again requires computing type of `hoge::IN`, completing the cycle
note: cycle used when computing type of `hoge`
 --> src/lib.rs:5:1
  |
5 | fn hoge<const IN: [u32; LEN]>() {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (feb3536eb 2020-06-09)
binary: rustc
commit-hash: feb3536eba10c2e4585d066629598f03d5ddc7c6
commit-date: 2020-06-09
host: x86_64-apple-darwin
release: 1.46.0-nightly
LLVM version: 10.0

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions