146
146
//!
147
147
//! ```{.text}
148
148
//! EnumNonMatchingCollapsed(
149
- //! &[<ident for self index value>, <ident of __arg_1 index value>])
149
+ //! &[<ident for self index value>, <ident of __arg1 index value>])
150
150
//! ```
151
151
//!
152
152
//! It is the same for when the arguments are flipped to `C1 {x}` and
153
153
//! `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
155
155
//! be in the generated code.
156
156
//!
157
157
//! `EnumNonMatchingCollapsed` deliberately provides far less information
@@ -1125,12 +1125,12 @@ impl<'a> MethodDef<'a> {
1125
1125
/// impl ::core::cmp::PartialEq for A {
1126
1126
/// #[inline]
1127
1127
/// 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 {
1131
1131
/// 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 ,
1134
1134
/// _ => true,
1135
1135
/// }
1136
1136
/// } else {
@@ -1171,25 +1171,22 @@ impl<'a> MethodDef<'a> {
1171
1171
. iter ( )
1172
1172
. enumerate ( )
1173
1173
. skip ( 1 )
1174
- . map ( |( arg_count, _selflike_arg) | format ! ( "__arg_ {}" , arg_count) ) ,
1174
+ . map ( |( arg_count, _selflike_arg) | format ! ( "__arg {}" , arg_count) ) ,
1175
1175
)
1176
1176
. collect :: < Vec < String > > ( ) ;
1177
1177
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
1179
1179
// a series of let statements mapping each selflike_arg to an int
1180
1180
// value corresponding to its discriminant.
1181
- let vi_idents = prefixes
1181
+ let tag_idents = prefixes
1182
1182
. 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) )
1187
1184
. collect :: < Vec < Ident > > ( ) ;
1188
1185
1189
1186
// Builds, via callback to call_substructure_method, the
1190
1187
// delegated expression that handles the catch-all case,
1191
1188
// using `__variants_tuple` to drive logic if necessary.
1192
- let catch_all_substructure = EnumNonMatchingCollapsed ( & vi_idents ) ;
1189
+ let catch_all_substructure = EnumNonMatchingCollapsed ( & tag_idents ) ;
1193
1190
1194
1191
let first_fieldless = variants. iter ( ) . find ( |v| v. data . fields ( ) . is_empty ( ) ) ;
1195
1192
@@ -1303,15 +1300,15 @@ impl<'a> MethodDef<'a> {
1303
1300
// i.e., for `enum E<T> { A, B(1), C(T, T) }` for `PartialEq::eq`,
1304
1301
// builds two statements:
1305
1302
// ```
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);
1308
1305
// ```
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 ) ;
1310
1307
1311
1308
// 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 `.
1313
1310
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 ( ) {
1315
1312
let variant_value = deriving:: call_intrinsic (
1316
1313
cx,
1317
1314
span,
@@ -1322,7 +1319,7 @@ impl<'a> MethodDef<'a> {
1322
1319
index_let_stmts. push ( let_stmt) ;
1323
1320
1324
1321
if i > 0 {
1325
- let id0 = cx. expr_ident ( span, vi_idents [ 0 ] ) ;
1322
+ let id0 = cx. expr_ident ( span, tag_idents [ 0 ] ) ;
1326
1323
let id = cx. expr_ident ( span, ident) ;
1327
1324
let test = cx. expr_binary ( span, BinOpKind :: Eq , id0, id) ;
1328
1325
discriminant_test = if i == 1 {
@@ -1346,7 +1343,7 @@ impl<'a> MethodDef<'a> {
1346
1343
let match_arg = cx. expr ( span, ast:: ExprKind :: Tup ( selflike_args) ) ;
1347
1344
1348
1345
// 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 {
1350
1347
// match (self, other) {
1351
1348
// (Variant1, Variant1, ...) => Body1
1352
1349
// (Variant2, Variant2, ...) => Body2,
@@ -1355,7 +1352,7 @@ impl<'a> MethodDef<'a> {
1355
1352
// }
1356
1353
// }
1357
1354
// else {
1358
- // <delegated expression referring to __self_vi , et al.>
1355
+ // <delegated expression referring to __self_tag , et al.>
1359
1356
// }
1360
1357
let all_match = cx. expr_match ( span, match_arg, match_arms) ;
1361
1358
let arm_expr = cx. expr_if ( span, discriminant_test, all_match, Some ( arm_expr) ) ;
0 commit comments