Skip to content

Commit

Permalink
Auto merge of #117804 - saethlin:no-recursive-panics, r=<try>
Browse files Browse the repository at this point in the history
Panic directly in Arguments::new* instead of recursing

This has been bothering me because it looks very silly in MIR. Maybe the simpler form is faster? It surely inlines more... but is that good?

r? `@ghost`
  • Loading branch information
bors committed Feb 14, 2024
2 parents ee9c7c9 + 28561aa commit 2d12f93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<'a> Arguments<'a> {
#[rustc_const_unstable(feature = "const_fmt_arguments_new", issue = "none")]
pub const fn new_const(pieces: &'a [&'static str]) -> Self {
if pieces.len() > 1 {
panic!("invalid args");
crate::panicking::panic("invalid args");
}
Arguments { pieces, fmt: None, args: &[] }
}
Expand All @@ -330,7 +330,7 @@ impl<'a> Arguments<'a> {
#[inline]
pub fn new_v1(pieces: &'a [&'static str], args: &'a [rt::Argument<'a>]) -> Arguments<'a> {
if pieces.len() < args.len() || pieces.len() > args.len() + 1 {
panic!("invalid args");
crate::panicking::panic("invalid args");
}
Arguments { pieces, fmt: None, args }
}
Expand Down

0 comments on commit 2d12f93

Please sign in to comment.