Auto merge of #91359 - dtolnay:args, r=Mark-Simulacrum
Emit simpler code from format_args I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code. <br> `println!("rust")` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &match () { _args => [], })); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); }; ``` `println!("{}", x)` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &match (&x,) { _args => [::core::fmt::ArgumentV1::new( _args.0, ::core::fmt::Display::fmt, )], }, )); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)], )); }; ```
This commit is contained in:
commit
0bcacb391b
11 changed files with 128 additions and 96 deletions
|
@ -39,6 +39,7 @@ use rustc_span::{Span, DUMMY_SP};
|
|||
use std::cmp::Ordering;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -1276,6 +1277,19 @@ impl Expr {
|
|||
ExprKind::Err => ExprPrecedence::Err,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take(&mut self) -> Self {
|
||||
mem::replace(
|
||||
self,
|
||||
Expr {
|
||||
id: DUMMY_NODE_ID,
|
||||
kind: ExprKind::Err,
|
||||
span: DUMMY_SP,
|
||||
attrs: ThinVec::new(),
|
||||
tokens: None,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Limit types of a range (inclusive or exclusive)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue