about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-04-25 17:43:12 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-04-25 18:58:59 +0800
commit44232a67c320c8df31e2b82ae15d2ec7c83ec759 (patch)
tree8a750bdd51e31b1c1edb5345c5da89109c3d518e /tests
parent645d0ad2a4f145ae576e442ec5c73c0f8eed829b (diff)
downloadrust-44232a67c320c8df31e2b82ae15d2ec7c83ec759.tar.gz
rust-44232a67c320c8df31e2b82ae15d2ec7c83ec759.zip
Add ui test parser/issues/invalid-parse-format-issue-139104.rs
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/parser/issues/invalid-parse-format-issue-139104.rs8
-rw-r--r--tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr66
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs b/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs
new file mode 100644
index 00000000000..40af6262356
--- /dev/null
+++ b/tests/ui/parser/issues/invalid-parse-format-issue-139104.rs
@@ -0,0 +1,8 @@
+fn main() {
+    println!("{foo:_1.4}", foo = 3.14); //~ ERROR invalid format string: tuple index access isn't supported
+    println!("{foo:1.4_1.4}", foo = 3.14); //~ ERROR invalid format string: tuple index access isn't supported
+    println!("xxx{0:_1.4", 1.11); //~ ERROR invalid format string: expected `}`, found `.`
+    println!("{foo:_1.4", foo = 3.14); //~ ERROR invalid format string: expected `}`, found `.`
+    println!("xxx{0:_1.4", 1.11); //~ ERROR invalid format string: expected `}`, found `.`
+    println!("xxx{  0", 1.11); //~ ERROR invalid format string: expected `}`, found `0`
+}
diff --git a/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr b/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr
new file mode 100644
index 00000000000..d0a8d0998a4
--- /dev/null
+++ b/tests/ui/parser/issues/invalid-parse-format-issue-139104.stderr
@@ -0,0 +1,66 @@
+error: invalid format string: tuple index access isn't supported
+  --> $DIR/invalid-parse-format-issue-139104.rs:2:16
+   |
+LL |     println!("{foo:_1.4}", foo = 3.14);
+   |                ^^^^^^^^ not supported in format string
+   |
+help: consider using a positional formatting argument instead
+   |
+LL -     println!("{foo:_1.4}", foo = 3.14);
+LL +     println!("{0}", foo:_1.4, foo = 3.14);
+   |
+
+error: invalid format string: tuple index access isn't supported
+  --> $DIR/invalid-parse-format-issue-139104.rs:3:16
+   |
+LL |     println!("{foo:1.4_1.4}", foo = 3.14);
+   |                ^^^^^^^^^^^ not supported in format string
+   |
+help: consider using a positional formatting argument instead
+   |
+LL -     println!("{foo:1.4_1.4}", foo = 3.14);
+LL +     println!("{0}", foo:1.4_1.4, foo = 3.14);
+   |
+
+error: invalid format string: expected `}`, found `.`
+  --> $DIR/invalid-parse-format-issue-139104.rs:4:23
+   |
+LL |     println!("xxx{0:_1.4", 1.11);
+   |                  -    ^ expected `}` in format string
+   |                  |
+   |                  because of this opening brace
+   |
+   = note: if you intended to print `{`, you can escape it using `{{`
+
+error: invalid format string: expected `}`, found `.`
+  --> $DIR/invalid-parse-format-issue-139104.rs:5:22
+   |
+LL |     println!("{foo:_1.4", foo = 3.14);
+   |               -      ^ expected `}` in format string
+   |               |
+   |               because of this opening brace
+   |
+   = note: if you intended to print `{`, you can escape it using `{{`
+
+error: invalid format string: expected `}`, found `.`
+  --> $DIR/invalid-parse-format-issue-139104.rs:6:23
+   |
+LL |     println!("xxx{0:_1.4", 1.11);
+   |                  -    ^ expected `}` in format string
+   |                  |
+   |                  because of this opening brace
+   |
+   = note: if you intended to print `{`, you can escape it using `{{`
+
+error: invalid format string: expected `}`, found `0`
+  --> $DIR/invalid-parse-format-issue-139104.rs:7:21
+   |
+LL |     println!("xxx{  0", 1.11);
+   |                  -  ^ expected `}` in format string
+   |                  |
+   |                  because of this opening brace
+   |
+   = note: if you intended to print `{`, you can escape it using `{{`
+
+error: aborting due to 6 previous errors
+