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

Sort lint_groups in no_lint_suggestion #106008

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

uweigand
Copy link
Contributor

The no_lint_suggestion routine passes a vector of lint group names to find_best_match_for_name. That routine depends on the sort order of its input vector, which matters in case multiple inputs are at the same Levenshtein distance to the target name.

However, no_lint_suggestion currently just passes lint_groups.keys() as input vector - this is sorted in hash value order, which is not guaranteed to be stable, and in fact differs between big- and little-endian host platforms, causing test failures on s390x.

To fix this, always sort the lint groups before using their names as input to find_best_match_for_name. In doing so, prefer non- deprecated lint group names over deprecated ones, and then use alphabetical order.

Fixes #105379

@rustbot
Copy link
Collaborator

rustbot commented Dec 21, 2022

r? @Nilstrieb

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 21, 2022
@Noratrieb
Copy link
Member

Ah, the dangers of HashMap. Thanks, also good catch with the deprecated!

I think it makes more sense to just filter out deprecated lint groups, they are not what people should use so we shouldn't suggest them.

The no_lint_suggestion routine passes a vector of lint group names
to find_best_match_for_name.  That routine depends on the sort
order of its input vector, which matters in case multiple inputs
are at the same Levenshtein distance to the target name.

However, no_lint_suggestion currently just passes lint_groups.keys()
as input vector - this is sorted in hash value order, which is not
guaranteed to be stable, and in fact differs between big- and
little-endian host platforms, causing test failures on s390x.

To fix this, always sort the lint groups before using their names
as input to find_best_match_for_name.  In addition, deprecated
lint groups should never be suggested, so filter those out.

Fixes rust-lang#105379
@uweigand
Copy link
Contributor Author

I think it makes more sense to just filter out deprecated lint groups, they are not what people should use so we shouldn't suggest them.

Agreed, patch updated accordingly.

@Noratrieb
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 21, 2022

📌 Commit 30fbfd5 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 21, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 22, 2022
Rollup of 8 pull requests

Successful merges:

 - rust-lang#105584 (add assert messages if chunks/windows are length 0)
 - rust-lang#105602 (interpret: add read_machine_[ui]size convenience methods)
 - rust-lang#105824 (str.lines() docstring: clarify that line endings are not returned)
 - rust-lang#105980 (Refer to "Waker" rather than "RawWaker" in `drop` comment)
 - rust-lang#105986 (Fix typo in reading_half_a_pointer.rs)
 - rust-lang#105995 (Add regression test for rust-lang#96530)
 - rust-lang#106008 (Sort lint_groups in no_lint_suggestion)
 - rust-lang#106014 (Add comment explaining what the scrape-examples-toggle.goml GUI test is about)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4c2dd75 into rust-lang:master Dec 22, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 22, 2022
@uweigand uweigand deleted the s390x-lintgroup-order branch December 22, 2022 09:08
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…Nilstrieb

Sort lint_groups in no_lint_suggestion

The no_lint_suggestion routine passes a vector of lint group names to find_best_match_for_name.  That routine depends on the sort order of its input vector, which matters in case multiple inputs are at the same Levenshtein distance to the target name.

However, no_lint_suggestion currently just passes lint_groups.keys() as input vector - this is sorted in hash value order, which is not guaranteed to be stable, and in fact differs between big- and little-endian host platforms, causing test failures on s390x.

To fix this, always sort the lint groups before using their names as input to find_best_match_for_name.  In doing so, prefer non- deprecated lint group names over deprecated ones, and then use alphabetical order.

Fixes rust-lang#105379
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
Rollup of 8 pull requests

Successful merges:

 - rust-lang#105584 (add assert messages if chunks/windows are length 0)
 - rust-lang#105602 (interpret: add read_machine_[ui]size convenience methods)
 - rust-lang#105824 (str.lines() docstring: clarify that line endings are not returned)
 - rust-lang#105980 (Refer to "Waker" rather than "RawWaker" in `drop` comment)
 - rust-lang#105986 (Fix typo in reading_half_a_pointer.rs)
 - rust-lang#105995 (Add regression test for rust-lang#96530)
 - rust-lang#106008 (Sort lint_groups in no_lint_suggestion)
 - rust-lang#106014 (Add comment explaining what the scrape-examples-toggle.goml GUI test is about)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint suggestions depend on host endianness
4 participants