Skip to content

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

Description

@tmiasko

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions