Don't lint unnecessary_debug_formatting
in tests
#14345
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
The issues checked for by
unnecessary_debug_formatting
(see #12674) don't apply to tests — tests are, in general, often going to printDebug
format when they fail, whether explicitly or via.unwrap()
or an internal assertion of the code under test, and their output is not user-facing output. So, satisfying theunnecessary_debug_formatting
lint is usually wasted effort in tests; the lint should automatically skip tests.Or, instead, it could be disabled in the format strings of the
assert!()
family of macros. I think this is a less good idea, because an assertion might fire while a program is in use, in which case the amount and format of information in it is relevant, but one could argue that in context ofdebug-fmt-detail
, most asserts should be expected to be badly formatted anyway.Lint Name
unnecessary_debug_formatting
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: No lint.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: