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

write_literal breaks raw strings #13959

Open
ChrisJefferson opened this issue Jan 7, 2025 · 0 comments
Open

write_literal breaks raw strings #13959

ChrisJefferson opened this issue Jan 7, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@ChrisJefferson
Copy link

ChrisJefferson commented Jan 7, 2025

Summary

write_literal doesn't correctly handle raw strings.

Reproducer

I tried this code:

writeln!(
                pre,
                "{}",
                r#"
$#CON colcheck "Use the sum of col {{index[0]}} for {{index[1]}}"
find colcheck: matrix indexed by [int(1..width), ALLRANGE] of bool"#
                "
            )?;

I expected write_literal to rewrite this to valid Rust. Instead, this happened:

writeln!(
                pre,
                "
$#CON colcheck \\"Use the sum of col {{{{index[0]}}}} for {{{{index[1]}}}}\\"
find colcheck: matrix indexed by [int(1..width), ALLRANGE] of bool"
            )?;

My preference would be to just leave the raw string as is, I can't see why that wouldn't be the easist, and least-suprising option.

Version

rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1

Additional Labels

No response

@ChrisJefferson ChrisJefferson added the C-bug Category: Clippy is not doing the correct thing label Jan 7, 2025
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

No branches or pull requests

1 participant