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

Rvalue::Repeat should hold a ty::Const #68567

Closed
varkor opened this issue Jan 27, 2020 · 1 comment · Fixed by #69981
Closed

Rvalue::Repeat should hold a ty::Const #68567

varkor opened this issue Jan 27, 2020 · 1 comment · Fixed by #69981
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented Jan 27, 2020

fn test<const N: usize>() {
    let array = [0; N];
}

currently fails with error: array lengths can't depend on generic parameters, because we can't tell what concrete value N should take here. This is an artificial limitation: when producing a Rvalue::Repeat, we currently need to provide the length of the array, which is impossible at this stage.
cc #43408 (comment)

@varkor varkor added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Jan 27, 2020
@eddyb
Copy link
Member

eddyb commented Jan 27, 2020

cc @oli-obk @yodaldevoid

@varkor varkor self-assigned this Jan 28, 2020
@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Feb 16, 2020
@oli-obk oli-obk self-assigned this Mar 13, 2020
Centril added a commit to Centril/rust that referenced this issue Mar 23, 2020
Evaluate repeat expression lengths as late as possible

Fixes rust-lang#68567

r? @varkor
@bors bors closed this as completed in a73ed5a Mar 24, 2020
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-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. F-const_generics `#![feature(const_generics)]` 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.

4 participants