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

Wrong print_literal/write_literal suggestion with byte literal #8615

Closed
asrcpq opened this issue Apr 1, 2022 · 0 comments · Fixed by #8518
Closed

Wrong print_literal/write_literal suggestion with byte literal #8615

asrcpq opened this issue Apr 1, 2022 · 0 comments · Fixed by #8518
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@asrcpq
Copy link

asrcpq commented Apr 1, 2022

Summary

When formatting with byte literals, e.g. println!("Ascii code of letter e is {}", b'e');

clippy gives

warning: literal with an empty format string
 --> src/main.rs:2:43
  |
2 |     println!("Ascii code of letter e is {}", b'e');
  |                                              ^^^^
  |
  = note: `#[warn(clippy::print_literal)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#print_literal
help: try this
  |
2 -     println!("Ascii code of letter e is {}", b'e');
2 +     println!("Ascii code of letter e is e");
  | 

However, the output changed by this modification, from
Ascii code of letter e is 101
to
Ascii code of letter e is e

Reproducer

println!("Ascii code of letter e is {}", b'e');

Version

rustc 1.59.0 (9d1b2106e 2022-02-23)
binary: rustc
commit-hash: 9d1b2106e23b1abd32fce1f17267604a5102f57a
commit-date: 2022-02-23
host: x86_64-unknown-linux-gnu
release: 1.59.0
LLVM version: 13.0.0

Additional Labels

No response

@asrcpq asrcpq added the C-bug Category: Clippy is not doing the correct thing label Apr 1, 2022
@bors bors closed this as completed in 2ddbc86 Sep 14, 2022
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.

1 participant