@@ -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
@@ -1252,7 +1252,7 @@ impl<'a> MethodDef<'a> {
1252
1252
// expressions for referencing every field of every
1253
1253
// Self arg, assuming all are instances of VariantK.
1254
1254
// Build up code associated with such a case.
1255
- let substructure = EnumMatching ( index, variant, field_tuples) ;
1255
+ let substructure = EnumMatching ( index, variants . len ( ) , variant, field_tuples) ;
1256
1256
let arm_expr = self . call_substructure_method ( cx,
1257
1257
trait_,
1258
1258
type_ident,
@@ -1269,12 +1269,13 @@ impl<'a> MethodDef<'a> {
1269
1269
// We need a default case that handles the fieldless variants.
1270
1270
// The index and actual variant aren't meaningful in this case,
1271
1271
// so just use whatever
1272
+ let substructure = EnumMatching ( 0 , variants. len ( ) , v, Vec :: new ( ) ) ;
1272
1273
Some ( self . call_substructure_method ( cx,
1273
1274
trait_,
1274
1275
type_ident,
1275
1276
& self_args[ ..] ,
1276
1277
nonself_args,
1277
- & EnumMatching ( 0 , v , Vec :: new ( ) ) ) )
1278
+ & substructure ) )
1278
1279
}
1279
1280
_ if variants. len ( ) > 1 && self_args. len ( ) > 1 => {
1280
1281
// Since we know that all the arguments will match if we reach
0 commit comments