@@ -305,10 +305,10 @@ pub enum StaticFields {
305305/// A summary of the possible sets of fields.
306306pub enum SubstructureFields < ' a > {
307307 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,
309309 /// fields: the field name is only non-`None` in the case of a struct
310310 /// variant.
311- EnumMatching ( usize , & ' a ast:: Variant , Vec < FieldInfo < ' a > > ) ,
311+ EnumMatching ( usize , usize , & ' a ast:: Variant , Vec < FieldInfo < ' a > > ) ,
312312
313313 /// Non-matching variants of the enum, but with all state hidden from
314314 /// the consequent code. The first component holds `Ident`s for all of
@@ -1252,7 +1252,7 @@ impl<'a> MethodDef<'a> {
12521252 // expressions for referencing every field of every
12531253 // Self arg, assuming all are instances of VariantK.
12541254 // 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) ;
12561256 let arm_expr = self . call_substructure_method ( cx,
12571257 trait_,
12581258 type_ident,
@@ -1269,12 +1269,13 @@ impl<'a> MethodDef<'a> {
12691269 // We need a default case that handles the fieldless variants.
12701270 // The index and actual variant aren't meaningful in this case,
12711271 // so just use whatever
1272+ let substructure = EnumMatching ( 0 , variants. len ( ) , v, Vec :: new ( ) ) ;
12721273 Some ( self . call_substructure_method ( cx,
12731274 trait_,
12741275 type_ident,
12751276 & self_args[ ..] ,
12761277 nonself_args,
1277- & EnumMatching ( 0 , v , Vec :: new ( ) ) ) )
1278+ & substructure ) )
12781279 }
12791280 _ if variants. len ( ) > 1 && self_args. len ( ) > 1 => {
12801281 // Since we know that all the arguments will match if we reach
0 commit comments