@@ -305,10 +305,10 @@ pub enum StaticFields {
305
305
/// A summary of the possible sets of fields.
306
306
pub enum SubstructureFields < ' a > {
307
307
Struct ( & ' a ast:: VariantData , Vec < FieldInfo < ' a > > ) ,
308
- /// Matching variants of the enum: variant index, ast::Variant,
308
+ /// Matching variants of the enum: variant index, variant count, ast::Variant,
309
309
/// fields: the field name is only non-`None` in the case of a struct
310
310
/// variant.
311
- EnumMatching ( usize , & ' a ast:: Variant , Vec < FieldInfo < ' a > > ) ,
311
+ EnumMatching ( usize , usize , & ' a ast:: Variant , Vec < FieldInfo < ' a > > ) ,
312
312
313
313
/// Non-matching variants of the enum, but with all state hidden from
314
314
/// the consequent code. The first component holds `Ident`s for all of
@@ -1250,7 +1250,7 @@ impl<'a> MethodDef<'a> {
1250
1250
// expressions for referencing every field of every
1251
1251
// Self arg, assuming all are instances of VariantK.
1252
1252
// Build up code associated with such a case.
1253
- let substructure = EnumMatching ( index, variant, field_tuples) ;
1253
+ let substructure = EnumMatching ( index, variants . len ( ) , variant, field_tuples) ;
1254
1254
let arm_expr = self . call_substructure_method ( cx,
1255
1255
trait_,
1256
1256
type_ident,
@@ -1267,12 +1267,13 @@ impl<'a> MethodDef<'a> {
1267
1267
// We need a default case that handles the fieldless variants.
1268
1268
// The index and actual variant aren't meaningful in this case,
1269
1269
// so just use whatever
1270
+ let substructure = EnumMatching ( 0 , variants. len ( ) , v, Vec :: new ( ) ) ;
1270
1271
Some ( self . call_substructure_method ( cx,
1271
1272
trait_,
1272
1273
type_ident,
1273
1274
& self_args[ ..] ,
1274
1275
nonself_args,
1275
- & EnumMatching ( 0 , v , Vec :: new ( ) ) ) )
1276
+ & substructure ) )
1276
1277
}
1277
1278
_ if variants. len ( ) > 1 && self_args. len ( ) > 1 => {
1278
1279
// Since we know that all the arguments will match if we reach
0 commit comments