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

Add fix for str_to_string #12768

Open
Wilfred opened this issue May 6, 2024 · 0 comments
Open

Add fix for str_to_string #12768

Wilfred opened this issue May 6, 2024 · 0 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@Wilfred
Copy link
Contributor

Wilfred commented May 6, 2024

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

@y21 y21 added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

2 participants