]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/format.rs
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / format.rs
index 4a10b580d2600171fed59d008a687756fcfef0aa..e805f18188989167cf0b7ed0aab8c7613c8e3fae 100644 (file)
@@ -1,12 +1,13 @@
 // run-rustfix
-
+#![warn(clippy::useless_format)]
 #![allow(
+    unused_tuple_struct_fields,
     clippy::print_literal,
     clippy::redundant_clone,
     clippy::to_string_in_format_args,
-    clippy::needless_borrow
+    clippy::needless_borrow,
+    clippy::uninlined_format_args
 )]
-#![warn(clippy::useless_format)]
 
 struct Foo(pub String);
 
@@ -29,18 +30,14 @@ fn main() {
     format!("{:?}", "foo"); // Don't warn about `Debug`.
     format!("{:8}", "foo");
     format!("{:width$}", "foo", width = 8);
-    format!("{:+}", "foo"); // Warn when the format makes no difference.
-    format!("{:<}", "foo"); // Warn when the format makes no difference.
     format!("foo {}", "bar");
     format!("{} bar", "foo");
 
-    let arg: String = "".to_owned();
+    let arg = String::new();
     format!("{}", arg);
     format!("{:?}", arg); // Don't warn about debug.
     format!("{:8}", arg);
     format!("{:width$}", arg, width = 8);
-    format!("{:+}", arg); // Warn when the format makes no difference.
-    format!("{:<}", arg); // Warn when the format makes no difference.
     format!("foo {}", arg);
     format!("{} bar", arg);
 
@@ -86,4 +83,10 @@ fn main() {
     let _ = format!("{x}");
     let _ = format!("{x:?}"); // Don't lint on debug
     let _ = format!("{y}", y = x);
+
+    // Issue #9234
+    let abc = "abc";
+    let _ = format!("{abc}");
+    let xx = "xx";
+    let _ = format!("{xx}");
 }