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

FN useless_format: fmt::DIsplay impl #6773

Closed
matthiaskrgr opened this issue Feb 21, 2021 · 1 comment
Closed

FN useless_format: fmt::DIsplay impl #6773

matthiaskrgr opened this issue Feb 21, 2021 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@matthiaskrgr
Copy link
Member

Lint name: useless_format

I tried this code:

use std::fmt;

struct S {}

impl fmt::Display for S {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "")
    }
}

fn main() {
    let x: String = format!("{}", S {});
    // could just be:
    // let x = S{}.to_string();
}

IMO clippy should issue a useless_format warning here, I'm not sure why it does not.

Meta

  • cargo clippy -V: clippy 0.1.52 (07194ff 2021-02-10)
rustc 1.52.0-nightly (07194ffcd 2021-02-10)
binary: rustc
commit-hash: 07194ffcd25b0871ce560b9f702e52db27ac9f77
commit-date: 2021-02-10
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1
@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Feb 21, 2021
@camsteffen
Copy link
Contributor

Duplicate of #3753

@camsteffen camsteffen marked this as a duplicate of #3753 Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

2 participants