-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
False literal with empty format string warning when printing two macros #2768
Labels
T-macros
Type: Issues with macros and macro expansion
Comments
println!(concat!(crate_name!(), " ", crate_description!())); |
You seem to be right. Tested it on playground. |
Hi! This is acting up again - see playground: println!("{} blah {}", file!(), line!()); causes warning: literal with an empty format string
--> src/main.rs:5:9
|
5 | file!(),
| ^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#print_literal
= note: `#[warn(clippy::print_literal)]` on by default
help: try this
|
4 - "{} blah {}",
4 + "ile!( blah {}",
| |
Can someone reopen this issue? It still is not fixed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Look at the following snippet:
In this code,
crate_name!()
andcrate_description!()
are macros provided by theclap
crate. These two macros return a&str
.This snippet produces the following
clippy
warnings:I believe these warnings are incorrect in this situation, and I don't see a way of improving this statement.
Is this some edge case for which the warning shouldn't be triggered, thus requiring a lint change? Or am I thinking wrong?
Of course, when only a single macro is used it can be printed directly:
However, this snippet uses two macros and one of these implementations wouldn't work as the first parameter isn't a valid format string:
A code example that produces this
clippy
warning can be found on the playground.The warnings might be correct, and I might have missed something. In that case; sorry.
The text was updated successfully, but these errors were encountered: