mirror of https://github.com/rust-lang/rust.git
Avoid ref when using format! for perf
Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.
This commit is contained in:
parent
d3dd34a1d4
commit
91275b2c2b
|
@ -1026,7 +1026,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
|
||||||
/// assert_eq!(format!("{}", value), "a");
|
/// assert_eq!(format!("{}", value), "a");
|
||||||
/// assert_eq!(format!("{:?}", value), "'a'");
|
/// assert_eq!(format!("{:?}", value), "'a'");
|
||||||
///
|
///
|
||||||
/// let wrapped = fmt::FormatterFn(|f| write!(f, "{:?}", &value));
|
/// let wrapped = fmt::FormatterFn(|f| write!(f, "{value:?}"));
|
||||||
/// assert_eq!(format!("{}", wrapped), "'a'");
|
/// assert_eq!(format!("{}", wrapped), "'a'");
|
||||||
/// assert_eq!(format!("{:?}", wrapped), "'a'");
|
/// assert_eq!(format!("{:?}", wrapped), "'a'");
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn test_join() {
|
||||||
|
|
||||||
let y = String::new();
|
let y = String::new();
|
||||||
let x = join!(async {
|
let x = join!(async {
|
||||||
println!("{}", &y);
|
println!("{y}");
|
||||||
1
|
1
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -1544,10 +1544,10 @@ impl fmt::Debug for Literal {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Literal")
|
f.debug_struct("Literal")
|
||||||
// format the kind on one line even in {:#?} mode
|
// format the kind on one line even in {:#?} mode
|
||||||
.field("kind", &format_args!("{:?}", &self.0.kind))
|
.field("kind", &format_args!("{:?}", self.0.kind))
|
||||||
.field("symbol", &self.0.symbol)
|
.field("symbol", &self.0.symbol)
|
||||||
// format `Some("...")` on one line even in {:#?} mode
|
// format `Some("...")` on one line even in {:#?} mode
|
||||||
.field("suffix", &format_args!("{:?}", &self.0.suffix))
|
.field("suffix", &format_args!("{:?}", self.0.suffix))
|
||||||
.field("span", &self.0.span)
|
.field("span", &self.0.span)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,7 +683,7 @@ fn recursive_rmdir_toctou() {
|
||||||
let drop_canary_arc = Arc::new(());
|
let drop_canary_arc = Arc::new(());
|
||||||
let drop_canary_weak = Arc::downgrade(&drop_canary_arc);
|
let drop_canary_weak = Arc::downgrade(&drop_canary_arc);
|
||||||
|
|
||||||
eprintln!("x: {:?}", &victim_del_path);
|
eprintln!("x: {victim_del_path:?}");
|
||||||
|
|
||||||
// victim just continuously removes `victim_del`
|
// victim just continuously removes `victim_del`
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
|
|
@ -775,7 +775,7 @@ impl Error {
|
||||||
///
|
///
|
||||||
/// impl Display for MyError {
|
/// impl Display for MyError {
|
||||||
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
/// write!(f, "MyError: {}", &self.v)
|
/// write!(f, "MyError: {}", self.v)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue