From 35c7939ae5d3a0e34963bbd57bbc4b91c3ce0ce3 Mon Sep 17 00:00:00 2001 From: Cassaundra Smith Date: Mon, 21 Nov 2022 20:36:11 -0800 Subject: Fix incorrect span when using byte-escaped rbrace Fix #103826. --- src/test/ui/fmt/issue-103826.rs | 8 ++++++++ src/test/ui/fmt/issue-103826.stderr | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/test/ui/fmt/issue-103826.rs create mode 100644 src/test/ui/fmt/issue-103826.stderr (limited to 'src') diff --git a/src/test/ui/fmt/issue-103826.rs b/src/test/ui/fmt/issue-103826.rs new file mode 100644 index 00000000000..a11ec37a06d --- /dev/null +++ b/src/test/ui/fmt/issue-103826.rs @@ -0,0 +1,8 @@ +fn main() { + format!("{\x7D"); + //~^ ERROR 1 positional argument in format string, but no arguments were given + format!("\x7B\x7D"); + //~^ ERROR 1 positional argument in format string, but no arguments were given + format!("{\x7D {\x7D"); + //~^ ERROR 2 positional arguments in format string, but no arguments were given +} diff --git a/src/test/ui/fmt/issue-103826.stderr b/src/test/ui/fmt/issue-103826.stderr new file mode 100644 index 00000000000..0f27e1930bc --- /dev/null +++ b/src/test/ui/fmt/issue-103826.stderr @@ -0,0 +1,20 @@ +error: 1 positional argument in format string, but no arguments were given + --> $DIR/issue-103826.rs:2:14 + | +LL | format!("{\x7D"); + | ^^^^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/issue-103826.rs:4:14 + | +LL | format!("\x7B\x7D"); + | ^^^^^^^^ + +error: 2 positional arguments in format string, but no arguments were given + --> $DIR/issue-103826.rs:6:14 + | +LL | format!("{\x7D {\x7D"); + | ^^^^^ ^^^^^ + +error: aborting due to 3 previous errors + -- cgit 1.4.1-3-g733a5