@@ -16,13 +16,6 @@ use super::{FulfillmentContext, FulfillmentError};
1616use super :: { ObligationCause , PredicateObligation , PendingPredicateObligation } ;
1717
1818pub trait TraitEngine < ' tcx > {
19- /// "Normalize" a projection type `<SomeType as SomeTrait>::X` by
20- /// creating a fresh type variable `$0` as well as a projection
21- /// predicate `<SomeType as SomeTrait>::X == $0`. When the
22- /// inference engine runs, it will attempt to find an impl of
23- /// `SomeTrait` or a where clause that lets us unify `$0` with
24- /// something concrete. If this fails, we'll unify `$0` with
25- /// `projection_ty` again.
2619 fn normalize_projection_type < ' a , ' gcx > (
2720 & mut self ,
2821 infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
@@ -31,9 +24,6 @@ pub trait TraitEngine<'tcx> {
3124 cause : ObligationCause < ' tcx > ,
3225 ) -> Ty < ' tcx > ;
3326
34- /// Requires that `ty` must implement the trait with `def_id` in
35- /// the given environment. This trait must not have any type
36- /// parameters (except for `Self`).
3727 fn register_bound < ' a , ' gcx > (
3828 & mut self ,
3929 infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
@@ -62,8 +52,19 @@ pub trait TraitEngine<'tcx> {
6252 fn pending_obligations ( & self ) -> Vec < PendingPredicateObligation < ' tcx > > ;
6353}
6454
65- impl < ' tcx > dyn TraitEngine < ' tcx > {
66- pub fn new ( _tcx : TyCtxt < ' _ , ' _ , ' tcx > ) -> Box < Self > {
67- Box :: new ( FulfillmentContext :: new ( ) )
68- }
55+ impl < ' a , ' gcx , ' tcx > dyn TraitEngine < ' tcx > +' tcx {
56+ pub fn new ( _tcx : TyCtxt < ' _ , ' _ , ' tcx > ) -> Box < Self + ' tcx >
57+ {
58+ Box :: new ( FulfillmentContext :: new ( ) )
59+ }
60+
61+ pub fn register_predicate_obligations < I > ( & mut self ,
62+ infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
63+ obligations : I )
64+ where I : IntoIterator < Item = PredicateObligation < ' tcx > >
65+ {
66+ for obligation in obligations {
67+ self . register_predicate_obligation ( infcx, obligation) ;
68+ }
69+ }
6970}
0 commit comments