summaryrefslogtreecommitdiffstats
path: root/src/test/ui/fmt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /src/test/ui/fmt
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/fmt')
-rw-r--r--src/test/ui/fmt/format-raw-string-error.rs3
-rw-r--r--src/test/ui/fmt/format-raw-string-error.stderr10
-rw-r--r--src/test/ui/fmt/issue-104142.rs6
-rw-r--r--src/test/ui/fmt/issue-104142.stderr10
-rw-r--r--src/test/ui/fmt/unicode-escape-spans.rs19
-rw-r--r--src/test/ui/fmt/unicode-escape-spans.stderr63
6 files changed, 111 insertions, 0 deletions
diff --git a/src/test/ui/fmt/format-raw-string-error.rs b/src/test/ui/fmt/format-raw-string-error.rs
new file mode 100644
index 000000000..9f0bc01a7
--- /dev/null
+++ b/src/test/ui/fmt/format-raw-string-error.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found
+}
diff --git a/src/test/ui/fmt/format-raw-string-error.stderr b/src/test/ui/fmt/format-raw-string-error.stderr
new file mode 100644
index 000000000..8d61950d8
--- /dev/null
+++ b/src/test/ui/fmt/format-raw-string-error.stderr
@@ -0,0 +1,10 @@
+error: invalid format string: unmatched `}` found
+ --> $DIR/format-raw-string-error.rs:2:45
+ |
+LL | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#);
+ | ^ unmatched `}` in format string
+ |
+ = note: if you intended to print `}`, you can escape it using `}}`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/fmt/issue-104142.rs b/src/test/ui/fmt/issue-104142.rs
new file mode 100644
index 000000000..8d7283a71
--- /dev/null
+++ b/src/test/ui/fmt/issue-104142.rs
@@ -0,0 +1,6 @@
+fn main() {
+ println!(
+ r#"
+ \"\'}、"# //~ ERROR invalid format string: unmatched `}` found
+ );
+}
diff --git a/src/test/ui/fmt/issue-104142.stderr b/src/test/ui/fmt/issue-104142.stderr
new file mode 100644
index 000000000..d41644faa
--- /dev/null
+++ b/src/test/ui/fmt/issue-104142.stderr
@@ -0,0 +1,10 @@
+error: invalid format string: unmatched `}` found
+ --> $DIR/issue-104142.rs:4:9
+ |
+LL | \"\'}、"#
+ | ^ unmatched `}` in format string
+ |
+ = note: if you intended to print `}`, you can escape it using `}}`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/fmt/unicode-escape-spans.rs b/src/test/ui/fmt/unicode-escape-spans.rs
new file mode 100644
index 000000000..753d91ce5
--- /dev/null
+++ b/src/test/ui/fmt/unicode-escape-spans.rs
@@ -0,0 +1,19 @@
+fn main() {
+ // 1 byte in UTF-8
+ format!("\u{000041}{a}"); //~ ERROR cannot find value
+ format!("\u{0041}{a}"); //~ ERROR cannot find value
+ format!("\u{41}{a}"); //~ ERROR cannot find value
+ format!("\u{0}{a}"); //~ ERROR cannot find value
+
+ // 2 bytes
+ format!("\u{0df}{a}"); //~ ERROR cannot find value
+ format!("\u{df}{a}"); //~ ERROR cannot find value
+
+ // 3 bytes
+ format!("\u{00211d}{a}"); //~ ERROR cannot find value
+ format!("\u{211d}{a}"); //~ ERROR cannot find value
+
+ // 4 bytes
+ format!("\u{1f4a3}{a}"); //~ ERROR cannot find value
+ format!("\u{10ffff}{a}"); //~ ERROR cannot find value
+}
diff --git a/src/test/ui/fmt/unicode-escape-spans.stderr b/src/test/ui/fmt/unicode-escape-spans.stderr
new file mode 100644
index 000000000..1d8473f01
--- /dev/null
+++ b/src/test/ui/fmt/unicode-escape-spans.stderr
@@ -0,0 +1,63 @@
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:3:25
+ |
+LL | format!("\u{000041}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:4:23
+ |
+LL | format!("\u{0041}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:5:21
+ |
+LL | format!("\u{41}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:6:20
+ |
+LL | format!("\u{0}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:9:22
+ |
+LL | format!("\u{0df}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:10:21
+ |
+LL | format!("\u{df}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:13:25
+ |
+LL | format!("\u{00211d}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:14:23
+ |
+LL | format!("\u{211d}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:17:24
+ |
+LL | format!("\u{1f4a3}{a}");
+ | ^ not found in this scope
+
+error[E0425]: cannot find value `a` in this scope
+ --> $DIR/unicode-escape-spans.rs:18:25
+ |
+LL | format!("\u{10ffff}{a}");
+ | ^ not found in this scope
+
+error: aborting due to 10 previous errors
+
+For more information about this error, try `rustc --explain E0425`.