146
146
//!
147
147
//! ```{.text}
148
148
//! EnumNonMatchingCollapsed(
149
- //! vec![<ident of self>, <ident of __arg_1>],
150
- //! &[<ast::Variant for C0>, <ast::Variant for C1>],
151
149
//! &[<ident for self index value>, <ident of __arg_1 index value>])
152
150
//! ```
153
151
//!
@@ -299,13 +297,10 @@ pub enum SubstructureFields<'a> {
299
297
/// variant.
300
298
EnumMatching ( usize , usize , & ' a ast:: Variant , Vec < FieldInfo < ' a > > ) ,
301
299
302
- /// Non-matching variants of the enum, but with all state hidden from
303
- /// the consequent code. The first component holds `Ident`s for all of
304
- /// the `Self` arguments; the second component is a slice of all of the
305
- /// variants for the enum itself, and the third component is a list of
306
- /// `Ident`s bound to the variant index values for each of the actual
307
- /// input `Self` arguments.
308
- EnumNonMatchingCollapsed ( Vec < Ident > , & ' a [ ast:: Variant ] , & ' a [ Ident ] ) ,
300
+ /// Non-matching variants of the enum, but with all state hidden from the
301
+ /// consequent code. The field is a list of `Ident`s bound to the variant
302
+ /// index values for each of the actual input `Self` arguments.
303
+ EnumNonMatchingCollapsed ( & ' a [ Ident ] ) ,
309
304
310
305
/// A static method where `Self` is a struct.
311
306
StaticStruct ( & ' a ast:: VariantData , StaticFields ) ,
@@ -318,13 +313,10 @@ pub enum SubstructureFields<'a> {
318
313
pub type CombineSubstructureFunc < ' a > =
319
314
Box < dyn FnMut ( & mut ExtCtxt < ' _ > , Span , & Substructure < ' _ > ) -> P < Expr > + ' a > ;
320
315
321
- /// Deal with non-matching enum variants. The tuple is a list of
322
- /// identifiers (one for each `Self` argument, which could be any of the
323
- /// variants since they have been collapsed together) and the identifiers
324
- /// holding the variant index value for each of the `Self` arguments. The
325
- /// last argument is all the non-`Self` args of the method being derived.
316
+ /// Deal with non-matching enum variants. The slice is the identifiers holding
317
+ /// the variant index value for each of the `Self` arguments.
326
318
pub type EnumNonMatchCollapsedFunc < ' a > =
327
- Box < dyn FnMut ( & mut ExtCtxt < ' _ > , Span , ( & [ Ident ] , & [ Ident ] ) , & [ P < Expr > ] ) -> P < Expr > + ' a > ;
319
+ Box < dyn FnMut ( & mut ExtCtxt < ' _ > , Span , & [ Ident ] ) -> P < Expr > + ' a > ;
328
320
329
321
pub fn combine_substructure (
330
322
f : CombineSubstructureFunc < ' _ > ,
@@ -1184,11 +1176,6 @@ impl<'a> MethodDef<'a> {
1184
1176
)
1185
1177
. collect :: < Vec < String > > ( ) ;
1186
1178
1187
- let self_arg_idents = self_arg_names
1188
- . iter ( )
1189
- . map ( |name| Ident :: from_str_and_span ( name, span) )
1190
- . collect :: < Vec < Ident > > ( ) ;
1191
-
1192
1179
// The `vi_idents` will be bound, solely in the catch-all, to
1193
1180
// a series of let statements mapping each self_arg to an int
1194
1181
// value corresponding to its discriminant.
@@ -1203,8 +1190,7 @@ impl<'a> MethodDef<'a> {
1203
1190
// Builds, via callback to call_substructure_method, the
1204
1191
// delegated expression that handles the catch-all case,
1205
1192
// using `__variants_tuple` to drive logic if necessary.
1206
- let catch_all_substructure =
1207
- EnumNonMatchingCollapsed ( self_arg_idents, & variants, & vi_idents) ;
1193
+ let catch_all_substructure = EnumNonMatchingCollapsed ( & vi_idents) ;
1208
1194
1209
1195
let first_fieldless = variants. iter ( ) . find ( |v| v. data . fields ( ) . is_empty ( ) ) ;
1210
1196
@@ -1657,9 +1643,7 @@ pub fn cs_fold_enumnonmatch(
1657
1643
substructure : & Substructure < ' _ > ,
1658
1644
) -> P < Expr > {
1659
1645
match * substructure. fields {
1660
- EnumNonMatchingCollapsed ( ref all_args, _, tuple) => {
1661
- enum_nonmatch_f ( cx, trait_span, ( & all_args[ ..] , tuple) , substructure. nonself_args )
1662
- }
1646
+ EnumNonMatchingCollapsed ( tuple) => enum_nonmatch_f ( cx, trait_span, tuple) ,
1663
1647
_ => cx. span_bug ( trait_span, "cs_fold_enumnonmatch expected an EnumNonMatchingCollapsed" ) ,
1664
1648
}
1665
1649
}
0 commit comments