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