Skip to content
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

generator: Emit new c"" CStr literals #848

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

Conversation

MarijnS95
Copy link
Collaborator

@MarijnS95 MarijnS95 commented Dec 7, 2023

These will land in Rust 1.76 have landed in Rust 1.77 just now and automatically append a \0 terminator in the compiler without having to have a checked or unsafe-unchecked constructor on CStr.

Hacking in an invalid \0 anywhere in the string is disallowed with a compiler error.

Note that proc-macro, and by extension proc-macro2 only has support for parsing this literal, but not for emitting it yet.

@MarijnS95 MarijnS95 force-pushed the cstr-literal branch 5 times, most recently from f6949e5 to e7ee21c Compare December 10, 2023 17:08
@Friz64
Copy link
Contributor

Friz64 commented Mar 21, 2024

C-string literals have now landed in Rust 1.77.

These will land in Rust 1.76 and automatically append a `\0` terminator
in the compiler without having to have a checked or `unsafe`-unchecked
constructor on `CStr`.

Hacking in an invalid `\0` anywhere in the string is disallowed with a
compiler error.

Note that `proc-macro`, and by extension `proc-macro2` only has support
for parsing this literal, but not for emitting it yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants