-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
remove deduplicate-diagnostics=no
in suspicious_operation_groupings.stderr
#13266
base: master
Are you sure you want to change the base?
remove deduplicate-diagnostics=no
in suspicious_operation_groupings.stderr
#13266
Conversation
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` | ||
|
||
error: this sequence of operators looks suspiciously like a bug | ||
--> tests/ui/suspicious_operation_groupings.rs:88:19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is identical to the one at line 23, so it can be safely removed.
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` | ||
|
||
error: this sequence of operators looks suspiciously like a bug | ||
--> tests/ui/suspicious_operation_groupings.rs:136:42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is identical to the one at line 77 91, so it can be safely removed.
edit: I made a mistake with the line numbers in the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would indicate there's a place that should be using span_lint_hir_and_then
but is not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this lint, span_lint_and_sugg is used, but what is the difference between it and span_lint_hir_and_then?
It seems to me that specifying hir may not be necessary in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It tells the compiler at what node the lint is being emitted for the purposes of #[allow]
/etc, if not specified it will be the node that check_xxx
was called on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me confirm my understanding. I think this duplicate error output is coming from both sides of binOp.
I still don't understand the relationship between solving this problem and the need to use span_lint_hir_and_then
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this wouldn't work, but usually this is done by early returning if the other check successfully lints?
On span_lint_hir_and_then
, this will need to use it one day as it doesn't lint on the exact node in check_expr
, however that'd require rewriting the whole lint. I'm curious how that'd fix it? It does hash the diagnostic it's about to emit in emit_diagnostic
so maybe the node differing causes it to emit regardless of deduplicate-diagnostics
, but I'd like confirmation on that
r? rust-lang/clippy |
Yeah, I don't think this is the right fix. We should use the right spans whilst linting. Why is this lint emitting duplicate diagnostics? |
☔ The latest upstream changes (presumably #13440) made this pull request unmergeable. Please resolve the merge conflicts. |
a part of #12379.
In this PR, we will update the lint to store already outputted Spans internally to prevent suspicious_operation_groupings from outputting the same error multiple times.
changelog:
Fixed duplicate errors in suspicious_operation_groupings.