Skip to content

Support _ for const inference with const generics #80528

New issue

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

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

Already on GitHub? # to your account

Open
varkor opened this issue Dec 30, 2020 · 0 comments
Open

Support _ for const inference with const generics #80528

varkor opened this issue Dec 30, 2020 · 0 comments
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented Dec 30, 2020

Currently, users may specify _ in place of a type: the compiler will then suggest the intended type. This ought to work for consts too, but currently does not (see #79557).

fn foo<const N: usize, const K: usize>(data: [u32; N]) -> [u32; K] {
    [0; K]
}

fn main() {
    let a = foo::<_, 2>([0, 1, 2]);
}

The difficulty is that the intended use of _ (as either a type or const) is ambiguous until type checking, so runs into the same problems as #66615 and #77773.

@varkor varkor added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. A-const-generics Area: const generics (parameters and arguments) labels Dec 30, 2020
branlwyd added a commit to divviup/janus that referenced this issue Jun 18, 2022
This version of libprio-rs implements draft-irtf-cfrg-vdaf-01, which is
the version we are targeting for interop tests.

This change is large but mostly-mechanical. A large number of line
changes are due to the new `L` const generic parameter to the VDAF
Aggregator trait.  This parameter is effectively the underlying PRG's
seed size.  Unfortunately, Rust currently doesn't allow const generic
parameters to be inferred; there is an open issue to resolve this, but
it doesn't appear to have received much attention thus far[1].

[1] rust-lang/rust#80528
branlwyd added a commit to divviup/janus that referenced this issue Jun 21, 2022
This version of libprio-rs implements draft-irtf-cfrg-vdaf-01, which is
the version we are targeting for interop tests.

This change is large but mostly-mechanical. A large number of line
changes are due to the new `L` const generic parameter to the VDAF
Aggregator trait.  This parameter is effectively the underlying PRG's
seed size.  Unfortunately, Rust currently doesn't allow const generic
parameters to be inferred; there is an open issue to resolve this, but
it doesn't appear to have received much attention thus far[1].

[1] rust-lang/rust#80528
@Dylan-DPC Dylan-DPC added C-bug Category: This is a bug. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Jan 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints 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

2 participants