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

Don't check match scrutinee of postfix match for unused parens #123096

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Mar 26, 2024

We only check the scrutinees of block-like constructs and a few others (return/index/assign/method calls). Just don't do it for postfix match at all.

Fixes #123064

r? 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 Mar 26, 2024
@@ -865,7 +865,9 @@ trait UnusedDelimLint {
(iter, UnusedDelimsCtx::ForIterExpr, true, None, Some(body.span.lo()), true)
}

Match(ref head, ..) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
Match(ref head, _, ast::MatchKind::Prefix)
Copy link
Member

@fmease fmease Mar 28, 2024

Choose a reason for hiding this comment

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

I was about to say that this is too coarse-grained since it leads to us no longer flagging (0).match {} or (f()).match {} but after a quick check I realized that we currently don't flag (f()).await, (0).f() and (f()).g() either.

I'm gonna add an item to my TODO list to open an issue for all of these cases unless there already exists one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'd prefer if those were implemented in a principled way. This PR doesn't add more inconsistency.

@fmease
Copy link
Member

fmease commented Mar 28, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 28, 2024

📌 Commit 950b40f has been approved by fmease

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 Mar 28, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 28, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#123063 (Function ABI is irrelevant for reachability)
 - rust-lang#123096 (Don't check match scrutinee of postfix match for unused parens)
 - rust-lang#123146 (Use compiletest directives instead of manually checking TARGET / tools)
 - rust-lang#123160 (remove `def_id_to_node_id` in ast lowering)
 - rust-lang#123162 (Correctly get complete intra-doc link data)
 - rust-lang#123164 (Bump Unicode printables to version 15.1, align to unicode_data)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 69cfe80 into rust-lang:master Mar 28, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 28, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 28, 2024
Rollup merge of rust-lang#123096 - compiler-errors:postfix-match-parens, r=fmease

Don't check match scrutinee of postfix match for unused parens

We only check the scrutinees of block-like constructs and a few others (return/index/assign/method calls). Just don't do it for postfix match at all.

Fixes rust-lang#123064

r? fmease
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.

Postfix match: Unexpected unused_parens warning when LHS contained parenthesis
4 participants