Skip to content

type parameter M/#0 (M/0) out of range when substituting, -Z mir-opt-level=2 #76248

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

Closed
tmiasko opened this issue Sep 2, 2020 · 0 comments · Fixed by #76254
Closed

type parameter M/#0 (M/0) out of range when substituting, -Z mir-opt-level=2 #76248

tmiasko opened this issue Sep 2, 2020 · 0 comments · Fixed by #76254
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. 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

@tmiasko
Copy link
Contributor

tmiasko commented Sep 2, 2020

Code

use std::marker::PhantomData;

const N: usize = 1;

pub struct Elem<M> {
    pub x: [usize; N],
    pub m: PhantomData<M>,
}

pub fn f() -> Elem<()> {
    g()
}

#[inline]
pub fn g<M>() -> Elem<M> {
    Elem {
        x: [0; N],
        m: PhantomData,
    }
}

pub fn main() {
    f();
}

Error output

error: internal compiler error: src/librustc_middle/ty/subst.rs:529:17: type parameter `M/#0` (M/0) out of range when substituting, substs=[]
...
note: rustc 1.48.0-nightly (d006f5734 2020-08-28) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z mir-opt-level=2

The ICE happens during codegen, but it seems to be caused by MIR inliner.

@tmiasko tmiasko added C-bug Category: This is a bug. 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. labels Sep 2, 2020
@jonas-schievink jonas-schievink added A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining requires-nightly This issue requires a nightly compiler in some way. labels Sep 2, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Sep 5, 2020
@bors bors closed this as completed in 79b8f59 Sep 5, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. 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.

2 participants