diff --git a/src/test/ui/mir/ssa-analysis-regression-50041.rs b/src/test/ui/mir/ssa-analysis-regression-50041.rs new file mode 100644 index 0000000000000..c818f2976e1cf --- /dev/null +++ b/src/test/ui/mir/ssa-analysis-regression-50041.rs @@ -0,0 +1,34 @@ +// build-pass +// compile-flags: -Z mir-opt-level=3 + +#![crate_type="lib"] +#![feature(lang_items)] +#![no_std] + +#[lang = "owned_box"] +pub struct Box(*mut T); + +impl Drop for Box { + fn drop(&mut self) { + } +} + +#[lang = "box_free"] +#[inline(always)] +unsafe fn box_free(ptr: *mut T) { + dealloc(ptr) +} + +#[inline(never)] +fn dealloc(_: *mut T) { +} + +pub struct Foo(T); + +pub fn foo(a: Option>>) -> usize { + let f = match a { + None => Foo(0), + Some(vec) => *vec, + }; + f.0 +}