File tree 6 files changed +66
-0
lines changed
6 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -47,3 +47,30 @@ pub mod mem {
47
47
}
48
48
) ;
49
49
}
50
+
51
+ #[ cfg( feature = "const-fn" ) ] // Remove this if there are more tests
52
+ #[ cfg( test) ]
53
+ mod test {
54
+ use __core;
55
+ use __core:: mem:: ManuallyDrop ;
56
+ use core;
57
+
58
+ #[ cfg( feature = "const-fn" ) ]
59
+ #[ test]
60
+ fn static_uninitzialized ( ) {
61
+ static mut I : i32 = unsafe { __core:: mem:: uninitialized ( ) } ;
62
+ // Initialize before drop
63
+ unsafe { core:: ptr:: write ( & mut I as * mut i32 , 42 ) } ;
64
+ unsafe { assert_eq ! ( I , 42 ) } ;
65
+ }
66
+
67
+ #[ cfg( feature = "const-fn" ) ]
68
+ #[ test]
69
+ fn static_new_manually_drop ( ) {
70
+ static mut M : ManuallyDrop < i32 > = ManuallyDrop :: new ( 42 ) ;
71
+ unsafe { assert_eq ! ( * M , 42 ) ; }
72
+ // Drop before deinitialization
73
+ unsafe { core:: ptr:: drop_in_place ( & mut M as & mut i32 as * mut i32 ) } ;
74
+ }
75
+
76
+ }
Original file line number Diff line number Diff line change @@ -433,6 +433,12 @@ mod tests {
433
433
use binary_heap:: { self , BinaryHeap , Min } ;
434
434
use consts:: * ;
435
435
436
+ #[ cfg( feature = "const-fn" ) ]
437
+ #[ test]
438
+ fn static_new ( ) {
439
+ static mut _B: BinaryHeap < i32 , U16 , Min > = BinaryHeap :: new ( ) ;
440
+ }
441
+
436
442
#[ test]
437
443
fn min ( ) {
438
444
let mut heap = BinaryHeap :: < _ , U16 , Min > :: new ( ) ;
Original file line number Diff line number Diff line change @@ -442,3 +442,18 @@ where
442
442
self . iter . next ( ) . map ( |& mut ( ref k, ref mut v) | ( k, v) )
443
443
}
444
444
}
445
+
446
+
447
+ #[ cfg( feature = "const-fn" ) ] // Remove this if there are more tests
448
+ #[ cfg( test) ]
449
+ mod test {
450
+ use consts:: * ;
451
+ use LinearMap ;
452
+
453
+ #[ cfg( feature = "const-fn" ) ]
454
+ #[ test]
455
+ fn static_new ( ) {
456
+ static mut _L: LinearMap < i32 , i32 , U8 > = LinearMap :: new ( ) ;
457
+ }
458
+
459
+ }
Original file line number Diff line number Diff line change @@ -445,6 +445,12 @@ mod tests {
445
445
use consts:: * ;
446
446
use RingBuffer ;
447
447
448
+ #[ cfg( feature = "const-fn" ) ]
449
+ #[ test]
450
+ fn static_new ( ) {
451
+ static mut _R: RingBuffer < i32 , U4 > = RingBuffer :: new ( ) ;
452
+ }
453
+
448
454
#[ test]
449
455
fn drop ( ) {
450
456
struct Droppable ;
Original file line number Diff line number Diff line change @@ -524,6 +524,12 @@ mod tests {
524
524
use consts:: * ;
525
525
use { String , Vec } ;
526
526
527
+ #[ cfg( feature = "const-fn" ) ]
528
+ #[ test]
529
+ fn static_new ( ) {
530
+ static mut _S: String < U8 > = String :: new ( ) ;
531
+ }
532
+
527
533
#[ test]
528
534
fn debug ( ) {
529
535
extern crate std;
Original file line number Diff line number Diff line change @@ -514,6 +514,12 @@ mod tests {
514
514
use consts:: * ;
515
515
use Vec ;
516
516
517
+ #[ cfg( feature = "const-fn" ) ]
518
+ #[ test]
519
+ fn static_new ( ) {
520
+ static mut _V: Vec < i32 , U4 > = Vec :: new ( ) ;
521
+ }
522
+
517
523
macro_rules! droppable {
518
524
( ) => (
519
525
struct Droppable ;
You can’t perform that action at this time.
0 commit comments