@@ -540,6 +540,17 @@ mod type_aliases {
540
540
PairBoth ( Fst , Snd ) ,
541
541
}
542
542
543
+ impl < Fst , Snd > PairOption < Fst , Snd > {
544
+ fn unwrapSnd ( self ) -> Snd {
545
+ match self {
546
+ PairOption :: PairNone ( ) => panic ! ( "PairNone has no second element" ) ,
547
+ PairOption :: PairFst ( _) => panic ! ( "PairFst has no second element" ) ,
548
+ PairOption :: PairSnd ( snd) => snd,
549
+ PairOption :: PairBoth ( _, snd) => snd,
550
+ }
551
+ }
552
+ }
553
+
543
554
#[ derive( Debug ) ]
544
555
struct S1 ;
545
556
@@ -553,24 +564,37 @@ mod type_aliases {
553
564
type MyPair = PairOption < S1 , S2 > ;
554
565
555
566
// Generic type alias that partially applies the generic type
556
- type AnotherPair < Thr > = PairOption < S2 , Thr > ;
567
+ type AnotherPair < A3 > = PairOption < S2 , A3 > ;
568
+
569
+ // Alias to another alias
570
+ type AliasToAlias < A4 > = AnotherPair < A4 > ;
571
+
572
+ // Alias that appears nested withing another alias
573
+ type NestedAlias < A5 > = AnotherPair < AliasToAlias < A5 > > ;
574
+
575
+ fn g ( t : NestedAlias < S3 > ) {
576
+ let x = t. unwrapSnd ( ) . unwrapSnd ( ) ; // $ method=unwrapSnd MISSING: type=x:S3
577
+ println ! ( "{:?}" , x) ;
578
+ }
557
579
558
580
pub fn f ( ) {
559
581
// Type can be inferred from the constructor
560
582
let p1: MyPair = PairOption :: PairBoth ( S1 , S2 ) ;
561
583
println ! ( "{:?}" , p1) ;
562
584
563
585
// Type can be only inferred from the type alias
564
- let p2: MyPair = PairOption :: PairNone ( ) ; // types for ` Fst` and ` Snd` missing
586
+ let p2: MyPair = PairOption :: PairNone ( ) ; // $ MISSING: type=p2: Fst.S1 MISSING: type=p2: Snd.S2
565
587
println ! ( "{:?}" , p2) ;
566
588
567
589
// First type from alias, second from constructor
568
- let p3: AnotherPair < _ > = PairOption :: PairSnd ( S3 ) ; // type for ` Fst` missing
590
+ let p3: AnotherPair < _ > = PairOption :: PairSnd ( S3 ) ; // $ MISSING: type=p3: Fst.S2
569
591
println ! ( "{:?}" , p3) ;
570
592
571
593
// First type from alias definition, second from argument to alias
572
- let p3: AnotherPair < S3 > = PairOption :: PairNone ( ) ; // type for `Snd` missing, spurious `S3` for `Fst`
594
+ let p3: AnotherPair < S3 > = PairOption :: PairNone ( ) ; // $ SPURIOUS: type=p3:Fst.S3 MISSING: type=p3:Snd.S3
573
595
println ! ( "{:?}" , p3) ;
596
+
597
+ g ( PairOption :: PairSnd ( PairOption :: PairSnd ( S3 ) ) ) ;
574
598
}
575
599
}
576
600
0 commit comments