@@ -62,38 +62,36 @@ macro_rules! __impl_stable_hash_field {
62
62
#[ macro_export]
63
63
macro_rules! impl_stable_hash_for {
64
64
// Enums
65
- // FIXME(mark-i-m): Some of these should be `?` rather than `*`. See the git blame and change
66
- // them back when `?` is supported again.
67
65
( enum $enum_name: path {
68
66
$( $variant: ident
69
67
// this incorrectly allows specifying both tuple-like and struct-like fields, as in `Variant(a,b){c,d}`,
70
68
// when it should be only one or the other
71
- $( ( $( $field: ident $( -> $delegate: tt) * ) ,* ) ) *
72
- $( { $( $named_field: ident $( -> $named_delegate: tt) * ) ,* } ) *
73
- ) ,* $( , ) *
69
+ $( ( $( $field: ident $( -> $delegate: tt) ? ) ,* ) ) ?
70
+ $( { $( $named_field: ident $( -> $named_delegate: tt) ? ) ,* } ) ?
71
+ ) ,* $( , ) ?
74
72
} ) => {
75
73
impl_stable_hash_for!(
76
74
impl <> for enum $enum_name [ $enum_name ] { $( $variant
77
- $( ( $( $field $( -> $delegate) * ) ,* ) ) *
78
- $( { $( $named_field $( -> $named_delegate) * ) ,* } ) *
75
+ $( ( $( $field $( -> $delegate) ? ) ,* ) ) ?
76
+ $( { $( $named_field $( -> $named_delegate) ? ) ,* } ) ?
79
77
) ,* }
80
78
) ;
81
79
} ;
82
80
// We want to use the enum name both in the `impl ... for $enum_name` as well as for
83
81
// importing all the variants. Unfortunately it seems we have to take the name
84
82
// twice for this purpose
85
- ( impl <$( $lt: lifetime $( : $lt_bound: lifetime) * ) ,* $( , ) * $( $T: ident) ,* $( , ) * >
83
+ ( impl <$( $lt: lifetime $( : $lt_bound: lifetime) ? ) ,* $( , ) ? $( $T: ident) ,* $( , ) ? >
86
84
for enum $enum_name: path
87
85
[ $enum_path: path ]
88
86
{
89
87
$( $variant: ident
90
88
// this incorrectly allows specifying both tuple-like and struct-like fields, as in `Variant(a,b){c,d}`,
91
89
// when it should be only one or the other
92
- $( ( $( $field: ident $( -> $delegate: tt) * ) ,* ) ) *
93
- $( { $( $named_field: ident $( -> $named_delegate: tt) * ) ,* } ) *
94
- ) ,* $( , ) *
90
+ $( ( $( $field: ident $( -> $delegate: tt) ? ) ,* ) ) ?
91
+ $( { $( $named_field: ident $( -> $named_delegate: tt) ? ) ,* } ) ?
92
+ ) ,* $( , ) ?
95
93
} ) => {
96
- impl <' a, $( $lt $( : $lt_bound) * , ) * $( $T, ) * >
94
+ impl <' a, $( $lt $( : $lt_bound) ? , ) * $( $T, ) * >
97
95
:: rustc_data_structures:: stable_hasher:: HashStable <$crate:: ich:: StableHashingContext <' a>>
98
96
for $enum_name
99
97
where $( $T: :: rustc_data_structures:: stable_hasher:: HashStable <$crate:: ich:: StableHashingContext <' a>>) ,*
@@ -107,26 +105,25 @@ macro_rules! impl_stable_hash_for {
107
105
108
106
match * self {
109
107
$(
110
- $variant $( ( $( ref $field) ,* ) ) * $( { $( ref $named_field) ,* } ) * => {
111
- $( $( __impl_stable_hash_field!( $field, __ctx, __hasher $( , $delegate) * ) ) ;* ) *
112
- $( $( __impl_stable_hash_field!( $named_field, __ctx, __hasher $( , $named_delegate) * ) ) ;* ) *
108
+ $variant $( ( $( ref $field) ,* ) ) ? $( { $( ref $named_field) ,* } ) ? => {
109
+ $( $( __impl_stable_hash_field!( $field, __ctx, __hasher $( , $delegate) ? ) ) ;* ) ?
110
+ $( $( __impl_stable_hash_field!( $named_field, __ctx, __hasher $( , $named_delegate) ? ) ) ;* ) ?
113
111
}
114
112
) *
115
113
}
116
114
}
117
115
}
118
116
} ;
119
117
// Structs
120
- // FIXME(mark-i-m): same here.
121
- ( struct $struct_name: path { $( $field: ident $( -> $delegate: tt) * ) ,* $( , ) * } ) => {
118
+ ( struct $struct_name: path { $( $field: ident $( -> $delegate: tt) ?) ,* $( , ) ? } ) => {
122
119
impl_stable_hash_for!(
123
- impl <' tcx> for struct $struct_name { $( $field $( -> $delegate) * ) ,* }
120
+ impl <' tcx> for struct $struct_name { $( $field $( -> $delegate) ? ) ,* }
124
121
) ;
125
122
} ;
126
- ( impl <$( $lt: lifetime $( : $lt_bound: lifetime) * ) ,* $( , ) * $( $T: ident) ,* $( , ) * > for struct $struct_name: path {
127
- $( $field: ident $( -> $delegate: tt) * ) ,* $( , ) *
123
+ ( impl <$( $lt: lifetime $( : $lt_bound: lifetime) ? ) ,* $( , ) ? $( $T: ident) ,* $( , ) ? > for struct $struct_name: path {
124
+ $( $field: ident $( -> $delegate: tt) ? ) ,* $( , ) ?
128
125
} ) => {
129
- impl <' a, $( $lt $( : $lt_bound) * , ) * $( $T, ) * >
126
+ impl <' a, $( $lt $( : $lt_bound) ? , ) * $( $T, ) * >
130
127
:: rustc_data_structures:: stable_hasher:: HashStable <$crate:: ich:: StableHashingContext <' a>> for $struct_name
131
128
where $( $T: :: rustc_data_structures:: stable_hasher:: HashStable <$crate:: ich:: StableHashingContext <' a>>) ,*
132
129
{
@@ -138,21 +135,20 @@ macro_rules! impl_stable_hash_for {
138
135
$( ref $field) ,*
139
136
} = * self ;
140
137
141
- $( __impl_stable_hash_field!( $field, __ctx, __hasher $( , $delegate) * ) ) ;*
138
+ $( __impl_stable_hash_field!( $field, __ctx, __hasher $( , $delegate) ? ) ) ;*
142
139
}
143
140
}
144
141
} ;
145
142
// Tuple structs
146
- // We cannot use normale parentheses here, the parser won't allow it
147
- // FIXME(mark-i-m): same here.
148
- ( tuple_struct $struct_name: path { $( $field: ident $( -> $delegate: tt) * ) ,* $( , ) * } ) => {
143
+ // We cannot use normal parentheses here, the parser won't allow it
144
+ ( tuple_struct $struct_name: path { $( $field: ident $( -> $delegate: tt) ?) ,* $( , ) ? } ) => {
149
145
impl_stable_hash_for!(
150
- impl <' tcx> for tuple_struct $struct_name { $( $field $( -> $delegate) * ) ,* }
146
+ impl <' tcx> for tuple_struct $struct_name { $( $field $( -> $delegate) ? ) ,* }
151
147
) ;
152
148
} ;
153
- ( impl <$( $lt: lifetime $( : $lt_bound: lifetime) * ) ,* $( , ) * $( $T: ident) ,* $( , ) * >
154
- for tuple_struct $struct_name: path { $( $field: ident $( -> $delegate: tt) * ) ,* $( , ) * } ) => {
155
- impl <' a, $( $lt $( : $lt_bound) * , ) * $( $T, ) * >
149
+ ( impl <$( $lt: lifetime $( : $lt_bound: lifetime) ? ) ,* $( , ) ? $( $T: ident) ,* $( , ) ? >
150
+ for tuple_struct $struct_name: path { $( $field: ident $( -> $delegate: tt) ? ) ,* $( , ) ? } ) => {
151
+ impl <' a, $( $lt $( : $lt_bound) ? , ) * $( $T, ) * >
156
152
:: rustc_data_structures:: stable_hasher:: HashStable <$crate:: ich:: StableHashingContext <' a>> for $struct_name
157
153
where $( $T: :: rustc_data_structures:: stable_hasher:: HashStable <$crate:: ich:: StableHashingContext <' a>>) ,*
158
154
{
@@ -164,7 +160,7 @@ macro_rules! impl_stable_hash_for {
164
160
$( ref $field) ,*
165
161
) = * self ;
166
162
167
- $( __impl_stable_hash_field!( $field, __ctx, __hasher $( , $delegate) * ) ) ;*
163
+ $( __impl_stable_hash_field!( $field, __ctx, __hasher $( , $delegate) ? ) ) ;*
168
164
}
169
165
}
170
166
} ;
0 commit comments