]> 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 a065b1b5683c1b9ccbfeb81df5cf1b96d7d12c4d..e805f18188989167cf0b7ed0aab8c7613c8e3fae 100644 (file)
@@ -1,7 +1,13 @@
 // run-rustfix
-
-#![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)]
 #![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::uninlined_format_args
+)]
 
 struct Foo(pub String);
 
@@ -24,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);
 
@@ -75,4 +77,16 @@ fn main() {
     let _s: String = format!("{}", &*v.join("\n"));
 
     format!("prepend {:+}", "s");
+
+    // Issue #8290
+    let x = "foo";
+    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}");
 }