diff options
| author | bors <bors@rust-lang.org> | 2020-10-05 11:41:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-05 11:41:59 +0000 |
| commit | d890e64dff3fd2c28635c60cc9315648dd46c8f7 (patch) | |
| tree | ff5218d31163334a9bdc1178b6efeb062ad71098 /src/test/ui | |
| parent | 62bfcfd8a3b1603e2b5f5e2c011aa0f35f117af1 (diff) | |
| parent | f271957d89c8d694bd6b8963e4c21278e1cc0354 (diff) | |
Auto merge of #77549 - tmiasko:simplify-branch-same-fix, r=oli-obk
Fix miscompile in SimplifyBranchSame Cherry-picked from #77486, but with a different test case that used to be compiled incorrectly on both master & beta branches.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/mir/simplify-branch-same.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/mir/simplify-branch-same.rs b/src/test/ui/mir/simplify-branch-same.rs new file mode 100644 index 00000000000..d631c33d61f --- /dev/null +++ b/src/test/ui/mir/simplify-branch-same.rs @@ -0,0 +1,21 @@ +// Regression test for SimplifyBranchSame miscompilation. +// run-pass + +macro_rules! m { + ($a:expr, $b:expr, $c:block) => { + match $a { + Lto::Fat | Lto::Thin => { $b; (); $c } + Lto::No => { $b; () } + } + } +} + +pub enum Lto { No, Thin, Fat } + +fn f(mut cookie: u32, lto: Lto) -> u32 { + let mut _a = false; + m!(lto, _a = true, {cookie = 0}); + cookie +} + +fn main() { assert_eq!(f(42, Lto::Thin), 0) } |
