@@ -334,11 +334,29 @@ enum FlagV1 {
334334impl < ' a > Arguments < ' a > {
335335 /// When using the format_args!() macro, this function is used to generate the
336336 /// 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) ]
337352 #[ doc( hidden) ]
338353 #[ inline]
339354 #[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
340355 #[ rustc_const_unstable( feature = "const_fmt_arguments_new" , issue = "none" ) ]
341356 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+ }
342360 Arguments { pieces, fmt : None , args }
343361 }
344362
@@ -348,6 +366,19 @@ impl<'a> Arguments<'a> {
348366 /// `CountIsParam` or `CountIsNextParam` has to point to an argument
349367 /// created with `argumentusize`. However, failing to do so doesn't cause
350368 /// 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) ]
351382 #[ doc( hidden) ]
352383 #[ inline]
353384 #[ unstable( feature = "fmt_internals" , reason = "internal to format_args!" , issue = "none" ) ]
0 commit comments