@@ -644,39 +644,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
644644
645645 ast:: ItemTrait ( ..) => {
646646 let trait_def = ty:: lookup_trait_def ( tcx, did) ;
647- let predicates = ty:: lookup_super_predicates ( tcx, did) ;
648- self . add_constraints_from_predicates ( & trait_def. generics ,
649- predicates. predicates . as_slice ( ) ,
650- self . covariant ) ;
651-
652- let trait_items = ty:: trait_items ( tcx, did) ;
653- for trait_item in & * trait_items {
654- match * trait_item {
655- ty:: MethodTraitItem ( ref method) => {
656- self . add_constraints_from_predicates (
657- & method. generics ,
658- method. predicates . predicates . get_slice ( FnSpace ) ,
659- self . contravariant ) ;
660-
661- self . add_constraints_from_sig (
662- & method. generics ,
663- & method. fty . sig ,
664- self . covariant ) ;
665- }
666- ty:: TypeTraitItem ( ref data) => {
667- // Any trait with an associated type is
668- // invariant with respect to all of its
669- // inputs. See length discussion in the comment
670- // on this module.
671- let projection_ty = ty:: mk_projection ( tcx,
672- trait_def. trait_ref . clone ( ) ,
673- data. name ) ;
674- self . add_constraints_from_ty ( & trait_def. generics ,
675- projection_ty,
676- self . invariant ) ;
677- }
678- }
679- }
647+ self . add_constraints_from_trait_ref ( & trait_def. generics ,
648+ & trait_def. trait_ref ,
649+ self . invariant ) ;
680650 }
681651
682652 ast:: ItemExternCrate ( _) |
@@ -1045,69 +1015,6 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
10451015 }
10461016 }
10471017
1048- fn add_constraints_from_predicates ( & mut self ,
1049- generics : & ty:: Generics < ' tcx > ,
1050- predicates : & [ ty:: Predicate < ' tcx > ] ,
1051- variance : VarianceTermPtr < ' a > ) {
1052- debug ! ( "add_constraints_from_generics({})" ,
1053- generics. repr( self . tcx( ) ) ) ;
1054-
1055- for predicate in predicates. iter ( ) {
1056- match * predicate {
1057- ty:: Predicate :: Trait ( ty:: Binder ( ref data) ) => {
1058- self . add_constraints_from_trait_ref ( generics, & * data. trait_ref , variance) ;
1059- }
1060-
1061- ty:: Predicate :: Equate ( ty:: Binder ( ref data) ) => {
1062- // A == B is only true if A and B are the same
1063- // types, not subtypes of one another, so this is
1064- // an invariant position:
1065- self . add_constraints_from_ty ( generics, data. 0 , self . invariant ) ;
1066- self . add_constraints_from_ty ( generics, data. 1 , self . invariant ) ;
1067- }
1068-
1069- ty:: Predicate :: TypeOutlives ( ty:: Binder ( ref data) ) => {
1070- // Why contravariant on both? Let's consider:
1071- //
1072- // Under what conditions is `(T:'t) <: (U:'u)`,
1073- // meaning that `(T:'t) => (U:'u)`. The answer is
1074- // if `U <: T` or `'u <= 't`. Let's see some examples:
1075- //
1076- // (T: 'big) => (T: 'small)
1077- // where 'small <= 'big
1078- //
1079- // (&'small Foo: 't) => (&'big Foo: 't)
1080- // where 'small <= 'big
1081- // note that &'big Foo <: &'small Foo
1082-
1083- let variance_r = self . xform ( variance, self . contravariant ) ;
1084- self . add_constraints_from_ty ( generics, data. 0 , variance_r) ;
1085- self . add_constraints_from_region ( generics, data. 1 , variance_r) ;
1086- }
1087-
1088- ty:: Predicate :: RegionOutlives ( ty:: Binder ( ref data) ) => {
1089- // `'a : 'b` is still true if 'a gets bigger
1090- self . add_constraints_from_region ( generics, data. 0 , variance) ;
1091-
1092- // `'a : 'b` is still true if 'b gets smaller
1093- let variance_r = self . xform ( variance, self . contravariant ) ;
1094- self . add_constraints_from_region ( generics, data. 1 , variance_r) ;
1095- }
1096-
1097- ty:: Predicate :: Projection ( ty:: Binder ( ref data) ) => {
1098- self . add_constraints_from_trait_ref ( generics,
1099- & * data. projection_ty . trait_ref ,
1100- variance) ;
1101-
1102- // as the equality predicate above, a binder is a
1103- // type equality relation, not a subtyping
1104- // relation
1105- self . add_constraints_from_ty ( generics, data. ty , self . invariant ) ;
1106- }
1107- }
1108- }
1109- }
1110-
11111018 /// Adds constraints appropriate for a function with signature
11121019 /// `sig` appearing in a context with ambient variance `variance`
11131020 fn add_constraints_from_sig ( & mut self ,
0 commit comments