rust/tests/ui/issues/issue-18845.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
380 B
Rust
Raw Normal View History

// run-pass
// This used to generate invalid IR in that even if we took the
// `false` branch we'd still try to free the Box from the other
// arm. This was due to treating `*Box::new(9)` as an rvalue datum
// instead of as a place.
fn test(foo: bool) -> u8 {
match foo {
true => *Box::new(9),
false => 0
}
}
fn main() {
assert_eq!(9, test(true));
}