@@ -334,11 +334,29 @@ enum FlagV1 {
334
334
impl < ' a > Arguments < ' a > {
335
335
/// When using the format_args!() macro, this function is used to generate the
336
336
/// Arguments structure.
337
+ #[ cfg( not( bootstrap) ) ]
338
+ #[ doc( hidden) ]
339
+ #[ inline]
340
+ #[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
341
+ #[ rustc_const_unstable( feature = "const_fmt_arguments_new" , issue = "none" ) ]
342
+ pub const unsafe fn new_v1 (
343
+ pieces : & ' a [ & ' static str ] ,
344
+ args : & ' a [ ArgumentV1 < ' a > ] ,
345
+ ) -> Arguments < ' a > {
346
+ if pieces. len ( ) < args. len ( ) || pieces. len ( ) > args. len ( ) + 1 {
347
+ panic ! ( "invalid args" ) ;
348
+ }
349
+ Arguments { pieces, fmt : None , args }
350
+ }
351
+ #[ cfg( bootstrap) ]
337
352
#[ doc( hidden) ]
338
353
#[ inline]
339
354
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
340
355
#[ rustc_const_unstable( feature = "const_fmt_arguments_new" , issue = "none" ) ]
341
356
pub const fn new_v1 ( pieces : & ' a [ & ' static str ] , args : & ' a [ ArgumentV1 < ' a > ] ) -> Arguments < ' a > {
357
+ if pieces. len ( ) < args. len ( ) || pieces. len ( ) > args. len ( ) + 1 {
358
+ panic ! ( "invalid args" ) ;
359
+ }
342
360
Arguments { pieces, fmt : None , args }
343
361
}
344
362
@@ -348,6 +366,19 @@ impl<'a> Arguments<'a> {
348
366
/// `CountIsParam` or `CountIsNextParam` has to point to an argument
349
367
/// created with `argumentusize`. However, failing to do so doesn't cause
350
368
/// unsafety, but will ignore invalid .
369
+ #[ cfg( not( bootstrap) ) ]
370
+ #[ doc( hidden) ]
371
+ #[ inline]
372
+ #[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
373
+ #[ rustc_const_unstable( feature = "const_fmt_arguments_new" , issue = "none" ) ]
374
+ pub const unsafe fn new_v1_formatted (
375
+ pieces : & ' a [ & ' static str ] ,
376
+ args : & ' a [ ArgumentV1 < ' a > ] ,
377
+ fmt : & ' a [ rt:: v1:: Argument ] ,
378
+ ) -> Arguments < ' a > {
379
+ Arguments { pieces, fmt : Some ( fmt) , args }
380
+ }
381
+ #[ cfg( bootstrap) ]
351
382
#[ doc( hidden) ]
352
383
#[ inline]
353
384
#[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
0 commit comments