-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
ICE: "can't hash a TyVid" when failing to infer a const generic #62536
Comments
EDIT: Apparently const-generics in array repeat positions isn't a thing yet, at all. I apologize for the not-even-currently-valid example. I get the same ICE for this code: #![feature(const_generics, const_fn)]
pub struct TinyStack<T, const N: usize> {
pub index: usize,
pub stack: [T; N],
}
impl<T, const N: usize> TinyStack<T, {N}>
where
T: Copy,
{
#[inline(always)]
pub const fn new(value: T) -> TinyStack<T, {N}> {
TinyStack { index: 0, stack: [value; N] }
}
#[inline(always)]
pub fn push(&mut self, x: T) {
if self.index < N {
self.stack[self.index] = x;
self.index += 1;
}
}
#[inline(always)]
pub fn pop(&mut self) -> Option<T> {
if self.index > 0 {
let res = Some(self.stack[self.index]);
self.index -= 1;
res
} else {
None
}
}
}
fn main() {
let stack: TinyStack<usize, {64}> = TinyStack::new(0);
} which does give the explicit type, so it's not (entirely) a deduction thing. Entire build log:
|
Could you check the ICE still appears? I cannot reproduce it with latest nightly on playground. https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3504980d8445be3ee76087f26bf37bc8 |
Although this isn't throwing an error on the playground, I get an assertion failure when adding a test:
Let's leave this open until we have a test for it. |
A clean rust project on the latest nightly rustc with just this
src/main.rs
:produces the following error on cargo check/build:
The error is most likely caused by the inability to deduce the value of the const generic parameter
N
; when it is made clear (with, say,let x: S<_, {3}> = f(0u8);
) the ICE no longer occurs.Thus the expected behavior is probably still a failure to build (just not an ICE).
The text was updated successfully, but these errors were encountered: