about summary refs log tree commit diff
path: root/src/test/ui/macros/format-parse-errors.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-07-15 20:51:32 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-07-15 20:51:32 -0700
commit33ec1823d758c08fd7f2eaddabe083dfb3c4b26f (patch)
treeeeb359479f56e4c5320c71cb10cb3f7a7bddf846 /src/test/ui/macros/format-parse-errors.rs
parent4b65a86ebace8600c8e269e8bfe3365cdc460e68 (diff)
downloadrust-33ec1823d758c08fd7f2eaddabe083dfb3c4b26f.tar.gz
rust-33ec1823d758c08fd7f2eaddabe083dfb3c4b26f.zip
Specific error for positional args after named args in `format!()`
When writing positional arguments after named arguments in the
`format!()` and `println!()` macros, provide a targeted diagnostic.
Diffstat (limited to 'src/test/ui/macros/format-parse-errors.rs')
-rw-r--r--src/test/ui/macros/format-parse-errors.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/test/ui/macros/format-parse-errors.rs b/src/test/ui/macros/format-parse-errors.rs
index 96aee5e6aee..ffa7a2817ff 100644
--- a/src/test/ui/macros/format-parse-errors.rs
+++ b/src/test/ui/macros/format-parse-errors.rs
@@ -1,9 +1,15 @@
 fn main() {
+    let foo = "";
+    let bar = "";
     format!(); //~ ERROR requires at least a format string argument
     format!(struct); //~ ERROR expected expression
     format!("s", name =); //~ ERROR expected expression
-    format!("s", foo = foo, bar); //~ ERROR expected `=`
-    format!("s", foo = struct); //~ ERROR expected expression
+    format!(
+        "s {foo} {} {}",
+        foo = foo,
+        bar, //~ ERROR positional arguments cannot follow named arguments
+    );
+    format!("s {foo}", foo = struct); //~ ERROR expected expression
     format!("s", struct); //~ ERROR expected expression
 
     // This error should come after parsing errors to ensure they are non-fatal.