Skip to content

proc_macro does not have a constructor for byte literals #71358

Closed
@CAD97

Description

@CAD97
Contributor

We have Literal::string(&str) for string literals, Literal::character(char) for character literals, and Literal::byte_string(&[u8]) for byte string literals, but no Literal::byte_character(u8) for byte literals.

Activity

added
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Apr 20, 2020
wycats

wycats commented on Oct 7, 2021

@wycats
Contributor

This seems important. Is there something we're missing?

CAD97

CAD97 commented on Oct 8, 2021

@CAD97
ContributorAuthor

Byte literal chars are "just" sugar for u8, so I assume you'd be quite hard pressed to find a location where using one or the other is important (modulo a proc macro to specifically check for that). Additionally, you can always use <TokenStream as FromStr>

wycats

wycats commented on Nov 16, 2021

@wycats
Contributor

@CAD97's comments notwithstanding, I still don't get why this constructor is missing. It makes it impossible to construct a token stream that is a high-fidelity representation of the input (which can have implications for error message). It also has implications for round tripping.

added 2 commits that reference this issue on Sep 7, 2023

Auto merge of rust-lang#112711 - Emilgardis:lit_byte_char, r=dtolnay

Auto merge of rust-lang#112711 - Emilgardis:lit_byte_char, r=dtolnay

added a commit that references this issue on Sep 23, 2023

Auto merge of rust-lang#112711 - Emilgardis:lit_byte_char, r=dtolnay

Emilgardis

Emilgardis commented on Sep 24, 2023

@Emilgardis
Contributor

This has been added as Literal::byte_character behind #![feature(proc_macro_byte_character)], tracked in #115268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wycats@Aaron1011@Emilgardis@jonas-schievink@dtolnay

        Issue actions

          proc_macro does not have a constructor for byte literals · Issue #71358 · rust-lang/rust