Skip to content

Suggest >= for => typo in closure and call argument positions#158376

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ChronoCoders:diag-eq-gt-closure-arg
Jun 27, 2026
Merged

Suggest >= for => typo in closure and call argument positions#158376
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ChronoCoders:diag-eq-gt-closure-arg

Conversation

@ChronoCoders

@ChronoCoders ChronoCoders commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

The parser suggests replacing => with >= when it looks like a typo in a comparison, but it skipped the suggestion whenever a comma was an expected token. That excluded closure bodies used as call arguments, such as iter.position(|x| x => &y), which is the case reported in #149805.

The comma exclusion was there to avoid suggesting >= for a missing comma between match arms, where => is a real arm arrow. Those cases have a close brace in the expected token set, while the comparison cases do not, so this gates on the close brace instead of the comma. The existing if/let/match cases keep working, and the missing-comma-in-match suggestion is unaffected.

Fixes #149805

@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@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 Jun 24, 2026
@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @chenyukang (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 20 candidates

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ChronoCoders ChronoCoders force-pushed the diag-eq-gt-closure-arg branch from 5086a49 to 5b4d30a Compare June 24, 2026 20:22
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ChronoCoders ChronoCoders force-pushed the diag-eq-gt-closure-arg branch from 5b4d30a to 494adf0 Compare June 24, 2026 20:28
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ChronoCoders ChronoCoders force-pushed the diag-eq-gt-closure-arg branch from 494adf0 to 9d5ebef Compare June 24, 2026 22:37
@rustbot

This comment has been minimized.

The parser suggests replacing `=>` with `>=` when it looks like a typo
in a comparison, but it skipped the suggestion whenever a comma was an
expected token. That excluded closure bodies used as call arguments,
such as `iter.position(|x| x => &y)`, which is the case in rust-lang#149805.

The comma exclusion was there to avoid suggesting `>=` for a missing
comma between match arms, where `=>` is a real arm arrow. Those cases
have a close brace in the expected token set, while the comparison
cases do not, so gate on the close brace instead of the comma.

Fixes rust-lang#149805
@ChronoCoders ChronoCoders force-pushed the diag-eq-gt-closure-arg branch from 9d5ebef to b6a4c3a Compare June 25, 2026 20:35
@rustbot

rustbot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@chenyukang

Copy link
Copy Markdown
Member

Thanks!
@bors r=chenyukang

@rust-bors

rust-bors Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b6a4c3a has been approved by chenyukang

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot 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 Jun 26, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 26, 2026
…g, r=chenyukang

Suggest `>=` for `=>` typo in closure and call argument positions

The parser suggests replacing `=>` with `>=` when it looks like a typo in a comparison, but it skipped the suggestion whenever a comma was an expected token. That excluded closure bodies used as call arguments, such as `iter.position(|x| x => &y)`, which is the case reported in rust-lang#149805.

The comma exclusion was there to avoid suggesting `>=` for a missing comma between match arms, where `=>` is a real arm arrow. Those cases have a close brace in the expected token set, while the comparison cases do not, so this gates on the close brace instead of the comma. The existing `if`/`let`/`match` cases keep working, and the missing-comma-in-match suggestion is unaffected.

Fixes rust-lang#149805
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #158438 (Use rigidness marker in fast_reject)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158446 (Update Enzyme submodule)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 26, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #158438 (Use rigidness marker in fast_reject)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158446 (Update Enzyme submodule)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #153697 (Add arg splat experiment initial tuple impl)
 - #158360 (Various borrowck cleanups and param_env/opaque_types_defined_by query simplifications for typeck children)
 - #158438 (Use rigidness marker in fast_reject)
 - #157127 (cg_LLVM: Stop needing an alloca for volatile loads)
 - #158376 (Suggest `>=` for `=>` typo in closure and call argument positions)
 - #158185 (perf: Make stable_crate_ids reads lock-free after crate loading)
 - #158244 (Attribute docs `deprecated` , `warn`, `allow`, `cfg`, `deny`, and `forbid` )
 - #158355 (Fixup the refactoring errors in #156246)
 - #158361 (Move `check_ffi_pure` into the attribute parser)
 - #158382 (Add safety section for SliceIndex::get_unchecked(mut))
 - #158399 (std: truncate thread names on NetBSD)
 - #158418 (Eliminate double length check in `Vec::into_array`)
 - #158430 (Guard clone suggestion against empty obligation errors)
 - #158446 (Update Enzyme submodule)
 - #158448 (Cleanup `NumBuffer` comment and replace `ilog(10)` with `ilog10()`)
@rust-bors rust-bors Bot merged commit f5c2bd7 into rust-lang:main Jun 27, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 27, 2026
rust-timer added a commit that referenced this pull request Jun 27, 2026
Rollup merge of #158376 - ChronoCoders:diag-eq-gt-closure-arg, r=chenyukang

Suggest `>=` for `=>` typo in closure and call argument positions

The parser suggests replacing `=>` with `>=` when it looks like a typo in a comparison, but it skipped the suggestion whenever a comma was an expected token. That excluded closure bodies used as call arguments, such as `iter.position(|x| x => &y)`, which is the case reported in #149805.

The comma exclusion was there to avoid suggesting `>=` for a missing comma between match arms, where `=>` is a real arm arrow. Those cases have a close brace in the expected token set, while the comparison cases do not, so this gates on the close brace instead of the comma. The existing `if`/`let`/`match` cases keep working, and the missing-comma-in-match suggestion is unaffected.

Fixes #149805
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.

Diagnosis of incorrect operator syntax could be more helpful

4 participants