diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index ceec98c8659fb..9ed1f451dc572 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -155,7 +155,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> { #[stable(feature = "debug_builders", since = "1.2.0")] pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut Self { self.result = self.result.and_then(|_| { - if self.is_pretty() { + if crate::hint::unlikely(self.is_pretty()) { if !self.has_fields { self.fmt.write_str(" {\n")?; } @@ -352,7 +352,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> { #[stable(feature = "debug_builders", since = "1.2.0")] pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut Self { self.result = self.result.and_then(|_| { - if self.is_pretty() { + if crate::hint::unlikely(self.is_pretty()) { if self.fields == 0 { self.fmt.write_str("(\n")?; } @@ -479,7 +479,7 @@ struct DebugInner<'a, 'b: 'a> { impl<'a, 'b: 'a> DebugInner<'a, 'b> { fn entry(&mut self, entry: &dyn fmt::Debug) { self.result = self.result.and_then(|_| { - if self.is_pretty() { + if crate::hint::unlikely(self.is_pretty()) { if !self.has_fields { self.fmt.write_str("\n")?; } @@ -1004,7 +1004,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { without completing the previous one" ); - if self.is_pretty() { + if crate::hint::unlikely(self.is_pretty()) { if !self.has_fields { self.fmt.write_str("\n")?; } @@ -1076,7 +1076,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> { self.result = self.result.and_then(|_| { assert!(self.has_key, "attempted to format a map value before its key"); - if self.is_pretty() { + if crate::hint::unlikely(self.is_pretty()) { let mut slot = None; let mut writer = PadAdapter::wrap(self.fmt, &mut slot, &mut self.state); value.fmt(&mut writer)?;