146146//!
147147//! ```{.text}
148148//! EnumNonMatchingCollapsed(
149- //! vec![<ident of self>, <ident of __arg_1>],
150- //! &[<ast::Variant for C0>, <ast::Variant for C1>],
151149//! &[<ident for self index value>, <ident of __arg_1 index value>])
152150//! ```
153151//!
@@ -299,13 +297,10 @@ pub enum SubstructureFields<'a> {
299297 /// variant.
300298 EnumMatching ( usize , usize , & ' a ast:: Variant , Vec < FieldInfo < ' a > > ) ,
301299
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 ] ) ,
309304
310305 /// A static method where `Self` is a struct.
311306 StaticStruct ( & ' a ast:: VariantData , StaticFields ) ,
@@ -318,13 +313,10 @@ pub enum SubstructureFields<'a> {
318313pub type CombineSubstructureFunc < ' a > =
319314 Box < dyn FnMut ( & mut ExtCtxt < ' _ > , Span , & Substructure < ' _ > ) -> P < Expr > + ' a > ;
320315
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.
326318pub 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 > ;
328320
329321pub fn combine_substructure (
330322 f : CombineSubstructureFunc < ' _ > ,
@@ -1184,11 +1176,6 @@ impl<'a> MethodDef<'a> {
11841176 )
11851177 . collect :: < Vec < String > > ( ) ;
11861178
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-
11921179 // The `vi_idents` will be bound, solely in the catch-all, to
11931180 // a series of let statements mapping each self_arg to an int
11941181 // value corresponding to its discriminant.
@@ -1203,8 +1190,7 @@ impl<'a> MethodDef<'a> {
12031190 // Builds, via callback to call_substructure_method, the
12041191 // delegated expression that handles the catch-all case,
12051192 // 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) ;
12081194
12091195 let first_fieldless = variants. iter ( ) . find ( |v| v. data . fields ( ) . is_empty ( ) ) ;
12101196
@@ -1657,9 +1643,7 @@ pub fn cs_fold_enumnonmatch(
16571643 substructure : & Substructure < ' _ > ,
16581644) -> P < Expr > {
16591645 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) ,
16631647 _ => cx. span_bug ( trait_span, "cs_fold_enumnonmatch expected an EnumNonMatchingCollapsed" ) ,
16641648 }
16651649}
0 commit comments