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

never patterns: lower never patterns to Unreachable in MIR #123332

Merged
merged 2 commits into from
May 7, 2024

Conversation

Nadrieril
Copy link
Member

This lowers a ! pattern to "goto Unreachable". Ideally I'd like to read from the place to make it clear that the UB is coming from an invalid value, but that's tricky so I'm leaving it for later.

r? @compiler-errors how do you feel about a lil bit of MIR lowering

@Nadrieril Nadrieril added the F-never_patterns `#![feature(never_patterns)]` label Apr 1, 2024
@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 Apr 1, 2024
@compiler-errors
Copy link
Member

hmmmm maybe r? @matthewjasper instead?

happy to review it if matthewjasper is unavailable tho

@bors

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment on lines -1 to -12
//@ known-bug: #120421
//@ compile-flags: -Zlint-mir

#![feature(never_patterns)]

enum Void {}

fn main() {
let res_void: Result<bool, Void> = Ok(true);

for (Ok(mut _x) | Err(!)) in [res_void] {}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I deleted this because it felt like an entirely artificial construct and I couldn't find a sensible name to keep it under. What surprises me is that it took something so complicated to break the feature back when it was explicitly not lowering to MIR correctly. It's probably not minimal

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 7, 2024

📌 Commit 57e8aeb has been approved by matthewjasper

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 May 7, 2024
@bors
Copy link
Contributor

bors commented May 7, 2024

⌛ Testing commit 57e8aeb with merge 0f40f14...

@bors
Copy link
Contributor

bors commented May 7, 2024

☀️ Test successful - checks-actions
Approved by: matthewjasper
Pushing 0f40f14 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 7, 2024
@bors bors merged commit 0f40f14 into rust-lang:master May 7, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 7, 2024
@Nadrieril Nadrieril deleted the testkind-never branch May 7, 2024 18:44
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0f40f14): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

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)
- - 0
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 1
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

Cycles

Results

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)
- - 0
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

Binary size

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

Bootstrap: 676.002s -> 676.385s (0.06%)
Artifact size: 315.77 MiB -> 315.93 MiB (0.05%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-never_patterns `#![feature(never_patterns)]` 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.

7 participants