Auto merge of #117804 - saethlin:no-recursive-panics, r=joboet
Panic directly in Arguments::new* instead of recursing This has been bothering me because it looks very silly in MIR.
This commit is contained in:
commit
606afbb617
1 changed files with 5 additions and 2 deletions
|
@ -340,7 +340,9 @@ 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");
|
||||
// Since panic!() expands to panic_fmt(format_args!()), using panic! here is both a
|
||||
// bit silly and also significantly increases the amount of MIR generated by panics.
|
||||
crate::panicking::panic_nounwind("invalid args");
|
||||
}
|
||||
Arguments { pieces, fmt: None, args: &[] }
|
||||
}
|
||||
|
@ -350,7 +352,8 @@ 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");
|
||||
// See Arguments::new_const for why we don't use panic!.
|
||||
crate::panicking::panic_nounwind("invalid args");
|
||||
}
|
||||
Arguments { pieces, fmt: None, args }
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue