@@ -646,97 +646,53 @@ pub enum ImplSource<'tcx, N> {
646
646
/// ImplSource identifying a particular impl.
647
647
UserDefined ( ImplSourceUserDefinedData < ' tcx , N > ) ,
648
648
649
- /// ImplSource for auto trait implementations.
650
- /// This carries the information and nested obligations with regards
651
- /// to an auto implementation for a trait `Trait`. The nested obligations
652
- /// ensure the trait implementation holds for all the constituent types.
653
- AutoImpl ( ImplSourceAutoImplData < N > ) ,
654
-
655
649
/// Successful resolution to an obligation provided by the caller
656
650
/// for some type parameter. The `Vec<N>` represents the
657
651
/// obligations incurred from normalizing the where-clause (if
658
652
/// any).
659
653
Param ( Vec < N > , ty:: BoundConstness ) ,
660
654
661
655
/// Virtual calls through an object.
662
- Object ( ImplSourceObjectData < ' tcx , N > ) ,
656
+ Object ( ImplSourceObjectData < N > ) ,
663
657
664
658
/// Successful resolution for a builtin trait.
665
- Builtin ( ImplSourceBuiltinData < N > ) ,
659
+ Builtin ( Vec < N > ) ,
666
660
667
661
/// ImplSource for trait upcasting coercion
668
- TraitUpcasting ( ImplSourceTraitUpcastingData < ' tcx , N > ) ,
669
-
670
- /// ImplSource automatically generated for a closure. The `DefId` is the ID
671
- /// of the closure expression. This is an `ImplSource::UserDefined` in spirit, but the
672
- /// impl is generated by the compiler and does not appear in the source.
673
- Closure ( ImplSourceClosureData < ' tcx , N > ) ,
674
-
675
- /// Same as above, but for a function pointer type with the given signature.
676
- FnPointer ( ImplSourceFnPointerData < ' tcx , N > ) ,
677
-
678
- /// ImplSource automatically generated for a generator.
679
- Generator ( ImplSourceGeneratorData < ' tcx , N > ) ,
680
-
681
- /// ImplSource automatically generated for a generator backing an async future.
682
- Future ( ImplSourceFutureData < ' tcx , N > ) ,
662
+ TraitUpcasting ( ImplSourceTraitUpcastingData < N > ) ,
683
663
684
664
/// ImplSource for a trait alias.
685
665
TraitAlias ( ImplSourceTraitAliasData < ' tcx , N > ) ,
686
-
687
- /// ImplSource for a `const Drop` implementation.
688
- ConstDestruct ( ImplSourceConstDestructData < N > ) ,
689
666
}
690
667
691
668
impl < ' tcx , N > ImplSource < ' tcx , N > {
692
669
pub fn nested_obligations ( self ) -> Vec < N > {
693
670
match self {
694
671
ImplSource :: UserDefined ( i) => i. nested ,
695
- ImplSource :: Param ( n, _) => n,
696
- ImplSource :: Builtin ( i) => i. nested ,
697
- ImplSource :: AutoImpl ( d) => d. nested ,
698
- ImplSource :: Closure ( c) => c. nested ,
699
- ImplSource :: Generator ( c) => c. nested ,
700
- ImplSource :: Future ( c) => c. nested ,
672
+ ImplSource :: Param ( n, _) | ImplSource :: Builtin ( n) => n,
701
673
ImplSource :: Object ( d) => d. nested ,
702
- ImplSource :: FnPointer ( d) => d. nested ,
703
674
ImplSource :: TraitAlias ( d) => d. nested ,
704
675
ImplSource :: TraitUpcasting ( d) => d. nested ,
705
- ImplSource :: ConstDestruct ( i) => i. nested ,
706
676
}
707
677
}
708
678
709
679
pub fn borrow_nested_obligations ( & self ) -> & [ N ] {
710
680
match self {
711
681
ImplSource :: UserDefined ( i) => & i. nested ,
712
- ImplSource :: Param ( n, _) => n,
713
- ImplSource :: Builtin ( i) => & i. nested ,
714
- ImplSource :: AutoImpl ( d) => & d. nested ,
715
- ImplSource :: Closure ( c) => & c. nested ,
716
- ImplSource :: Generator ( c) => & c. nested ,
717
- ImplSource :: Future ( c) => & c. nested ,
682
+ ImplSource :: Param ( n, _) | ImplSource :: Builtin ( n) => & n,
718
683
ImplSource :: Object ( d) => & d. nested ,
719
- ImplSource :: FnPointer ( d) => & d. nested ,
720
684
ImplSource :: TraitAlias ( d) => & d. nested ,
721
685
ImplSource :: TraitUpcasting ( d) => & d. nested ,
722
- ImplSource :: ConstDestruct ( i) => & i. nested ,
723
686
}
724
687
}
725
688
726
689
pub fn borrow_nested_obligations_mut ( & mut self ) -> & mut [ N ] {
727
690
match self {
728
691
ImplSource :: UserDefined ( i) => & mut i. nested ,
729
- ImplSource :: Param ( n, _) => n,
730
- ImplSource :: Builtin ( i) => & mut i. nested ,
731
- ImplSource :: AutoImpl ( d) => & mut d. nested ,
732
- ImplSource :: Closure ( c) => & mut c. nested ,
733
- ImplSource :: Generator ( c) => & mut c. nested ,
734
- ImplSource :: Future ( c) => & mut c. nested ,
692
+ ImplSource :: Param ( n, _) | ImplSource :: Builtin ( n) => n,
735
693
ImplSource :: Object ( d) => & mut d. nested ,
736
- ImplSource :: FnPointer ( d) => & mut d. nested ,
737
694
ImplSource :: TraitAlias ( d) => & mut d. nested ,
738
695
ImplSource :: TraitUpcasting ( d) => & mut d. nested ,
739
- ImplSource :: ConstDestruct ( i) => & mut i. nested ,
740
696
}
741
697
}
742
698
@@ -751,54 +707,23 @@ impl<'tcx, N> ImplSource<'tcx, N> {
751
707
nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
752
708
} ) ,
753
709
ImplSource :: Param ( n, ct) => ImplSource :: Param ( n. into_iter ( ) . map ( f) . collect ( ) , ct) ,
754
- ImplSource :: Builtin ( i) => ImplSource :: Builtin ( ImplSourceBuiltinData {
755
- nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
756
- } ) ,
710
+ ImplSource :: Builtin ( n) => ImplSource :: Builtin ( n. into_iter ( ) . map ( f) . collect ( ) ) ,
757
711
ImplSource :: Object ( o) => ImplSource :: Object ( ImplSourceObjectData {
758
- upcast_trait_ref : o. upcast_trait_ref ,
712
+ upcast_trait_def_id : o. upcast_trait_def_id ,
759
713
vtable_base : o. vtable_base ,
760
714
nested : o. nested . into_iter ( ) . map ( f) . collect ( ) ,
761
715
} ) ,
762
- ImplSource :: AutoImpl ( d) => ImplSource :: AutoImpl ( ImplSourceAutoImplData {
763
- trait_def_id : d. trait_def_id ,
764
- nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
765
- } ) ,
766
- ImplSource :: Closure ( c) => ImplSource :: Closure ( ImplSourceClosureData {
767
- closure_def_id : c. closure_def_id ,
768
- substs : c. substs ,
769
- nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
770
- } ) ,
771
- ImplSource :: Generator ( c) => ImplSource :: Generator ( ImplSourceGeneratorData {
772
- generator_def_id : c. generator_def_id ,
773
- substs : c. substs ,
774
- nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
775
- } ) ,
776
- ImplSource :: Future ( c) => ImplSource :: Future ( ImplSourceFutureData {
777
- generator_def_id : c. generator_def_id ,
778
- substs : c. substs ,
779
- nested : c. nested . into_iter ( ) . map ( f) . collect ( ) ,
780
- } ) ,
781
- ImplSource :: FnPointer ( p) => ImplSource :: FnPointer ( ImplSourceFnPointerData {
782
- fn_ty : p. fn_ty ,
783
- nested : p. nested . into_iter ( ) . map ( f) . collect ( ) ,
784
- } ) ,
785
716
ImplSource :: TraitAlias ( d) => ImplSource :: TraitAlias ( ImplSourceTraitAliasData {
786
717
alias_def_id : d. alias_def_id ,
787
718
substs : d. substs ,
788
719
nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
789
720
} ) ,
790
721
ImplSource :: TraitUpcasting ( d) => {
791
722
ImplSource :: TraitUpcasting ( ImplSourceTraitUpcastingData {
792
- upcast_trait_ref : d. upcast_trait_ref ,
793
723
vtable_vptr_slot : d. vtable_vptr_slot ,
794
724
nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
795
725
} )
796
726
}
797
- ImplSource :: ConstDestruct ( i) => {
798
- ImplSource :: ConstDestruct ( ImplSourceConstDestructData {
799
- nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
800
- } )
801
- }
802
727
}
803
728
}
804
729
}
@@ -823,47 +748,7 @@ pub struct ImplSourceUserDefinedData<'tcx, N> {
823
748
824
749
#[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
825
750
#[ derive( TypeFoldable , TypeVisitable ) ]
826
- pub struct ImplSourceGeneratorData < ' tcx , N > {
827
- pub generator_def_id : DefId ,
828
- pub substs : SubstsRef < ' tcx > ,
829
- /// Nested obligations. This can be non-empty if the generator
830
- /// signature contains associated types.
831
- pub nested : Vec < N > ,
832
- }
833
-
834
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
835
- #[ derive( TypeFoldable , TypeVisitable ) ]
836
- pub struct ImplSourceFutureData < ' tcx , N > {
837
- pub generator_def_id : DefId ,
838
- pub substs : SubstsRef < ' tcx > ,
839
- /// Nested obligations. This can be non-empty if the generator
840
- /// signature contains associated types.
841
- pub nested : Vec < N > ,
842
- }
843
-
844
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
845
- #[ derive( TypeFoldable , TypeVisitable ) ]
846
- pub struct ImplSourceClosureData < ' tcx , N > {
847
- pub closure_def_id : DefId ,
848
- pub substs : SubstsRef < ' tcx > ,
849
- /// Nested obligations. This can be non-empty if the closure
850
- /// signature contains associated types.
851
- pub nested : Vec < N > ,
852
- }
853
-
854
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
855
- #[ derive( TypeFoldable , TypeVisitable ) ]
856
- pub struct ImplSourceAutoImplData < N > {
857
- pub trait_def_id : DefId ,
858
- pub nested : Vec < N > ,
859
- }
860
-
861
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
862
- #[ derive( TypeFoldable , TypeVisitable ) ]
863
- pub struct ImplSourceTraitUpcastingData < ' tcx , N > {
864
- /// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
865
- pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
866
-
751
+ pub struct ImplSourceTraitUpcastingData < N > {
867
752
/// The vtable is formed by concatenating together the method lists of
868
753
/// the base object trait and all supertraits, pointers to supertrait vtable will
869
754
/// be provided when necessary; this is the position of `upcast_trait_ref`'s vtable
@@ -873,17 +758,11 @@ pub struct ImplSourceTraitUpcastingData<'tcx, N> {
873
758
pub nested : Vec < N > ,
874
759
}
875
760
876
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
877
- #[ derive( TypeFoldable , TypeVisitable ) ]
878
- pub struct ImplSourceBuiltinData < N > {
879
- pub nested : Vec < N > ,
880
- }
881
-
882
761
#[ derive( PartialEq , Eq , Clone , TyEncodable , TyDecodable , HashStable , Lift ) ]
883
762
#[ derive( TypeFoldable , TypeVisitable ) ]
884
- pub struct ImplSourceObjectData < ' tcx , N > {
763
+ pub struct ImplSourceObjectData < N > {
885
764
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
886
- pub upcast_trait_ref : ty :: PolyTraitRef < ' tcx > ,
765
+ pub upcast_trait_def_id : DefId ,
887
766
888
767
/// The vtable is formed by concatenating together the method lists of
889
768
/// the base object trait and all supertraits, pointers to supertrait vtable will
@@ -894,19 +773,6 @@ pub struct ImplSourceObjectData<'tcx, N> {
894
773
pub nested : Vec < N > ,
895
774
}
896
775
897
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
898
- #[ derive( TypeFoldable , TypeVisitable ) ]
899
- pub struct ImplSourceFnPointerData < ' tcx , N > {
900
- pub fn_ty : Ty < ' tcx > ,
901
- pub nested : Vec < N > ,
902
- }
903
-
904
- #[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
905
- #[ derive( TypeFoldable , TypeVisitable ) ]
906
- pub struct ImplSourceConstDestructData < N > {
907
- pub nested : Vec < N > ,
908
- }
909
-
910
776
#[ derive( Clone , PartialEq , Eq , TyEncodable , TyDecodable , HashStable , Lift ) ]
911
777
#[ derive( TypeFoldable , TypeVisitable ) ]
912
778
pub struct ImplSourceTraitAliasData < ' tcx , N > {
0 commit comments