@@ -505,6 +505,9 @@ pub enum ImplSource<'tcx, N> {
505
505
/// Successful resolution for a builtin trait.
506
506
Builtin ( ImplSourceBuiltinData < N > ) ,
507
507
508
+ /// ImplSource for trait upcasting coercion
509
+ TraitUpcasting ( ImplSourceTraitUpcastingData < ' tcx , N > ) ,
510
+
508
511
/// ImplSource automatically generated for a closure. The `DefId` is the ID
509
512
/// of the closure expression. This is a `ImplSource::UserDefined` in spirit, but the
510
513
/// impl is generated by the compiler and does not appear in the source.
@@ -540,6 +543,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
540
543
ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
541
544
| ImplSource :: Pointee ( ImplSourcePointeeData ) => Vec :: new ( ) ,
542
545
ImplSource :: TraitAlias ( d) => d. nested ,
546
+ ImplSource :: TraitUpcasting ( d) => d. nested ,
543
547
}
544
548
}
545
549
@@ -556,6 +560,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
556
560
ImplSource :: DiscriminantKind ( ImplSourceDiscriminantKindData )
557
561
| ImplSource :: Pointee ( ImplSourcePointeeData ) => & [ ] ,
558
562
ImplSource :: TraitAlias ( d) => & d. nested [ ..] ,
563
+ ImplSource :: TraitUpcasting ( d) => & d. nested [ ..] ,
559
564
}
560
565
}
561
566
@@ -607,6 +612,13 @@ impl<'tcx, N> ImplSource<'tcx, N> {
607
612
substs : d. substs ,
608
613
nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
609
614
} ) ,
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
+ }
610
622
}
611
623
}
612
624
}
@@ -652,6 +664,20 @@ pub struct ImplSourceAutoImplData<N> {
652
664
pub nested : Vec < N > ,
653
665
}
654
666
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
+
655
681
#[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , TypeFoldable , Lift ) ]
656
682
pub struct ImplSourceBuiltinData < N > {
657
683
pub nested : Vec < N > ,
@@ -663,8 +689,9 @@ pub struct ImplSourceObjectData<'tcx, N> {
663
689
pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
664
690
665
691
/// 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.
668
695
pub vtable_base : usize ,
669
696
670
697
pub nested : Vec < N > ,
0 commit comments