dtolnay / dtolnay/proc-macro2

Invalid characters accepted for byte and char literals

Open
#531 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
934
Forks
135
PR merge metrics
No merged PRs in 30d

Description

Byte and char literals must not contain the characters `'`, `LF`, `CR`, or `TAB`. However, proc-macro2 accepts all of these and parses them as a byte literal.

```rust
use std::str::FromStr;

fn main() {
for input in [
"b'''",
"b'\r'",
"b'\n'",
"b'\t'",
] {
println!("{:?}", proc_macro2::TokenStream::from_str(input));
}
}
```

Checked [here](https://github.com/rust-lang/literal-escaper/blob/637cc2e289f081b77c3d46ac934932024fb6e19e/src/lib.rs#L326-L337) I believe.

Using `proc-macro2 1.0.106`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.