From af0d099004e1b1ffe19109fba5813aebfd435437 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Thu, 14 Jan 2021 20:10:13 +0200 Subject: [PATCH] Add a regression test for #50041 AFAICT the test case never landed alongside the fix for the issue. --- .../ui/mir/ssa-analysis-regression-50041.rs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/ui/mir/ssa-analysis-regression-50041.rs 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 +}