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

single_char_pattern produces incorrect suggestion for double quote character #11973

Closed
mondeja opened this issue Dec 16, 2023 · 1 comment · Fixed by #12030
Closed

single_char_pattern produces incorrect suggestion for double quote character #11973

mondeja opened this issue Dec 16, 2023 · 1 comment · Fixed by #12030
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@mondeja
Copy link

mondeja commented Dec 16, 2023

Summary

When the char to replace is a double quote ", clippy suggests to replace it using the escape character, but in this case the escape character is not needed.

Reproducer

error: single-character string constant used as pattern
  --> crates/.../src/lib.rs:79:92
   |
79 | ...                   let clean_string = lit.to_string().replace("\"", "");
   |                                                                  ^^^^ help: try using a `char` instead: `'\"'`

The message should be:

try using a `char` instead: `'"'`

Version

rustc 1.73.0-nightly (0d95f9132 2023-07-26)
binary: rustc
commit-hash: 0d95f9132909ae7c5f2456748d0ffd1c3ba4a8e8
commit-date: 2023-07-26
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Additional Labels

No response

@mondeja mondeja added the C-bug Category: Clippy is not doing the correct thing label Dec 16, 2023
@torfsen
Copy link
Contributor

torfsen commented Dec 27, 2023

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants