1 //! This module contains the code to instantiate a "query result", and
2 //! in particular to extract out the resulting region obligations and
3 //! encode them therein.
5 //! For an overview of what canonicalization is and how it fits into
6 //! rustc, check out the [chapter in the rustc dev guide][c].
8 //! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
10 use crate::infer::canonical::substitute::{substitute_value, CanonicalExt};
11 use crate::infer::canonical::{
12 Canonical, CanonicalQueryResponse, CanonicalVarValues, Certainty, OriginalQueryValues,
13 QueryOutlivesConstraint, QueryRegionConstraints, QueryResponse,
15 use crate::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRelatingDelegate};
16 use crate::infer::region_constraints::{Constraint, RegionConstraintData};
17 use crate::infer::{InferCtxt, InferOk, InferResult, NllRegionVariableOrigin};
18 use crate::traits::query::{Fallible, NoSolution};
19 use crate::traits::{Obligation, ObligationCause, PredicateObligation};
20 use crate::traits::{PredicateObligations, TraitEngine, TraitEngineExt};
21 use rustc_data_structures::captures::Captures;
22 use rustc_index::vec::Idx;
23 use rustc_index::vec::IndexVec;
24 use rustc_middle::arena::ArenaAllocatable;
25 use rustc_middle::mir::ConstraintCategory;
26 use rustc_middle::ty::fold::TypeFoldable;
27 use rustc_middle::ty::relate::TypeRelation;
28 use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
29 use rustc_middle::ty::{self, BoundVar, ToPredicate, Ty, TyCtxt};
34 impl<'tcx> InferCtxt<'tcx> {
35 /// This method is meant to be invoked as the final step of a canonical query
36 /// implementation. It is given:
38 /// - the instantiated variables `inference_vars` created from the query key
39 /// - the result `answer` of the query
40 /// - a fulfillment context `fulfill_cx` that may contain various obligations which
41 /// have yet to be proven.
43 /// Given this, the function will process the obligations pending
46 /// - If all the obligations can be proven successfully, it will
47 /// package up any resulting region obligations (extracted from
48 /// `infcx`) along with the fully resolved value `answer` into a
49 /// query result (which is then itself canonicalized).
50 /// - If some obligations can be neither proven nor disproven, then
51 /// the same thing happens, but the resulting query is marked as ambiguous.
52 /// - Finally, if any of the obligations result in a hard error,
53 /// then `Err(NoSolution)` is returned.
54 #[instrument(skip(self, inference_vars, answer, fulfill_cx), level = "trace")]
55 pub fn make_canonicalized_query_response<T>(
57 inference_vars: CanonicalVarValues<'tcx>,
59 fulfill_cx: &mut dyn TraitEngine<'tcx>,
60 ) -> Fallible<CanonicalQueryResponse<'tcx, T>>
62 T: Debug + TypeFoldable<'tcx>,
63 Canonical<'tcx, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>,
65 let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?;
66 debug!("query_response = {:#?}", query_response);
67 let canonical_result = self.canonicalize_response(query_response);
68 debug!("canonical_result = {:#?}", canonical_result);
70 Ok(self.tcx.arena.alloc(canonical_result))
73 /// A version of `make_canonicalized_query_response` that does
74 /// not pack in obligations, for contexts that want to drop
75 /// pending obligations instead of treating them as an ambiguity (e.g.
76 /// typeck "probing" contexts).
78 /// If you DO want to keep track of pending obligations (which
79 /// include all region obligations, so this includes all cases
80 /// that care about regions) with this function, you have to
81 /// do it yourself, by e.g., having them be a part of the answer.
82 pub fn make_query_response_ignoring_pending_obligations<T>(
84 inference_vars: CanonicalVarValues<'tcx>,
86 ) -> Canonical<'tcx, QueryResponse<'tcx, T>>
88 T: Debug + TypeFoldable<'tcx>,
90 self.canonicalize_response(QueryResponse {
91 var_values: inference_vars,
92 region_constraints: QueryRegionConstraints::default(),
93 certainty: Certainty::Proven, // Ambiguities are OK!
99 /// Helper for `make_canonicalized_query_response` that does
100 /// everything up until the final canonicalization.
101 #[instrument(skip(self, fulfill_cx), level = "debug")]
102 fn make_query_response<T>(
104 inference_vars: CanonicalVarValues<'tcx>,
106 fulfill_cx: &mut dyn TraitEngine<'tcx>,
107 ) -> Result<QueryResponse<'tcx, T>, NoSolution>
109 T: Debug + TypeFoldable<'tcx>,
113 // Select everything, returning errors.
114 let true_errors = fulfill_cx.select_where_possible(self);
115 debug!("true_errors = {:#?}", true_errors);
117 if !true_errors.is_empty() {
118 // FIXME -- we don't indicate *why* we failed to solve
119 debug!("make_query_response: true_errors={:#?}", true_errors);
120 return Err(NoSolution);
123 // Anything left unselected *now* must be an ambiguity.
124 let ambig_errors = fulfill_cx.select_all_or_error(self);
125 debug!("ambig_errors = {:#?}", ambig_errors);
127 let region_obligations = self.take_registered_region_obligations();
128 debug!(?region_obligations);
129 let region_constraints = self.with_region_constraints(|region_constraints| {
130 make_query_region_constraints(
134 .map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())),
138 debug!(?region_constraints);
141 if ambig_errors.is_empty() { Certainty::Proven } else { Certainty::Ambiguous };
143 let opaque_types = self.take_opaque_types_for_query_response();
146 var_values: inference_vars,
154 /// FIXME: This method should only be used for canonical queries and therefore be private.
156 /// As the new solver does canonicalization slightly differently, this is also used there
157 /// for now. This should hopefully change fairly soon.
158 pub fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
159 std::mem::take(&mut self.inner.borrow_mut().opaque_type_storage.opaque_types)
161 .map(|(k, v)| (self.tcx.mk_opaque(k.def_id.to_def_id(), k.substs), v.hidden_type.ty))
165 /// Given the (canonicalized) result to a canonical query,
166 /// instantiates the result so it can be used, plugging in the
167 /// values from the canonical query. (Note that the result may
168 /// have been ambiguous; you should check the certainty level of
169 /// the query before applying this function.)
171 /// To get a good understanding of what is happening here, check
172 /// out the [chapter in the rustc dev guide][c].
174 /// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#processing-the-canonicalized-query-result
175 pub fn instantiate_query_response_and_region_obligations<R>(
177 cause: &ObligationCause<'tcx>,
178 param_env: ty::ParamEnv<'tcx>,
179 original_values: &OriginalQueryValues<'tcx>,
180 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
181 ) -> InferResult<'tcx, R>
183 R: Debug + TypeFoldable<'tcx>,
185 let InferOk { value: result_subst, mut obligations } =
186 self.query_response_substitution(cause, param_env, original_values, query_response)?;
188 obligations.extend(self.query_outlives_constraints_into_obligations(
191 &query_response.value.region_constraints.outlives,
196 query_response.substitute_projected(self.tcx, &result_subst, |q_r| q_r.value.clone());
198 Ok(InferOk { value: user_result, obligations })
201 /// An alternative to
202 /// `instantiate_query_response_and_region_obligations` that is more
203 /// efficient for NLL. NLL is a bit more advanced in the
204 /// "transition to chalk" than the rest of the compiler. During
205 /// the NLL type check, all of the "processing" of types and
206 /// things happens in queries -- the NLL checker itself is only
207 /// interested in the region obligations (`'a: 'b` or `T: 'b`)
208 /// that come out of these queries, which it wants to convert into
209 /// MIR-based constraints and solve. Therefore, it is most
210 /// convenient for the NLL Type Checker to **directly consume**
211 /// the `QueryOutlivesConstraint` values that arise from doing a
212 /// query. This is contrast to other parts of the compiler, which
213 /// would prefer for those `QueryOutlivesConstraint` to be converted
214 /// into the older infcx-style constraints (e.g., calls to
215 /// `sub_regions` or `register_region_obligation`).
217 /// Therefore, `instantiate_nll_query_response_and_region_obligations` performs the same
218 /// basic operations as `instantiate_query_response_and_region_obligations` but
219 /// it returns its result differently:
221 /// - It creates a substitution `S` that maps from the original
222 /// query variables to the values computed in the query
223 /// result. If any errors arise, they are propagated back as an
225 /// - In the case of a successful substitution, we will append
226 /// `QueryOutlivesConstraint` values onto the
227 /// `output_query_region_constraints` vector for the solver to
228 /// use (if an error arises, some values may also be pushed, but
229 /// they should be ignored).
230 /// - It **can happen** (though it rarely does currently) that
231 /// equating types and things will give rise to subobligations
232 /// that must be processed. In this case, those subobligations
233 /// are propagated back in the return value.
234 /// - Finally, the query result (of type `R`) is propagated back,
235 /// after applying the substitution `S`.
236 pub fn instantiate_nll_query_response_and_region_obligations<R>(
238 cause: &ObligationCause<'tcx>,
239 param_env: ty::ParamEnv<'tcx>,
240 original_values: &OriginalQueryValues<'tcx>,
241 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
242 output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
243 ) -> InferResult<'tcx, R>
245 R: Debug + TypeFoldable<'tcx>,
247 let InferOk { value: result_subst, mut obligations } = self
248 .query_response_substitution_guess(cause, param_env, original_values, query_response)?;
250 // Compute `QueryOutlivesConstraint` values that unify each of
251 // the original values `v_o` that was canonicalized into a
254 let constraint_category = cause.to_constraint_category();
256 for (index, original_value) in original_values.var_values.iter().enumerate() {
257 // ...with the value `v_r` of that variable from the query.
258 let result_value = query_response.substitute_projected(self.tcx, &result_subst, |v| {
259 v.var_values[BoundVar::new(index)]
261 match (original_value.unpack(), result_value.unpack()) {
262 (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
263 if re1.is_erased() && re2.is_erased() =>
268 (GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => {
269 // To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`.
271 output_query_region_constraints
273 .push((ty::OutlivesPredicate(v_o.into(), v_r), constraint_category));
274 output_query_region_constraints
276 .push((ty::OutlivesPredicate(v_r.into(), v_o), constraint_category));
280 (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
283 QueryTypeRelatingDelegate {
287 obligations: &mut obligations,
289 ty::Variance::Invariant,
294 (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
297 QueryTypeRelatingDelegate {
301 obligations: &mut obligations,
303 ty::Variance::Invariant,
309 bug!("kind mismatch, cannot unify {:?} and {:?}", original_value, result_value);
314 // ...also include the other query region constraints from the query.
315 output_query_region_constraints.outlives.extend(
316 query_response.value.region_constraints.outlives.iter().filter_map(|&r_c| {
317 let r_c = substitute_value(self.tcx, &result_subst, r_c);
319 // Screen out `'a: 'a` cases.
320 let ty::OutlivesPredicate(k1, r2) = r_c.0;
321 if k1 != r2.into() { Some(r_c) } else { None }
325 // ...also include the query member constraints.
326 output_query_region_constraints.member_constraints.extend(
332 .map(|p_c| substitute_value(self.tcx, &result_subst, p_c.clone())),
336 query_response.substitute_projected(self.tcx, &result_subst, |q_r| q_r.value.clone());
338 Ok(InferOk { value: user_result, obligations })
341 /// Given the original values and the (canonicalized) result from
342 /// computing a query, returns a substitution that can be applied
343 /// to the query result to convert the result back into the
344 /// original namespace.
346 /// The substitution also comes accompanied with subobligations
347 /// that arose from unification; these might occur if (for
348 /// example) we are doing lazy normalization and the value
349 /// assigned to a type variable is unified with an unnormalized
351 fn query_response_substitution<R>(
353 cause: &ObligationCause<'tcx>,
354 param_env: ty::ParamEnv<'tcx>,
355 original_values: &OriginalQueryValues<'tcx>,
356 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
357 ) -> InferResult<'tcx, CanonicalVarValues<'tcx>>
359 R: Debug + TypeFoldable<'tcx>,
362 "query_response_substitution(original_values={:#?}, query_response={:#?})",
363 original_values, query_response,
366 let mut value = self.query_response_substitution_guess(
373 value.obligations.extend(
374 self.unify_query_response_substitution_guess(
387 /// Given the original values and the (canonicalized) result from
388 /// computing a query, returns a **guess** at a substitution that
389 /// can be applied to the query result to convert the result back
390 /// into the original namespace. This is called a **guess**
391 /// because it uses a quick heuristic to find the values for each
392 /// canonical variable; if that quick heuristic fails, then we
393 /// will instantiate fresh inference variables for each canonical
394 /// variable instead. Therefore, the result of this method must be
396 fn query_response_substitution_guess<R>(
398 cause: &ObligationCause<'tcx>,
399 param_env: ty::ParamEnv<'tcx>,
400 original_values: &OriginalQueryValues<'tcx>,
401 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
402 ) -> InferResult<'tcx, CanonicalVarValues<'tcx>>
404 R: Debug + TypeFoldable<'tcx>,
407 "query_response_substitution_guess(original_values={:#?}, query_response={:#?})",
408 original_values, query_response,
411 // For each new universe created in the query result that did
412 // not appear in the original query, create a local
414 let mut universe_map = original_values.universe_map.clone();
415 let num_universes_in_query = original_values.universe_map.len();
416 let num_universes_in_response = query_response.max_universe.as_usize() + 1;
417 for _ in num_universes_in_query..num_universes_in_response {
418 universe_map.push(self.create_next_universe());
420 assert!(!universe_map.is_empty()); // always have the root universe
421 assert_eq!(universe_map[ty::UniverseIndex::ROOT.as_usize()], ty::UniverseIndex::ROOT);
423 // Every canonical query result includes values for each of
424 // the inputs to the query. Therefore, we begin by unifying
425 // these values with the original inputs that were
427 let result_values = &query_response.value.var_values;
428 assert_eq!(original_values.var_values.len(), result_values.len());
430 // Quickly try to find initial values for the canonical
431 // variables in the result in terms of the query. We do this
432 // by iterating down the values that the query gave to each of
433 // the canonical inputs. If we find that one of those values
434 // is directly equal to one of the canonical variables in the
435 // result, then we can type the corresponding value from the
436 // input. See the example above.
437 let mut opt_values: IndexVec<BoundVar, Option<GenericArg<'tcx>>> =
438 IndexVec::from_elem_n(None, query_response.variables.len());
440 // In terms of our example above, we are iterating over pairs like:
441 // [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
442 for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
444 match result_value.unpack() {
445 GenericArgKind::Type(result_value) => {
446 // e.g., here `result_value` might be `?0` in the example above...
447 if let ty::Bound(debruijn, b) = *result_value.kind() {
448 // ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
450 // We only allow a `ty::INNERMOST` index in substitutions.
451 assert_eq!(debruijn, ty::INNERMOST);
452 opt_values[b.var] = Some(*original_value);
455 GenericArgKind::Lifetime(result_value) => {
456 // e.g., here `result_value` might be `'?1` in the example above...
457 if let ty::ReLateBound(debruijn, br) = *result_value {
458 // ... in which case we would set `canonical_vars[0]` to `Some('static)`.
460 // We only allow a `ty::INNERMOST` index in substitutions.
461 assert_eq!(debruijn, ty::INNERMOST);
462 opt_values[br.var] = Some(*original_value);
465 GenericArgKind::Const(result_value) => {
466 if let ty::ConstKind::Bound(debrujin, b) = result_value.kind() {
467 // ...in which case we would set `canonical_vars[0]` to `Some(const X)`.
469 // We only allow a `ty::INNERMOST` index in substitutions.
470 assert_eq!(debrujin, ty::INNERMOST);
471 opt_values[b] = Some(*original_value);
477 // Create a result substitution: if we found a value for a
478 // given variable in the loop above, use that. Otherwise, use
479 // a fresh inference variable.
480 let result_subst = CanonicalVarValues {
481 var_values: self.tcx.mk_substs(query_response.variables.iter().enumerate().map(
483 if info.is_existential() {
484 match opt_values[BoundVar::new(index)] {
486 None => self.instantiate_canonical_var(cause.span, info, |u| {
487 universe_map[u.as_usize()]
491 self.instantiate_canonical_var(cause.span, info, |u| {
492 universe_map[u.as_usize()]
499 let mut obligations = vec![];
501 // Carry all newly resolved opaque types to the caller's scope
502 for &(a, b) in &query_response.value.opaque_types {
503 let a = substitute_value(self.tcx, &result_subst, a);
504 let b = substitute_value(self.tcx, &result_subst, b);
505 obligations.extend(self.at(cause, param_env).eq(a, b)?.obligations);
508 Ok(InferOk { value: result_subst, obligations })
511 /// Given a "guess" at the values for the canonical variables in
512 /// the input, try to unify with the *actual* values found in the
513 /// query result. Often, but not always, this is a no-op, because
514 /// we already found the mapping in the "guessing" step.
516 /// See also: `query_response_substitution_guess`
517 fn unify_query_response_substitution_guess<R>(
519 cause: &ObligationCause<'tcx>,
520 param_env: ty::ParamEnv<'tcx>,
521 original_values: &OriginalQueryValues<'tcx>,
522 result_subst: &CanonicalVarValues<'tcx>,
523 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
524 ) -> InferResult<'tcx, ()>
526 R: Debug + TypeFoldable<'tcx>,
528 // A closure that yields the result value for the given
529 // canonical variable; this is taken from
530 // `query_response.var_values` after applying the substitution
532 let substituted_query_response = |index: BoundVar| -> GenericArg<'tcx> {
533 query_response.substitute_projected(self.tcx, &result_subst, |v| v.var_values[index])
536 // Unify the original value for each variable with the value
537 // taken from `query_response` (after applying `result_subst`).
538 self.unify_canonical_vars(cause, param_env, original_values, substituted_query_response)
541 /// Converts the region constraints resulting from a query into an
542 /// iterator of obligations.
543 fn query_outlives_constraints_into_obligations<'a>(
545 cause: &'a ObligationCause<'tcx>,
546 param_env: ty::ParamEnv<'tcx>,
547 unsubstituted_region_constraints: &'a [QueryOutlivesConstraint<'tcx>],
548 result_subst: &'a CanonicalVarValues<'tcx>,
549 ) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
550 unsubstituted_region_constraints.iter().map(move |&constraint| {
551 let predicate = substitute_value(self.tcx, result_subst, constraint);
552 self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env)
556 pub fn query_outlives_constraint_to_obligation(
558 (predicate, _): QueryOutlivesConstraint<'tcx>,
559 cause: ObligationCause<'tcx>,
560 param_env: ty::ParamEnv<'tcx>,
561 ) -> Obligation<'tcx, ty::Predicate<'tcx>> {
562 let ty::OutlivesPredicate(k1, r2) = predicate;
564 let atom = match k1.unpack() {
565 GenericArgKind::Lifetime(r1) => {
566 ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(r1, r2)))
568 GenericArgKind::Type(t1) => {
569 ty::PredicateKind::Clause(ty::Clause::TypeOutlives(ty::OutlivesPredicate(t1, r2)))
571 GenericArgKind::Const(..) => {
572 // Consts cannot outlive one another, so we don't expect to
573 // encounter this branch.
574 span_bug!(cause.span, "unexpected const outlives {:?}", predicate);
577 let predicate = ty::Binder::dummy(atom);
579 Obligation::new(self.tcx, cause, param_env, predicate)
582 /// Given two sets of values for the same set of canonical variables, unify them.
583 /// The second set is produced lazily by supplying indices from the first set.
584 fn unify_canonical_vars(
586 cause: &ObligationCause<'tcx>,
587 param_env: ty::ParamEnv<'tcx>,
588 variables1: &OriginalQueryValues<'tcx>,
589 variables2: impl Fn(BoundVar) -> GenericArg<'tcx>,
590 ) -> InferResult<'tcx, ()> {
591 self.commit_if_ok(|_| {
592 let mut obligations = vec![];
593 for (index, value1) in variables1.var_values.iter().enumerate() {
594 let value2 = variables2(BoundVar::new(index));
596 match (value1.unpack(), value2.unpack()) {
597 (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
599 .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
601 (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
602 if re1.is_erased() && re2.is_erased() =>
606 (GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => {
608 .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
610 (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
611 let ok = self.at(cause, param_env).eq(v1, v2)?;
612 obligations.extend(ok.into_obligations());
615 bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,);
619 Ok(InferOk { value: (), obligations })
624 /// Given the region obligations and constraints scraped from the infcx,
625 /// creates query region constraints.
626 pub fn make_query_region_constraints<'tcx>(
628 outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>, ConstraintCategory<'tcx>)>,
629 region_constraints: &RegionConstraintData<'tcx>,
630 ) -> QueryRegionConstraints<'tcx> {
631 let RegionConstraintData { constraints, verifys, givens, member_constraints } =
634 assert!(verifys.is_empty());
635 assert!(givens.is_empty());
637 debug!(?constraints);
639 let outlives: Vec<_> = constraints
642 let constraint = match *k {
643 // Swap regions because we are going from sub (<=) to outlives
645 Constraint::VarSubVar(v1, v2) => ty::OutlivesPredicate(
646 tcx.mk_region(ty::ReVar(v2)).into(),
647 tcx.mk_region(ty::ReVar(v1)),
649 Constraint::VarSubReg(v1, r2) => {
650 ty::OutlivesPredicate(r2.into(), tcx.mk_region(ty::ReVar(v1)))
652 Constraint::RegSubVar(r1, v2) => {
653 ty::OutlivesPredicate(tcx.mk_region(ty::ReVar(v2)).into(), r1)
655 Constraint::RegSubReg(r1, r2) => ty::OutlivesPredicate(r2.into(), r1),
657 (constraint, origin.to_constraint_category())
659 .chain(outlives_obligations.map(|(ty, r, constraint_category)| {
660 (ty::OutlivesPredicate(ty.into(), r), constraint_category)
664 QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() }
667 struct QueryTypeRelatingDelegate<'a, 'tcx> {
668 infcx: &'a InferCtxt<'tcx>,
669 obligations: &'a mut Vec<PredicateObligation<'tcx>>,
670 param_env: ty::ParamEnv<'tcx>,
671 cause: &'a ObligationCause<'tcx>,
674 impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
675 fn span(&self) -> Span {
679 fn param_env(&self) -> ty::ParamEnv<'tcx> {
683 fn create_next_universe(&mut self) -> ty::UniverseIndex {
684 self.infcx.create_next_universe()
687 fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
688 let origin = NllRegionVariableOrigin::Existential { from_forall };
689 self.infcx.next_nll_region_var(origin)
692 fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx> {
693 self.infcx.tcx.mk_region(ty::RePlaceholder(placeholder))
696 fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
697 self.infcx.next_nll_region_var_in_universe(
698 NllRegionVariableOrigin::Existential { from_forall: false },
705 sup: ty::Region<'tcx>,
706 sub: ty::Region<'tcx>,
707 _info: ty::VarianceDiagInfo<'tcx>,
709 self.obligations.push(Obligation {
710 cause: self.cause.clone(),
711 param_env: self.param_env,
712 predicate: ty::Binder::dummy(ty::PredicateKind::Clause(ty::Clause::RegionOutlives(
713 ty::OutlivesPredicate(sup, sub),
715 .to_predicate(self.infcx.tcx),
720 fn normalization() -> NormalizationStrategy {
721 NormalizationStrategy::Eager
724 fn forbid_inference_vars() -> bool {
728 fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
729 self.obligations.extend(obligations);