@@ -5,7 +5,7 @@ use std::{iter, sync::Arc};
5
5
6
6
use tracing:: debug;
7
7
8
- use chalk_ir:: { cast:: Cast , fold:: shift:: Shift , CanonicalVarKinds } ;
8
+ use chalk_ir:: { cast:: Caster , fold:: shift:: Shift , CanonicalVarKinds } ;
9
9
use chalk_solve:: rust_ir:: { self , OpaqueTyDatumBound , WellKnownTrait } ;
10
10
11
11
use base_db:: CrateId ;
@@ -846,28 +846,34 @@ pub(super) fn generic_predicate_to_inline_bound(
846
846
}
847
847
let args_no_self = trait_ref. substitution . as_slice ( Interner ) [ 1 ..]
848
848
. iter ( )
849
- . map ( |ty| ty. clone ( ) . cast ( Interner ) )
849
+ . cloned ( )
850
+ . casted ( Interner )
850
851
. collect ( ) ;
851
852
let trait_bound = rust_ir:: TraitBound { trait_id : trait_ref. trait_id , args_no_self } ;
852
853
Some ( chalk_ir:: Binders :: new ( binders, rust_ir:: InlineBound :: TraitBound ( trait_bound) ) )
853
854
}
854
855
WhereClause :: AliasEq ( AliasEq { alias : AliasTy :: Projection ( projection_ty) , ty } ) => {
855
- let trait_ = projection_ty. trait_ ( db) ;
856
- if projection_ty. self_type_parameter ( db) != self_ty_shifted_in {
856
+ let generics =
857
+ generics ( db. upcast ( ) , from_assoc_type_id ( projection_ty. associated_ty_id ) . into ( ) ) ;
858
+ let ( assoc_args, trait_args) =
859
+ projection_ty. substitution . as_slice ( Interner ) . split_at ( generics. len_self ( ) ) ;
860
+ let ( self_ty, args_no_self) =
861
+ trait_args. split_first ( ) . expect ( "projection without trait self type" ) ;
862
+ if self_ty. assert_ty_ref ( Interner ) != & self_ty_shifted_in {
857
863
return None ;
858
864
}
859
- let args_no_self = projection_ty . substitution . as_slice ( Interner ) [ 1 .. ]
860
- . iter ( )
861
- . map ( |ty| ty . clone ( ) . cast ( Interner ) )
862
- . collect ( ) ;
865
+
866
+ let args_no_self = args_no_self . iter ( ) . cloned ( ) . casted ( Interner ) . collect ( ) ;
867
+ let parameters = assoc_args . to_vec ( ) ;
868
+
863
869
let alias_eq_bound = rust_ir:: AliasEqBound {
864
870
value : ty. clone ( ) ,
865
871
trait_bound : rust_ir:: TraitBound {
866
- trait_id : to_chalk_trait_id ( trait_) ,
872
+ trait_id : to_chalk_trait_id ( projection_ty . trait_ ( db ) ) ,
867
873
args_no_self,
868
874
} ,
869
875
associated_ty_id : projection_ty. associated_ty_id ,
870
- parameters : Vec :: new ( ) , // FIXME we don't support generic associated types yet
876
+ parameters,
871
877
} ;
872
878
Some ( chalk_ir:: Binders :: new (
873
879
binders,
0 commit comments