Skip to content

use_debug in Debug implementation #5039

Closed
@jsim2010

Description

@jsim2010

In my opinion, clippy::use_debug should allow the debug format "{:?}" within Debug trait implementations. This seems to be backed up by the comment in the test here:

impl Debug for Foo {
fn fmt(&self, f: &mut Formatter) -> Result {
// ok, we can use `Debug` formatting in `Debug` implementations
write!(f, "{:?}", 42.718)
}
}

However, the expected output actually expects an error in this case

error: use of `Debug`-based formatting
--> $DIR/print.rs:18:19
|
LL | write!(f, "{:?}", 42.718)
| ^^^^^^

I propose that this error be removed from the test and the code adjusted to allow for debug formatting in Debug. If this is not desired, then the comment in tests/ui/print.rs should be removed to avoid confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions