Tokenise suffixes on all literals by huonw · Pull Request #19103 · rust-lang/rust (original) (raw)
Futureproof Rust for fancier suffixed literals. The Rust compiler tokenises a literal followed immediately (no whitespace) by an identifier as a single token: (for example) the text sequences "foo"bar
, 1baz
and 1u1024
are now a single token rather than the pairs "foo"
bar
, 1
baz
and 1u
1024
respectively.
The compiler rejects all such suffixes in the parser, except for the 12 numeric suffixes we have now.
I'm fairly sure this will affect very few programs, since it's not currently legal to have <literal><identifier>
in a Rust program, except in a macro invocation. Any macro invocation relying on this behaviour can simply separate the two tokens with whitespace: foo!("bar"baz)
becomes foo!("bar" baz)
.