about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLzu Tao <taolzu@gmail.com>2024-06-01 11:18:21 +0000
committerLzu Tao <taolzu@gmail.com>2024-06-16 09:39:42 +0000
commit28708912fb011f1c7666281ba5a22862f4503d4d (patch)
tree9d428b0a43c71c90da9342aae3eee154165f300b
parent06aee7ee03a87a53c29f72f08e41469b9d88232e (diff)
downloadrust-28708912fb011f1c7666281ba5a22862f4503d4d.tar.gz
rust-28708912fb011f1c7666281ba5a22862f4503d4d.zip
prefer tracing::instrument over debug strings
-rw-r--r--compiler/rustc_mir_transform/src/promote_consts.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs
index ecd1179ca99..a0ee4c432c6 100644
--- a/compiler/rustc_mir_transform/src/promote_consts.rs
+++ b/compiler/rustc_mir_transform/src/promote_consts.rs
@@ -98,8 +98,8 @@ struct Collector<'a, 'tcx> {
 }
 
 impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
+    #[instrument(level = "debug", skip(self))]
     fn visit_local(&mut self, index: Local, context: PlaceContext, location: Location) {
-        debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
         // We're only interested in temporaries and the return place
         match self.ccx.body.local_kind(index) {
             LocalKind::Arg => return,
@@ -111,20 +111,15 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
         // then it's constant and thus drop is noop.
         // Non-uses are also irrelevant.
         if context.is_drop() || !context.is_use() {
-            debug!(
-                "visit_local: context.is_drop={:?} context.is_use={:?}",
-                context.is_drop(),
-                context.is_use(),
-            );
+            debug!(is_drop = context.is_drop(), is_use = context.is_use());
             return;
         }
 
         let temp = &mut self.temps[index];
-        debug!("visit_local: temp={:?}", temp);
+        debug!(?temp);
         *temp = match *temp {
             TempState::Undefined => match context {
-                PlaceContext::MutatingUse(MutatingUseContext::Store)
-                | PlaceContext::MutatingUse(MutatingUseContext::Call) => {
+                PlaceContext::MutatingUse(MutatingUseContext::Store | MutatingUseContext::Call) => {
                     TempState::Defined { location, uses: 0, valid: Err(()) }
                 }
                 _ => TempState::Unpromotable,
@@ -137,7 +132,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
                     | PlaceContext::NonMutatingUse(_) => true,
                     PlaceContext::MutatingUse(_) | PlaceContext::NonUse(_) => false,
                 };
-                debug!("visit_local: allowed_use={:?}", allowed_use);
+                debug!(?allowed_use);
                 if allowed_use {
                     *uses += 1;
                     return;
@@ -146,6 +141,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
             }
             TempState::Unpromotable | TempState::PromotedOut => TempState::Unpromotable,
         };
+        debug!(?temp);
     }
 
     fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
@@ -972,7 +968,7 @@ fn promote_candidates<'tcx>(
     candidates: Vec<Candidate>,
 ) -> IndexVec<Promoted, Body<'tcx>> {
     // Visit candidates in reverse, in case they're nested.
-    debug!("promote_candidates({:?})", candidates);
+    debug!(promote_candidates = ?candidates);
 
     let mut promotions = IndexVec::new();