diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index a5d5782dbd2..2e21d197cdf 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -146,12 +146,12 @@ //! //! ```{.text} //! EnumNonMatchingCollapsed( -//! &[, ]) +//! &[, ]) //! ``` //! //! It is the same for when the arguments are flipped to `C1 {x}` and //! `C0(a)`; the only difference is what the values of the identifiers -//! and will +//! and will //! be in the generated code. //! //! `EnumNonMatchingCollapsed` deliberately provides far less information @@ -1125,12 +1125,12 @@ fn expand_static_struct_method_body( /// impl ::core::cmp::PartialEq for A { /// #[inline] /// fn eq(&self, other: &A) -> bool { - /// let __self_vi = ::core::intrinsics::discriminant_value(self); - /// let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - /// if __self_vi == __arg_1_vi { + /// let __self_tag = ::core::intrinsics::discriminant_value(self); + /// let __arg1_tag = ::core::intrinsics::discriminant_value(other); + /// if __self_tag == __arg1_tag { /// match (self, other) { - /// (A::A2(__self_0), A::A2(__arg_1_0)) => - /// *__self_0 == *__arg_1_0, + /// (A::A2(__self_0), A::A2(__arg1_0)) => + /// *__self_0 == *__arg1_0, /// _ => true, /// } /// } else { @@ -1171,25 +1171,22 @@ fn expand_enum_method_body<'b>( .iter() .enumerate() .skip(1) - .map(|(arg_count, _selflike_arg)| format!("__arg_{}", arg_count)), + .map(|(arg_count, _selflike_arg)| format!("__arg{}", arg_count)), ) .collect::>(); - // The `vi_idents` will be bound, solely in the catch-all, to + // The `tag_idents` will be bound, solely in the catch-all, to // a series of let statements mapping each selflike_arg to an int // value corresponding to its discriminant. - let vi_idents = prefixes + let tag_idents = prefixes .iter() - .map(|name| { - let vi_suffix = format!("{}_vi", name); - Ident::from_str_and_span(&vi_suffix, span) - }) + .map(|name| Ident::from_str_and_span(&format!("{}_tag", name), span)) .collect::>(); // Builds, via callback to call_substructure_method, the // delegated expression that handles the catch-all case, // using `__variants_tuple` to drive logic if necessary. - let catch_all_substructure = EnumNonMatchingCollapsed(&vi_idents); + let catch_all_substructure = EnumNonMatchingCollapsed(&tag_idents); let first_fieldless = variants.iter().find(|v| v.data.fields().is_empty()); @@ -1303,15 +1300,15 @@ fn expand_enum_method_body<'b>( // i.e., for `enum E { A, B(1), C(T, T) }` for `PartialEq::eq`, // builds two statements: // ``` - // let __self_vi = ::core::intrinsics::discriminant_value(self); - // let __arg_1_vi = ::core::intrinsics::discriminant_value(other); + // let __self_tag = ::core::intrinsics::discriminant_value(self); + // let __arg1_tag = ::core::intrinsics::discriminant_value(other); // ``` - let mut index_let_stmts: Vec = Vec::with_capacity(vi_idents.len() + 1); + let mut index_let_stmts: Vec = Vec::with_capacity(tag_idents.len() + 1); // We also build an expression which checks whether all discriminants are equal, e.g. - // `__self_vi == __arg_1_vi`. + // `__self_tag == __arg1_tag`. let mut discriminant_test = cx.expr_bool(span, true); - for (i, (&ident, selflike_arg)) in iter::zip(&vi_idents, &selflike_args).enumerate() { + for (i, (&ident, selflike_arg)) in iter::zip(&tag_idents, &selflike_args).enumerate() { let variant_value = deriving::call_intrinsic( cx, span, @@ -1322,7 +1319,7 @@ fn expand_enum_method_body<'b>( index_let_stmts.push(let_stmt); if i > 0 { - let id0 = cx.expr_ident(span, vi_idents[0]); + let id0 = cx.expr_ident(span, tag_idents[0]); let id = cx.expr_ident(span, ident); let test = cx.expr_binary(span, BinOpKind::Eq, id0, id); discriminant_test = if i == 1 { @@ -1346,7 +1343,7 @@ fn expand_enum_method_body<'b>( let match_arg = cx.expr(span, ast::ExprKind::Tup(selflike_args)); // Lastly we create an expression which branches on all discriminants being equal, e.g. - // if __self_vi == _arg_1_vi { + // if __self_tag == _arg1_tag { // match (self, other) { // (Variant1, Variant1, ...) => Body1 // (Variant2, Variant2, ...) => Body2, @@ -1355,7 +1352,7 @@ fn expand_enum_method_body<'b>( // } // } // else { - // + // // } let all_match = cx.expr_match(span, match_arg, match_arms); let arm_expr = cx.expr_if(span, discriminant_test, all_match, Some(arm_expr)); diff --git a/src/test/ui/deriving/deriving-all-codegen.stdout b/src/test/ui/deriving/deriving-all-codegen.stdout index 0b88d68fce8..0337ca2634f 100644 --- a/src/test/ui/deriving/deriving-all-codegen.stdout +++ b/src/test/ui/deriving/deriving-all-codegen.stdout @@ -710,15 +710,15 @@ impl ::core::cmp::PartialEq for Enum1 { #[inline] fn eq(&self, other: &Enum1) -> bool { match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg_1_0 }) => - *__self_0 == *__arg_1_0, + (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => + *__self_0 == *__arg1_0, } } #[inline] fn ne(&self, other: &Enum1) -> bool { match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg_1_0 }) => - *__self_0 != *__arg_1_0, + (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => + *__self_0 != *__arg1_0, } } } @@ -740,8 +740,8 @@ impl ::core::cmp::PartialOrd for Enum1 { fn partial_cmp(&self, other: &Enum1) -> ::core::option::Option<::core::cmp::Ordering> { match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg_1_0 }) => - ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg_1_0), + (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), } } } @@ -751,8 +751,8 @@ impl ::core::cmp::Ord for Enum1 { #[inline] fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering { match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg_1_0 }) => - ::core::cmp::Ord::cmp(__self_0, __arg_1_0), + (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), } } } @@ -883,9 +883,9 @@ impl ::core::marker::StructuralPartialEq for Fieldless {} impl ::core::cmp::PartialEq for Fieldless { #[inline] fn eq(&self, other: &Fieldless) -> bool { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { _ => true, } } else { false } } @@ -905,15 +905,15 @@ impl ::core::cmp::PartialOrd for Fieldless { #[inline] fn partial_cmp(&self, other: &Fieldless) -> ::core::option::Option<::core::cmp::Ordering> { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { _ => ::core::option::Option::Some(::core::cmp::Ordering::Equal), } } else { - ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi) + ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) } } } @@ -922,11 +922,11 @@ impl ::core::cmp::PartialOrd for Fieldless { impl ::core::cmp::Ord for Fieldless { #[inline] fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { _ => ::core::cmp::Ordering::Equal, } - } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) } + } else { ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) } } } @@ -1005,30 +1005,30 @@ impl ::core::marker::StructuralPartialEq for Mixed {} impl ::core::cmp::PartialEq for Mixed { #[inline] fn eq(&self, other: &Mixed) -> bool { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg_1_0)) => - *__self_0 == *__arg_1_0, + (Mixed::R(__self_0), Mixed::R(__arg1_0)) => + *__self_0 == *__arg1_0, (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { - d1: __arg_1_0, d2: __arg_1_1 }) => - *__self_0 == *__arg_1_0 && *__self_1 == *__arg_1_1, + d1: __arg1_0, d2: __arg1_1 }) => + *__self_0 == *__arg1_0 && *__self_1 == *__arg1_1, _ => true, } } else { false } } #[inline] fn ne(&self, other: &Mixed) -> bool { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg_1_0)) => - *__self_0 != *__arg_1_0, + (Mixed::R(__self_0), Mixed::R(__arg1_0)) => + *__self_0 != *__arg1_0, (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { - d1: __arg_1_0, d2: __arg_1_1 }) => - *__self_0 != *__arg_1_0 || *__self_1 != *__arg_1_1, + d1: __arg1_0, d2: __arg1_1 }) => + *__self_0 != *__arg1_0 || *__self_1 != *__arg1_1, _ => false, } } else { true } @@ -1051,26 +1051,25 @@ impl ::core::cmp::PartialOrd for Mixed { #[inline] fn partial_cmp(&self, other: &Mixed) -> ::core::option::Option<::core::cmp::Ordering> { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg_1_0)) => - ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg_1_0), + (Mixed::R(__self_0), Mixed::R(__arg1_0)) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { - d1: __arg_1_0, d2: __arg_1_1 }) => + d1: __arg1_0, d2: __arg1_1 }) => match ::core::cmp::PartialOrd::partial_cmp(__self_0, - __arg_1_0) { + __arg1_0) { ::core::option::Option::Some(::core::cmp::Ordering::Equal) - => - ::core::cmp::PartialOrd::partial_cmp(__self_1, __arg_1_1), + => ::core::cmp::PartialOrd::partial_cmp(__self_1, __arg1_1), cmp => cmp, }, _ => ::core::option::Option::Some(::core::cmp::Ordering::Equal), } } else { - ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi) + ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) } } } @@ -1079,22 +1078,22 @@ impl ::core::cmp::PartialOrd for Mixed { impl ::core::cmp::Ord for Mixed { #[inline] fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg_1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg_1_0), + (Mixed::R(__self_0), Mixed::R(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { - d1: __arg_1_0, d2: __arg_1_1 }) => - match ::core::cmp::Ord::cmp(__self_0, __arg_1_0) { + d1: __arg1_0, d2: __arg1_1 }) => + match ::core::cmp::Ord::cmp(__self_0, __arg1_0) { ::core::cmp::Ordering::Equal => - ::core::cmp::Ord::cmp(__self_1, __arg_1_1), + ::core::cmp::Ord::cmp(__self_1, __arg1_1), cmp => cmp, }, _ => ::core::cmp::Ordering::Equal, } - } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) } + } else { ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) } } } @@ -1162,32 +1161,32 @@ impl ::core::marker::StructuralPartialEq for Fielded {} impl ::core::cmp::PartialEq for Fielded { #[inline] fn eq(&self, other: &Fielded) -> bool { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg_1_0)) => - *__self_0 == *__arg_1_0, - (Fielded::Y(__self_0), Fielded::Y(__arg_1_0)) => - *__self_0 == *__arg_1_0, - (Fielded::Z(__self_0), Fielded::Z(__arg_1_0)) => - *__self_0 == *__arg_1_0, + (Fielded::X(__self_0), Fielded::X(__arg1_0)) => + *__self_0 == *__arg1_0, + (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => + *__self_0 == *__arg1_0, + (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => + *__self_0 == *__arg1_0, _ => unsafe { ::core::intrinsics::unreachable() } } } else { false } } #[inline] fn ne(&self, other: &Fielded) -> bool { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg_1_0)) => - *__self_0 != *__arg_1_0, - (Fielded::Y(__self_0), Fielded::Y(__arg_1_0)) => - *__self_0 != *__arg_1_0, - (Fielded::Z(__self_0), Fielded::Z(__arg_1_0)) => - *__self_0 != *__arg_1_0, + (Fielded::X(__self_0), Fielded::X(__arg1_0)) => + *__self_0 != *__arg1_0, + (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => + *__self_0 != *__arg1_0, + (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => + *__self_0 != *__arg1_0, _ => unsafe { ::core::intrinsics::unreachable() } } } else { true } @@ -1212,20 +1211,20 @@ impl ::core::cmp::PartialOrd for Fielded { #[inline] fn partial_cmp(&self, other: &Fielded) -> ::core::option::Option<::core::cmp::Ordering> { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg_1_0)) => - ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg_1_0), - (Fielded::Y(__self_0), Fielded::Y(__arg_1_0)) => - ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg_1_0), - (Fielded::Z(__self_0), Fielded::Z(__arg_1_0)) => - ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg_1_0), + (Fielded::X(__self_0), Fielded::X(__arg1_0)) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), + (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), + (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => + ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), _ => unsafe { ::core::intrinsics::unreachable() } } } else { - ::core::cmp::PartialOrd::partial_cmp(&__self_vi, &__arg_1_vi) + ::core::cmp::PartialOrd::partial_cmp(&__self_tag, &__arg1_tag) } } } @@ -1234,19 +1233,19 @@ impl ::core::cmp::PartialOrd for Fielded { impl ::core::cmp::Ord for Fielded { #[inline] fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering { - let __self_vi = ::core::intrinsics::discriminant_value(self); - let __arg_1_vi = ::core::intrinsics::discriminant_value(other); - if __self_vi == __arg_1_vi { + let __self_tag = ::core::intrinsics::discriminant_value(self); + let __arg1_tag = ::core::intrinsics::discriminant_value(other); + if __self_tag == __arg1_tag { match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg_1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg_1_0), - (Fielded::Y(__self_0), Fielded::Y(__arg_1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg_1_0), - (Fielded::Z(__self_0), Fielded::Z(__arg_1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg_1_0), + (Fielded::X(__self_0), Fielded::X(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), _ => unsafe { ::core::intrinsics::unreachable() } } - } else { ::core::cmp::Ord::cmp(&__self_vi, &__arg_1_vi) } + } else { ::core::cmp::Ord::cmp(&__self_tag, &__arg1_tag) } } }