Closed
Description
Things like "abc"suffix
are lexically valid tokens, but they are reported as errors when parsed with the Rust Language Parser.
However, macro inputs are not parsed by the Rust Language Parser, each macro has its own language that it parses by itself.
It means that suffixed string and char literals can be passed to procedural macros (a procedural macro can process them as they want and make them legal and meaningful in its language), or declarative macros (if they are ignored).
Example:
macro_rules! blackhole { ($tt:tt) => () }
fn main() {
blackhole!("string"suffix); // OK
}
Possible solutions:
- Alternative 1: Prohibit this during lexing, a string/character literal tokens won't be able to be suffixed, proc macros won't be able to use them in their DSLs.
- Alternative 2: Do nothing, string/character literal tokens can be suffixed (but not in the Rust Language proper), proc macros will be able to use them in their DSLs.