forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#76254 - tmiasko:fold-len, r=wesleywiser
Fold length constant in Rvalue::Repeat Fixes rust-lang#76248.
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |