Skip to content

suggest using raw strings when invalid escapes appear in literals #93999

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

barzamin
Copy link
Contributor

i'd guess about 70% of "bad escape" cases occur when someone meant to use a raw string literal because they're passing it directly to Regex::new().
this emits an advisory (Applicability::MaybeIncorrect) help: suggestion to the user that they use an r"" string, on top of the normal notes about looking at the string literal documentation/spec.

@rust-highfive
Copy link
Contributor

r? @jackh726

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 14, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 14, 2022
@jackh726
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 14, 2022

📌 Commit bf8f067d0734f8f52c9b560dd5c64fc9c15564d7 has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 14, 2022
@barzamin barzamin force-pushed the suggest-raw-strings branch from bf8f067 to eb6f34d Compare February 14, 2022 19:56
i'd guess about 70% of "bad escape" cases occur when someone meant to
use a raw string literal because they're passing it directly to
Regex::new(). this emits an advisory (Applicability::MaybeIncorrect)
help: suggestion to the user that they use an r"" string,
on top of the normal notes about looking at the
string literal documentation/spec.
@barzamin barzamin force-pushed the suggest-raw-strings branch from eb6f34d to e59cda9 Compare February 14, 2022 20:12
@barzamin
Copy link
Contributor Author

prevented lint from firing on byte strings + fixed up

@barzamin barzamin requested a review from jackh726 February 14, 2022 21:32
@jackh726
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 14, 2022

📌 Commit e59cda9 has been approved by jackh726

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 15, 2022
…askrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#93899 (Describe VecDeque with more consistent names)
 - rust-lang#93949 (Add basic platform support to library/{panic_}unwind for m68k)
 - rust-lang#93999 (suggest using raw strings when invalid escapes appear in literals)
 - rust-lang#94001 (llvm: migrate to new parameter-bearing uwtable attr)
 - rust-lang#94014 (Move transmute_undefined_repr back to nursery)

Failed merges:

 - rust-lang#94020 (Support pretty printing of invalid constants)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c6b27db into rust-lang:master Feb 15, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 15, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants