File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
compiler/rustc_builtin_macros/src/deriving/generic Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -339,11 +339,19 @@ impl BlockOrExpr {
339339 // Converts it into an expression.
340340 fn into_expr ( self , cx : & ExtCtxt < ' _ > , span : Span ) -> P < Expr > {
341341 if self . 0 . is_empty ( ) {
342+ // No statements.
342343 match self . 1 {
343344 None => cx. expr_block ( cx. block ( span, vec ! [ ] ) ) ,
344345 Some ( expr) => expr,
345346 }
347+ } else if self . 0 . len ( ) == 1
348+ && let ast:: StmtKind :: Expr ( expr) = & self . 0 [ 0 ] . kind
349+ && self . 1 . is_none ( )
350+ {
351+ // There's only a single statement expression. Pull it out.
352+ expr. clone ( )
346353 } else {
354+ // Multiple statements and/or expressions.
347355 cx. expr_block ( self . into_block ( cx, span) )
348356 }
349357 }
Original file line number Diff line number Diff line change @@ -697,9 +697,8 @@ impl ::core::fmt::Debug for Enum1 {
697697impl ::core::hash::Hash for Enum1 {
698698 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
699699 match self {
700- Enum1::Single { x: __self_0 } => {
701- ::core::hash::Hash::hash(__self_0, state)
702- }
700+ Enum1::Single { x: __self_0 } =>
701+ ::core::hash::Hash::hash(__self_0, state),
703702 }
704703 }
705704}
@@ -870,10 +869,9 @@ impl ::core::default::Default for Fieldless {
870869impl ::core::hash::Hash for Fieldless {
871870 fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
872871 match self {
873- _ => {
872+ _ =>
874873 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
875- state)
876- }
874+ state),
877875 }
878876 }
879877}
@@ -992,10 +990,9 @@ impl ::core::hash::Hash for Mixed {
992990 ::core::hash::Hash::hash(__self_0, state);
993991 ::core::hash::Hash::hash(__self_1, state)
994992 }
995- _ => {
993+ _ =>
996994 ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
997- state)
998- }
995+ state),
999996 }
1000997 }
1001998}
You can’t perform that action at this time.
0 commit comments