From 377c3c79b9e1aae3cde2e7e39e297013390aab4b Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Tue, 19 Aug 2025 21:14:25 +0900 Subject: [PATCH 1/6] fix: incorrect error message for string literal suffixes --- compiler/rustc_parse/src/parser/expr.rs | 9 ++- tests/ui/parser/bad-lit-suffixes.stderr | 80 +++++++++---------- tests/ui/parser/raw-string-suffix-invalid.rs | 8 ++ .../parser/raw-string-suffix-invalid.stderr | 14 ++++ tests/ui/parser/raw-string-suffix-long.rs | 7 ++ tests/ui/parser/raw-string-suffix-long.stderr | 8 ++ tests/ui/parser/raw-string-suffix-word.rs | 7 ++ tests/ui/parser/raw-string-suffix-word.stderr | 8 ++ 8 files changed, 100 insertions(+), 41 deletions(-) create mode 100644 tests/ui/parser/raw-string-suffix-invalid.rs create mode 100644 tests/ui/parser/raw-string-suffix-invalid.stderr create mode 100644 tests/ui/parser/raw-string-suffix-long.rs create mode 100644 tests/ui/parser/raw-string-suffix-long.stderr create mode 100644 tests/ui/parser/raw-string-suffix-word.rs create mode 100644 tests/ui/parser/raw-string-suffix-word.stderr diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index d0604f763171b..8572cdbbb2c43 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1561,7 +1561,14 @@ impl<'a> Parser<'a> { fn parse_expr_lit(&mut self) -> PResult<'a, Box> { let lo = self.token.span; match self.parse_opt_token_lit() { - Some((token_lit, _)) => { + Some((token_lit, span)) => { + // Check for invalid suffix on literals + if let Err(err) = ast::LitKind::from_token_lit(token_lit) { + let guar = report_lit_error(&self.psess, err, token_lit, span); + let token_lit = token::Lit::new(token::Err(guar), token_lit.symbol, None); + let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); + return self.maybe_recover_from_bad_qpath(expr); + } let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); self.maybe_recover_from_bad_qpath(expr) } diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index 9a51cf7096071..daad5a6ceccd2 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -10,46 +10,6 @@ error: suffixes on string literals are invalid LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:30:17 - | -LL | #[rustc_dummy = "string"suffix] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:34:14 - | -LL | #[must_use = "string"suffix] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:39:15 - | -LL | #[link(name = "string"suffix)] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:43:41 - | -LL | #[rustc_layout_scalar_valid_range_start(0suffix)] - | ^^^^^^^ invalid suffix `suffix` - | - = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) - -warning: `extern` declarations without an explicit ABI are deprecated - --> $DIR/bad-lit-suffixes.rs:3:1 - | -LL | extern - | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` - | - = note: `#[warn(missing_abi)]` on by default - -warning: `extern` declarations without an explicit ABI are deprecated - --> $DIR/bad-lit-suffixes.rs:7:1 - | -LL | extern - | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` - error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:12:5 | @@ -150,6 +110,46 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:30:17 + | +LL | #[rustc_dummy = "string"suffix] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:34:14 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:39:15 + | +LL | #[link(name = "string"suffix)] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: invalid suffix `suffix` for number literal + --> $DIR/bad-lit-suffixes.rs:43:41 + | +LL | #[rustc_layout_scalar_valid_range_start(0suffix)] + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +warning: `extern` declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:3:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + +warning: `extern` declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:7:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` + error[E0539]: malformed `must_use` attribute input --> $DIR/bad-lit-suffixes.rs:34:1 | diff --git a/tests/ui/parser/raw-string-suffix-invalid.rs b/tests/ui/parser/raw-string-suffix-invalid.rs new file mode 100644 index 0000000000000..1309fba742c8d --- /dev/null +++ b/tests/ui/parser/raw-string-suffix-invalid.rs @@ -0,0 +1,8 @@ +// Test for issue #144161: Wrong error for string literal suffix when stuck together +// This tests the case where a raw string has an invalid suffix immediately followed by another string + +fn main() { + let s = r#" \\ "#r"\\ "; + //~^ ERROR suffixes on string literals are invalid + //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator +} diff --git a/tests/ui/parser/raw-string-suffix-invalid.stderr b/tests/ui/parser/raw-string-suffix-invalid.stderr new file mode 100644 index 0000000000000..73bb11f4486e7 --- /dev/null +++ b/tests/ui/parser/raw-string-suffix-invalid.stderr @@ -0,0 +1,14 @@ +error: suffixes on string literals are invalid + --> $DIR/raw-string-suffix-invalid.rs:5:13 + | +LL | let s = r#" \ "#r"\ "; + | ^^^^^^^^^^ invalid suffix `r` + +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `"\ "` + --> $DIR/raw-string-suffix-invalid.rs:5:23 + | +LL | let s = r#" \ "#r"\ "; + | ^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/raw-string-suffix-long.rs b/tests/ui/parser/raw-string-suffix-long.rs new file mode 100644 index 0000000000000..cc09933ca643d --- /dev/null +++ b/tests/ui/parser/raw-string-suffix-long.rs @@ -0,0 +1,7 @@ +// Test for raw string literals with invalid suffixes + +fn main() { + // Raw string literal with hash delimiters and suffix + let s2 = r##"test"##suffix; + //~^ ERROR suffixes on string literals are invalid +} diff --git a/tests/ui/parser/raw-string-suffix-long.stderr b/tests/ui/parser/raw-string-suffix-long.stderr new file mode 100644 index 0000000000000..9409e0edb620a --- /dev/null +++ b/tests/ui/parser/raw-string-suffix-long.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/raw-string-suffix-long.rs:5:14 + | +LL | let s2 = r##"test"##suffix; + | ^^^^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/raw-string-suffix-word.rs b/tests/ui/parser/raw-string-suffix-word.rs new file mode 100644 index 0000000000000..bb2f8b19d903c --- /dev/null +++ b/tests/ui/parser/raw-string-suffix-word.rs @@ -0,0 +1,7 @@ +// Test for raw string literal with word suffix + +fn main() { + // Raw string literal with word suffix + let s3 = r#"test"#invalid; + //~^ ERROR suffixes on string literals are invalid +} diff --git a/tests/ui/parser/raw-string-suffix-word.stderr b/tests/ui/parser/raw-string-suffix-word.stderr new file mode 100644 index 0000000000000..c6d3e539c281a --- /dev/null +++ b/tests/ui/parser/raw-string-suffix-word.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/raw-string-suffix-word.rs:5:14 + | +LL | let s3 = r#"test"#invalid; + | ^^^^^^^^^^^^^^^^ invalid suffix `invalid` + +error: aborting due to 1 previous error + From 9e029cb46ce8f62457620bceed6228d752c853a6 Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Tue, 19 Aug 2025 21:48:48 +0900 Subject: [PATCH 2/6] fix consume token --- compiler/rustc_parse/src/parser/expr.rs | 10 ++++++++++ tests/ui/parser/raw-string-suffix-invalid.rs | 2 -- tests/ui/parser/raw-string-suffix-invalid.stderr | 10 ++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 8572cdbbb2c43..ca719b653f891 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1567,6 +1567,16 @@ impl<'a> Parser<'a> { let guar = report_lit_error(&self.psess, err, token_lit, span); let token_lit = token::Lit::new(token::Err(guar), token_lit.symbol, None); let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); + + // Try to consume the next token if it looks like another string literal + // This prevents cascading errors when raw strings with invalid suffixes + // are immediately followed by another string + if let TokenKind::Literal(lit) = &self.token.kind { + if matches!(lit.kind, token::LitKind::Str | token::LitKind::StrRaw(_)) { + self.bump(); + } + } + return self.maybe_recover_from_bad_qpath(expr); } let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); diff --git a/tests/ui/parser/raw-string-suffix-invalid.rs b/tests/ui/parser/raw-string-suffix-invalid.rs index 1309fba742c8d..3543d86fd7a56 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.rs +++ b/tests/ui/parser/raw-string-suffix-invalid.rs @@ -1,8 +1,6 @@ // Test for issue #144161: Wrong error for string literal suffix when stuck together -// This tests the case where a raw string has an invalid suffix immediately followed by another string fn main() { let s = r#" \\ "#r"\\ "; //~^ ERROR suffixes on string literals are invalid - //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator } diff --git a/tests/ui/parser/raw-string-suffix-invalid.stderr b/tests/ui/parser/raw-string-suffix-invalid.stderr index 73bb11f4486e7..84feb3342e389 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.stderr +++ b/tests/ui/parser/raw-string-suffix-invalid.stderr @@ -1,14 +1,8 @@ error: suffixes on string literals are invalid - --> $DIR/raw-string-suffix-invalid.rs:5:13 + --> $DIR/raw-string-suffix-invalid.rs:4:13 | LL | let s = r#" \ "#r"\ "; | ^^^^^^^^^^ invalid suffix `r` -error: expected one of `.`, `;`, `?`, `else`, or an operator, found `"\ "` - --> $DIR/raw-string-suffix-invalid.rs:5:23 - | -LL | let s = r#" \ "#r"\ "; - | ^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error From 4dbf84f322b2898f6175e1852c7fe10a8f67cc70 Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Tue, 19 Aug 2025 23:41:56 +0900 Subject: [PATCH 3/6] fix --- compiler/rustc_parse/src/parser/expr.rs | 27 +++--- tests/ui/parser/bad-lit-suffixes.stderr | 92 +++++++++---------- tests/ui/parser/raw-string-suffix-invalid.rs | 2 + .../parser/raw-string-suffix-invalid.stderr | 10 +- 4 files changed, 68 insertions(+), 63 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index ca719b653f891..903115bfea888 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1562,22 +1562,19 @@ impl<'a> Parser<'a> { let lo = self.token.span; match self.parse_opt_token_lit() { Some((token_lit, span)) => { - // Check for invalid suffix on literals - if let Err(err) = ast::LitKind::from_token_lit(token_lit) { - let guar = report_lit_error(&self.psess, err, token_lit, span); - let token_lit = token::Lit::new(token::Err(guar), token_lit.symbol, None); - let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); - - // Try to consume the next token if it looks like another string literal - // This prevents cascading errors when raw strings with invalid suffixes - // are immediately followed by another string - if let TokenKind::Literal(lit) = &self.token.kind { - if matches!(lit.kind, token::LitKind::Str | token::LitKind::StrRaw(_)) { - self.bump(); - } + // For raw string literals with suffixes, report the error immediately + // This helps provide better error messages for cases like r#"..."#suffix + if token_lit.suffix.is_some() + && matches!(token_lit.kind, token::StrRaw(_)) + && ast::LitKind::from_token_lit(token_lit).is_err() + { + if let Err(err) = ast::LitKind::from_token_lit(token_lit) { + let guar = report_lit_error(&self.psess, err, token_lit, span); + let token_lit = token::Lit::new(token::Err(guar), token_lit.symbol, None); + let expr = + self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); + return self.maybe_recover_from_bad_qpath(expr); } - - return self.maybe_recover_from_bad_qpath(expr); } let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); self.maybe_recover_from_bad_qpath(expr) diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index daad5a6ceccd2..04fc12e1a29dd 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -10,6 +10,52 @@ error: suffixes on string literals are invalid LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:14:5 + | +LL | r#""#suffix; + | ^^^^^^^^^^^ invalid suffix `suffix` + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:30:17 + | +LL | #[rustc_dummy = "string"suffix] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:34:14 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:39:15 + | +LL | #[link(name = "string"suffix)] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: invalid suffix `suffix` for number literal + --> $DIR/bad-lit-suffixes.rs:43:41 + | +LL | #[rustc_layout_scalar_valid_range_start(0suffix)] + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +warning: `extern` declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:3:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + +warning: `extern` declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:7:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` + error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:12:5 | @@ -22,12 +68,6 @@ error: suffixes on byte string literals are invalid LL | b""suffix; | ^^^^^^^^^ invalid suffix `suffix` -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:14:5 - | -LL | r#""#suffix; - | ^^^^^^^^^^^ invalid suffix `suffix` - error: suffixes on byte string literals are invalid --> $DIR/bad-lit-suffixes.rs:15:5 | @@ -110,46 +150,6 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:30:17 - | -LL | #[rustc_dummy = "string"suffix] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:34:14 - | -LL | #[must_use = "string"suffix] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:39:15 - | -LL | #[link(name = "string"suffix)] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:43:41 - | -LL | #[rustc_layout_scalar_valid_range_start(0suffix)] - | ^^^^^^^ invalid suffix `suffix` - | - = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) - -warning: `extern` declarations without an explicit ABI are deprecated - --> $DIR/bad-lit-suffixes.rs:3:1 - | -LL | extern - | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` - | - = note: `#[warn(missing_abi)]` on by default - -warning: `extern` declarations without an explicit ABI are deprecated - --> $DIR/bad-lit-suffixes.rs:7:1 - | -LL | extern - | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"` - error[E0539]: malformed `must_use` attribute input --> $DIR/bad-lit-suffixes.rs:34:1 | diff --git a/tests/ui/parser/raw-string-suffix-invalid.rs b/tests/ui/parser/raw-string-suffix-invalid.rs index 3543d86fd7a56..1309fba742c8d 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.rs +++ b/tests/ui/parser/raw-string-suffix-invalid.rs @@ -1,6 +1,8 @@ // Test for issue #144161: Wrong error for string literal suffix when stuck together +// This tests the case where a raw string has an invalid suffix immediately followed by another string fn main() { let s = r#" \\ "#r"\\ "; //~^ ERROR suffixes on string literals are invalid + //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator } diff --git a/tests/ui/parser/raw-string-suffix-invalid.stderr b/tests/ui/parser/raw-string-suffix-invalid.stderr index 84feb3342e389..73bb11f4486e7 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.stderr +++ b/tests/ui/parser/raw-string-suffix-invalid.stderr @@ -1,8 +1,14 @@ error: suffixes on string literals are invalid - --> $DIR/raw-string-suffix-invalid.rs:4:13 + --> $DIR/raw-string-suffix-invalid.rs:5:13 | LL | let s = r#" \ "#r"\ "; | ^^^^^^^^^^ invalid suffix `r` -error: aborting due to 1 previous error +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `"\ "` + --> $DIR/raw-string-suffix-invalid.rs:5:23 + | +LL | let s = r#" \ "#r"\ "; + | ^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator + +error: aborting due to 2 previous errors From 1901740bf5bf6ab1da98cdde20877e845889a2da Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Wed, 20 Aug 2025 00:12:54 +0900 Subject: [PATCH 4/6] print out only one error --- compiler/rustc_parse/src/parser/expr.rs | 10 ++++++++++ tests/ui/parser/raw-string-suffix-invalid.rs | 1 - tests/ui/parser/raw-string-suffix-invalid.stderr | 8 +------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 903115bfea888..299c4a389a36e 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1573,6 +1573,16 @@ impl<'a> Parser<'a> { let token_lit = token::Lit::new(token::Err(guar), token_lit.symbol, None); let expr = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Lit(token_lit)); + + // Consume the next token if it looks like another string literal + // This prevents cascading errors when raw strings with invalid suffixes + // are immediately followed by another string + if let TokenKind::Literal(lit) = &self.token.kind { + if matches!(lit.kind, token::LitKind::Str | token::LitKind::StrRaw(_)) { + self.bump(); + } + } + return self.maybe_recover_from_bad_qpath(expr); } } diff --git a/tests/ui/parser/raw-string-suffix-invalid.rs b/tests/ui/parser/raw-string-suffix-invalid.rs index 1309fba742c8d..9462931305c5f 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.rs +++ b/tests/ui/parser/raw-string-suffix-invalid.rs @@ -4,5 +4,4 @@ fn main() { let s = r#" \\ "#r"\\ "; //~^ ERROR suffixes on string literals are invalid - //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator } diff --git a/tests/ui/parser/raw-string-suffix-invalid.stderr b/tests/ui/parser/raw-string-suffix-invalid.stderr index 73bb11f4486e7..273413a6d7d55 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.stderr +++ b/tests/ui/parser/raw-string-suffix-invalid.stderr @@ -4,11 +4,5 @@ error: suffixes on string literals are invalid LL | let s = r#" \ "#r"\ "; | ^^^^^^^^^^ invalid suffix `r` -error: expected one of `.`, `;`, `?`, `else`, or an operator, found `"\ "` - --> $DIR/raw-string-suffix-invalid.rs:5:23 - | -LL | let s = r#" \ "#r"\ "; - | ^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error From 818d6f23557428f88b1f097aa95e211d5d4b4bf0 Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Wed, 20 Aug 2025 08:58:15 +0900 Subject: [PATCH 5/6] fix: lint --- tests/ui/parser/raw-string-suffix-invalid.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ui/parser/raw-string-suffix-invalid.rs b/tests/ui/parser/raw-string-suffix-invalid.rs index 9462931305c5f..3543d86fd7a56 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.rs +++ b/tests/ui/parser/raw-string-suffix-invalid.rs @@ -1,5 +1,4 @@ // Test for issue #144161: Wrong error for string literal suffix when stuck together -// This tests the case where a raw string has an invalid suffix immediately followed by another string fn main() { let s = r#" \\ "#r"\\ "; From d045dc78ff69f8d9b6d0358e0dac9957f054c64e Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Wed, 20 Aug 2025 10:15:54 +0900 Subject: [PATCH 6/6] fix --- tests/ui/parser/raw-string-suffix-invalid.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/parser/raw-string-suffix-invalid.stderr b/tests/ui/parser/raw-string-suffix-invalid.stderr index 273413a6d7d55..84feb3342e389 100644 --- a/tests/ui/parser/raw-string-suffix-invalid.stderr +++ b/tests/ui/parser/raw-string-suffix-invalid.stderr @@ -1,5 +1,5 @@ error: suffixes on string literals are invalid - --> $DIR/raw-string-suffix-invalid.rs:5:13 + --> $DIR/raw-string-suffix-invalid.rs:4:13 | LL | let s = r#" \ "#r"\ "; | ^^^^^^^^^^ invalid suffix `r`