@@ -45,6 +45,37 @@ impl Default for Counted {
4545 unsafe { Counted :: new ( ) }
4646 }
4747}
48+ pub static mut drops_0: std:: cell:: LazyCell < i32 > = std:: cell:: LazyCell :: new ( || unsafe { 0 } ) ;
49+ #[ repr( C ) ]
50+ #[ derive( ) ]
51+ pub struct Dropped { }
52+ impl Dropped {
53+ pub unsafe fn new ( ) -> Self {
54+ let mut this = Self { } ;
55+ this
56+ }
57+ pub unsafe fn copy_from ( _a0 : * const Dropped ) -> Self {
58+ let mut this = Self { } ;
59+ this
60+ }
61+ pub unsafe fn move_from ( _a0 : * mut Dropped ) -> Self {
62+ let mut this = Self { } ;
63+ this
64+ }
65+ pub unsafe fn destructor ( & mut self ) {
66+ ( * std:: cell:: LazyCell :: force_mut ( & mut * & raw mut drops_0) ) . postfix_inc ( ) ;
67+ }
68+ }
69+ impl Clone for Dropped {
70+ fn clone ( & self ) -> Self {
71+ unsafe { Dropped :: copy_from ( self as * const Dropped ) }
72+ }
73+ }
74+ impl Default for Dropped {
75+ fn default ( ) -> Self {
76+ unsafe { Dropped :: new ( ) }
77+ }
78+ }
4879pub fn main ( ) {
4980 unsafe {
5081 __cpp2rust_init_globals ( ) ;
@@ -96,6 +127,16 @@ unsafe fn main_0() -> i32 {
96127 } )
97128 . clone ( ) ;
98129 assert ! ( ( ( unsafe { a2( ) } ) == ( 4 ) ) ) ;
130+ {
131+ let mut m2: _ = ( || { } ) ;
132+ }
133+ assert ! ( ( ( * std:: cell:: LazyCell :: force_mut( & mut * & raw mut drops_0) ) == ( 2 ) ) ) ;
134+ {
135+ let mut k2: _ = ( || { } ) . clone ( ) ;
136+ }
137+ assert ! ( ( ( * std:: cell:: LazyCell :: force_mut( & mut * & raw mut drops_0) ) == ( 4 ) ) ) ;
99138 return 0 ;
100139}
101- pub unsafe fn __cpp2rust_init_globals ( ) { }
140+ pub unsafe fn __cpp2rust_init_globals ( ) {
141+ std:: cell:: LazyCell :: force ( & * & raw const drops_0) ;
142+ }
0 commit comments