about summary refs log tree commit diff
path: root/tests/ui/fmt
diff options
context:
space:
mode:
authorlukas <lukas.walter@aceart.de>2024-07-04 16:47:20 +0200
committerlukas <lukas.walter@aceart.de>2024-07-06 14:24:20 +0200
commit3e9c9a05a825005cf0b199d4f68edf8817599ade (patch)
tree96d341f2ec83a5f68cd394c1048f9ab943e0d918 /tests/ui/fmt
parent28cc0b643d6c07e2e0ba24a85f397963961b4c0d (diff)
downloadrust-3e9c9a05a825005cf0b199d4f68edf8817599ade.tar.gz
rust-3e9c9a05a825005cf0b199d4f68edf8817599ade.zip
Mark format! with must_use hint
Diffstat (limited to 'tests/ui/fmt')
-rw-r--r--tests/ui/fmt/struct-field-as-captured-argument.fixed14
-rw-r--r--tests/ui/fmt/struct-field-as-captured-argument.rs14
-rw-r--r--tests/ui/fmt/struct-field-as-captured-argument.stderr70
3 files changed, 49 insertions, 49 deletions
diff --git a/tests/ui/fmt/struct-field-as-captured-argument.fixed b/tests/ui/fmt/struct-field-as-captured-argument.fixed
index e13af744ec8..0da40737354 100644
--- a/tests/ui/fmt/struct-field-as-captured-argument.fixed
+++ b/tests/ui/fmt/struct-field-as-captured-argument.fixed
@@ -8,11 +8,11 @@ struct Foo {
 fn main() {
     let foo = Foo { field: 0 };
     let bar = 3;
-    format!("{0}", foo.field); //~ ERROR invalid format string: field access isn't supported
-    format!("{1} {} {bar}", "aa", foo.field); //~ ERROR invalid format string: field access isn't supported
-    format!("{2} {} {1} {bar}", "aa", "bb", foo.field); //~ ERROR invalid format string: field access isn't supported
-    format!("{1} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{1:?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{0}", foo.field); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1} {} {bar}", "aa", foo.field); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{2} {} {1} {bar}", "aa", "bb", foo.field); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1:?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
 }
diff --git a/tests/ui/fmt/struct-field-as-captured-argument.rs b/tests/ui/fmt/struct-field-as-captured-argument.rs
index 6a875a85848..325b4e3a218 100644
--- a/tests/ui/fmt/struct-field-as-captured-argument.rs
+++ b/tests/ui/fmt/struct-field-as-captured-argument.rs
@@ -8,11 +8,11 @@ struct Foo {
 fn main() {
     let foo = Foo { field: 0 };
     let bar = 3;
-    format!("{foo.field}"); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field} {} {bar}", "aa"); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field} {} {1} {bar}", "aa", "bb"); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field:?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field:#?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field:.3} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field}"); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field} {} {bar}", "aa"); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field} {} {1} {bar}", "aa", "bb"); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field:?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field:#?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field:.3} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
 }
diff --git a/tests/ui/fmt/struct-field-as-captured-argument.stderr b/tests/ui/fmt/struct-field-as-captured-argument.stderr
index 7ea8b4068f2..4ef022cecb0 100644
--- a/tests/ui/fmt/struct-field-as-captured-argument.stderr
+++ b/tests/ui/fmt/struct-field-as-captured-argument.stderr
@@ -1,79 +1,79 @@
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:11:15
+  --> $DIR/struct-field-as-captured-argument.rs:11:23
    |
-LL |     format!("{foo.field}");
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field}");
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{0}", foo.field);
-   |               ~  +++++++++++
+LL |     let _ = format!("{0}", foo.field);
+   |                       ~  +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:12:15
+  --> $DIR/struct-field-as-captured-argument.rs:12:23
    |
-LL |     format!("{foo.field} {} {bar}", "aa");
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field} {} {bar}", "aa");
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1} {} {bar}", "aa", foo.field);
-   |               ~                 +++++++++++
+LL |     let _ = format!("{1} {} {bar}", "aa", foo.field);
+   |                       ~                 +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:13:15
+  --> $DIR/struct-field-as-captured-argument.rs:13:23
    |
-LL |     format!("{foo.field} {} {1} {bar}", "aa", "bb");
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field} {} {1} {bar}", "aa", "bb");
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{2} {} {1} {bar}", "aa", "bb", foo.field);
-   |               ~                           +++++++++++
+LL |     let _ = format!("{2} {} {1} {bar}", "aa", "bb", foo.field);
+   |                       ~                           +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:14:15
+  --> $DIR/struct-field-as-captured-argument.rs:14:23
    |
-LL |     format!("{foo.field} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                 +++++++++++
+LL |     let _ = format!("{1} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                 +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:15:15
+  --> $DIR/struct-field-as-captured-argument.rs:15:23
    |
-LL |     format!("{foo.field:?} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field:?} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1:?} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                   +++++++++++
+LL |     let _ = format!("{1:?} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                   +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:16:15
+  --> $DIR/struct-field-as-captured-argument.rs:16:23
    |
-LL |     format!("{foo.field:#?} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field:#?} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                    +++++++++++
+LL |     let _ = format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                    +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:17:15
+  --> $DIR/struct-field-as-captured-argument.rs:17:23
    |
-LL |     format!("{foo.field:.3} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field:.3} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                    +++++++++++
+LL |     let _ = format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                    +++++++++++
 
 error: aborting due to 7 previous errors