@@ -649,46 +649,31 @@ pub enum ImplSource<'tcx, N> {
649
649
/// for some type parameter. The `Vec<N>` represents the
650
650
/// obligations incurred from normalizing the where-clause (if
651
651
/// any).
652
- Param ( Vec < N > , ty:: BoundConstness ) ,
652
+ Param ( ty:: BoundConstness , Vec < N > ) ,
653
653
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 > ) ,
665
656
}
666
657
667
658
impl < ' tcx , N > ImplSource < ' tcx , N > {
668
659
pub fn nested_obligations ( self ) -> Vec < N > {
669
660
match self {
670
661
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,
674
663
}
675
664
}
676
665
677
666
pub fn borrow_nested_obligations ( & self ) -> & [ N ] {
678
667
match self {
679
668
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,
683
670
}
684
671
}
685
672
686
673
pub fn borrow_nested_obligations_mut ( & mut self ) -> & mut [ N ] {
687
674
match self {
688
675
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,
692
677
}
693
678
}
694
679
@@ -702,20 +687,9 @@ impl<'tcx, N> ImplSource<'tcx, N> {
702
687
args : i. args ,
703
688
nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
704
689
} ) ,
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 ( ) )
719
693
}
720
694
}
721
695
}
@@ -739,29 +713,31 @@ pub struct ImplSourceUserDefinedData<'tcx, N> {
739
713
pub nested : Vec < N > ,
740
714
}
741
715
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 } ,
745
728
/// The vtable is formed by concatenating together the method lists of
746
729
/// the base object trait and all supertraits, pointers to supertrait vtable will
747
730
/// be provided when necessary; this is the position of `upcast_trait_ref`'s vtable
748
731
/// 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 ,
752
738
}
753
739
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 }
765
741
766
742
#[ derive( Clone , Debug , PartialEq , Eq , Hash , HashStable , PartialOrd , Ord ) ]
767
743
pub enum ObjectSafetyViolation {
0 commit comments