-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix in clippy::unchecked_duration_subtraction produces unclearer panic #10061
Copy link
Copy link
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesC-questionCategory: QuestionsCategory: QuestionsI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveL-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingC-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesCategory: Enhancement of lints, like adding more cases or adding help messagesC-questionCategory: QuestionsCategory: QuestionsI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveL-correctnessLint: Belongs in the correctness lint groupLint: Belongs in the correctness lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
The fix for a case of
clippy::unchecked_duration_substractionseems to result in a less helpful panic message then without applying the fix.Example
Considering the reproducer; without the fix we get the following runtime panic error:
which is very descriptive on what happened.
Applying the fix, we get a way less descriptive error:
It's way harder from this to figure out what happened. So I think one would be better off just leaving the line alone. Considering this either don't apply a fix or move the lint to the pedantic group, but that's just from this little experience. Maybe I missed something.
Linking the issue in which we discovered this problem: libp2p/rust-libp2p#3220 (comment)
Reproducer
I tried this code:
I expected to see this happen:
No changes were applied.
Instead, this happened:
Got changed to:
Version
Additional Labels
@rustbot label +L-suggestion +L-correctness +I-false-positive +C-bug +C-question +C-enhancement