@@ -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
@@ -1250,7 +1250,7 @@ impl<'a> MethodDef<'a> {
12501250 // expressions for referencing every field of every
12511251 // Self arg, assuming all are instances of VariantK.
12521252 // 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) ;
12541254 let arm_expr = self . call_substructure_method ( cx,
12551255 trait_,
12561256 type_ident,
@@ -1267,12 +1267,13 @@ impl<'a> MethodDef<'a> {
12671267 // We need a default case that handles the fieldless variants.
12681268 // The index and actual variant aren't meaningful in this case,
12691269 // so just use whatever
1270+ let substructure = EnumMatching ( 0 , variants. len ( ) , v, Vec :: new ( ) ) ;
12701271 Some ( self . call_substructure_method ( cx,
12711272 trait_,
12721273 type_ident,
12731274 & self_args[ ..] ,
12741275 nonself_args,
1275- & EnumMatching ( 0 , v , Vec :: new ( ) ) ) )
1276+ & substructure ) )
12761277 }
12771278 _ if variants. len ( ) > 1 && self_args. len ( ) > 1 => {
12781279 // Since we know that all the arguments will match if we reach
0 commit comments