-
Notifications
You must be signed in to change notification settings - Fork 13k
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 a never arm to an unreachable terminator #120758
Changes from all commits
809a253
c0c83c1
95d881d
97ad3cb
3717857
065ccb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,19 +570,9 @@ impl<'hir> LoweringContext<'_, 'hir> { | |
self.dcx().emit_err(NeverPatternWithGuard { span: g.span }); | ||
} | ||
|
||
// We add a fake `loop {}` arm body so that it typecks to `!`. | ||
// FIXME(never_patterns): Desugar into a call to `unreachable_unchecked`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your PR description doesn't explain the challenges of just lowering a call to, for example, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, we discussed this on Zulip. Intrinsics don't exist at the hir level, they have to be constructed during mir lowering/codegen, so that's essentially what I'm doing. Alternatives would be to make |
||
let block = self.arena.alloc(hir::Block { | ||
stmts: &[], | ||
expr: None, | ||
hir_id: self.next_id(), | ||
rules: hir::BlockCheckMode::DefaultBlock, | ||
span, | ||
targeted_by_break: false, | ||
}); | ||
self.arena.alloc(hir::Expr { | ||
hir_id: self.next_id(), | ||
kind: hir::ExprKind::Loop(block, None, hir::LoopSource::Loop, span), | ||
kind: hir::ExprKind::Unreachable, | ||
span, | ||
}) | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just give
ExprKind::Unreachable
a dummy precedence? Like, just give it the same precedence asLit
or something.