Skip to content

Const generics: Wrong number of const arguments #62878

@Centril

Description

@Centril

The following should type check but does not:

#![feature(const_generics)]

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

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

Errors with:



error[E0107]: wrong number of const arguments: expected 2, found 1
 --> src/lib.rs:6:5
  |
6 |     foo::<_, {[1]}>();
  |     ^^^^^^^^^^^^^^^ expected 2 const arguments

error[E0107]: wrong number of type arguments: expected 0, found 1
 --> src/lib.rs:6:11
  |
6 |     foo::<_, {[1]}>();
  |           ^ unexpected type argument

error[E0308]: mismatched types
 --> src/lib.rs:6:15
  |
6 |     foo::<_, {[1]}>();
  |               ^^^ expected usize, found array of 1 elements
  |
  = note: expected type `usize`
             found type `[{integer}; 1]`

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.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