File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
compiler/rustc_builtin_macros/src/deriving/generic Expand file tree Collapse file tree 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> {
11731173 let span = trait_. span ;
11741174 let variants = & enum_def. variants ;
11751175
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+
11761182 let prefixes = iter:: once ( "__self" . to_string ( ) )
11771183 . chain (
11781184 selflike_args
@@ -1365,11 +1371,6 @@ impl<'a> MethodDef<'a> {
13651371 let all_match = cx. expr_match ( span, match_arg, match_arms) ;
13661372 let arm_expr = cx. expr_if ( span, discriminant_test, all_match, Some ( arm_expr) ) ;
13671373 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) ) )
13731374 } else {
13741375 let match_arg = if selflike_args. len ( ) == 1 {
13751376 selflike_args. pop ( ) . unwrap ( )
You can’t perform that action at this time.
0 commit comments