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

Reserve guarded string literals (RFC 3593) #123951

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pitaj
Copy link
Contributor

@pitaj pitaj commented Apr 15, 2024

Implementation for RFC 3593, including:

  • lexer / parser changes
  • diagnostics
  • migration lint
  • tests

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: #123735
RFC: rust-lang/rfcs#3593

@rustbot
Copy link
Collaborator

rustbot commented Apr 15, 2024

r? @estebank

rustbot has assigned @estebank.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 15, 2024
@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment was marked as off-topic.

@mattheww
Copy link
Contributor

In edition 2024 I'm seeing a panic inside cook_unicode if I give this an empty guarded string without enough closing hashes (eg #"" or ##""#).

@mattheww
Copy link
Contributor

In edition 2024 if I give this a string like blah"xx" I get both a warning for an unknown prefix and a warning for an unprefixed guarded string literal.

I think it would be better if I got only the first warning.

@rust-log-analyzer

This comment has been minimized.

@pitaj
Copy link
Contributor Author

pitaj commented Apr 30, 2024

@mattheww good catch with the empty strings. I wasn't able to reproduce the "double-warning" issue with blah"xx", but just managed to do so with blah#"xx"#.

I think it's actually the correct behavior. When you fix the issue with blah #"xx"# as recommended, you'll end up getting the second error anyways. Better to get both at once, then you can make a more educated decision.

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.

@mattheww
Copy link
Contributor

My stress-tester is now giving an ICE for £#""# in editions older than 2024.

@bors

This comment was marked as resolved.

@pitaj pitaj force-pushed the reserve-guarded-strings branch from bb1c797 to 8f57684 Compare May 2, 2024 04:05
@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-unprefixed_guarded_strings `#![feature(unprefixed_guarded_strings)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants