@@ -381,10 +381,7 @@ impl LowerWhereClause<ir::DomainGoal> for WhereClause {
381
381
ir:: DomainGoal :: Implemented ( trait_ref. lower ( env) ?)
382
382
}
383
383
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 {
388
385
projection : projection. lower ( env) ?,
389
386
ty : ty. lower ( env) ?,
390
387
} )
@@ -406,18 +403,11 @@ impl LowerWhereClause<ir::DomainGoal> for WhereClause {
406
403
impl LowerWhereClause < ir:: LeafGoal > for WhereClause {
407
404
fn lower ( & self , env : & Env ) -> Result < ir:: LeafGoal > {
408
405
Ok ( match * self {
409
- WhereClause :: Implemented { .. } => {
406
+ WhereClause :: Implemented { .. } |
407
+ WhereClause :: ProjectionEq { .. } => {
410
408
let g: ir:: DomainGoal = self . lower ( env) ?;
411
409
g. cast ( )
412
410
}
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
- }
421
411
WhereClause :: TyWellFormed { ref ty } => {
422
412
ir:: WellFormed :: Ty ( ty. lower ( env) ?) . cast ( )
423
413
}
@@ -806,7 +796,8 @@ impl ir::ImplDatum {
806
796
consequence : bound. trait_ref . clone ( ) . cast ( ) ,
807
797
conditions : bound. where_clauses . clone ( ) . cast ( ) ,
808
798
}
809
- } )
799
+ } ) ,
800
+ fallback_clause : false ,
810
801
}
811
802
}
812
803
}
@@ -824,7 +815,7 @@ impl ir::AssociatedTyValue {
824
815
///
825
816
/// ```notrust
826
817
/// forall<'a, T> {
827
- /// (Vec<T>: Iterable<IntoIter<'a> =raw Iter<'a, T>>) :-
818
+ /// (Vec<T>: Iterable<IntoIter<'a> = Iter<'a, T>>) :-
828
819
/// (Vec<T>: Iterable), // (1)
829
820
/// (T: 'a) // (2)
830
821
/// }
@@ -868,13 +859,14 @@ impl ir::AssociatedTyValue {
868
859
implication : ir:: Binders {
869
860
binders : all_binders. clone ( ) ,
870
861
value : ir:: ProgramClauseImplication {
871
- consequence : ir:: DomainGoal :: RawNormalize ( ir:: Normalize {
862
+ consequence : ir:: DomainGoal :: Normalize ( ir:: Normalize {
872
863
projection : projection. clone ( ) ,
873
864
ty : self . value . value . ty . clone ( )
874
865
} ) ,
875
866
conditions : conditions. clone ( ) ,
876
867
}
877
- }
868
+ } ,
869
+ fallback_clause : false ,
878
870
} ;
879
871
880
872
vec ! [ normalization]
@@ -932,7 +924,8 @@ impl ir::StructDatum {
932
924
. map ( |wc| wc. cast ( ) )
933
925
. collect ( ) ,
934
926
}
935
- } )
927
+ } ) ,
928
+ fallback_clause : false ,
936
929
} ;
937
930
938
931
vec ! [ wf]
@@ -972,7 +965,8 @@ impl ir::TraitDatum {
972
965
tys. chain ( where_clauses) . collect ( )
973
966
}
974
967
}
975
- } )
968
+ } ) ,
969
+ fallback_clause : false ,
976
970
} ;
977
971
978
972
vec ! [ wf]
@@ -981,8 +975,9 @@ impl ir::TraitDatum {
981
975
982
976
impl ir:: AssociatedTyDatum {
983
977
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.
986
981
//
987
982
// Given:
988
983
//
@@ -992,8 +987,7 @@ impl ir::AssociatedTyDatum {
992
987
//
993
988
// we generate:
994
989
//
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>.
997
991
998
992
let binders: Vec < _ > = self . parameter_kinds . iter ( ) . map ( |pk| pk. map ( |_| ( ) ) ) . collect ( ) ;
999
993
let parameters: Vec < _ > = binders. iter ( ) . zip ( 0 ..) . map ( |p| p. to_parameter ( ) ) . collect ( ) ;
@@ -1002,52 +996,25 @@ impl ir::AssociatedTyDatum {
1002
996
parameters : parameters. clone ( ) ,
1003
997
} ;
1004
998
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
-
1024
999
let fallback = {
1025
1000
// Construct an application from the projection. So if we have `<T as Iterator>::Item`,
1026
1001
// we would produce `(Iterator::Item)<T>`.
1027
1002
let app = ir:: ApplicationTy { name : ir:: TypeName :: AssociatedType ( self . id ) , parameters } ;
1028
1003
let ty = ir:: Ty :: Apply ( app) ;
1029
1004
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
-
1040
1005
ir:: ProgramClause {
1041
1006
implication : ir:: Binders {
1042
1007
binders,
1043
1008
value : ir:: ProgramClauseImplication {
1044
1009
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 ! [ ] ,
1046
1012
}
1047
- }
1013
+ } ,
1014
+ fallback_clause : true ,
1048
1015
}
1049
1016
} ;
1050
1017
1051
- vec ! [ raw , fallback]
1018
+ vec ! [ fallback]
1052
1019
}
1053
1020
}
0 commit comments