Skip to content

non_ascii_literal, invisible_characters: don't suggest a fix on raw strings#17302

Open
shulaoda wants to merge 2 commits into
rust-lang:masterfrom
shulaoda:fix/unicode-raw-string-no-suggestion
Open

non_ascii_literal, invisible_characters: don't suggest a fix on raw strings#17302
shulaoda wants to merge 2 commits into
rust-lang:masterfrom
shulaoda:fix/unicode-raw-string-no-suggestion

Conversation

@shulaoda

@shulaoda shulaoda commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Both non_ascii_literal and invisible_characters build their suggestion from the source snippet and inject \u{...} escapes into it. Those escapes are inert inside a raw string literal, so cargo clippy --fix corrupts raw strings: the real character is dropped.

For a raw string literal the lints now keep the warning but only emit a help to use a normal string literal, instead of a machine-applicable suggestion that would corrupt the code. Cooked strings, char literals and unicode_not_nfc are left unchanged.

Fixes #9805

changelog: [non_ascii_literal]: warn without a suggestion on raw strings instead of suggesting a fix that corrupts them
changelog: [invisible_characters]: warn without a suggestion on raw strings instead of suggesting a fix that corrupts them

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 24, 2026
@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

r? @dswij

rustbot has assigned @dswij.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 8 candidates
  • 8 candidates expanded to 8 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@shulaoda shulaoda marked this pull request as draft June 24, 2026 23:43
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 24, 2026
@shulaoda shulaoda force-pushed the fix/unicode-raw-string-no-suggestion branch from 67759a5 to d365262 Compare June 24, 2026 23:45
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Lintcheck changes for 04ac508

Lint Added Removed Changed
clippy::non_ascii_literal 0 0 2

This comment will be updated if you push new changes

@shulaoda shulaoda force-pushed the fix/unicode-raw-string-no-suggestion branch from d365262 to 04ac508 Compare June 24, 2026 23:57
@shulaoda shulaoda marked this pull request as ready for review June 25, 2026 00:04
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

non_ascii_literal should not be machine-applicable to raw strings

3 participants