@@ -649,46 +649,31 @@ pub enum ImplSource<'tcx, N> {
649649 /// for some type parameter. The `Vec<N>` represents the
650650 /// obligations incurred from normalizing the where-clause (if
651651 /// any).
652- Param ( Vec < N > , ty:: BoundConstness ) ,
652+ Param ( ty:: BoundConstness , Vec < N > ) ,
653653
654- /// Virtual calls through an object.
655- Object ( ImplSourceObjectData < N > ) ,
656-
657- /// Successful resolution for a builtin trait.
658- Builtin ( Vec < N > ) ,
659-
660- // Unsizing a tuple like `(A, B, ..., X)` to `(A, B, ..., Y)` if `X` unsizes to `Y`
661- TupleUnsizing ( Vec < N > ) ,
662-
663- /// ImplSource for trait upcasting coercion
664- TraitUpcasting ( ImplSourceTraitUpcastingData < N > ) ,
654+ /// Successful resolution for a builtin impl.
655+ Builtin ( BuiltinImplSource , Vec < N > ) ,
665656}
666657
667658impl < ' tcx , N > ImplSource < ' tcx , N > {
668659 pub fn nested_obligations ( self ) -> Vec < N > {
669660 match self {
670661 ImplSource :: UserDefined ( i) => i. nested ,
671- ImplSource :: Param ( n, _) | ImplSource :: Builtin ( n) | ImplSource :: TupleUnsizing ( n) => n,
672- ImplSource :: Object ( d) => d. nested ,
673- ImplSource :: TraitUpcasting ( d) => d. nested ,
662+ ImplSource :: Param ( _, n) | ImplSource :: Builtin ( _, n) => n,
674663 }
675664 }
676665
677666 pub fn borrow_nested_obligations ( & self ) -> & [ N ] {
678667 match self {
679668 ImplSource :: UserDefined ( i) => & i. nested ,
680- ImplSource :: Param ( n, _) | ImplSource :: Builtin ( n) | ImplSource :: TupleUnsizing ( n) => & n,
681- ImplSource :: Object ( d) => & d. nested ,
682- ImplSource :: TraitUpcasting ( d) => & d. nested ,
669+ ImplSource :: Param ( _, n) | ImplSource :: Builtin ( _, n) => & n,
683670 }
684671 }
685672
686673 pub fn borrow_nested_obligations_mut ( & mut self ) -> & mut [ N ] {
687674 match self {
688675 ImplSource :: UserDefined ( i) => & mut i. nested ,
689- ImplSource :: Param ( n, _) | ImplSource :: Builtin ( n) | ImplSource :: TupleUnsizing ( n) => n,
690- ImplSource :: Object ( d) => & mut d. nested ,
691- ImplSource :: TraitUpcasting ( d) => & mut d. nested ,
676+ ImplSource :: Param ( _, n) | ImplSource :: Builtin ( _, n) => n,
692677 }
693678 }
694679
@@ -702,20 +687,9 @@ impl<'tcx, N> ImplSource<'tcx, N> {
702687 args : i. args ,
703688 nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
704689 } ) ,
705- ImplSource :: Param ( n, ct) => ImplSource :: Param ( n. into_iter ( ) . map ( f) . collect ( ) , ct) ,
706- ImplSource :: Builtin ( n) => ImplSource :: Builtin ( n. into_iter ( ) . map ( f) . collect ( ) ) ,
707- ImplSource :: TupleUnsizing ( n) => {
708- ImplSource :: TupleUnsizing ( n. into_iter ( ) . map ( f) . collect ( ) )
709- }
710- ImplSource :: Object ( o) => ImplSource :: Object ( ImplSourceObjectData {
711- vtable_base : o. vtable_base ,
712- nested : o. nested . into_iter ( ) . map ( f) . collect ( ) ,
713- } ) ,
714- ImplSource :: TraitUpcasting ( d) => {
715- ImplSource :: TraitUpcasting ( ImplSourceTraitUpcastingData {
716- vtable_vptr_slot : d. vtable_vptr_slot ,
717- nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
718- } )
690+ ImplSource :: Param ( ct, n) => ImplSource :: Param ( ct, n. into_iter ( ) . map ( f) . collect ( ) ) ,
691+ ImplSource :: Builtin ( source, n) => {
692+ ImplSource :: Builtin ( source, n. into_iter ( ) . map ( f) . collect ( ) )
719693 }
720694 }
721695 }
@@ -739,29 +713,31 @@ pub struct ImplSourceUserDefinedData<'tcx, N> {
739713 pub nested : Vec < N > ,
740714}
741715
742- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
743- #[ derive( TypeFoldable , TypeVisitable ) ]
744- pub struct ImplSourceTraitUpcastingData < N > {
716+ #[ derive( Copy , Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Debug ) ]
717+ pub enum BuiltinImplSource {
718+ /// Some builtin impl we don't need to differentiate. This should be used
719+ /// unless more specific information is necessary.
720+ Misc ,
721+ /// A builtin impl for trait objects.
722+ ///
723+ /// The vtable is formed by concatenating together the method lists of
724+ /// the base object trait and all supertraits, pointers to supertrait vtable will
725+ /// be provided when necessary; this is the start of `upcast_trait_ref`'s methods
726+ /// in that vtable.
727+ Object { vtable_base : usize } ,
745728 /// The vtable is formed by concatenating together the method lists of
746729 /// the base object trait and all supertraits, pointers to supertrait vtable will
747730 /// be provided when necessary; this is the position of `upcast_trait_ref`'s vtable
748731 /// within that vtable.
749- pub vtable_vptr_slot : Option < usize > ,
750-
751- pub nested : Vec < N > ,
732+ TraitUpcasting { vtable_vptr_slot : Option < usize > } ,
733+ /// Unsizing a tuple like `(A, B, ..., X)` to `(A, B, ..., Y)` if `X` unsizes to `Y`.
734+ ///
735+ /// This needs to be a separate variant as it is still unstable and we need to emit
736+ /// a feature error when using it on stable.
737+ TupleUnsizing ,
752738}
753739
754- #[ derive( PartialEq , Eq , Clone , TyEncodable , TyDecodable , HashStable , Lift ) ]
755- #[ derive( TypeFoldable , TypeVisitable ) ]
756- pub struct ImplSourceObjectData < N > {
757- /// The vtable is formed by concatenating together the method lists of
758- /// the base object trait and all supertraits, pointers to supertrait vtable will
759- /// be provided when necessary; this is the start of `upcast_trait_ref`'s methods
760- /// in that vtable.
761- pub vtable_base : usize ,
762-
763- pub nested : Vec < N > ,
764- }
740+ TrivialTypeTraversalAndLiftImpls ! { BuiltinImplSource }
765741
766742#[ derive( Clone , Debug , PartialEq , Eq , Hash , HashStable , PartialOrd , Ord ) ]
767743pub enum ObjectSafetyViolation {
0 commit comments