33use std:: iter:: { repeat, repeat_with} ;
44use std:: { mem, sync:: Arc } ;
55
6- use chalk_ir:: { Mutability , TyVariableKind } ;
6+ use chalk_ir:: { cast :: Cast , Mutability , TyVariableKind } ;
77use hir_def:: {
88 expr:: { Array , BinaryOp , Expr , ExprId , Literal , Statement , UnaryOp } ,
99 path:: { GenericArg , GenericArgs } ,
@@ -21,7 +21,7 @@ use crate::{
2121 to_assoc_type_id, to_chalk_trait_id,
2222 traits:: { chalk:: from_chalk, FnTrait , InEnvironment } ,
2323 utils:: { generics, variant_data, Generics } ,
24- AdtId , Binders , CallableDefId , FnPointer , FnSig , Interner , Obligation , Rawness , Scalar ,
24+ AdtId , Binders , CallableDefId , DomainGoal , FnPointer , FnSig , Interner , Rawness , Scalar ,
2525 Substitution , TraitRef , Ty , TyKind ,
2626} ;
2727
@@ -90,10 +90,9 @@ impl<'a> InferenceContext<'a> {
9090 Substitution :: build_for_generics ( & generic_params) . push ( ty. clone ( ) ) . push ( arg_ty) . build ( ) ;
9191
9292 let trait_env = Arc :: clone ( & self . trait_env ) ;
93- let implements_fn_trait = Obligation :: Trait ( TraitRef {
94- trait_id : to_chalk_trait_id ( fn_once_trait) ,
95- substitution : substs. clone ( ) ,
96- } ) ;
93+ let implements_fn_trait: DomainGoal =
94+ TraitRef { trait_id : to_chalk_trait_id ( fn_once_trait) , substitution : substs. clone ( ) }
95+ . cast ( & Interner ) ;
9796 let goal = self . canonicalizer ( ) . canonicalize_obligation ( InEnvironment {
9897 value : implements_fn_trait. clone ( ) ,
9998 environment : trait_env,
@@ -938,22 +937,20 @@ impl<'a> InferenceContext<'a> {
938937 let generic_predicates = self . db . generic_predicates ( def. into ( ) ) ;
939938 for predicate in generic_predicates. iter ( ) {
940939 let predicate = predicate. clone ( ) . subst ( parameters) ;
941- if let Some ( obligation) = Obligation :: from_predicate ( predicate) {
942- self . obligations . push ( obligation) ;
943- }
940+ self . obligations . push ( predicate. cast ( & Interner ) ) ;
944941 }
945942 // add obligation for trait implementation, if this is a trait method
946943 match def {
947944 CallableDefId :: FunctionId ( f) => {
948945 if let AssocContainerId :: TraitId ( trait_) = f. lookup ( self . db . upcast ( ) ) . container
949946 {
950- // construct a TraitDef
947+ // construct a TraitRef
951948 let substs =
952949 parameters. prefix ( generics ( self . db . upcast ( ) , trait_. into ( ) ) . len ( ) ) ;
953- self . obligations . push ( Obligation :: Trait ( TraitRef {
954- trait_id : to_chalk_trait_id ( trait_) ,
955- substitution : substs ,
956- } ) ) ;
950+ self . obligations . push (
951+ TraitRef { trait_id : to_chalk_trait_id ( trait_) , substitution : substs }
952+ . cast ( & Interner ) ,
953+ ) ;
957954 }
958955 }
959956 CallableDefId :: StructId ( _) | CallableDefId :: EnumVariantId ( _) => { }
0 commit comments