From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- ...e-70677-panic-on-unterminated-raw-str-at-eof.rs | 5 +++ ...677-panic-on-unterminated-raw-str-at-eof.stderr | 9 +++++ tests/ui/parser/raw/raw-byte-string-eof.rs | 3 ++ tests/ui/parser/raw/raw-byte-string-eof.stderr | 13 ++++++++ tests/ui/parser/raw/raw-byte-string-literals.rs | 7 ++++ .../ui/parser/raw/raw-byte-string-literals.stderr | 20 +++++++++++ tests/ui/parser/raw/raw-literal-keywords.rs | 25 ++++++++++++++ tests/ui/parser/raw/raw-literal-keywords.stderr | 39 ++++++++++++++++++++++ tests/ui/parser/raw/raw-literal-self.rs | 4 +++ tests/ui/parser/raw/raw-literal-self.stderr | 8 +++++ tests/ui/parser/raw/raw-literal-underscore.rs | 4 +++ tests/ui/parser/raw/raw-literal-underscore.stderr | 8 +++++ tests/ui/parser/raw/raw-str-delim.rs | 3 ++ tests/ui/parser/raw/raw-str-delim.stderr | 8 +++++ tests/ui/parser/raw/raw-str-in-macro-call.rs | 14 ++++++++ tests/ui/parser/raw/raw-str-unbalanced.rs | 22 ++++++++++++ tests/ui/parser/raw/raw-str-unbalanced.stderr | 36 ++++++++++++++++++++ tests/ui/parser/raw/raw-str-unterminated.rs | 4 +++ tests/ui/parser/raw/raw-str-unterminated.stderr | 11 ++++++ tests/ui/parser/raw/raw-string-2.rs | 4 +++ tests/ui/parser/raw/raw-string-2.stderr | 11 ++++++ tests/ui/parser/raw/raw-string.rs | 4 +++ tests/ui/parser/raw/raw-string.stderr | 13 ++++++++ 23 files changed, 275 insertions(+) create mode 100644 tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs create mode 100644 tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr create mode 100644 tests/ui/parser/raw/raw-byte-string-eof.rs create mode 100644 tests/ui/parser/raw/raw-byte-string-eof.stderr create mode 100644 tests/ui/parser/raw/raw-byte-string-literals.rs create mode 100644 tests/ui/parser/raw/raw-byte-string-literals.stderr create mode 100644 tests/ui/parser/raw/raw-literal-keywords.rs create mode 100644 tests/ui/parser/raw/raw-literal-keywords.stderr create mode 100644 tests/ui/parser/raw/raw-literal-self.rs create mode 100644 tests/ui/parser/raw/raw-literal-self.stderr create mode 100644 tests/ui/parser/raw/raw-literal-underscore.rs create mode 100644 tests/ui/parser/raw/raw-literal-underscore.stderr create mode 100644 tests/ui/parser/raw/raw-str-delim.rs create mode 100644 tests/ui/parser/raw/raw-str-delim.stderr create mode 100644 tests/ui/parser/raw/raw-str-in-macro-call.rs create mode 100644 tests/ui/parser/raw/raw-str-unbalanced.rs create mode 100644 tests/ui/parser/raw/raw-str-unbalanced.stderr create mode 100644 tests/ui/parser/raw/raw-str-unterminated.rs create mode 100644 tests/ui/parser/raw/raw-str-unterminated.stderr create mode 100644 tests/ui/parser/raw/raw-string-2.rs create mode 100644 tests/ui/parser/raw/raw-string-2.stderr create mode 100644 tests/ui/parser/raw/raw-string.rs create mode 100644 tests/ui/parser/raw/raw-string.stderr (limited to 'tests/ui/parser/raw') diff --git a/tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs b/tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs new file mode 100644 index 000000000..bdfc29a3d --- /dev/null +++ b/tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.rs @@ -0,0 +1,5 @@ +// This won't actually panic because of the error comment -- the `"` needs to be +// the last byte in the file (including not having a trailing newline) +// Prior to the fix you get the error: 'expected item, found `r" ...`' +// because the string being unterminated wasn't properly detected. +r" //~ unterminated raw string diff --git a/tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr b/tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr new file mode 100644 index 000000000..3a7e2a4b1 --- /dev/null +++ b/tests/ui/parser/raw/issue-70677-panic-on-unterminated-raw-str-at-eof.stderr @@ -0,0 +1,9 @@ +error[E0748]: unterminated raw string + --> $DIR/issue-70677-panic-on-unterminated-raw-str-at-eof.rs:5:1 + | +LL | r" + | ^ unterminated raw string + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0748`. diff --git a/tests/ui/parser/raw/raw-byte-string-eof.rs b/tests/ui/parser/raw/raw-byte-string-eof.rs new file mode 100644 index 000000000..b74907b72 --- /dev/null +++ b/tests/ui/parser/raw/raw-byte-string-eof.rs @@ -0,0 +1,3 @@ +pub fn main() { + br##"a"#; //~ unterminated raw string +} diff --git a/tests/ui/parser/raw/raw-byte-string-eof.stderr b/tests/ui/parser/raw/raw-byte-string-eof.stderr new file mode 100644 index 000000000..a76668e80 --- /dev/null +++ b/tests/ui/parser/raw/raw-byte-string-eof.stderr @@ -0,0 +1,13 @@ +error[E0748]: unterminated raw string + --> $DIR/raw-byte-string-eof.rs:2:5 + | +LL | br##"a"#; + | ^ - help: consider terminating the string here: `##` + | | + | unterminated raw string + | + = note: this raw string should be terminated with `"##` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0748`. diff --git a/tests/ui/parser/raw/raw-byte-string-literals.rs b/tests/ui/parser/raw/raw-byte-string-literals.rs new file mode 100644 index 000000000..1b859fee5 --- /dev/null +++ b/tests/ui/parser/raw/raw-byte-string-literals.rs @@ -0,0 +1,7 @@ +// ignore-tidy-cr + +pub fn main() { + br"a "; //~ ERROR bare CR not allowed in raw string + br"é"; //~ ERROR non-ASCII character in raw byte string literal + br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation +} diff --git a/tests/ui/parser/raw/raw-byte-string-literals.stderr b/tests/ui/parser/raw/raw-byte-string-literals.stderr new file mode 100644 index 000000000..a2f27d1ed --- /dev/null +++ b/tests/ui/parser/raw/raw-byte-string-literals.stderr @@ -0,0 +1,20 @@ +error: bare CR not allowed in raw string + --> $DIR/raw-byte-string-literals.rs:4:9 + | +LL | br"a "; + | ^ + +error: non-ASCII character in raw byte string literal + --> $DIR/raw-byte-string-literals.rs:5:8 + | +LL | br"é"; + | ^ must be ASCII + +error: found invalid character; only `#` is allowed in raw string delimitation: ~ + --> $DIR/raw-byte-string-literals.rs:6:5 + | +LL | br##~"a"~##; + | ^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/raw/raw-literal-keywords.rs b/tests/ui/parser/raw/raw-literal-keywords.rs new file mode 100644 index 000000000..a986980fa --- /dev/null +++ b/tests/ui/parser/raw/raw-literal-keywords.rs @@ -0,0 +1,25 @@ +fn test_if() { + r#if true { } //~ ERROR found keyword `true` +} + +fn test_struct() { + r#struct Test; //~ ERROR found `Test` +} + +fn test_union() { + r#union Test; //~ ERROR found `Test` +} + +fn test_if_2() { + let _ = r#if; //~ ERROR cannot find value `r#if` in this scope +} + +fn test_struct_2() { + let _ = r#struct; //~ ERROR cannot find value `r#struct` in this scope +} + +fn test_union_2() { + let _ = r#union; //~ ERROR cannot find value `union` in this scope +} + +fn main() {} diff --git a/tests/ui/parser/raw/raw-literal-keywords.stderr b/tests/ui/parser/raw/raw-literal-keywords.stderr new file mode 100644 index 000000000..f7b6c894a --- /dev/null +++ b/tests/ui/parser/raw/raw-literal-keywords.stderr @@ -0,0 +1,39 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `true` + --> $DIR/raw-literal-keywords.rs:2:10 + | +LL | r#if true { } + | ^^^^ expected one of 8 possible tokens + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:6:14 + | +LL | r#struct Test; + | ^^^^ expected one of 8 possible tokens + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:10:13 + | +LL | r#union Test; + | ^^^^ expected one of 8 possible tokens + +error[E0425]: cannot find value `r#if` in this scope + --> $DIR/raw-literal-keywords.rs:14:13 + | +LL | let _ = r#if; + | ^^^^ not found in this scope + +error[E0425]: cannot find value `r#struct` in this scope + --> $DIR/raw-literal-keywords.rs:18:13 + | +LL | let _ = r#struct; + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `union` in this scope + --> $DIR/raw-literal-keywords.rs:22:13 + | +LL | let _ = r#union; + | ^^^^^^^ not found in this scope + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/raw/raw-literal-self.rs b/tests/ui/parser/raw/raw-literal-self.rs new file mode 100644 index 000000000..a0c9e24c2 --- /dev/null +++ b/tests/ui/parser/raw/raw-literal-self.rs @@ -0,0 +1,4 @@ +fn main() { + let r#self: (); + //~^ ERROR `self` cannot be a raw identifier +} diff --git a/tests/ui/parser/raw/raw-literal-self.stderr b/tests/ui/parser/raw/raw-literal-self.stderr new file mode 100644 index 000000000..2a40dfe20 --- /dev/null +++ b/tests/ui/parser/raw/raw-literal-self.stderr @@ -0,0 +1,8 @@ +error: `self` cannot be a raw identifier + --> $DIR/raw-literal-self.rs:2:9 + | +LL | let r#self: (); + | ^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/raw/raw-literal-underscore.rs b/tests/ui/parser/raw/raw-literal-underscore.rs new file mode 100644 index 000000000..a9d9e13a9 --- /dev/null +++ b/tests/ui/parser/raw/raw-literal-underscore.rs @@ -0,0 +1,4 @@ +fn main() { + let r#_: (); + //~^ ERROR `_` cannot be a raw identifier +} diff --git a/tests/ui/parser/raw/raw-literal-underscore.stderr b/tests/ui/parser/raw/raw-literal-underscore.stderr new file mode 100644 index 000000000..d7a364d85 --- /dev/null +++ b/tests/ui/parser/raw/raw-literal-underscore.stderr @@ -0,0 +1,8 @@ +error: `_` cannot be a raw identifier + --> $DIR/raw-literal-underscore.rs:2:9 + | +LL | let r#_: (); + | ^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/raw/raw-str-delim.rs b/tests/ui/parser/raw/raw-str-delim.rs new file mode 100644 index 000000000..2f13893ce --- /dev/null +++ b/tests/ui/parser/raw/raw-str-delim.rs @@ -0,0 +1,3 @@ +static s: &'static str = + r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation +; diff --git a/tests/ui/parser/raw/raw-str-delim.stderr b/tests/ui/parser/raw/raw-str-delim.stderr new file mode 100644 index 000000000..8a04f99a1 --- /dev/null +++ b/tests/ui/parser/raw/raw-str-delim.stderr @@ -0,0 +1,8 @@ +error: found invalid character; only `#` is allowed in raw string delimitation: ~ + --> $DIR/raw-str-delim.rs:2:5 + | +LL | r#~"#"~# + | ^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/raw/raw-str-in-macro-call.rs b/tests/ui/parser/raw/raw-str-in-macro-call.rs new file mode 100644 index 000000000..462c2279f --- /dev/null +++ b/tests/ui/parser/raw/raw-str-in-macro-call.rs @@ -0,0 +1,14 @@ +// check-pass + +macro_rules! m1 { + ($tt:tt #) => () +} + +macro_rules! m2 { + ($tt:tt) => () +} + +fn main() { + m1!(r#"abc"##); + m2!(r#"abc"#); +} diff --git a/tests/ui/parser/raw/raw-str-unbalanced.rs b/tests/ui/parser/raw/raw-str-unbalanced.rs new file mode 100644 index 000000000..38537f8b3 --- /dev/null +++ b/tests/ui/parser/raw/raw-str-unbalanced.rs @@ -0,0 +1,22 @@ +static s: &'static str = + r#""## //~ ERROR too many `#` when terminating raw string +; + +static s2: &'static str = + r#" + "#### //~ ERROR too many `#` when terminating raw string +; + +const A: &'static str = r"" //~ ERROR expected `;`, found `#` + +// Test +#[test] +fn test() {} + +const B: &'static str = r""## //~ ERROR too many `#` when terminating raw string + +// Test +#[test] +fn test2() {} + +fn main() {} diff --git a/tests/ui/parser/raw/raw-str-unbalanced.stderr b/tests/ui/parser/raw/raw-str-unbalanced.stderr new file mode 100644 index 000000000..eac8c06c1 --- /dev/null +++ b/tests/ui/parser/raw/raw-str-unbalanced.stderr @@ -0,0 +1,36 @@ +error: too many `#` when terminating raw string + --> $DIR/raw-str-unbalanced.rs:2:10 + | +LL | r#""## + | -----^ help: remove the extra `#` + | | + | this raw string started with 1 `#` + +error: too many `#` when terminating raw string + --> $DIR/raw-str-unbalanced.rs:7:9 + | +LL | / r#" +LL | | "#### + | | -^^^ help: remove the extra `#`s + | |________| + | this raw string started with 1 `#` + +error: expected `;`, found `#` + --> $DIR/raw-str-unbalanced.rs:10:28 + | +LL | const A: &'static str = r"" + | ^ help: add `;` here +... +LL | #[test] + | - unexpected token + +error: too many `#` when terminating raw string + --> $DIR/raw-str-unbalanced.rs:16:28 + | +LL | const B: &'static str = r""## + | ---^^ help: remove the extra `#`s + | | + | this raw string started with 0 `#`s + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/raw/raw-str-unterminated.rs b/tests/ui/parser/raw/raw-str-unterminated.rs new file mode 100644 index 000000000..fd3172955 --- /dev/null +++ b/tests/ui/parser/raw/raw-str-unterminated.rs @@ -0,0 +1,4 @@ +static s: &'static str = + r#" string literal goes on + and on + //~^^ ERROR unterminated raw string diff --git a/tests/ui/parser/raw/raw-str-unterminated.stderr b/tests/ui/parser/raw/raw-str-unterminated.stderr new file mode 100644 index 000000000..077f763f1 --- /dev/null +++ b/tests/ui/parser/raw/raw-str-unterminated.stderr @@ -0,0 +1,11 @@ +error[E0748]: unterminated raw string + --> $DIR/raw-str-unterminated.rs:2:5 + | +LL | r#" string literal goes on + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"#` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0748`. diff --git a/tests/ui/parser/raw/raw-string-2.rs b/tests/ui/parser/raw/raw-string-2.rs new file mode 100644 index 000000000..067332d28 --- /dev/null +++ b/tests/ui/parser/raw/raw-string-2.rs @@ -0,0 +1,4 @@ +fn main() { + let x = r###"here's a long string"# "# "##; + //~^ ERROR unterminated raw string +} diff --git a/tests/ui/parser/raw/raw-string-2.stderr b/tests/ui/parser/raw/raw-string-2.stderr new file mode 100644 index 000000000..8bbac9d7b --- /dev/null +++ b/tests/ui/parser/raw/raw-string-2.stderr @@ -0,0 +1,11 @@ +error[E0748]: unterminated raw string + --> $DIR/raw-string-2.rs:2:13 + | +LL | let x = r###"here's a long string"# "# "##; + | ^ unterminated raw string -- help: consider terminating the string here: `###` + | + = note: this raw string should be terminated with `"###` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0748`. diff --git a/tests/ui/parser/raw/raw-string.rs b/tests/ui/parser/raw/raw-string.rs new file mode 100644 index 000000000..84f07c4a9 --- /dev/null +++ b/tests/ui/parser/raw/raw-string.rs @@ -0,0 +1,4 @@ +fn main() { + let x = r##"lol"#; + //~^ ERROR unterminated raw string +} diff --git a/tests/ui/parser/raw/raw-string.stderr b/tests/ui/parser/raw/raw-string.stderr new file mode 100644 index 000000000..b2b853a89 --- /dev/null +++ b/tests/ui/parser/raw/raw-string.stderr @@ -0,0 +1,13 @@ +error[E0748]: unterminated raw string + --> $DIR/raw-string.rs:2:13 + | +LL | let x = r##"lol"#; + | ^ - help: consider terminating the string here: `##` + | | + | unterminated raw string + | + = note: this raw string should be terminated with `"##` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0748`. -- cgit v1.2.3