Add a comparison between match *self and intrinsics::unreachable()
This commit is contained in:
parent
f441adc89a
commit
56633b3f51
1 changed files with 3 additions and 2 deletions
|
@ -1149,8 +1149,9 @@ impl<'a> MethodDef<'a> {
|
|||
let unify_fieldless_variants =
|
||||
self.fieldless_variants_strategy == FieldlessVariantsStrategy::Unify;
|
||||
|
||||
// For zero-variant enum, this function body is unreachable.
|
||||
// Generate `match *self {}`.
|
||||
// For zero-variant enum, this function body is unreachable. Generate
|
||||
// `match *self {}`. This produces machine code identical to `unsafe {
|
||||
// core::intrinsics::unreachable() }` while being safe and stable.
|
||||
if variants.is_empty() {
|
||||
selflike_args.truncate(1);
|
||||
let match_arg = cx.expr_deref(span, selflike_args.pop().unwrap());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue