-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Reserve guarded string literals (RFC 3593) #123951
Conversation
This comment has been minimized.
This comment has been minimized.
This comment was marked as off-topic.
This comment was marked as off-topic.
In edition 2024 I'm seeing a panic inside |
In edition 2024 if I give this a string like I think it would be better if I got only the first warning. |
This comment has been minimized.
This comment has been minimized.
@mattheww good catch with the empty strings. I wasn't able to reproduce the "double-warning" issue with I think it's actually the correct behavior. When you fix the issue with Regardless, that case will be exceedingly rare if it exists in the wild at all, so I'm not going to spend any time on it. |
My stress-tester is now giving an ICE for |
This comment was marked as resolved.
This comment was marked as resolved.
bb1c797
to
8f57684
Compare
This comment has been minimized.
This comment has been minimized.
My lexer stress-tests don't find any problems with this now. (They're checking for ICEs, cases where the lexer output changes in previous editions, and cases where the lexer output is not as expected in the 2024 edition.) |
This comment was marked as resolved.
This comment was marked as resolved.
Experiment: Reserve guarded string literal syntax (RFC 3593) on all editions Purpose: crater run to see if we even need to make this change on an edition boundary. This syntax change applies to all editions, because the particular syntax `#"foo"#` is unlikely to exist in the wild. Subset of rust-lang#123951 Tracking issue: rust-lang#123735 RFC: rust-lang/rfcs#3593
The crater run for #124605 found some real regressions. So that proves the effort made here for backwards compatibility is warranted. |
029bc5a
to
01505bc
Compare
This comment was marked as resolved.
This comment was marked as resolved.
@traviscross I'm just concerned with introducing the snapshotting behavior into the lexer. There's no precedent for that approach in that stage of the compiler. It might be that there's no alternative, but would like more people in @rust-lang/compiler to double check on the implementation. |
cc @Nilstrieb @compiler-errors fun lexer things |
forwarding my ping to @nnethercote |
7637ef8
to
321a5db
Compare
@rustbot ready |
@bors r+ |
…viscross Reserve guarded string literals (RFC 3593) Implementation for RFC 3593, including: - lexer / parser changes - diagnostics - migration lint - tests We reserve `#"`, `##"`, `###"`, `####`, and any other string of four or more repeated `#`. This avoids infinite lookahead in the lexer, though we still use infinite lookahead in the parser to provide better forward compatibility diagnostics. This PR does not implement any special lexing of the string internals: - strings preceded by one or more `#` are denied - regardless of the number of trailing `#` - string contents are lexed as if it was just a bare `"string"` Tracking issue: rust-lang#123735 RFC: rust-lang/rfcs#3593
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
That failure looks unrelated. Can we try rerunning bors? |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#123951 (Reserve guarded string literals (RFC 3593)) - rust-lang#130827 (Library: Rename "object safe" to "dyn compatible") - rust-lang#131383 (Add docs about slicing slices at the ends) - rust-lang#131403 (Fix needless_lifetimes in rustc_serialize) - rust-lang#131417 (Fix methods alignment on mobile) - rust-lang#131449 (Decouple WASIp2 sockets from WasiFd) - rust-lang#131462 (Mention allocation errors for `open_buffered`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#123951 - pitaj:reserve-guarded-strings, r=traviscross Reserve guarded string literals (RFC 3593) Implementation for RFC 3593, including: - lexer / parser changes - diagnostics - migration lint - tests We reserve `#"`, `##"`, `###"`, `####`, and any other string of four or more repeated `#`. This avoids infinite lookahead in the lexer, though we still use infinite lookahead in the parser to provide better forward compatibility diagnostics. This PR does not implement any special lexing of the string internals: - strings preceded by one or more `#` are denied - regardless of the number of trailing `#` - string contents are lexed as if it was just a bare `"string"` Tracking issue: rust-lang#123735 RFC: rust-lang/rfcs#3593
This implements the edition 2024 reservations: #" ## See rust-lang/rust#123951 (comment)
Implementation for RFC 3593, including:
We reserve
#"
,##"
,###"
,####
, and any other string of four or more repeated#
. This avoids infinite lookahead in the lexer, though we still use infinite lookahead in the parser to provide better forward compatibility diagnostics.This PR does not implement any special lexing of the string internals:
#
are denied#
"string"
Tracking issue: #123735
RFC: rust-lang/rfcs#3593