Rollup merge of #81060 - nagisa:nagisa/regression-50041, r=Mark-Simulacrum

Add a regression test for #50041

AFAICT the test case never landed alongside the fix for the issue.
This commit is contained in:
Mara Bos 2021-01-16 17:30:12 +00:00 committed by GitHub
commit b67689bdf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}