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, CanonicalVarValues, CanonicalizedQueryResponse, 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::TraitEngine;
20 use crate::traits::{Obligation, ObligationCause, PredicateObligation};
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::ty::error::TypeError;
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, Const, ToPredicate, Ty, TyCtxt};
34 impl<'cx, 'tcx> InferCtxt<'cx, '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<CanonicalizedQueryResponse<'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 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 let region_constraints = self.with_region_constraints(|region_constraints| {
129 make_query_region_constraints(
131 region_obligations.iter().map(|(_, r_o)| (r_o.sup_type, r_o.sub_region)),
137 if ambig_errors.is_empty() { Certainty::Proven } else { Certainty::Ambiguous };
139 let opaque_types = self.take_opaque_types_for_query_response();
142 var_values: inference_vars,
150 fn take_opaque_types_for_query_response(&self) -> Vec<(Ty<'tcx>, Ty<'tcx>)> {
156 .map(|(k, v)| (self.tcx.mk_opaque(k.def_id, k.substs), v.hidden_type.ty))
160 /// Given the (canonicalized) result to a canonical query,
161 /// instantiates the result so it can be used, plugging in the
162 /// values from the canonical query. (Note that the result may
163 /// have been ambiguous; you should check the certainty level of
164 /// the query before applying this function.)
166 /// To get a good understanding of what is happening here, check
167 /// out the [chapter in the rustc dev guide][c].
169 /// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#processing-the-canonicalized-query-result
170 pub fn instantiate_query_response_and_region_obligations<R>(
172 cause: &ObligationCause<'tcx>,
173 param_env: ty::ParamEnv<'tcx>,
174 original_values: &OriginalQueryValues<'tcx>,
175 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
176 ) -> InferResult<'tcx, R>
178 R: Debug + TypeFoldable<'tcx>,
180 let InferOk { value: result_subst, mut obligations } =
181 self.query_response_substitution(cause, param_env, original_values, query_response)?;
183 obligations.extend(self.query_outlives_constraints_into_obligations(
186 &query_response.value.region_constraints.outlives,
191 query_response.substitute_projected(self.tcx, &result_subst, |q_r| q_r.value.clone());
193 Ok(InferOk { value: user_result, obligations })
196 /// An alternative to
197 /// `instantiate_query_response_and_region_obligations` that is more
198 /// efficient for NLL. NLL is a bit more advanced in the
199 /// "transition to chalk" than the rest of the compiler. During
200 /// the NLL type check, all of the "processing" of types and
201 /// things happens in queries -- the NLL checker itself is only
202 /// interested in the region obligations (`'a: 'b` or `T: 'b`)
203 /// that come out of these queries, which it wants to convert into
204 /// MIR-based constraints and solve. Therefore, it is most
205 /// convenient for the NLL Type Checker to **directly consume**
206 /// the `QueryOutlivesConstraint` values that arise from doing a
207 /// query. This is contrast to other parts of the compiler, which
208 /// would prefer for those `QueryOutlivesConstraint` to be converted
209 /// into the older infcx-style constraints (e.g., calls to
210 /// `sub_regions` or `register_region_obligation`).
212 /// Therefore, `instantiate_nll_query_response_and_region_obligations` performs the same
213 /// basic operations as `instantiate_query_response_and_region_obligations` but
214 /// it returns its result differently:
216 /// - It creates a substitution `S` that maps from the original
217 /// query variables to the values computed in the query
218 /// result. If any errors arise, they are propagated back as an
220 /// - In the case of a successful substitution, we will append
221 /// `QueryOutlivesConstraint` values onto the
222 /// `output_query_region_constraints` vector for the solver to
223 /// use (if an error arises, some values may also be pushed, but
224 /// they should be ignored).
225 /// - It **can happen** (though it rarely does currently) that
226 /// equating types and things will give rise to subobligations
227 /// that must be processed. In this case, those subobligations
228 /// are propagated back in the return value.
229 /// - Finally, the query result (of type `R`) is propagated back,
230 /// after applying the substitution `S`.
231 pub fn instantiate_nll_query_response_and_region_obligations<R>(
233 cause: &ObligationCause<'tcx>,
234 param_env: ty::ParamEnv<'tcx>,
235 original_values: &OriginalQueryValues<'tcx>,
236 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
237 output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
238 ) -> InferResult<'tcx, R>
240 R: Debug + TypeFoldable<'tcx>,
242 let InferOk { value: result_subst, mut obligations } = self
243 .query_response_substitution_guess(cause, param_env, original_values, query_response)?;
245 // Compute `QueryOutlivesConstraint` values that unify each of
246 // the original values `v_o` that was canonicalized into a
249 for (index, original_value) in original_values.var_values.iter().enumerate() {
250 // ...with the value `v_r` of that variable from the query.
251 let result_value = query_response.substitute_projected(self.tcx, &result_subst, |v| {
252 v.var_values[BoundVar::new(index)]
254 match (original_value.unpack(), result_value.unpack()) {
255 (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
256 if re1.is_erased() && re2.is_erased() =>
261 (GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => {
262 // To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`.
264 output_query_region_constraints
266 .push(ty::Binder::dummy(ty::OutlivesPredicate(v_o.into(), v_r)));
267 output_query_region_constraints
269 .push(ty::Binder::dummy(ty::OutlivesPredicate(v_r.into(), v_o)));
273 (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
276 QueryTypeRelatingDelegate {
280 obligations: &mut obligations,
282 ty::Variance::Invariant,
287 (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
290 QueryTypeRelatingDelegate {
294 obligations: &mut obligations,
296 ty::Variance::Invariant,
302 bug!("kind mismatch, cannot unify {:?} and {:?}", original_value, result_value);
307 // ...also include the other query region constraints from the query.
308 output_query_region_constraints.outlives.extend(
309 query_response.value.region_constraints.outlives.iter().filter_map(|&r_c| {
310 let r_c = substitute_value(self.tcx, &result_subst, r_c);
312 // Screen out `'a: 'a` cases -- we skip the binder here but
313 // only compare the inner values to one another, so they are still at
314 // consistent binding levels.
315 let ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
316 if k1 != r2.into() { Some(r_c) } else { None }
320 // ...also include the query member constraints.
321 output_query_region_constraints.member_constraints.extend(
327 .map(|p_c| substitute_value(self.tcx, &result_subst, p_c.clone())),
331 query_response.substitute_projected(self.tcx, &result_subst, |q_r| q_r.value.clone());
333 Ok(InferOk { value: user_result, obligations })
336 /// Given the original values and the (canonicalized) result from
337 /// computing a query, returns a substitution that can be applied
338 /// to the query result to convert the result back into the
339 /// original namespace.
341 /// The substitution also comes accompanied with subobligations
342 /// that arose from unification; these might occur if (for
343 /// example) we are doing lazy normalization and the value
344 /// assigned to a type variable is unified with an unnormalized
346 fn query_response_substitution<R>(
348 cause: &ObligationCause<'tcx>,
349 param_env: ty::ParamEnv<'tcx>,
350 original_values: &OriginalQueryValues<'tcx>,
351 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
352 ) -> InferResult<'tcx, CanonicalVarValues<'tcx>>
354 R: Debug + TypeFoldable<'tcx>,
357 "query_response_substitution(original_values={:#?}, query_response={:#?})",
358 original_values, query_response,
361 let mut value = self.query_response_substitution_guess(
368 value.obligations.extend(
369 self.unify_query_response_substitution_guess(
382 /// Given the original values and the (canonicalized) result from
383 /// computing a query, returns a **guess** at a substitution that
384 /// can be applied to the query result to convert the result back
385 /// into the original namespace. This is called a **guess**
386 /// because it uses a quick heuristic to find the values for each
387 /// canonical variable; if that quick heuristic fails, then we
388 /// will instantiate fresh inference variables for each canonical
389 /// variable instead. Therefore, the result of this method must be
391 fn query_response_substitution_guess<R>(
393 cause: &ObligationCause<'tcx>,
394 param_env: ty::ParamEnv<'tcx>,
395 original_values: &OriginalQueryValues<'tcx>,
396 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
397 ) -> InferResult<'tcx, CanonicalVarValues<'tcx>>
399 R: Debug + TypeFoldable<'tcx>,
402 "query_response_substitution_guess(original_values={:#?}, query_response={:#?})",
403 original_values, query_response,
406 // For each new universe created in the query result that did
407 // not appear in the original query, create a local
409 let mut universe_map = original_values.universe_map.clone();
410 let num_universes_in_query = original_values.universe_map.len();
411 let num_universes_in_response = query_response.max_universe.as_usize() + 1;
412 for _ in num_universes_in_query..num_universes_in_response {
413 universe_map.push(self.create_next_universe());
415 assert!(!universe_map.is_empty()); // always have the root universe
416 assert_eq!(universe_map[ty::UniverseIndex::ROOT.as_usize()], ty::UniverseIndex::ROOT);
418 // Every canonical query result includes values for each of
419 // the inputs to the query. Therefore, we begin by unifying
420 // these values with the original inputs that were
422 let result_values = &query_response.value.var_values;
423 assert_eq!(original_values.var_values.len(), result_values.len());
425 // Quickly try to find initial values for the canonical
426 // variables in the result in terms of the query. We do this
427 // by iterating down the values that the query gave to each of
428 // the canonical inputs. If we find that one of those values
429 // is directly equal to one of the canonical variables in the
430 // result, then we can type the corresponding value from the
431 // input. See the example above.
432 let mut opt_values: IndexVec<BoundVar, Option<GenericArg<'tcx>>> =
433 IndexVec::from_elem_n(None, query_response.variables.len());
435 // In terms of our example above, we are iterating over pairs like:
436 // [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
437 for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
439 match result_value.unpack() {
440 GenericArgKind::Type(result_value) => {
441 // e.g., here `result_value` might be `?0` in the example above...
442 if let ty::Bound(debruijn, b) = *result_value.kind() {
443 // ...in which case we would set `canonical_vars[0]` to `Some(?U)`.
445 // We only allow a `ty::INNERMOST` index in substitutions.
446 assert_eq!(debruijn, ty::INNERMOST);
447 opt_values[b.var] = Some(*original_value);
450 GenericArgKind::Lifetime(result_value) => {
451 // e.g., here `result_value` might be `'?1` in the example above...
452 if let ty::ReLateBound(debruijn, br) = *result_value {
453 // ... in which case we would set `canonical_vars[0]` to `Some('static)`.
455 // We only allow a `ty::INNERMOST` index in substitutions.
456 assert_eq!(debruijn, ty::INNERMOST);
457 opt_values[br.var] = Some(*original_value);
460 GenericArgKind::Const(result_value) => {
461 if let ty::ConstKind::Bound(debrujin, b) = result_value.kind() {
462 // ...in which case we would set `canonical_vars[0]` to `Some(const X)`.
464 // We only allow a `ty::INNERMOST` index in substitutions.
465 assert_eq!(debrujin, ty::INNERMOST);
466 opt_values[b] = Some(*original_value);
472 // Create a result substitution: if we found a value for a
473 // given variable in the loop above, use that. Otherwise, use
474 // a fresh inference variable.
475 let result_subst = CanonicalVarValues {
476 var_values: query_response
480 .map(|(index, info)| {
481 if info.is_existential() {
482 match opt_values[BoundVar::new(index)] {
484 None => self.instantiate_canonical_var(cause.span, info, |u| {
485 universe_map[u.as_usize()]
489 self.instantiate_canonical_var(cause.span, info, |u| {
490 universe_map[u.as_usize()]
497 let mut obligations = vec![];
499 // Carry all newly resolved opaque types to the caller's scope
500 for &(a, b) in &query_response.value.opaque_types {
501 let a = substitute_value(self.tcx, &result_subst, a);
502 let b = substitute_value(self.tcx, &result_subst, b);
503 obligations.extend(self.handle_opaque_type(a, b, true, cause, param_env)?.obligations);
506 Ok(InferOk { value: result_subst, obligations })
509 /// Given a "guess" at the values for the canonical variables in
510 /// the input, try to unify with the *actual* values found in the
511 /// query result. Often, but not always, this is a no-op, because
512 /// we already found the mapping in the "guessing" step.
514 /// See also: `query_response_substitution_guess`
515 fn unify_query_response_substitution_guess<R>(
517 cause: &ObligationCause<'tcx>,
518 param_env: ty::ParamEnv<'tcx>,
519 original_values: &OriginalQueryValues<'tcx>,
520 result_subst: &CanonicalVarValues<'tcx>,
521 query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>,
522 ) -> InferResult<'tcx, ()>
524 R: Debug + TypeFoldable<'tcx>,
526 // A closure that yields the result value for the given
527 // canonical variable; this is taken from
528 // `query_response.var_values` after applying the substitution
530 let substituted_query_response = |index: BoundVar| -> GenericArg<'tcx> {
531 query_response.substitute_projected(self.tcx, &result_subst, |v| v.var_values[index])
534 // Unify the original value for each variable with the value
535 // taken from `query_response` (after applying `result_subst`).
536 self.unify_canonical_vars(cause, param_env, original_values, substituted_query_response)
539 /// Converts the region constraints resulting from a query into an
540 /// iterator of obligations.
541 fn query_outlives_constraints_into_obligations<'a>(
543 cause: &'a ObligationCause<'tcx>,
544 param_env: ty::ParamEnv<'tcx>,
545 unsubstituted_region_constraints: &'a [QueryOutlivesConstraint<'tcx>],
546 result_subst: &'a CanonicalVarValues<'tcx>,
547 ) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
548 unsubstituted_region_constraints.iter().map(move |&constraint| {
549 let predicate = substitute_value(self.tcx, result_subst, constraint);
550 self.query_outlives_constraint_to_obligation(predicate, cause.clone(), param_env)
554 pub fn query_outlives_constraint_to_obligation(
556 predicate: QueryOutlivesConstraint<'tcx>,
557 cause: ObligationCause<'tcx>,
558 param_env: ty::ParamEnv<'tcx>,
559 ) -> Obligation<'tcx, ty::Predicate<'tcx>> {
560 let ty::OutlivesPredicate(k1, r2) = predicate.skip_binder();
562 let atom = match k1.unpack() {
563 GenericArgKind::Lifetime(r1) => {
564 ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(r1, r2))
566 GenericArgKind::Type(t1) => {
567 ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(t1, r2))
569 GenericArgKind::Const(..) => {
570 // Consts cannot outlive one another, so we don't expect to
571 // encounter this branch.
572 span_bug!(cause.span, "unexpected const outlives {:?}", predicate);
575 let predicate = predicate.rebind(atom).to_predicate(self.tcx);
577 Obligation::new(cause, param_env, predicate)
580 /// Given two sets of values for the same set of canonical variables, unify them.
581 /// The second set is produced lazily by supplying indices from the first set.
582 fn unify_canonical_vars(
584 cause: &ObligationCause<'tcx>,
585 param_env: ty::ParamEnv<'tcx>,
586 variables1: &OriginalQueryValues<'tcx>,
587 variables2: impl Fn(BoundVar) -> GenericArg<'tcx>,
588 ) -> InferResult<'tcx, ()> {
589 self.commit_if_ok(|_| {
590 let mut obligations = vec![];
591 for (index, value1) in variables1.var_values.iter().enumerate() {
592 let value2 = variables2(BoundVar::new(index));
594 match (value1.unpack(), value2.unpack()) {
595 (GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
597 .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
599 (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
600 if re1.is_erased() && re2.is_erased() =>
604 (GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => {
606 .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations());
608 (GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
609 let ok = self.at(cause, param_env).eq(v1, v2)?;
610 obligations.extend(ok.into_obligations());
613 bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,);
617 Ok(InferOk { value: (), obligations })
622 /// Given the region obligations and constraints scraped from the infcx,
623 /// creates query region constraints.
624 pub fn make_query_region_constraints<'tcx>(
626 outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>)>,
627 region_constraints: &RegionConstraintData<'tcx>,
628 ) -> QueryRegionConstraints<'tcx> {
629 let RegionConstraintData { constraints, verifys, givens, member_constraints } =
632 assert!(verifys.is_empty());
633 assert!(givens.is_empty());
635 let outlives: Vec<_> = constraints
637 .map(|(k, _)| match *k {
638 // Swap regions because we are going from sub (<=) to outlives
640 Constraint::VarSubVar(v1, v2) => ty::OutlivesPredicate(
641 tcx.mk_region(ty::ReVar(v2)).into(),
642 tcx.mk_region(ty::ReVar(v1)),
644 Constraint::VarSubReg(v1, r2) => {
645 ty::OutlivesPredicate(r2.into(), tcx.mk_region(ty::ReVar(v1)))
647 Constraint::RegSubVar(r1, v2) => {
648 ty::OutlivesPredicate(tcx.mk_region(ty::ReVar(v2)).into(), r1)
650 Constraint::RegSubReg(r1, r2) => ty::OutlivesPredicate(r2.into(), r1),
652 .map(ty::Binder::dummy) // no bound vars in the code above
655 .map(|(ty, r)| ty::OutlivesPredicate(ty.into(), r))
656 .map(ty::Binder::dummy), // no bound vars in the code above
660 QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() }
663 struct QueryTypeRelatingDelegate<'a, 'tcx> {
664 infcx: &'a InferCtxt<'a, 'tcx>,
665 obligations: &'a mut Vec<PredicateObligation<'tcx>>,
666 param_env: ty::ParamEnv<'tcx>,
667 cause: &'a ObligationCause<'tcx>,
670 impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
671 fn span(&self) -> Span {
675 fn param_env(&self) -> ty::ParamEnv<'tcx> {
679 fn create_next_universe(&mut self) -> ty::UniverseIndex {
680 self.infcx.create_next_universe()
683 fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
684 let origin = NllRegionVariableOrigin::Existential { from_forall };
685 self.infcx.next_nll_region_var(origin)
688 fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty::Region<'tcx> {
689 self.infcx.tcx.mk_region(ty::RePlaceholder(placeholder))
692 fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
693 self.infcx.next_nll_region_var_in_universe(
694 NllRegionVariableOrigin::Existential { from_forall: false },
701 sup: ty::Region<'tcx>,
702 sub: ty::Region<'tcx>,
703 _info: ty::VarianceDiagInfo<'tcx>,
705 self.obligations.push(Obligation {
706 cause: self.cause.clone(),
707 param_env: self.param_env,
708 predicate: ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
711 .to_predicate(self.infcx.tcx),
716 fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {
718 self.cause.span(self.infcx.tcx),
719 "generic_const_exprs: unreachable `const_equate`"
723 fn normalization() -> NormalizationStrategy {
724 NormalizationStrategy::Eager
727 fn forbid_inference_vars() -> bool {
731 fn register_opaque_type(
736 ) -> Result<(), TypeError<'tcx>> {
737 self.obligations.extend(
739 .handle_opaque_type(a, b, a_is_expected, &self.cause, self.param_env)?