Add a regression test for #50041

AFAICT the test case never landed alongside the fix for the issue.
This commit is contained in:
Simonas Kazlauskas 2021-01-14 20:10:13 +02:00
parent d03fe84169
commit af0d099004

View File

@ -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<T: ?Sized>(*mut T);
impl<T: ?Sized> Drop for Box<T> {
fn drop(&mut self) {
}
}
#[lang = "box_free"]
#[inline(always)]
unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
dealloc(ptr)
}
#[inline(never)]
fn dealloc<T: ?Sized>(_: *mut T) {
}
pub struct Foo<T>(T);
pub fn foo(a: Option<Box<Foo<usize>>>) -> usize {
let f = match a {
None => Foo(0),
Some(vec) => *vec,
};
f.0
}