-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This compiles:
use arrayvec::{Array, ArrayVec};
#[ext(pub, name = IterExt)]
impl<T: Iterator<Item = U>, U> T {
fn collect_arr<const N: usize>(self) -> [U; N]
where
[U; N]: Array<Item = U>,
ArrayVec<[U; N]>: Debug,
{
self.collect::<ArrayVec<[U; N]>>().into_inner().expect("collect_arr")
}
}
(Using the extend
and arrayvec
crates.)
But using it with a constant doesn't compile:
Even though pub const CUE_POINT_COUNT: usize = 8;
is in scope!
If I write .collect_arr::<8usize>()
instead, it compiles.
Also, if I don't use the extension trait method but inline it (.collect::<ArrayVec<[_; CUE_POINT_COUNT]>>().into_inner().unwrap()
) it works with the constant!
So for some reason rustc can't see that CUE_POINT_COUNT == 8
here.
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.