@@ -503,6 +503,9 @@ pub enum ImplSource<'tcx, N> {
503
503
/// Successful resolution for a builtin trait.
504
504
Builtin ( ImplSourceBuiltinData < N > ) ,
505
505
506
+ /// ImplSource for trait upcasting coercion
507
+ TraitUpcasting ( ImplSourceTraitUpcastingData < ' tcx , N > ) ,
508
+
506
509
/// ImplSource automatically generated for a closure. The `DefId` is the ID
507
510
/// of the closure expression. This is a `ImplSource::UserDefined` in spirit, but the
508
511
/// impl is generated by the compiler and does not appear in the source.
@@ -538,6 +541,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
538
541
ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
539
542
| ImplSource :: Pointee ( ImplSourcePointeeData ) => Vec :: new ( ) ,
540
543
ImplSource :: TraitAlias ( d) => d. nested ,
544
+ ImplSource :: TraitUpcasting ( d) => d. nested ,
541
545
}
542
546
}
543
547
@@ -554,6 +558,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
554
558
ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
555
559
| ImplSource :: Pointee ( ImplSourcePointeeData ) => & [ ] ,
556
560
ImplSource :: TraitAlias ( d) => & d. nested [ ..] ,
561
+ ImplSource :: TraitUpcasting ( d) => & d. nested [ ..] ,
557
562
}
558
563
}
559
564
@@ -605,6 +610,13 @@ impl<'tcx, N> ImplSource<'tcx, N> {
605
610
substs : d. substs ,
606
611
nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
607
612
} ) ,
613
+ ImplSource :: TraitUpcasting ( d) => {
614
+ ImplSource :: TraitUpcasting ( ImplSourceTraitUpcastingData {
615
+ upcast_trait_ref : d. upcast_trait_ref ,
616
+ vtable_vptr_slot : d. vtable_vptr_slot ,
617
+ nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
618
+ } )
619
+ }
608
620
}
609
621
}
610
622
}
@@ -650,6 +662,20 @@ pub struct ImplSourceAutoImplData<N> {
650
662
pub nested : Vec < N > ,
651
663
}
652
664
665
+ #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , TypeFoldable , Lift ) ]
666
+ pub struct ImplSourceTraitUpcastingData < ' tcx , N > {
667
+ /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
668
+ pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
669
+
670
+ /// The vtable is formed by concatenating together the method lists of
671
+ /// the base object trait and all supertraits, pointers to supertrait vtable will
672
+ /// be provided when necessary; this is the position of `upcast_trait_ref`'s vtable
673
+ /// within that vtable.
674
+ pub vtable_vptr_slot : Option < usize > ,
675
+
676
+ pub nested : Vec < N > ,
677
+ }
678
+
653
679
#[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , TypeFoldable , Lift ) ]
654
680
pub struct ImplSourceBuiltinData < N > {
655
681
pub nested : Vec < N > ,
@@ -661,8 +687,9 @@ pub struct ImplSourceObjectData<'tcx, N> {
661
687
pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
662
688
663
689
/// The vtable is formed by concatenating together the method lists of
664
- /// the base object trait and all supertraits; this is the start of
665
- /// `upcast_trait_ref`'s methods in that vtable.
690
+ /// the base object trait and all supertraits, pointers to supertrait vtable will
691
+ /// be provided when necessary; this is the start of `upcast_trait_ref`'s methods
692
+ /// in that vtable.
666
693
pub vtable_base : usize ,
667
694
668
695
pub nested : Vec < N > ,
0 commit comments