-
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
Generalize string literal inlining into format-like macros #10739
Comments
nyurik
added a commit
to nyurik/rust-clippy
that referenced
this issue
May 4, 2023
A rough draft of rust-lang#10739 implementation. The goal is to allow any kind of literal string arguments to be inlined automatically. ```rust format!("hello {}", "world") // is replaced with format!("hello world") ```
nyurik
added a commit
to nyurik/rust-clippy
that referenced
this issue
Feb 12, 2024
A rough draft of rust-lang#10739 implementation. The goal is to allow any kind of literal string arguments to be inlined automatically. ```rust format!("hello {}", "world") // is replaced with format!("hello world") ```
nyurik
added a commit
to nyurik/rust-clippy
that referenced
this issue
Feb 13, 2024
A rough draft of rust-lang#10739 implementation. The goal is to allow any kind of literal string arguments to be inlined automatically. ```rust format!("hello {}", "world") // is replaced with format!("hello world") ```
nyurik
added a commit
to nyurik/rust-clippy
that referenced
this issue
Aug 25, 2024
A rough draft of rust-lang#10739 implementation. The goal is to allow any kind of literal string arguments to be inlined automatically. ```rust format!("hello {}", "world") // is replaced with format!("hello world") ```
nyurik
added a commit
to nyurik/rust-clippy
that referenced
this issue
Sep 20, 2024
A rough draft of rust-lang#10739 implementation. The goal is to allow any kind of literal string arguments to be inlined automatically. ```rust format!("hello {}", "world") // is replaced with format!("hello world") ```
nyurik
added a commit
to nyurik/rust-clippy
that referenced
this issue
Sep 22, 2024
A rough draft of rust-lang#10739 implementation. The goal is to allow any kind of literal string arguments to be inlined automatically. ```rust format!("hello {}", "world") // is replaced with format!("hello world") ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
A common pattern
format!("...{}...", "foo")
has a number of related lints like:println!("{}", "foo");
writeln!(buf, "{}", "foo");
we also have the uninlined_format_args which is more generic, but focuses on variables, not string literals.
I think these approaches should be combined, either as part of the
uninlined_format_args
, or as a new lint (and possibly sunset/remove the print/write literal?).Mixed cases like
format!("{}{}", foo, "bar")
may cause issues with multiple lints trying to fix the same, so a single lint might be better, but uninlined_format_args focuses on vars, so expanding its scope might be confusing? Although technically this is also inlining an argument, so might be ok?Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: