146146//!
147147//! ```{.text}
148148//! EnumNonMatchingCollapsed(
149- //! &[<ident for self index value>, <ident of __arg_1 index value>])
149+ //! &[<ident for self index value>, <ident of __arg1 index value>])
150150//! ```
151151//!
152152//! It is the same for when the arguments are flipped to `C1 {x}` and
153153//! `C0(a)`; the only difference is what the values of the identifiers
154- //! <ident for self index value> and <ident of __arg_1 index value> will
154+ //! <ident for self index value> and <ident of __arg1 index value> will
155155//! be in the generated code.
156156//!
157157//! `EnumNonMatchingCollapsed` deliberately provides far less information
@@ -1125,12 +1125,12 @@ impl<'a> MethodDef<'a> {
11251125 /// impl ::core::cmp::PartialEq for A {
11261126 /// #[inline]
11271127 /// fn eq(&self, other: &A) -> bool {
1128- /// let __self_vi = ::core::intrinsics::discriminant_value(self);
1129- /// let __arg_1_vi = ::core::intrinsics::discriminant_value(other);
1130- /// if __self_vi == __arg_1_vi {
1128+ /// let __self_tag = ::core::intrinsics::discriminant_value(self);
1129+ /// let __arg1_tag = ::core::intrinsics::discriminant_value(other);
1130+ /// if __self_tag == __arg1_tag {
11311131 /// match (self, other) {
1132- /// (A::A2(__self_0), A::A2(__arg_1_0 )) =>
1133- /// *__self_0 == *__arg_1_0 ,
1132+ /// (A::A2(__self_0), A::A2(__arg1_0 )) =>
1133+ /// *__self_0 == *__arg1_0 ,
11341134 /// _ => true,
11351135 /// }
11361136 /// } else {
@@ -1171,25 +1171,22 @@ impl<'a> MethodDef<'a> {
11711171 . iter ( )
11721172 . enumerate ( )
11731173 . skip ( 1 )
1174- . map ( |( arg_count, _selflike_arg) | format ! ( "__arg_ {}" , arg_count) ) ,
1174+ . map ( |( arg_count, _selflike_arg) | format ! ( "__arg {}" , arg_count) ) ,
11751175 )
11761176 . collect :: < Vec < String > > ( ) ;
11771177
1178- // The `vi_idents ` will be bound, solely in the catch-all, to
1178+ // The `tag_idents ` will be bound, solely in the catch-all, to
11791179 // a series of let statements mapping each selflike_arg to an int
11801180 // value corresponding to its discriminant.
1181- let vi_idents = prefixes
1181+ let tag_idents = prefixes
11821182 . iter ( )
1183- . map ( |name| {
1184- let vi_suffix = format ! ( "{}_vi" , name) ;
1185- Ident :: from_str_and_span ( & vi_suffix, span)
1186- } )
1183+ . map ( |name| Ident :: from_str_and_span ( & format ! ( "{}_tag" , name) , span) )
11871184 . collect :: < Vec < Ident > > ( ) ;
11881185
11891186 // Builds, via callback to call_substructure_method, the
11901187 // delegated expression that handles the catch-all case,
11911188 // using `__variants_tuple` to drive logic if necessary.
1192- let catch_all_substructure = EnumNonMatchingCollapsed ( & vi_idents ) ;
1189+ let catch_all_substructure = EnumNonMatchingCollapsed ( & tag_idents ) ;
11931190
11941191 let first_fieldless = variants. iter ( ) . find ( |v| v. data . fields ( ) . is_empty ( ) ) ;
11951192
@@ -1303,15 +1300,15 @@ impl<'a> MethodDef<'a> {
13031300 // i.e., for `enum E<T> { A, B(1), C(T, T) }` for `PartialEq::eq`,
13041301 // builds two statements:
13051302 // ```
1306- // let __self_vi = ::core::intrinsics::discriminant_value(self);
1307- // let __arg_1_vi = ::core::intrinsics::discriminant_value(other);
1303+ // let __self_tag = ::core::intrinsics::discriminant_value(self);
1304+ // let __arg1_tag = ::core::intrinsics::discriminant_value(other);
13081305 // ```
1309- let mut index_let_stmts: Vec < ast:: Stmt > = Vec :: with_capacity ( vi_idents . len ( ) + 1 ) ;
1306+ let mut index_let_stmts: Vec < ast:: Stmt > = Vec :: with_capacity ( tag_idents . len ( ) + 1 ) ;
13101307
13111308 // We also build an expression which checks whether all discriminants are equal, e.g.
1312- // `__self_vi == __arg_1_vi `.
1309+ // `__self_tag == __arg1_tag `.
13131310 let mut discriminant_test = cx. expr_bool ( span, true ) ;
1314- for ( i, ( & ident, selflike_arg) ) in iter:: zip ( & vi_idents , & selflike_args) . enumerate ( ) {
1311+ for ( i, ( & ident, selflike_arg) ) in iter:: zip ( & tag_idents , & selflike_args) . enumerate ( ) {
13151312 let variant_value = deriving:: call_intrinsic (
13161313 cx,
13171314 span,
@@ -1322,7 +1319,7 @@ impl<'a> MethodDef<'a> {
13221319 index_let_stmts. push ( let_stmt) ;
13231320
13241321 if i > 0 {
1325- let id0 = cx. expr_ident ( span, vi_idents [ 0 ] ) ;
1322+ let id0 = cx. expr_ident ( span, tag_idents [ 0 ] ) ;
13261323 let id = cx. expr_ident ( span, ident) ;
13271324 let test = cx. expr_binary ( span, BinOpKind :: Eq , id0, id) ;
13281325 discriminant_test = if i == 1 {
@@ -1346,7 +1343,7 @@ impl<'a> MethodDef<'a> {
13461343 let match_arg = cx. expr ( span, ast:: ExprKind :: Tup ( selflike_args) ) ;
13471344
13481345 // Lastly we create an expression which branches on all discriminants being equal, e.g.
1349- // if __self_vi == _arg_1_vi {
1346+ // if __self_tag == _arg1_tag {
13501347 // match (self, other) {
13511348 // (Variant1, Variant1, ...) => Body1
13521349 // (Variant2, Variant2, ...) => Body2,
@@ -1355,7 +1352,7 @@ impl<'a> MethodDef<'a> {
13551352 // }
13561353 // }
13571354 // else {
1358- // <delegated expression referring to __self_vi , et al.>
1355+ // <delegated expression referring to __self_tag , et al.>
13591356 // }
13601357 let all_match = cx. expr_match ( span, match_arg, match_arms) ;
13611358 let arm_expr = cx. expr_if ( span, discriminant_test, all_match, Some ( arm_expr) ) ;
0 commit comments