-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
confusing error when using c-string literals on older editions #118654
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
F-c_str_literals
`#![feature(c_str_literals)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
ehuss
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
F-c_str_literals
`#![feature(c_str_literals)]`
labels
Dec 5, 2023
rustbot
added
the
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
label
Dec 5, 2023
saethlin
removed
the
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
label
Dec 6, 2023
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this issue
Dec 19, 2023
…mease Add check for possible CStr literals in pre-2021 Fixes [rust-lang#118654](rust-lang#118654) Adds information to errors caused by possible CStr literals in pre-2021. The lexer separates `c"str"` into two tokens if the edition is less than 2021, which later causes an error when parsing. This error now has a more helpful message that directs them to information about editions. However, the user might also have written `c "str"` in a later edition, so to not confuse people who _are_ using a recent edition, I also added a note about whitespace. We could probably figure out exactly which scenario has been encountered by examining spans and editions, but I figured it would be better not to overcomplicate the creation of the error too much. This is my first code PR and I tried to follow existing conventions as much as possible, but I probably missed something, so let me know!
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 20, 2023
…mease Add check for possible CStr literals in pre-2021 Fixes [rust-lang#118654](rust-lang#118654) Adds information to errors caused by possible CStr literals in pre-2021. The lexer separates `c"str"` into two tokens if the edition is less than 2021, which later causes an error when parsing. This error now has a more helpful message that directs them to information about editions. However, the user might also have written `c "str"` in a later edition, so to not confuse people who _are_ using a recent edition, I also added a note about whitespace. We could probably figure out exactly which scenario has been encountered by examining spans and editions, but I figured it would be better not to overcomplicate the creation of the error too much. This is my first code PR and I tried to follow existing conventions as much as possible, but I probably missed something, so let me know!
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 20, 2023
Rollup merge of rust-lang#118691 - chfogelman:improve-cstr-error, r=fmease Add check for possible CStr literals in pre-2021 Fixes [rust-lang#118654](rust-lang#118654) Adds information to errors caused by possible CStr literals in pre-2021. The lexer separates `c"str"` into two tokens if the edition is less than 2021, which later causes an error when parsing. This error now has a more helpful message that directs them to information about editions. However, the user might also have written `c "str"` in a later edition, so to not confuse people who _are_ using a recent edition, I also added a note about whitespace. We could probably figure out exactly which scenario has been encountered by examining spans and editions, but I figured it would be better not to overcomplicate the creation of the error too much. This is my first code PR and I tried to follow existing conventions as much as possible, but I probably missed something, so let me know!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
F-c_str_literals
`#![feature(c_str_literals)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
c-string literals are only supported in the 2021 edition or newer. Attempts to use them in older editions may cause confusion.
I realize this may be difficult to implement since it needs to be careful to not assume that
c
followed by"
is invalid due to macros. But perhaps it may not be too difficult.Other cases
No response
Anything else?
The text was updated successfully, but these errors were encountered: