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

Const generics: Wrong number of const arguments #62878

Closed
Centril opened this issue Jul 22, 2019 · 0 comments · Fixed by #74159 or #74392
Closed

Const generics: Wrong number of const arguments #62878

Centril opened this issue Jul 22, 2019 · 0 comments · Fixed by #74159 or #74392
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Jul 22, 2019

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]`
@Centril Centril added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-const-generics Area: const generics (parameters and arguments) labels Jul 22, 2019
@jonas-schievink jonas-schievink added F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. labels Aug 6, 2019
@varkor varkor added the A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) label Jan 5, 2020
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
forbid generic params in the type of const params

implements and closes rust-lang#74152

fixes rust-lang#74101, closes rust-lang#71169, fixes rust-lang#73491, closes rust-lang#62878

@eddyb and I talked [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/type.20of.20const.20parameters/near/203405696) about this and we probably want to also forbid generic consts in the default
type of a parameter, e.g. `struct Foo<T, U = [u8; std::mem::size_of::<T>()]>`, this is currently still allowed
and I will probably fix that in a followup PR.

r? @varkor @eddyb
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
forbid generic params in the type of const params

implements and closes rust-lang#74152

fixes rust-lang#74101, closes rust-lang#71169, fixes rust-lang#73491, closes rust-lang#62878

@eddyb and I talked [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/type.20of.20const.20parameters/near/203405696) about this and we probably want to also forbid generic consts in the default
type of a parameter, e.g. `struct Foo<T, U = [u8; std::mem::size_of::<T>()]>`, this is currently still allowed
and I will probably fix that in a followup PR.

r? @varkor @eddyb
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
const generics triage

I went through all const generics issues and closed all issues which are already fixed.

Some issues already have a regression test but were not closed. Also doing this as part of this PR.

uff r? @eddyb @varkor

closes rust-lang#61936
closes rust-lang#62878
closes rust-lang#63695
closes rust-lang#67144
closes rust-lang#68596
closes rust-lang#69816
closes rust-lang#70217
closes rust-lang#70507
closes rust-lang#70586
closes rust-lang#71348
closes rust-lang#71805
closes rust-lang#73120
closes rust-lang#73508
closes rust-lang#73730
closes rust-lang#74255
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
const generics triage

I went through all const generics issues and closed all issues which are already fixed.

Some issues already have a regression test but were not closed. Also doing this as part of this PR.

uff r? @eddyb @varkor

closes rust-lang#61936
closes rust-lang#62878
closes rust-lang#63695
closes rust-lang#67144
closes rust-lang#68596
closes rust-lang#69816
closes rust-lang#70217
closes rust-lang#70507
closes rust-lang#70586
closes rust-lang#71348
closes rust-lang#71805
closes rust-lang#73120
closes rust-lang#73508
closes rust-lang#73730
closes rust-lang#74255
@bors bors closed this as completed in 6ef0dfa Jul 16, 2020
lcnr added a commit to lcnr/rust that referenced this issue Jul 17, 2020
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 18, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 19, 2020
…arth

Rollup of 7 pull requests

Successful merges:

 - rust-lang#70817 (Add core::task::ready! macro)
 - rust-lang#73762 (Document the trait keyword)
 - rust-lang#74021 (impl Index<RangeFrom> for CStr)
 - rust-lang#74071 (rustc_metadata: Make crate loading fully speculative)
 - rust-lang#74445 (add test for rust-lang#62878)
 - rust-lang#74459 (Make unreachable_unchecked a const fn)
 - rust-lang#74478 (Revert "Use an UTF-8 locale for the linker.")

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants