-
Notifications
You must be signed in to change notification settings - Fork 13.4k
ICE with const generics: llvm failed to get layout for [i32; _]
#61936
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
Labels
A-codegen
Area: Code generation
A-const-generics
Area: const generics (parameters and arguments)
C-bug
Category: This is a bug.
F-const_generics
`#![feature(const_generics)]`
glacier
ICE tracked in rust-lang/glacier.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
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
You can enable backtraces on the playground inside a menu.
|
[i32; _]
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this issue
Jan 7, 2020
…dtwco Fix ICE in const pretty printing and resolve FIXME Consts now have a `fmt::Display` impl, so we can just use that to pretty-print. This resolves an ICE in rust-lang#61936, though it hits more ICEs afterwards. I couldn't find a test case that was resolved by this that didn't hit errors later on.
since 342c5f3 this still ICEs, but needs an explicit type added on line 40 ( #![feature(const_generics)]
trait SliceExt<T: Clone> {
fn array_windows<'a, const N: usize>(&'a self) -> ArrayWindows<'a, T, {N}>;
}
impl <T: Clone> SliceExt<T> for [T] {
fn array_windows<'a, const N: usize>(&'a self) -> ArrayWindows<'a, T, {N}> {
ArrayWindows{ idx: 0, slice: &self }
}
}
struct ArrayWindows<'a, T, const N: usize> {
slice: &'a [T],
idx: usize,
}
impl <'a, T: Clone, const N: usize> Iterator for ArrayWindows<'a, T, {N}> {
type Item = [T; N];
fn next(&mut self) -> Option<Self::Item> {
let mut res = unsafe{ std::mem::zeroed() };
let mut ptr = &mut res as *mut [T; N] as *mut T;
for i in 0..N {
match self.slice[i..].get(i) {
None => return None,
Some(elem) => unsafe { std::ptr::write_volatile(ptr, elem.clone())},
};
ptr = ptr.wrapping_add(1);
self.idx += 1;
}
Some(res)
}
}
const FOUR: usize = 4;
fn main() {
let v: Vec<usize> = vec![100; 0usize];
for array in v.as_slice().array_windows::<{FOUR}>() {
// println!("{:?}", array);
}
} |
Merged
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
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-codegen
Area: Code generation
A-const-generics
Area: const generics (parameters and arguments)
C-bug
Category: This is a bug.
F-const_generics
`#![feature(const_generics)]`
glacier
ICE tracked in rust-lang/glacier.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
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.
Hi, I'm trying to learn how to use the new const generics stuff and I ICEd the compiler. Here's the code:
I can't give you the verbose compiler info because this was done on play.rust-lang.org but here's the version:
The text was updated successfully, but these errors were encountered: