Skip to content

Add new Literal::str_value, Literal::cstr_value and Literal::byte_str_value methods #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link

@GuillaumeGomez GuillaumeGomez commented Jun 24, 2025

Since rust-lang/rust#139367 was merged a while ago, I think it's ok to start making use of it as a nightly experiment if you're ok with it.

If this PR is merged, I plan to send a follow-up on syn for Literal::value to make use of these methods instead (when nightly feature is enabled) so the unescaping source code could be cfg-ed out.

Hopefully, when the API gets stabilized, we could get some nice numbers on compilation improvements for a lot of crates (although minor, considering how much your crates are used, definitely worth it).

So what do you think?

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Since the API of these methods is likely to change, in order to move this forward they need to be behind the procmacro2_semver_exempt cfg like the unstable Span methods such as def_site — a Cargo feature is not appropriate for this. Separately, each method needs a fallback implementation with identical behavior that works in non-macro code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants