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

useless_format: .to_string() suggested where format! could be omitted #3361

Open
matthiaskrgr opened this issue Oct 25, 2018 · 0 comments
Open
Labels
L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@matthiaskrgr
Copy link
Member

clippy 0.0.212 (5afdf8b 2018-10-14)

in this code

fn main() {
    let _: &str = &format!("hello");
}

clippy suggests

warning: useless use of `format!`
 --> src/main.rs:2:20
  |
2 |     let _: &str = &format!("hello");
  |                    ^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"hello".to_string()`
  |

but I think a better solution would be to simply omit the format!() like
let _: &str = &"hello";
or
let _: &str = "hello";

@matthiaskrgr matthiaskrgr added the L-suggestion Lint: Improving, adding or fixing lint suggestions label Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

1 participant