Skip to content

Invalid underscore suffix is accepted #532

@ehuss

Description

@ehuss

The literal suffix cannot be a bare underscore, but proc-macro2 is accepting the following:

use std::str::FromStr;

fn main() {
    for input in [
        "'x'_",
        "\"s\"_",
        "r#\"s\"#_",
    ] {
        println!("{:?}", proc_macro2::TokenStream::from_str(input));
    }
}

This was an FCW (rust-lang/rust#42326) but was made a hard error in 1.67 (rust-lang/rust#103914).

Using proc-macro2 1.0.106.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions