about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-07-17 00:36:00 +0000
committerMichael Goulet <michael@errs.io>2023-07-19 16:37:09 +0000
commita872762151760d65bddf6b3ebad19bc3ea7ec31d (patch)
treefc52b84fad464119759ff0f8152a38657175e0c4 /tests
parentfe4d1f9fe979bab54aba6316a5207f7793d751b1 (diff)
downloadrust-a872762151760d65bddf6b3ebad19bc3ea7ec31d.tar.gz
rust-a872762151760d65bddf6b3ebad19bc3ea7ec31d.zip
Improve error message when closing bracket interpreted as formatting fill character
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/fmt/closing-brace-as-fill.rs8
-rw-r--r--tests/ui/fmt/closing-brace-as-fill.stderr12
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/fmt/closing-brace-as-fill.rs b/tests/ui/fmt/closing-brace-as-fill.rs
new file mode 100644
index 00000000000..6ad257f943e
--- /dev/null
+++ b/tests/ui/fmt/closing-brace-as-fill.rs
@@ -0,0 +1,8 @@
+// issue: 112732
+
+// `}` is typoed since it is interpreted as a fill character rather than a closing bracket
+
+fn main() {
+    println!("Hello, world! {0:}<3", 2);
+    //~^ ERROR invalid format string: expected `'}'` but string was terminated
+}
diff --git a/tests/ui/fmt/closing-brace-as-fill.stderr b/tests/ui/fmt/closing-brace-as-fill.stderr
new file mode 100644
index 00000000000..aa1e5aff652
--- /dev/null
+++ b/tests/ui/fmt/closing-brace-as-fill.stderr
@@ -0,0 +1,12 @@
+error: invalid format string: expected `'}'` but string was terminated
+  --> $DIR/closing-brace-as-fill.rs:6:35
+   |
+LL |     println!("Hello, world! {0:}<3", 2);
+   |                                -  ^ expected `'}'` in format string
+   |                                |
+   |                                this is not interpreted as a formatting closing brace
+   |
+   = note: the character `'}'` is interpreted as a fill character because of the `:` that precedes it
+
+error: aborting due to previous error
+