diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-19 20:03:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-19 20:03:58 +0200 |
| commit | e28be0d16892825141044350d39766be3fa228ac (patch) | |
| tree | 0cbfc85689259beeb3222a263afb26089ef12a15 /library/std/src | |
| parent | 115b0868506fa3b48fe67be998ea291e4026ea75 (diff) | |
| parent | 91275b2c2bf824286b844c38252fdbeb6d995105 (diff) | |
| download | rust-e28be0d16892825141044350d39766be3fa228ac.tar.gz rust-e28be0d16892825141044350d39766be3fa228ac.zip | |
Rollup merge of #127978 - nyurik:lib-refs, r=workingjubilee
Avoid ref when using format! for perf
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/fs/tests.rs | 2 | ||||
| -rw-r--r-- | library/std/src/io/error.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 5ca631399aa..c1fc2e5488d 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -683,7 +683,7 @@ fn recursive_rmdir_toctou() { let drop_canary_arc = Arc::new(()); 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` thread::spawn(move || { diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index f366cb8f42b..8de27367a3f 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -775,7 +775,7 @@ impl Error { /// /// impl Display for MyError { /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - /// write!(f, "MyError: {}", &self.v) + /// write!(f, "MyError: {}", self.v) /// } /// } /// |
