File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,9 @@ impl<'a> Arguments<'a> {
340340 #[ rustc_const_unstable( feature = "const_fmt_arguments_new" , issue = "none" ) ]
341341 pub const fn new_const ( pieces : & ' a [ & ' static str ] ) -> Self {
342342 if pieces. len ( ) > 1 {
343- panic ! ( "invalid args" ) ;
343+ // Since panic!() expands to panic_fmt(format_args!()), using panic! here is both a
344+ // bit silly and also significantly increases the amount of MIR generated by panics.
345+ crate :: panicking:: panic_nounwind ( "invalid args" ) ;
344346 }
345347 Arguments { pieces, fmt : None , args : & [ ] }
346348 }
@@ -350,7 +352,8 @@ impl<'a> Arguments<'a> {
350352 #[ inline]
351353 pub fn new_v1 ( pieces : & ' a [ & ' static str ] , args : & ' a [ rt:: Argument < ' a > ] ) -> Arguments < ' a > {
352354 if pieces. len ( ) < args. len ( ) || pieces. len ( ) > args. len ( ) + 1 {
353- panic ! ( "invalid args" ) ;
355+ // See Arguments::new_const for why we don't use panic!.
356+ crate :: panicking:: panic_nounwind ( "invalid args" ) ;
354357 }
355358 Arguments { pieces, fmt : None , args }
356359 }
You can’t perform that action at this time.
0 commit comments