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

Add a machine-applicable suggestion to "unreachable pattern" #128991

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

Nadrieril
Copy link
Member

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Aug 11, 2024

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Aug 11, 2024
@rust-log-analyzer

This comment has been minimized.

@y21
Copy link
Member

y21 commented Aug 12, 2024

IMO more often than not this lint suggests that there's some other kind of bug and removing the unreachable pattern isn't what the user actually wants, so I'm not sure this should be machine applicable and autofixed by rustfix.

E.g. when using a constant as a pattern but that constant is suddenly no longer in scope (can happen after a refactor):

mod ext {
  pub const BAR: i32 = 1;
}

match 1 {
  BAR => {},
  _ => {}
}

The last arm has an unreachable arm warning, but removing the last arm here is not what the user wants. It's more an issue with the binding pattern that is causing this arm to be unreachable

@lcnr
Copy link
Contributor

lcnr commented Aug 12, 2024

r? compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned lcnr Aug 12, 2024
@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2024
@Nadrieril
Copy link
Member Author

Nadrieril commented Aug 14, 2024

IMO more often than not this lint suggests that there's some other kind of bug and removing the unreachable pattern isn't what the user actually wants

That's fair. I wonder if I should restrict it to the "empty pattern" cases, so it can function as a migration lint but not more. I doubt there'd be false positives there.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 14, 2024
@Nadrieril
Copy link
Member Author

I changed the suggestion to only apply to empty pattern. That way the lint makes the transition to min_exhaustive_patterns easier, without the risk of removing an arm unexpectedly.

@bors
Copy link
Contributor

bors commented Aug 21, 2024

☔ The latest upstream changes (presumably #129359) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

r=me when rebased

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 26, 2024
@Nadrieril
Copy link
Member Author

I'll wait for #129103 to get in first

@bors

This comment was marked as resolved.

@Nadrieril
Copy link
Member Author

@bors r=@compiler-errors

@bors
Copy link
Contributor

bors commented Sep 13, 2024

📌 Commit 1f69638 has been approved by compiler-errors

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 13, 2024
@bors
Copy link
Contributor

bors commented Sep 14, 2024

⌛ Testing commit 1f69638 with merge f9567d0...

@bors
Copy link
Contributor

bors commented Sep 14, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing f9567d0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 14, 2024
@bors bors merged commit f9567d0 into rust-lang:master Sep 14, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 14, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f9567d0): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary 3.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.2% [3.0%, 3.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 758.501s -> 757.31s (-0.16%)
Artifact size: 341.18 MiB -> 341.20 MiB (0.01%)

@Nadrieril Nadrieril deleted the rustfix-unreachable-pattern branch September 15, 2024 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

8 participants