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

use_debug in Debug implementation #5039

Closed
jsim2010 opened this issue Jan 10, 2020 · 1 comment · Fixed by #5047
Closed

use_debug in Debug implementation #5039

jsim2010 opened this issue Jan 10, 2020 · 1 comment · Fixed by #5047
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@jsim2010
Copy link

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.

@JohnTitor
Copy link
Member

I think it's a regression caused by #2949.

@JohnTitor JohnTitor added the C-bug Category: Clippy is not doing the correct thing label Jan 11, 2020
@JohnTitor JohnTitor assigned JohnTitor and unassigned JohnTitor Jan 11, 2020
@bors bors closed this as completed in f44181e Mar 3, 2020
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants