File tree 2 files changed +14
-9
lines changed
compiler/rustc_builtin_macros/src/deriving/generic
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -339,11 +339,19 @@ impl BlockOrExpr {
339
339
// Converts it into an expression.
340
340
fn into_expr ( self , cx : & ExtCtxt < ' _ > , span : Span ) -> P < Expr > {
341
341
if self . 0 . is_empty ( ) {
342
+ // No statements.
342
343
match self . 1 {
343
344
None => cx. expr_block ( cx. block ( span, vec ! [ ] ) ) ,
344
345
Some ( expr) => expr,
345
346
}
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 ( )
346
353
} else {
354
+ // Multiple statements and/or expressions.
347
355
cx. expr_block ( self . into_block ( cx, span) )
348
356
}
349
357
}
Original file line number Diff line number Diff line change @@ -697,9 +697,8 @@ impl ::core::fmt::Debug for Enum1 {
697
697
impl ::core::hash::Hash for Enum1 {
698
698
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
699
699
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),
703
702
}
704
703
}
705
704
}
@@ -870,10 +869,9 @@ impl ::core::default::Default for Fieldless {
870
869
impl ::core::hash::Hash for Fieldless {
871
870
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
872
871
match self {
873
- _ => {
872
+ _ =>
874
873
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
875
- state)
876
- }
874
+ state),
877
875
}
878
876
}
879
877
}
@@ -992,10 +990,9 @@ impl ::core::hash::Hash for Mixed {
992
990
::core::hash::Hash::hash(__self_0, state);
993
991
::core::hash::Hash::hash(__self_1, state)
994
992
}
995
- _ => {
993
+ _ =>
996
994
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
997
- state)
998
- }
995
+ state),
999
996
}
1000
997
}
1001
998
}
You can’t perform that action at this time.
0 commit comments