Avoid unnecessary 1-tuples in derived code.
This commit is contained in:
parent
a7b1d31a9f
commit
2c911dc16f
3 changed files with 42 additions and 34 deletions
|
@ -1239,7 +1239,11 @@ impl<'a> MethodDef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here is the pat = `(&VariantK, &VariantK, ...)`
|
// Here is the pat = `(&VariantK, &VariantK, ...)`
|
||||||
let single_pat = cx.pat_tuple(span, subpats);
|
let single_pat = if subpats.len() == 1 {
|
||||||
|
subpats.pop().unwrap()
|
||||||
|
} else {
|
||||||
|
cx.pat_tuple(span, subpats)
|
||||||
|
};
|
||||||
|
|
||||||
// For the BodyK, we need to delegate to our caller,
|
// For the BodyK, we need to delegate to our caller,
|
||||||
// passing it an EnumMatching to indicate which case
|
// passing it an EnumMatching to indicate which case
|
||||||
|
@ -1471,7 +1475,11 @@ impl<'a> MethodDef<'a> {
|
||||||
// expression; here add a layer of borrowing, turning
|
// expression; here add a layer of borrowing, turning
|
||||||
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
|
// `(*self, *__arg_0, ...)` into `(&*self, &*__arg_0, ...)`.
|
||||||
self_args.map_in_place(|self_arg| cx.expr_addr_of(span, self_arg));
|
self_args.map_in_place(|self_arg| cx.expr_addr_of(span, self_arg));
|
||||||
let match_arg = cx.expr(span, ast::ExprKind::Tup(self_args));
|
let match_arg = if self_args.len() == 1 {
|
||||||
|
self_args.pop().unwrap()
|
||||||
|
} else {
|
||||||
|
cx.expr(span, ast::ExprKind::Tup(self_args))
|
||||||
|
};
|
||||||
BlockOrExpr(vec![], Some(cx.expr_match(span, match_arg, match_arms)))
|
BlockOrExpr(vec![], Some(cx.expr_match(span, match_arg, match_arms)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// CHECK: @STATIC = {{.*}}, align 4
|
// CHECK: @STATIC = {{.*}}, align 4
|
||||||
|
|
||||||
// This checks the constants from inline_enum_const
|
// This checks the constants from inline_enum_const
|
||||||
// CHECK: @alloc14 = {{.*}}, align 2
|
// CHECK: @alloc12 = {{.*}}, align 2
|
||||||
|
|
||||||
// This checks the constants from {low,high}_align_const, they share the same
|
// This checks the constants from {low,high}_align_const, they share the same
|
||||||
// constant, but the alignment differs, so the higher one should be used
|
// constant, but the alignment differs, so the higher one should be used
|
||||||
|
|
|
@ -554,8 +554,8 @@ enum Enum1 {
|
||||||
impl ::core::clone::Clone for Enum1 {
|
impl ::core::clone::Clone for Enum1 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> Enum1 {
|
fn clone(&self) -> Enum1 {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Enum1::Single { x: ref __self_0 },) =>
|
&Enum1::Single { x: ref __self_0 } =>
|
||||||
Enum1::Single { x: ::core::clone::Clone::clone(&*__self_0) },
|
Enum1::Single { x: ::core::clone::Clone::clone(&*__self_0) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,8 +564,8 @@ impl ::core::clone::Clone for Enum1 {
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::fmt::Debug for Enum1 {
|
impl ::core::fmt::Debug for Enum1 {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Enum1::Single { x: ref __self_0 },) =>
|
&Enum1::Single { x: ref __self_0 } =>
|
||||||
::core::fmt::Formatter::debug_struct_field1_finish(f,
|
::core::fmt::Formatter::debug_struct_field1_finish(f,
|
||||||
"Single", "x", &&*__self_0),
|
"Single", "x", &&*__self_0),
|
||||||
}
|
}
|
||||||
|
@ -575,8 +575,8 @@ impl ::core::fmt::Debug for Enum1 {
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::hash::Hash for Enum1 {
|
impl ::core::hash::Hash for Enum1 {
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Enum1::Single { x: ref __self_0 },) => {
|
&Enum1::Single { x: ref __self_0 } => {
|
||||||
::core::hash::Hash::hash(&*__self_0, state)
|
::core::hash::Hash::hash(&*__self_0, state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,10 +669,10 @@ impl ::core::marker::Copy for Fieldless { }
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::fmt::Debug for Fieldless {
|
impl ::core::fmt::Debug for Fieldless {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Fieldless::A,) => ::core::fmt::Formatter::write_str(f, "A"),
|
&Fieldless::A => ::core::fmt::Formatter::write_str(f, "A"),
|
||||||
(&Fieldless::B,) => ::core::fmt::Formatter::write_str(f, "B"),
|
&Fieldless::B => ::core::fmt::Formatter::write_str(f, "B"),
|
||||||
(&Fieldless::C,) => ::core::fmt::Formatter::write_str(f, "C"),
|
&Fieldless::C => ::core::fmt::Formatter::write_str(f, "C"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,7 +686,7 @@ impl ::core::default::Default for Fieldless {
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::hash::Hash for Fieldless {
|
impl ::core::hash::Hash for Fieldless {
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
_ => {
|
_ => {
|
||||||
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
||||||
state)
|
state)
|
||||||
|
@ -775,13 +775,13 @@ impl ::core::marker::Copy for Mixed { }
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::fmt::Debug for Mixed {
|
impl ::core::fmt::Debug for Mixed {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Mixed::P,) => ::core::fmt::Formatter::write_str(f, "P"),
|
&Mixed::P => ::core::fmt::Formatter::write_str(f, "P"),
|
||||||
(&Mixed::Q,) => ::core::fmt::Formatter::write_str(f, "Q"),
|
&Mixed::Q => ::core::fmt::Formatter::write_str(f, "Q"),
|
||||||
(&Mixed::R(ref __self_0),) =>
|
&Mixed::R(ref __self_0) =>
|
||||||
::core::fmt::Formatter::debug_tuple_field1_finish(f, "R",
|
::core::fmt::Formatter::debug_tuple_field1_finish(f, "R",
|
||||||
&&*__self_0),
|
&&*__self_0),
|
||||||
(&Mixed::S { d1: ref __self_0, d2: ref __self_1 },) =>
|
&Mixed::S { d1: ref __self_0, d2: ref __self_1 } =>
|
||||||
::core::fmt::Formatter::debug_struct_field2_finish(f, "S",
|
::core::fmt::Formatter::debug_struct_field2_finish(f, "S",
|
||||||
"d1", &&*__self_0, "d2", &&*__self_1),
|
"d1", &&*__self_0, "d2", &&*__self_1),
|
||||||
}
|
}
|
||||||
|
@ -797,13 +797,13 @@ impl ::core::default::Default for Mixed {
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::hash::Hash for Mixed {
|
impl ::core::hash::Hash for Mixed {
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Mixed::R(ref __self_0),) => {
|
&Mixed::R(ref __self_0) => {
|
||||||
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
||||||
state);
|
state);
|
||||||
::core::hash::Hash::hash(&*__self_0, state)
|
::core::hash::Hash::hash(&*__self_0, state)
|
||||||
}
|
}
|
||||||
(&Mixed::S { d1: ref __self_0, d2: ref __self_1 },) => {
|
&Mixed::S { d1: ref __self_0, d2: ref __self_1 } => {
|
||||||
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
||||||
state);
|
state);
|
||||||
::core::hash::Hash::hash(&*__self_0, state);
|
::core::hash::Hash::hash(&*__self_0, state);
|
||||||
|
@ -943,12 +943,12 @@ enum Fielded { X(u32), Y(bool), Z(Option<i32>), }
|
||||||
impl ::core::clone::Clone for Fielded {
|
impl ::core::clone::Clone for Fielded {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> Fielded {
|
fn clone(&self) -> Fielded {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Fielded::X(ref __self_0),) =>
|
&Fielded::X(ref __self_0) =>
|
||||||
Fielded::X(::core::clone::Clone::clone(&*__self_0)),
|
Fielded::X(::core::clone::Clone::clone(&*__self_0)),
|
||||||
(&Fielded::Y(ref __self_0),) =>
|
&Fielded::Y(ref __self_0) =>
|
||||||
Fielded::Y(::core::clone::Clone::clone(&*__self_0)),
|
Fielded::Y(::core::clone::Clone::clone(&*__self_0)),
|
||||||
(&Fielded::Z(ref __self_0),) =>
|
&Fielded::Z(ref __self_0) =>
|
||||||
Fielded::Z(::core::clone::Clone::clone(&*__self_0)),
|
Fielded::Z(::core::clone::Clone::clone(&*__self_0)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -957,14 +957,14 @@ impl ::core::clone::Clone for Fielded {
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::fmt::Debug for Fielded {
|
impl ::core::fmt::Debug for Fielded {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Fielded::X(ref __self_0),) =>
|
&Fielded::X(ref __self_0) =>
|
||||||
::core::fmt::Formatter::debug_tuple_field1_finish(f, "X",
|
::core::fmt::Formatter::debug_tuple_field1_finish(f, "X",
|
||||||
&&*__self_0),
|
&&*__self_0),
|
||||||
(&Fielded::Y(ref __self_0),) =>
|
&Fielded::Y(ref __self_0) =>
|
||||||
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y",
|
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y",
|
||||||
&&*__self_0),
|
&&*__self_0),
|
||||||
(&Fielded::Z(ref __self_0),) =>
|
&Fielded::Z(ref __self_0) =>
|
||||||
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z",
|
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z",
|
||||||
&&*__self_0),
|
&&*__self_0),
|
||||||
}
|
}
|
||||||
|
@ -974,18 +974,18 @@ impl ::core::fmt::Debug for Fielded {
|
||||||
#[allow(unused_qualifications)]
|
#[allow(unused_qualifications)]
|
||||||
impl ::core::hash::Hash for Fielded {
|
impl ::core::hash::Hash for Fielded {
|
||||||
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
|
||||||
match (&*self,) {
|
match &*self {
|
||||||
(&Fielded::X(ref __self_0),) => {
|
&Fielded::X(ref __self_0) => {
|
||||||
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
||||||
state);
|
state);
|
||||||
::core::hash::Hash::hash(&*__self_0, state)
|
::core::hash::Hash::hash(&*__self_0, state)
|
||||||
}
|
}
|
||||||
(&Fielded::Y(ref __self_0),) => {
|
&Fielded::Y(ref __self_0) => {
|
||||||
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
||||||
state);
|
state);
|
||||||
::core::hash::Hash::hash(&*__self_0, state)
|
::core::hash::Hash::hash(&*__self_0, state)
|
||||||
}
|
}
|
||||||
(&Fielded::Z(ref __self_0),) => {
|
&Fielded::Z(ref __self_0) => {
|
||||||
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
|
||||||
state);
|
state);
|
||||||
::core::hash::Hash::hash(&*__self_0, state)
|
::core::hash::Hash::hash(&*__self_0, state)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue