1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -328,7 +328,9 @@ impl<'a> Arguments<'a> {
328
328
#[ rustc_const_unstable( feature = "const_fmt_arguments_new" , issue = "none" ) ]
329
329
pub const fn new_const ( pieces : & ' a [ & ' static str ] ) -> Self {
330
330
if pieces. len ( ) > 1 {
331
- panic ! ( "invalid args" ) ;
331
+ // Since panic!() expands to panic_fmt(format_args!()), using the macro here is both a
332
+ // bit silly and also significantly increases the amount of MIR generated by panics.
333
+ crate :: panicking:: panic ( "invalid args" ) ;
332
334
}
333
335
Arguments { pieces, fmt : None , args : & [ ] }
334
336
}
@@ -338,7 +340,8 @@ impl<'a> Arguments<'a> {
338
340
#[ inline]
339
341
pub fn new_v1 ( pieces : & ' a [ & ' static str ] , args : & ' a [ rt:: Argument < ' a > ] ) -> Arguments < ' a > {
340
342
if pieces. len ( ) < args. len ( ) || pieces. len ( ) > args. len ( ) + 1 {
341
- panic ! ( "invalid args" ) ;
343
+ // See Arguments::new_const for why we don't use panic!.
344
+ crate :: panicking:: panic ( "invalid args" ) ;
342
345
}
343
346
Arguments { pieces, fmt : None , args }
344
347
}
0 commit comments