Closed
Description
Code
// Edition 2024
macro_rules! m {
($a:tt $b:tt) => {};
}
m!{##}
Current output
error: invalid string literal
--> src/lib.rs:5:4
|
5 | m!{##}
| ^^
|
= note: unprefixed guarded string literals are reserved for future use since Rust 2024
help: consider inserting whitespace here
|
5 | m!{# #}
| +
error: unexpected end of macro invocation
--> src/lib.rs:5:6
|
1 | macro_rules! m {
| -------------- when calling this macro
...
5 | m!{##}
| ^ missing tokens in macro arguments
|
note: while trying to match meta-variable `$b:tt`
--> src/lib.rs:2:12
|
2 | ($a:tt $b:tt) => {};
| ^^^^^
Desired output
error: reserved multi-hash token is not allowed
--> src/lib.rs:5:4
|
5 | m!{##}
| ^^
|
= note: a sequence of two or more # is reserved for future use since Rust 2024
help: consider inserting whitespace here
|
5 | m!{# #}
| +
error: unexpected end of macro invocation
--> src/lib.rs:5:6
|
1 | macro_rules! m {
| -------------- when calling this macro
...
5 | m!{##}
| ^ missing tokens in macro arguments
|
note: while trying to match meta-variable `$b:tt`
--> src/lib.rs:2:12
|
2 | ($a:tt $b:tt) => {};
| ^^^^^
Rationale and extra context
The existing message referring to a "string literal" is confusing to me since there are no strings anywhere in the source. I don't think it will be obvious to users to make the connection between ##
and "that might come before some reserved string thing that doesn't yet exist". I would suggest avoiding the terminology of "string literal" if there is no string literal following the last #
.
Other cases
No response
Rust Version
rustc 1.83.0-nightly (1bc403d 2024-10-11)
binary: rustc
commit-hash: 1bc403d
commit-date: 2024-10-11
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.1
Anything else?
No response