File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ //! Test drop for zero-sized types.
2+ use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
3+
4+ static DROPPED : AtomicUsize = AtomicUsize :: new ( 0 ) ;
5+
6+ struct S ;
7+ impl Drop for S {
8+ fn drop ( & mut self ) {
9+ DROPPED . fetch_add ( 1 , Ordering :: Relaxed ) ;
10+ }
11+ }
12+
13+ fn f < T > ( x : T ) { }
14+
15+ #[ cfg_attr( crux, crux:: test) ]
16+ fn crux_test ( ) -> usize {
17+ {
18+ let s = S ;
19+ let s2 = ( S , ) ;
20+ f ( s2) ;
21+ }
22+ DROPPED . load ( Ordering :: Relaxed )
23+ }
24+
25+ pub fn main ( ) {
26+ println ! ( "{:?}" , crux_test( ) ) ;
27+ }
Original file line number Diff line number Diff line change 1+ fn my_replace < T : Clone > ( r : & mut T , x : T ) -> T {
2+ let old = ( * r) . clone ( ) ;
3+ * r = x;
4+ old
5+ }
6+
7+ #[ cfg_attr( crux, crux:: test) ]
8+ fn crux_test ( ) {
9+ let mut x = ( ) ;
10+ my_replace ( & mut x, ( ) ) ;
11+ let mut y = ( 1 , ( ) ) ;
12+ my_replace ( & mut y. 1 , ( ) ) ;
13+ }
14+
15+ pub fn main ( ) {
16+ println ! ( "{:?}" , crux_test( ) ) ;
17+ }
You can’t perform that action at this time.
0 commit comments