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] in inner const generic function #75299

Closed
leonardo-m opened this issue Aug 8, 2020 · 3 comments · Fixed by #77388
Closed

[ICE] in inner const generic function #75299

leonardo-m opened this issue Aug 8, 2020 · 3 comments · Fixed by #77388
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-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

@leonardo-m
Copy link

#![feature(const_generics, box_syntax)]
#![allow(incomplete_features)]
fn main() {
    fn foo<const N: usize>() {
        box [0; N];
    }
    foo::<1>();
}

Compiled with:
rustc -Z mir-opt-level=3 bug.rs

Using:
rustc 1.47.0-nightly (09f4c9f50 2020-08-07) running on x86_64-pc-windows-gnu

Gives:

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ bug[317d]::main[0]), const_param_did: None }) (
encountered `Assign` statement with incompatible types:
left-hand side has type: [i32; 1]
right-hand side has type: [i32; N]
 --> bug.rs:5:13
  |
5 |         box [0; N];
  |             ^^^^^^
  |
  = note: delayed at src\librustc_mir\transform\validate.rs:140:36

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src\librustc_errors\lib.rs:366:17
@leonardo-m leonardo-m added the C-bug Category: This is a bug. label Aug 8, 2020
@leonardo-m
Copy link
Author

The problem is not tied to box:

#![feature(const_generics)]
#![allow(incomplete_features)]
fn main() {
    fn foo<const N: usize>() -> [u8; N] {
        [0; N]
    }
    let _x = foo::<1>();
}

@leonardo-m leonardo-m changed the title [ICE] with box in const generic function [ICE] in inner const generic function Aug 8, 2020
@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` 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. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Aug 8, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 14, 2020
@Alexendoo
Copy link
Member

No longer ICEs after #76376

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 7, 2020
@leonardo-m
Copy link
Author

Ops, sorry, I reopen until a test is present.

@leonardo-m leonardo-m reopened this Sep 7, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 3, 2020
Add some regression tests

Closes rust-lang#66501
Closes rust-lang#68951
Closes rust-lang#72565
Closes rust-lang#74244
Closes rust-lang#75299

The first issue is fixed in 1.43.0, other issues are fixed in the recent nightly.
@bors bors closed this as completed in f09c962 Oct 4, 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-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants