]> git.lizzy.rs Git - rust.git/blobdiff - clippy_utils/src/macros.rs
Auto merge of #8518 - Alexendoo:write-late-pass, r=flip1995
[rust.git] / clippy_utils / src / macros.rs
index 2f371fe19b9c5a0f995325bb2405f4a2a788b8ba..a1808c0972009bbe2a147695882e60ded4cdf69b 100644 (file)
@@ -696,9 +696,14 @@ fn new(spec: rpf::FormatSpec<'_>, positions: ParamPosition, values: &FormatArgsV
         })
     }
 
-    /// Returns true if this format spec would change the contents of a string when formatted
-    pub fn has_string_formatting(&self) -> bool {
-        self.r#trait != sym::Display || !self.width.is_implied() || !self.precision.is_implied()
+    /// Returns true if this format spec is unchanged from the default. e.g. returns true for `{}`,
+    /// `{foo}` and `{2}`, but false for `{:?}`, `{foo:5}` and `{3:.5}`
+    pub fn is_default(&self) -> bool {
+        self.r#trait == sym::Display
+            && self.width.is_implied()
+            && self.precision.is_implied()
+            && self.align == Alignment::AlignUnknown
+            && self.flags == 0
     }
 }