Skip to content

Document potential_query_instability allow sites#157367

Closed
JinRudy wants to merge 1 commit into
rust-lang:mainfrom
JinRudy:fix/potential-query-instability-comments
Closed

Document potential_query_instability allow sites#157367
JinRudy wants to merge 1 commit into
rust-lang:mainfrom
JinRudy:fix/potential-query-instability-comments

Conversation

@JinRudy
Copy link
Copy Markdown

@JinRudy JinRudy commented Jun 3, 2026

Closes #84447.

This audits the remaining #[allow(rustc::potential_query_instability)] sites that did not have a local justification.

Changes:

  • Add local comments explaining why unstable hash iteration does not affect the result at the remaining allow sites.
  • Sort unexpected_cfg_name candidates before diagnostic matching so equally good suggestions are selected deterministically.
  • Sort macro transcribe diagnostic buckets before typo matching for deterministic suggestions.

Verification:

  • git diff --check
  • local scan for allow(rustc::potential_query_instability) sites without adjacent comments: no output
  • ./x fmt --check
  • ./x test tidy
  • ./x check compiler/rustc_attr_parsing compiler/rustc_expand compiler/rustc_interface compiler/rustc_codegen_ssa compiler/rustc_mir_build compiler/rustc_mir_dataflow

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 3, 2026

The Clippy subtree was changed

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred in check-cfg diagnostics

cc @Urgau

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 3, 2026

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @folkertdev (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 17 candidates

#[allow(rustc::potential_query_instability)]
let possibilities: Vec<Symbol> = sess.check_config.expecteds.keys().copied().collect();
let mut possibilities: Vec<Symbol> = sess.check_config.expecteds.keys().copied().collect();
possibilities.sort_by(|a, b| a.as_str().cmp(b.as_str()));
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT all uses below either don't care about order or already sort it.

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I removed the extra sort here and moved the justification into the allow reason.

let mut repeatables = Vec::new();
let mut non_repeatables = Vec::new();

// The buckets are sorted by symbol before diagnostic matching below.
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sorting is not strictly necessary given that find_best_match_for_name will already sort when there are multiple options with the same priority.

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I removed the additional sorting and kept this as an allow(..., reason = ...) justification.

@folkertdev
Copy link
Copy Markdown
Contributor

r? bjorn3

@rustbot rustbot assigned bjorn3 and unassigned folkertdev Jun 3, 2026
(name, name_span): (Symbol, Span),
value: Option<(Symbol, Span)>,
) -> errors::UnexpectedCfgName {
// Sort before diagnostic matching so equally good suggestions are chosen deterministically.
Copy link
Copy Markdown
Contributor

@ada4a ada4a Jun 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put this and other justifications into #[allow(rustc::potential_query_instability, reason = "<here>")]?

View changes since the review

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I moved the justifications into #[allow(rustc::potential_query_instability, reason = ...)] attributes across the touched sites.

- 为 potential_query_instability allow 补充 reason

- 按 review 移除不必要的诊断候选排序
@JinRudy JinRudy force-pushed the fix/potential-query-instability-comments branch from 0b7064a to 7767520 Compare June 3, 2026 11:25
@JinRudy
Copy link
Copy Markdown
Author

JinRudy commented Jun 3, 2026

Addressed the review feedback:

  • moved the justifications into #[allow(..., reason = ...)] at the touched sites
  • removed the additional diagnostic candidate sorting from check_cfg.rs and transcribe.rs

Verification:

  • git diff --check
  • ./x fmt --check
  • ./x test tidy
  • ./x check compiler/rustc_attr_parsing compiler/rustc_expand compiler/rustc_interface compiler/rustc_codegen_ssa compiler/rustc_mir_build compiler/rustc_mir_dataflow src/tools/clippy

@rustbot review

@oli-obk
Copy link
Copy Markdown
Contributor

oli-obk commented Jun 3, 2026

Hi,

For the last few months we have been receiving an increased amount of LLM generated contributions. We have no way to distinguish your PR from other generated ones and thus unfortunately need to put some additional barriers for contributions in you way.

We are a community of contributors, not just a code repository. We focus on contributors who desire to stay around and put in the work to produce high quality contributions or learn to do so.

We are thus warning you as per our policies (1) and contribution standards (2) to stop generating PRs and comments.

To make sure you can learn how to contribute, we invite you to join https://rust-lang.zulipchat.com/join/rlfvpemsaacs3pfi6kwqnqjb/ and start a thread asking for a mentor.

Thanks for understanding

Oli in the name of the mod team

@oli-obk oli-obk closed this Jun 3, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) T-clippy Relevant to the Clippy team. 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.

Audit and handle remaining cases of rustc::potential_query_instability lint (iterating HashMaps)

6 participants