@@ -381,10 +381,7 @@ impl LowerWhereClause<ir::DomainGoal> for WhereClause {
381381 ir:: DomainGoal :: Implemented ( trait_ref. lower ( env) ?)
382382 }
383383 WhereClause :: ProjectionEq { ref projection, ref ty } => {
384- // NB: here we generate a RawNormalize, because we want to make
385- // make a maximally-strong assumption (and not allow fallback to
386- // trigger).
387- ir:: DomainGoal :: RawNormalize ( ir:: Normalize {
384+ ir:: DomainGoal :: Normalize ( ir:: Normalize {
388385 projection : projection. lower ( env) ?,
389386 ty : ty. lower ( env) ?,
390387 } )
@@ -406,18 +403,11 @@ impl LowerWhereClause<ir::DomainGoal> for WhereClause {
406403impl LowerWhereClause < ir:: LeafGoal > for WhereClause {
407404 fn lower ( & self , env : & Env ) -> Result < ir:: LeafGoal > {
408405 Ok ( match * self {
409- WhereClause :: Implemented { .. } => {
406+ WhereClause :: Implemented { .. } |
407+ WhereClause :: ProjectionEq { .. } => {
410408 let g: ir:: DomainGoal = self . lower ( env) ?;
411409 g. cast ( )
412410 }
413- WhereClause :: ProjectionEq { ref projection, ref ty } => {
414- // NB: here we generate a full Normalize clause, allowing for
415- // fallback to trigger when we're trying to *prove* a goal
416- ir:: DomainGoal :: Normalize ( ir:: Normalize {
417- projection : projection. lower ( env) ?,
418- ty : ty. lower ( env) ?,
419- } ) . cast ( )
420- }
421411 WhereClause :: TyWellFormed { ref ty } => {
422412 ir:: WellFormed :: Ty ( ty. lower ( env) ?) . cast ( )
423413 }
@@ -806,7 +796,8 @@ impl ir::ImplDatum {
806796 consequence : bound. trait_ref . clone ( ) . cast ( ) ,
807797 conditions : bound. where_clauses . clone ( ) . cast ( ) ,
808798 }
809- } )
799+ } ) ,
800+ fallback_clause : false ,
810801 }
811802 }
812803}
@@ -824,7 +815,7 @@ impl ir::AssociatedTyValue {
824815 ///
825816 /// ```notrust
826817 /// forall<'a, T> {
827- /// (Vec<T>: Iterable<IntoIter<'a> =raw Iter<'a, T>>) :-
818+ /// (Vec<T>: Iterable<IntoIter<'a> = Iter<'a, T>>) :-
828819 /// (Vec<T>: Iterable), // (1)
829820 /// (T: 'a) // (2)
830821 /// }
@@ -868,13 +859,14 @@ impl ir::AssociatedTyValue {
868859 implication : ir:: Binders {
869860 binders : all_binders. clone ( ) ,
870861 value : ir:: ProgramClauseImplication {
871- consequence : ir:: DomainGoal :: RawNormalize ( ir:: Normalize {
862+ consequence : ir:: DomainGoal :: Normalize ( ir:: Normalize {
872863 projection : projection. clone ( ) ,
873864 ty : self . value . value . ty . clone ( )
874865 } ) ,
875866 conditions : conditions. clone ( ) ,
876867 }
877- }
868+ } ,
869+ fallback_clause : false ,
878870 } ;
879871
880872 vec ! [ normalization]
@@ -932,7 +924,8 @@ impl ir::StructDatum {
932924 . map ( |wc| wc. cast ( ) )
933925 . collect ( ) ,
934926 }
935- } )
927+ } ) ,
928+ fallback_clause : false ,
936929 } ;
937930
938931 vec ! [ wf]
@@ -972,7 +965,8 @@ impl ir::TraitDatum {
972965 tys. chain ( where_clauses) . collect ( )
973966 }
974967 }
975- } )
968+ } ) ,
969+ fallback_clause : false ,
976970 } ;
977971
978972 vec ! [ wf]
@@ -981,8 +975,9 @@ impl ir::TraitDatum {
981975
982976impl ir:: AssociatedTyDatum {
983977 fn to_program_clauses ( & self ) -> Vec < ir:: ProgramClause > {
984- // For each associated type, we define normalization including a
985- // "fallback" if we can't resolve a projection using an impl/where clauses.
978+ // For each associated type, we define a normalization "fallback" for
979+ // projecting when we don't have constraints to say anything interesting
980+ // about an associated type.
986981 //
987982 // Given:
988983 //
@@ -992,8 +987,7 @@ impl ir::AssociatedTyDatum {
992987 //
993988 // we generate:
994989 //
995- // ?T: Foo<Assoc = ?U> :- ?T: Foo<Assoc =raw ?U>.
996- // ?T: Foo<Assoc = (Foo::Assoc)<?T>> :- not { exists<U> { ?T: Foo<Assoc =raw U> } }.
990+ // <?T as Foo>::Assoc ==> (Foo::Assoc)<?T>.
997991
998992 let binders: Vec < _ > = self . parameter_kinds . iter ( ) . map ( |pk| pk. map ( |_| ( ) ) ) . collect ( ) ;
999993 let parameters: Vec < _ > = binders. iter ( ) . zip ( 0 ..) . map ( |p| p. to_parameter ( ) ) . collect ( ) ;
@@ -1002,52 +996,25 @@ impl ir::AssociatedTyDatum {
1002996 parameters : parameters. clone ( ) ,
1003997 } ;
1004998
1005- let raw = {
1006- let binders: Vec < _ > = binders. iter ( )
1007- . cloned ( )
1008- . chain ( Some ( ir:: ParameterKind :: Ty ( ( ) ) ) )
1009- . collect ( ) ;
1010- let ty = ir:: Ty :: Var ( binders. len ( ) - 1 ) ;
1011- let normalize = ir:: Normalize { projection : projection. clone ( ) , ty } ;
1012-
1013- ir:: ProgramClause {
1014- implication : ir:: Binders {
1015- binders,
1016- value : ir:: ProgramClauseImplication {
1017- consequence : normalize. clone ( ) . cast ( ) ,
1018- conditions : vec ! [ ir:: DomainGoal :: RawNormalize ( normalize) . cast( ) ] ,
1019- }
1020- }
1021- }
1022- } ;
1023-
1024999 let fallback = {
10251000 // Construct an application from the projection. So if we have `<T as Iterator>::Item`,
10261001 // we would produce `(Iterator::Item)<T>`.
10271002 let app = ir:: ApplicationTy { name : ir:: TypeName :: AssociatedType ( self . id ) , parameters } ;
10281003 let ty = ir:: Ty :: Apply ( app) ;
10291004
1030- let raw = ir:: DomainGoal :: RawNormalize ( ir:: Normalize {
1031- projection : projection. clone ( ) . up_shift ( 1 ) ,
1032- ty : ir:: Ty :: Var ( 0 ) ,
1033- } ) ;
1034- let exists_binders = ir:: Binders {
1035- binders : vec ! [ ir:: ParameterKind :: Ty ( ( ) ) ] ,
1036- value : Box :: new ( raw. cast ( ) ) ,
1037- } ;
1038- let exists = ir:: Goal :: Quantified ( ir:: QuantifierKind :: Exists , exists_binders) ;
1039-
10401005 ir:: ProgramClause {
10411006 implication : ir:: Binders {
10421007 binders,
10431008 value : ir:: ProgramClauseImplication {
10441009 consequence : ir:: Normalize { projection : projection. clone ( ) , ty } . cast ( ) ,
1045- conditions : vec ! [ ir:: Goal :: Not ( Box :: new( exists) ) ]
1010+ // TODO: should probably include the TraitRef here
1011+ conditions : vec ! [ ] ,
10461012 }
1047- }
1013+ } ,
1014+ fallback_clause : true ,
10481015 }
10491016 } ;
10501017
1051- vec ! [ raw , fallback]
1018+ vec ! [ fallback]
10521019 }
10531020}
0 commit comments