diff options
| author | Yuri Astrakhan <YuriAstrakhan@gmail.com> | 2024-07-19 11:51:21 -0400 |
|---|---|---|
| committer | Yuri Astrakhan <YuriAstrakhan@gmail.com> | 2024-07-19 14:52:07 -0400 |
| commit | aef0e346de744faeaa522b9c08562bb3e1814adc (patch) | |
| tree | 1d670ae42ce9ba8f4160dae59cc5ad09ace97d86 /compiler/rustc_mir_transform/src | |
| parent | 0cd01aac6a80735cc936f75b45e3545a5273e2ad (diff) | |
| download | rust-aef0e346de744faeaa522b9c08562bb3e1814adc.tar.gz rust-aef0e346de744faeaa522b9c08562bb3e1814adc.zip | |
Avoid ref when using format! in compiler
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 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/dead_store_elimination.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/early_otherwise_branch.rs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/dead_store_elimination.rs b/compiler/rustc_mir_transform/src/dead_store_elimination.rs index 08dba1de500..60230bea02e 100644 --- a/compiler/rustc_mir_transform/src/dead_store_elimination.rs +++ b/compiler/rustc_mir_transform/src/dead_store_elimination.rs @@ -102,7 +102,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { | StatementKind::Nop => (), StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => { - bug!("{:?} not found in this MIR phase!", &statement.kind) + bug!("{:?} not found in this MIR phase!", statement.kind) } } } diff --git a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs index 9edb8bcee6e..40c0c723d25 100644 --- a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs +++ b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs @@ -106,11 +106,11 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { let parent = BasicBlock::from_usize(i); let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue }; - if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {:?}", &opt_data)) { + if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {opt_data:?}")) { break; } - trace!("SUCCESS: found optimization possibility to apply: {:?}", &opt_data); + trace!("SUCCESS: found optimization possibility to apply: {opt_data:?}"); should_cleanup = true; |
