File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 40
40
#![ feature( never_type) ]
41
41
#![ feature( unwrap_infallible) ]
42
42
#![ feature( leading_trailing_ones) ]
43
+ #![ feature( const_forget) ]
43
44
44
45
extern crate test;
45
46
Original file line number Diff line number Diff line change @@ -129,3 +129,21 @@ fn test_discriminant_send_sync() {
129
129
is_send_sync :: < Discriminant < Regular > > ( ) ;
130
130
is_send_sync :: < Discriminant < NotSendSync > > ( ) ;
131
131
}
132
+
133
+ #[ test]
134
+ fn test_const_forget ( ) {
135
+ const fn test_const_forget < T > ( x : T ) {
136
+ forget ( x) ;
137
+ }
138
+
139
+ // Writing this function signature without const-forget
140
+ // triggers compiler errors:
141
+ // 1) That we use a non-const fn inside a const fn
142
+ // 2) without the forget, it complains about the destructor of Box
143
+ const fn const_forget_box < T > ( mut x : Box < T > ) {
144
+ forget ( x) ;
145
+ }
146
+
147
+ const _: ( ) = test_const_forget ( 0i32 ) ;
148
+ const _: ( ) = test_const_forget ( Vec :: < Vec < Box < i32 > > > :: new ( ) ) ;
149
+ }
You can’t perform that action at this time.
0 commit comments