]>
Commit | Line | Data |
---|---|---|
5869c6ff | 1 | // build-pass |
6a06907d | 2 | // compile-flags: -Z mir-opt-level=4 |
5869c6ff XL |
3 | |
4 | #![crate_type="lib"] | |
5 | #![feature(lang_items)] | |
6 | #![no_std] | |
7 | ||
8 | #[lang = "owned_box"] | |
9 | pub struct Box<T: ?Sized>(*mut T); | |
10 | ||
11 | impl<T: ?Sized> Drop for Box<T> { | |
12 | fn drop(&mut self) { | |
13 | } | |
14 | } | |
15 | ||
16 | #[lang = "box_free"] | |
17 | #[inline(always)] | |
18 | unsafe fn box_free<T: ?Sized>(ptr: *mut T) { | |
19 | dealloc(ptr) | |
20 | } | |
21 | ||
22 | #[inline(never)] | |
23 | fn dealloc<T: ?Sized>(_: *mut T) { | |
24 | } | |
25 | ||
26 | pub struct Foo<T>(T); | |
27 | ||
28 | pub fn foo(a: Option<Box<Foo<usize>>>) -> usize { | |
29 | let f = match a { | |
30 | None => Foo(0), | |
31 | Some(vec) => *vec, | |
32 | }; | |
33 | f.0 | |
34 | } |