]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mir/ssa-analysis-regression-50041.rs
Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06
[rust.git] / src / test / ui / mir / ssa-analysis-regression-50041.rs
1 // build-pass
2 // compile-flags: -Z mir-opt-level=4
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 }