@@ -463,7 +463,7 @@ macro_rules! spec_tuple_impl {
463463 (
464464 [ $( $params_: tt) * ] ,
465465 (
466- $params: tt, $SpecTupleExtendN: ident , $default_extend_tuple_n: ident
466+ $params: tt, $SpecTupleExtendN: tt , $default_extend_tuple_n: tt
467467 ) ,
468468 $( $remainder: tt, ) *
469469 ) => {
@@ -480,7 +480,7 @@ macro_rules! spec_tuple_impl {
480480 } ;
481481 ( [ $( $params_: tt) * ] , ) => { } ;
482482 (
483- $SpecTupleExtendN: ident , $default_extend_tuple_n: ident ,
483+ $SpecTupleExtendN: tt , $default_extend_tuple_n: tt ,
484484 $params: tt
485485 ) => {
486486 spec_tuple_impl!(
@@ -495,7 +495,7 @@ macro_rules! spec_tuple_impl {
495495 ) ;
496496 } ;
497497 (
498- $SpecTupleExtendN: ident , $default_extend_tuple_n: ident ,
498+ $SpecTupleExtendN: tt , $default_extend_tuple_n: tt ,
499499 $( $params: tt) ,+
500500 ) => {
501501 spec_tuple_impl!(
@@ -507,65 +507,66 @@ macro_rules! spec_tuple_impl {
507507 ) ;
508508 } ;
509509 (
510- $SpecTupleExtendN: ident, $default_extend_tuple_n: ident, #$maybe_special_case: tt
510+ $SpecTupleExtendN: tt, $default_extend_tuple_n: tt,
511+ #$skip_specialization_trait_for_1_tuple: tt
511512 #[ $meta: meta]
512513 $( #[ $doctext: meta] ) ? => $(
513514 (
514- $Ts : ident, $var_names: ident, $ExtendTs : ident, $cnts : tt
515+ $T : ident, $var_names: ident, $ExtendT : ident, $cnt : tt
515516 ) ,
516517 ) *
517518 ) => {
518519 #[ $meta]
519520 $( #[ $doctext] ) ?
520521 #[ stable( feature = "extend_for_tuple" , since = "1.56.0" ) ]
521- impl <$( $Ts , ) * $( $ExtendTs , ) * > Extend <( $( $Ts , ) * ) > for ( $( $ExtendTs , ) * )
522+ impl <$( $T , ) * $( $ExtendT , ) * > Extend <( $( $T , ) * ) > for ( $( $ExtendT , ) * )
522523 where
523- $( $ExtendTs : Extend <$Ts >, ) *
524+ $( $ExtendT : Extend <$T >, ) *
524525 {
526+ spec_tuple_impl!(
527+ #$skip_specialization_trait_for_1_tuple
525528
526- spec_tuple_impl!( #$maybe_special_case
527-
528- fn extend<I : IntoIterator <Item = ( $( $Ts, ) * ) >>( & mut self , into_iter: I ) {
529+ fn extend<I : IntoIterator <Item = ( $( $T, ) * ) >>( & mut self , into_iter: I ) {
529530 let ( $( $var_names, ) * ) = self ;
530531 let iter = into_iter. into_iter( ) ;
531532 $SpecTupleExtendN:: extend( iter, $( $var_names, ) * ) ;
532533 }
533534 ) ;
534535
535- fn extend_one( & mut self , item: ( $( $Ts , ) * ) ) {
536- $( self . $cnts . extend_one( item. $cnts ) ; ) *
536+ fn extend_one( & mut self , item: ( $( $T , ) * ) ) {
537+ $( self . $cnt . extend_one( item. $cnt ) ; ) *
537538 }
538539
539540 fn extend_reserve( & mut self , additional: usize ) {
540- $( self . $cnts . extend_reserve( additional) ; ) *
541+ $( self . $cnt . extend_reserve( additional) ; ) *
541542 }
542543
543- unsafe fn extend_one_unchecked( & mut self , item: ( $( $Ts , ) * ) ) {
544+ unsafe fn extend_one_unchecked( & mut self , item: ( $( $T , ) * ) ) {
544545 // SAFETY: Those are our safety preconditions, and we correctly forward `extend_reserve`.
545546 unsafe {
546- $( self . $cnts . extend_one_unchecked( item. $cnts ) ; ) *
547+ $( self . $cnt . extend_one_unchecked( item. $cnt ) ; ) *
547548 }
548549 }
549550 }
550551
551- spec_tuple_impl!( #$maybe_special_case
552+ spec_tuple_impl!(
553+ #$skip_specialization_trait_for_1_tuple
552554
553- trait $SpecTupleExtendN<$( $Ts ) ,* > {
554- fn extend( self , $( $var_names: & mut $Ts , ) * ) ;
555+ trait $SpecTupleExtendN<$( $T ) ,* > {
556+ fn extend( self , $( $var_names: & mut $T , ) * ) ;
555557 }
556558
557- fn $default_extend_tuple_n<$( $Ts , ) * $( $ExtendTs , ) * >(
558- iter: impl Iterator <Item = ( $( $Ts , ) * ) >,
559- $( $var_names: & mut $ExtendTs , ) *
559+ fn $default_extend_tuple_n<$( $T , ) * $( $ExtendT , ) * >(
560+ iter: impl Iterator <Item = ( $( $T , ) * ) >,
561+ $( $var_names: & mut $ExtendT , ) *
560562 ) where
561- $( $ExtendTs : Extend <$Ts >, ) *
563+ $( $ExtendT : Extend <$T >, ) *
562564 {
563- fn extend<' a, $( $Ts, ) * >(
564- $( $var_names: & ' a mut impl Extend <$Ts>, ) *
565- ) -> impl FnMut ( ( ) , ( $( $Ts, ) * ) ) + ' a {
566- #[ allow( non_snake_case) ]
567- move |( ) , ( $( $ExtendTs, ) * ) | {
568- $( $var_names. extend_one( $ExtendTs) ; ) *
565+ fn extend<' a, $( $T, ) * >(
566+ $( $var_names: & ' a mut impl Extend <$T>, ) *
567+ ) -> impl FnMut ( ( ) , ( $( $T, ) * ) ) + ' a {
568+ move |( ) , item| {
569+ $( $var_names. extend_one( item. $cnt) ; ) *
569570 }
570571 }
571572
@@ -577,30 +578,29 @@ macro_rules! spec_tuple_impl {
577578 iter. fold( ( ) , extend( $( $var_names, ) * ) ) ;
578579 }
579580
580- impl <$( $Ts , ) * $( $ExtendTs , ) * Iter > $SpecTupleExtendN<$( $ExtendTs ) ,* > for Iter
581+ impl <$( $T , ) * $( $ExtendT , ) * Iter > $SpecTupleExtendN<$( $ExtendT ) ,* > for Iter
581582 where
582- $( $ExtendTs : Extend <$Ts >, ) *
583- Iter : Iterator <Item = ( $( $Ts , ) * ) >,
583+ $( $ExtendT : Extend <$T >, ) *
584+ Iter : Iterator <Item = ( $( $T , ) * ) >,
584585 {
585- default fn extend( self , $( $var_names: & mut $ExtendTs ) ,* ) {
586+ default fn extend( self , $( $var_names: & mut $ExtendT ) ,* ) {
586587 $default_extend_tuple_n( self , $( $var_names) ,* ) ;
587588 }
588589 }
589590
590- impl <$( $Ts , ) * $( $ExtendTs , ) * Iter > $SpecTupleExtendN<$( $ExtendTs ) ,* > for Iter
591+ impl <$( $T , ) * $( $ExtendT , ) * Iter > $SpecTupleExtendN<$( $ExtendT ) ,* > for Iter
591592 where
592- $( $ExtendTs : Extend <$Ts >, ) *
593- Iter : TrustedLen <Item = ( $( $Ts , ) * ) >,
593+ $( $ExtendT : Extend <$T >, ) *
594+ Iter : TrustedLen <Item = ( $( $T , ) * ) >,
594595 {
595- fn extend( self , $( $var_names: & mut $ExtendTs, ) * ) {
596- fn extend<' a, $( $Ts, ) * >(
597- $( $var_names: & ' a mut impl Extend <$Ts>, ) *
598- ) -> impl FnMut ( ( ) , ( $( $Ts, ) * ) ) + ' a {
599- #[ allow( non_snake_case) ]
596+ fn extend( self , $( $var_names: & mut $ExtendT, ) * ) {
597+ fn extend<' a, $( $T, ) * >(
598+ $( $var_names: & ' a mut impl Extend <$T>, ) *
599+ ) -> impl FnMut ( ( ) , ( $( $T, ) * ) ) + ' a {
600600 // SAFETY: We reserve enough space for the `size_hint`, and the iterator is
601601 // `TrustedLen` so its `size_hint` is exact.
602- move |( ) , ( $ ( $ExtendTs , ) * ) | unsafe {
603- $( $var_names. extend_one_unchecked( $ExtendTs ) ; ) *
602+ move |( ) , item | unsafe {
603+ $( $var_names. extend_one_unchecked( item . $cnt ) ; ) *
604604 }
605605 }
606606
@@ -644,21 +644,21 @@ macro_rules! spec_tuple_impl {
644644 #[ $meta]
645645 $( #[ $doctext] ) ?
646646 #[ stable( feature = "from_iterator_for_tuple" , since = "1.79.0" ) ]
647- impl <$( $Ts , ) * $( $ExtendTs , ) * > FromIterator <( $( $ExtendTs , ) * ) > for ( $( $Ts , ) * )
647+ impl <$( $T , ) * $( $ExtendT , ) * > FromIterator <( $( $ExtendT , ) * ) > for ( $( $T , ) * )
648648 where
649- $( $Ts : Default + Extend <$ExtendTs >, ) *
649+ $( $T : Default + Extend <$ExtendT >, ) *
650650 {
651- fn from_iter<Iter : IntoIterator <Item = ( $( $ExtendTs , ) * ) >>( iter: Iter ) -> Self {
652- let mut res = <( $( $Ts , ) * ) >:: default ( ) ;
651+ fn from_iter<Iter : IntoIterator <Item = ( $( $ExtendT , ) * ) >>( iter: Iter ) -> Self {
652+ let mut res = <( $( $T , ) * ) >:: default ( ) ;
653653 res. extend( iter) ;
654654
655655 res
656656 }
657657 }
658658 } ;
659659 (
660- #special_case_1_tuple fn
661- $( $t: tt) *
660+ #special_case_1_tuple
661+ fn $( $t: tt) *
662662 ) => {
663663 /// Allows to `extend` a tuple of collections that also implement `Extend`.
664664 ///
@@ -681,12 +681,13 @@ macro_rules! spec_tuple_impl {
681681 /// assert_eq!(b, [2, 5, 8]);
682682 /// assert_eq!(c, [3, 6, 9]);
683683 /// ```
684- fn extend<I : IntoIterator <Item = ( T , ) >>( & mut self , into_iter : I ) {
685- self . 0 . extend( into_iter . into_iter( ) . map( |( a, ) | a) ) ;
684+ fn extend<I : IntoIterator <Item = ( T , ) >>( & mut self , iter : I ) {
685+ self . 0 . extend( iter . into_iter( ) . map( |( a, ) | a) ) ;
686686 }
687687 } ;
688688 (
689- #special_case_1_tuple $( $t: tt) *
689+ #special_case_1_tuple
690+ $( $t: tt) *
690691 ) => {
691692 // no specialization traits
692693 } ;
@@ -700,7 +701,7 @@ macro_rules! spec_tuple_impl {
700701
701702spec_tuple_impl ! (
702703 [ ] ,
703- ( ( T , t, ExtendT , 0 ) , SpecTupleExtend1 , default_extend_tuple_1 ) ,
704+ ( ( T , t, ExtendT , 0 ) , @ , @ ) ,
704705 ( ( U , u, ExtendU , 1 ) , SpecTupleExtend2 , default_extend_tuple_2) ,
705706 ( ( V , v, ExtendV , 2 ) , SpecTupleExtend3 , default_extend_tuple_3) ,
706707 ( ( X , x, ExtendX , 3 ) , SpecTupleExtend4 , default_extend_tuple_4) ,
0 commit comments