File tree 1 file changed +6
-5
lines changed
compiler/rustc_builtin_macros/src/deriving/generic
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -1173,6 +1173,12 @@ impl<'a> MethodDef<'a> {
1173
1173
let span = trait_. span ;
1174
1174
let variants = & enum_def. variants ;
1175
1175
1176
+ // There is no sensible code to be generated for *any* deriving on a
1177
+ // zero-variant enum. So we just generate a failing expression.
1178
+ if variants. is_empty ( ) {
1179
+ return BlockOrExpr ( vec ! [ ] , Some ( deriving:: call_unreachable ( cx, span) ) ) ;
1180
+ }
1181
+
1176
1182
let prefixes = iter:: once ( "__self" . to_string ( ) )
1177
1183
. chain (
1178
1184
selflike_args
@@ -1365,11 +1371,6 @@ impl<'a> MethodDef<'a> {
1365
1371
let all_match = cx. expr_match ( span, match_arg, match_arms) ;
1366
1372
let arm_expr = cx. expr_if ( span, discriminant_test, all_match, Some ( arm_expr) ) ;
1367
1373
BlockOrExpr ( index_let_stmts, Some ( arm_expr) )
1368
- } else if variants. is_empty ( ) {
1369
- // There is no sensible code to be generated for *any* deriving on
1370
- // a zero-variant enum. So we just generate a failing expression
1371
- // for the zero variant case.
1372
- BlockOrExpr ( vec ! [ ] , Some ( deriving:: call_unreachable ( cx, span) ) )
1373
1374
} else {
1374
1375
let match_arg = if selflike_args. len ( ) == 1 {
1375
1376
selflike_args. pop ( ) . unwrap ( )
You can’t perform that action at this time.
0 commit comments