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

ICE: rustc crashed on const generics #61341

Closed
qwerty19106 opened this issue May 30, 2019 · 5 comments · Fixed by #61380
Closed

ICE: rustc crashed on const generics #61341

qwerty19106 opened this issue May 30, 2019 · 5 comments · Fixed by #61380
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@qwerty19106
Copy link

qwerty19106 commented May 30, 2019

Test code:

#![feature(const_generics)]

use std::mem::MaybeUninit;

#[repr(transparent)]
pub struct OsThreadStack<const N: usize>(MaybeUninit<[u64; N]>);

fn main() {

}

It produced error:

error: internal compiler error: src/librustc/ty/sty.rs:2311: expected constant usize, got Const {
    ty: usize,
    val: Param(
        N/#0,
    ),
}

Playground version: rustc 1.37.0-nightly (2019-05-29 37d001e)

playground

@varkor varkor added A-const-generics Area: const generics (parameters and arguments) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 30, 2019
@varkor
Copy link
Member

varkor commented May 30, 2019

This may be the same as #61337. Both should be added as regression tests when this is fixed.

@Centril Centril added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 30, 2019
@qwerty19106
Copy link
Author

Also this code give other error:

#![feature(const_generics)]

use core::mem::MaybeUninit;

#[repr(C)]
pub struct OsThreadStack<const N: usize> {
    stack: MaybeUninit<[u64; N / 8]>
}

fn main() {
}
error: internal compiler error: constant in type had an ignored error
 --> src/main.rs:7:5
  |
7 |     stack: MaybeUninit<[u64; N / 8]>
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@varkor
Copy link
Member

varkor commented May 30, 2019

@qwerty19106: thanks, I've opened that as a new issue (as it has a different error message): #61368.

@varkor
Copy link
Member

varkor commented May 30, 2019

Note that this only occurs when #[repr(transparent)] is present.

@varkor
Copy link
Member

varkor commented May 30, 2019

I have a fix for this (separate from the one for #61337).

@varkor varkor self-assigned this May 30, 2019
Centril added a commit to Centril/rust that referenced this issue Jun 2, 2019
…eddyb

Fix some issues with `unwrap_usize` instead of `assert_usize`

Fixes rust-lang#61337.
Fixes rust-lang#61341.
Fixes rust-lang#61422.

r? @eddyb
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) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

3 participants