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

Generalize string literal inlining into format-like macros #10739

Open
nyurik opened this issue May 4, 2023 · 0 comments
Open

Generalize string literal inlining into format-like macros #10739

nyurik opened this issue May 4, 2023 · 0 comments

Comments

@nyurik
Copy link
Contributor

nyurik commented May 4, 2023

Description

A common pattern format!("...{}...", "foo") has a number of related lints like:

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

rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-unknown-linux-gnu
release: 1.69.0
LLVM version: 15.0.7

Additional Labels

No response

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant