-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Don't hash lints differently to non-lints. #120490
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
ah, my first rustc PR left this surprising behavior 😅 . I think we may need to investigate why two diagnostics with the same primary message( Give this extra diagnostic will still make users confused, even the note is different, but the second one didn't give more extra information. |
oh, I missed it, they are different line of code, ignore me. |
I think emitting both errors is fine here. I'd say this is rather an issue on the error creation itself. I think it would be better, if the |
☔ The latest upstream changes (presumably #120491) made this pull request unmergeable. Please resolve the merge conflicts. |
error: method's name is the same as an existing method in a trait | ||
--> $DIR/same_name_method.rs:75:13 | ||
| | ||
LL | fn foo() {} | ||
| ^^^^^^^^^^^ | ||
| | ||
note: existing `foo` defined here | ||
--> $DIR/same_name_method.rs:81:9 | ||
| | ||
LL | impl T2 for S {} | ||
| ^^^^^^^^^^^^^^^^ |
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.
You need to modify the .rs
file as well, don't you? Can you locally run python ./x.py test src/tools/clippy
to confirm this is actually passing now?
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.
Yeah, I ran the clippy tests before creating the PR, it works without changing the .rs
file. If I add the second ERROR
line it also works. And if I add a third ERROR
line then the test fails.
So I have updated with the second ERROR
added, because that's what one would expect. I don't know why it was working without the second ERROR.
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.
We don't enforce ERROR
annotations yet. Thanks for adding it!
r=me |
`Diagnostic::keys`, which is used for hashing and equating diagnostics, has a surprising behaviour: it ignores children, but only for lints. This was added in rust-lang#88493 to fix some duplicated diagnostics, but it doesn't seem necessary any more. This commit removes the special case and only four tests have changed output, with additional errors. And those additional errors aren't exact duplicates, they're just similar. For example, in src/tools/clippy/tests/ui/same_name_method.rs we currently have this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:79:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ ``` and with this change we also get this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:81:9 | LL | impl T2 for S {} | ^^^^^^^^^^^^^^^^ ``` I think printing this second argument is reasonable, possibly even preferable to hiding it. And the other cases are similar.
90b68e2
to
4225a1e
Compare
I rebased and added the second @bors r=estebank |
…estebank Don't hash lints differently to non-lints. `Diagnostic::keys`, which is used for hashing and equating diagnostics, has a surprising behaviour: it ignores children, but only for lints. This was added in rust-lang#88493 to fix some duplicated diagnostics, but it doesn't seem necessary any more. This commit removes the special case and only four tests have changed output, with additional errors. And those additional errors aren't exact duplicates, they're just similar. For example, in src/tools/clippy/tests/ui/same_name_method.rs we currently have this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:79:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ ``` and with this change we also get this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:81:9 | LL | impl T2 for S {} | ``` I think printing this second argument is reasonable, possibly even preferable to hiding it. And the other cases are similar. r? `@estebank`
Rollup of 12 pull requests Successful merges: - rust-lang#120207 (check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test) - rust-lang#120321 (pattern_analysis: cleanup the contexts) - rust-lang#120323 (On E0277 be clearer about implicit `Sized` bounds on type params and assoc types) - rust-lang#120355 (document `FromIterator for Vec` allocation behaviors) - rust-lang#120396 (Account for unbounded type param receiver in suggestions) - rust-lang#120430 (std: thread_local::register_dtor fix proposal for FreeBSD.) - rust-lang#120435 (Suggest name value cfg when only value is used for check-cfg) - rust-lang#120470 (Mark "unused binding" suggestion as maybe incorrect) - rust-lang#120472 (Make duplicate lang items fatal) - rust-lang#120490 (Don't hash lints differently to non-lints.) - rust-lang#120495 (Remove the `abi_amdgpu_kernel` feature) - rust-lang#120501 (rustdoc: Correctly handle attribute merge if this is a glob reexport) Failed merges: - rust-lang#120346 (hir: Refactor getters for owner nodes) r? `@ghost` `@rustbot` modify labels: rollup
Got this failure in rollup, which at a glance looks like it's coming from this PR. |
Welp, apparently came from a different PR |
Rollup of 9 pull requests Successful merges: - rust-lang#120207 (check `RUST_BOOTSTRAP_CONFIG` in `profile_user_dist` test) - rust-lang#120321 (pattern_analysis: cleanup the contexts) - rust-lang#120355 (document `FromIterator for Vec` allocation behaviors) - rust-lang#120430 (std: thread_local::register_dtor fix proposal for FreeBSD.) - rust-lang#120469 (Provide more context on derived obligation error primary label) - rust-lang#120472 (Make duplicate lang items fatal) - rust-lang#120490 (Don't hash lints differently to non-lints.) - rust-lang#120495 (Remove the `abi_amdgpu_kernel` feature) - rust-lang#120501 (rustdoc: Correctly handle attribute merge if this is a glob reexport) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120490 - nnethercote:Diagnostic-hashing, r=estebank Don't hash lints differently to non-lints. `Diagnostic::keys`, which is used for hashing and equating diagnostics, has a surprising behaviour: it ignores children, but only for lints. This was added in rust-lang#88493 to fix some duplicated diagnostics, but it doesn't seem necessary any more. This commit removes the special case and only four tests have changed output, with additional errors. And those additional errors aren't exact duplicates, they're just similar. For example, in src/tools/clippy/tests/ui/same_name_method.rs we currently have this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:79:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ ``` and with this change we also get this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:81:9 | LL | impl T2 for S {} | ``` I think printing this second argument is reasonable, possibly even preferable to hiding it. And the other cases are similar. r? `@estebank`
…estebank Don't hash lints differently to non-lints. `Diagnostic::keys`, which is used for hashing and equating diagnostics, has a surprising behaviour: it ignores children, but only for lints. This was added in rust-lang#88493 to fix some duplicated diagnostics, but it doesn't seem necessary any more. This commit removes the special case and only four tests have changed output, with additional errors. And those additional errors aren't exact duplicates, they're just similar. For example, in src/tools/clippy/tests/ui/same_name_method.rs we currently have this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:79:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ ``` and with this change we also get this error: ``` error: method's name is the same as an existing method in a trait --> $DIR/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here --> $DIR/same_name_method.rs:81:9 | LL | impl T2 for S {} | ``` I think printing this second argument is reasonable, possibly even preferable to hiding it. And the other cases are similar. r? `@estebank`
Diagnostic::keys
, which is used for hashing and equating diagnostics, has a surprising behaviour: it ignores children, but only for lints. This was added in #88493 to fix some duplicated diagnostics, but it doesn't seem necessary any more.This commit removes the special case and only four tests have changed output, with additional errors. And those additional errors aren't exact duplicates, they're just similar. For example, in src/tools/clippy/tests/ui/same_name_method.rs we currently have this error:
and with this change we also get this error:
I think printing this second argument is reasonable, possibly even preferable to hiding it. And the other cases are similar.
r? @estebank