Skip to content

Fix question_mark suggests wrongly when match scrutinee is a reference type#17431

Open
profetia wants to merge 1 commit into
rust-lang:masterfrom
profetia:issue17386
Open

Fix question_mark suggests wrongly when match scrutinee is a reference type#17431
profetia wants to merge 1 commit into
rust-lang:masterfrom
profetia:issue17386

Conversation

@profetia

@profetia profetia commented Jul 18, 2026

Copy link
Copy Markdown
Member

Closes #17386

question_mark suggests wrongly when match scrutinee is a reference type like &Option<T>, since ? is not implemented on references.

changelog: [question_mark] fix wrong suggestions when match scrutinee is a reference type.

@rustbot rustbot added the S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. label Jul 18, 2026
@rustbot

rustbot commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request. A reviewer will take a look after it receives 2 community reviews.

In the meantime, we would highly appreciate if you could try to review any of PRs waiting on community reviews.

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 18, 2026
Comment thread tests/ui/question_mark.rs
Some(it) => it,
None => return None,
};
// `match &v` still produces `&v?`, unchanged

@Gri-ffin Gri-ffin Jul 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't this cause an error if it's used after the match?

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-community-reviews Status: This is awaiting for positive reviews from the community before a maintainer is assigned. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Since 1.97.0, clippy::question_mark fires on code matching on &Option

3 participants