@@ -503,6 +503,9 @@ pub enum ImplSource<'tcx, N> {
503503 /// Successful resolution for a builtin trait.
504504 Builtin ( ImplSourceBuiltinData < N > ) ,
505505
506+ /// ImplSource for trait upcasting coercion
507+ TraitUpcasting ( ImplSourceTraitUpcastingData < ' tcx , N > ) ,
508+
506509 /// ImplSource automatically generated for a closure. The `DefId` is the ID
507510 /// of the closure expression. This is a `ImplSource::UserDefined` in spirit, but the
508511 /// impl is generated by the compiler and does not appear in the source.
@@ -538,6 +541,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
538541 ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
539542 | ImplSource :: Pointee ( ImplSourcePointeeData ) => Vec :: new ( ) ,
540543 ImplSource :: TraitAlias ( d) => d. nested ,
544+ ImplSource :: TraitUpcasting ( d) => d. nested ,
541545 }
542546 }
543547
@@ -554,6 +558,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
554558 ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
555559 | ImplSource :: Pointee ( ImplSourcePointeeData ) => & [ ] ,
556560 ImplSource :: TraitAlias ( d) => & d. nested [ ..] ,
561+ ImplSource :: TraitUpcasting ( d) => & d. nested [ ..] ,
557562 }
558563 }
559564
@@ -605,6 +610,13 @@ impl<'tcx, N> ImplSource<'tcx, N> {
605610 substs : d. substs ,
606611 nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
607612 } ) ,
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+ }
608620 }
609621 }
610622}
@@ -650,6 +662,20 @@ pub struct ImplSourceAutoImplData<N> {
650662 pub nested : Vec < N > ,
651663}
652664
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+
653679#[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , TypeFoldable , Lift ) ]
654680pub struct ImplSourceBuiltinData < N > {
655681 pub nested : Vec < N > ,
@@ -661,8 +687,9 @@ pub struct ImplSourceObjectData<'tcx, N> {
661687 pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
662688
663689 /// 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.
666693 pub vtable_base : usize ,
667694
668695 pub nested : Vec < N > ,
0 commit comments