Skip to content

Add fix for str_to_string #12768

Closed
Closed
@Wilfred

Description

@Wilfred

Description

Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=810bfbe41db9fada1864da9143f8f4e5

#![warn(clippy::str_to_string)]

fn main() {
    let _ = "foo".to_string();
}
warning: `to_string()` called on a `&str`
 --> src/main.rs:4:13
  |
4 |     let _ = "foo".to_string();
  |             ^^^^^^^^^^^^^^^^^
  |
  = help: consider using `.to_owned()`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
note: the lint level is defined here

This feels like a great fit for a machine applicable fix.

Version

$ rustc -Vv       
rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6

Additional Labels

C-enhancement

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions