File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1039,6 +1039,31 @@ impl ir::Program {
1039
1039
) ;
1040
1040
program_clauses. extend ( self . default_impl_data . iter ( ) . map ( |d| d. to_program_clause ( ) ) ) ;
1041
1041
1042
+ // Adds clause that defines Deref:
1043
+ // forall<T, U> { Deref(T, U) :- ProjectionEq(<T as Deref>::Target = U>) }
1044
+ if let Some ( trait_id) = self . lang_items . get ( & ir:: LangItem :: DerefTrait ) {
1045
+ // Find `Deref::Target`.
1046
+ let associated_ty_id = self . associated_ty_data . values ( )
1047
+ . find ( |d| d. trait_id == * trait_id)
1048
+ . expect ( "Deref has no assoc item" )
1049
+ . id ;
1050
+ let t = || ir:: Ty :: Var ( 0 ) ;
1051
+ let u = || ir:: Ty :: Var ( 1 ) ;
1052
+ program_clauses. push ( ir:: Binders {
1053
+ binders : vec ! [ ir:: ParameterKind :: Ty ( ( ) ) , ir:: ParameterKind :: Ty ( ( ) ) ] ,
1054
+ value : ir:: ProgramClauseImplication {
1055
+ consequence : ir:: DomainGoal :: Deref ( ir:: Deref { source : t ( ) , target : u ( ) } ) ,
1056
+ conditions : vec ! [ ir:: ProjectionEq {
1057
+ projection: ir:: ProjectionTy {
1058
+ associated_ty_id,
1059
+ parameters: vec![ t( ) . cast( ) ]
1060
+ } ,
1061
+ ty: u( ) ,
1062
+ } . cast( ) ]
1063
+ } ,
1064
+ } . cast ( ) ) ;
1065
+ }
1066
+
1042
1067
for datum in self . impl_data . values ( ) {
1043
1068
// If we encounter a negative impl, do not generate any rule. Negative impls
1044
1069
// are currently just there to deactivate default impls for auto traits.
You can’t perform that action at this time.
0 commit comments