Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8b5f6ac92ab1ea3dbc9d74c8d63d7514
const A: &'static str = r""
// Test
#[test]
fn test() {}
The current output is:
error: too many `#` when terminating raw string
--> src/lib.rs:4:1
|
4 | #[test]
| ^ help: remove the extra `#`
|
= note: the raw string started with 0 `#`s
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=28a29f9c008732dd3e7fc75455a4e325
fn main() {
let s = r""
#[cfg(unix)]
fn u() {}
}
The current output is:
error: too many `#` when terminating raw string
--> src/main.rs:4:5
|
4 | #[cfg(unix)]
| ^ help: remove the extra `#`
|
= note: the raw string started with 0 `#`s
The problem with the error message is that there is nothing wrong with the raw string literals (as rustc notes, they don't use any #
s anyway); in particular, the raw string literals are not incorrectly terminated. Rather, it is the item declaration or statement that is terminated incorrectly, in that it is missing its terminating semicolon. Besides being misleading as to the problem with the code, the error message includes a suggestion that would only break the syntax further.
I suggest this is a minor issue, especially as no-one appears to have reported it yet.
This issue appears to apply to stable, beta, and nightly.