@@ -505,6 +505,9 @@ pub enum ImplSource<'tcx, N> {
505505 /// Successful resolution for a builtin trait.
506506 Builtin ( ImplSourceBuiltinData < N > ) ,
507507
508+ /// ImplSource for trait upcasting coercion
509+ TraitUpcasting ( ImplSourceTraitUpcastingData < ' tcx , N > ) ,
510+
508511 /// ImplSource automatically generated for a closure. The `DefId` is the ID
509512 /// of the closure expression. This is a `ImplSource::UserDefined` in spirit, but the
510513 /// impl is generated by the compiler and does not appear in the source.
@@ -540,6 +543,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
540543 ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
541544 | ImplSource :: Pointee ( ImplSourcePointeeData ) => Vec :: new ( ) ,
542545 ImplSource :: TraitAlias ( d) => d. nested ,
546+ ImplSource :: TraitUpcasting ( d) => d. nested ,
543547 }
544548 }
545549
@@ -556,6 +560,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
556560 ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
557561 | ImplSource :: Pointee ( ImplSourcePointeeData ) => & [ ] ,
558562 ImplSource :: TraitAlias ( d) => & d. nested [ ..] ,
563+ ImplSource :: TraitUpcasting ( d) => & d. nested [ ..] ,
559564 }
560565 }
561566
@@ -607,6 +612,13 @@ impl<'tcx, N> ImplSource<'tcx, N> {
607612 substs : d. substs ,
608613 nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
609614 } ) ,
615+ ImplSource :: TraitUpcasting ( d) => {
616+ ImplSource :: TraitUpcasting ( ImplSourceTraitUpcastingData {
617+ upcast_trait_ref : d. upcast_trait_ref ,
618+ vtable_vptr_slot : d. vtable_vptr_slot ,
619+ nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
620+ } )
621+ }
610622 }
611623 }
612624}
@@ -652,6 +664,20 @@ pub struct ImplSourceAutoImplData<N> {
652664 pub nested : Vec < N > ,
653665}
654666
667+ #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , TypeFoldable , Lift ) ]
668+ pub struct ImplSourceTraitUpcastingData < ' tcx , N > {
669+ /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
670+ pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
671+
672+ /// The vtable is formed by concatenating together the method lists of
673+ /// the base object trait and all supertraits, pointers to supertrait vtable will
674+ /// be provided when necessary; this is the position of `upcast_trait_ref`'s vtable
675+ /// within that vtable.
676+ pub vtable_vptr_slot : Option < usize > ,
677+
678+ pub nested : Vec < N > ,
679+ }
680+
655681#[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , TypeFoldable , Lift ) ]
656682pub struct ImplSourceBuiltinData < N > {
657683 pub nested : Vec < N > ,
@@ -663,8 +689,9 @@ pub struct ImplSourceObjectData<'tcx, N> {
663689 pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
664690
665691 /// The vtable is formed by concatenating together the method lists of
666- /// the base object trait and all supertraits; this is the start of
667- /// `upcast_trait_ref`'s methods in that vtable.
692+ /// the base object trait and all supertraits, pointers to supertrait vtable will
693+ /// be provided when necessary; this is the start of `upcast_trait_ref`'s methods
694+ /// in that vtable.
668695 pub vtable_base : usize ,
669696
670697 pub nested : Vec < N > ,
0 commit comments