Fold length constant in Rvalue::Repeat
This commit is contained in:
parent
da897dfb6d
commit
af19262ab4
@ -175,7 +175,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
|
||||
use crate::mir::Rvalue::*;
|
||||
match *self {
|
||||
Use(ref op) => Use(op.fold_with(folder)),
|
||||
Repeat(ref op, len) => Repeat(op.fold_with(folder), len),
|
||||
Repeat(ref op, len) => Repeat(op.fold_with(folder), len.fold_with(folder)),
|
||||
ThreadLocalRef(did) => ThreadLocalRef(did.fold_with(folder)),
|
||||
Ref(region, bk, ref place) => {
|
||||
Ref(region.fold_with(folder), bk, place.fold_with(folder))
|
||||
|
29
src/test/ui/mir/issue-76248.rs
Normal file
29
src/test/ui/mir/issue-76248.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// This used to ICE during codegen after MIR inlining of g into f.
|
||||
// The root cause was a missing fold of length constant in Rvalue::Repeat.
|
||||
// Regression test for #76248.
|
||||
//
|
||||
// build-pass
|
||||
// compile-flags: -Zmir-opt-level=2
|
||||
|
||||
const N: usize = 1;
|
||||
|
||||
pub struct Elem<M> {
|
||||
pub x: [usize; N],
|
||||
pub m: M,
|
||||
}
|
||||
|
||||
pub fn f() -> Elem<()> {
|
||||
g(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn g<M>(m: M) -> Elem<M> {
|
||||
Elem {
|
||||
x: [0; N],
|
||||
m,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
f();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user