File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 4040#![ feature( never_type) ]
4141#![ feature( unwrap_infallible) ]
4242#![ feature( leading_trailing_ones) ]
43+ #![ feature( const_forget) ]
4344
4445extern crate test;
4546
Original file line number Diff line number Diff line change @@ -129,3 +129,21 @@ fn test_discriminant_send_sync() {
129129 is_send_sync :: < Discriminant < Regular > > ( ) ;
130130 is_send_sync :: < Discriminant < NotSendSync > > ( ) ;
131131}
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