- /// Given a fully substituted set of bounds (`generic_bounds`), and the values with which each
- /// type/region parameter was instantiated (`substs`), creates and registers suitable
- /// trait/region obligations.
- ///
- /// For example, if there is a function:
- ///
- /// ```
- /// fn foo<'a,T:'a>(...)
- /// ```
- ///
- /// and a reference:
- ///
- /// ```
- /// let f = foo;
- /// ```
- ///
- /// Then we will create a fresh region variable `'$0` and a fresh type variable `$1` for `'a`
- /// and `T`. This routine will add a region obligation `$1:'$0` and register it locally.
- pub fn add_obligations_for_parameters(
- &self,
- cause: traits::ObligationCause<'tcx>,
- predicates: ty::InstantiatedPredicates<'tcx>,
- ) {
- assert!(!predicates.has_escaping_bound_vars());
-
- debug!("add_obligations_for_parameters(predicates={:?})", predicates);
-
- for obligation in traits::predicates_for_generics(cause, self.param_env, predicates) {
- self.register_predicate(obligation);
- }
- }
-