Skip to content

MIR inliner doesn't support return place used as an index #105466

Closed
@tmiasko

Description

@tmiasko
#![feature(box_syntax)]

#[inline(always)]
pub fn f(a: usize, b: &mut usize, c: &[usize]) -> usize {
    let x = a + a;
    *b = c[x];
    x
}

pub fn g(a: usize, b: &mut usize, c: &[usize]) -> usize {
    f(a, b, c)
}

pub fn h(a: usize, b: &mut usize, c: &[usize]) -> Box<usize> {
    box f(a, b, c)
}
$ rustc a.rs --crate-type=lib -O -Zmir-opt-level=3
thread '<unnamed>' panicked at 'assertion failed: `(left != right)`
  left: `Index(_0)`,
 right: `Index(_0)`', compiler/rustc_mir_transform/src/inline.rs:1035:13

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-opt-inliningArea: MIR inliningC-bugCategory: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions