1use std::mem;
2use std::ops::ControlFlow;
3
4#[cfg(feature = "nightly")]
5use rustc_macros::StableHash;
6use rustc_type_ir::data_structures::{HashMap, HashSet};
7use rustc_type_ir::inherent::*;
8use rustc_type_ir::region_constraint::RegionConstraint;
9use rustc_type_ir::relate::Relate;
10use rustc_type_ir::relate::solver_relating::RelateExt;
11use rustc_type_ir::search_graph::{CandidateHeadUsages, PathKind};
12use rustc_type_ir::solve::{
13 AccessedOpaques, ExternalRegionConstraints, FetchEligibleAssocItemResponse, MaybeInfo,
14 NoSolutionOrRerunNonErased, OpaqueTypesJank, QueryResultOrRerunNonErased, RerunCondition,
15 RerunNonErased, RerunReason, RerunResultExt, SmallCopyList,
16};
17use rustc_type_ir::{
18 self as ty, CanonicalVarValues, ClauseKind, InferCtxtLike, Interner, MayBeErased,
19 OpaqueTypeKey, PredicateKind, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable,
20 TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode,
21};
22use tracing::{Level, debug, instrument, trace, warn};
23
24use super::has_only_region_constraints;
25use crate::canonical::{
26 canonicalize_goal, canonicalize_response, instantiate_and_apply_query_response,
27 response_no_constraints_raw,
28};
29use crate::coherence;
30use crate::delegate::SolverDelegate;
31use crate::placeholder::BoundVarReplacer;
32use crate::resolve::eager_resolve_vars;
33use crate::solve::search_graph::SearchGraph;
34use crate::solve::ty::may_use_unstable_feature;
35use crate::solve::{
36 CanonicalInput, CanonicalResponse, Certainty, ExternalConstraintsData, FIXPOINT_STEP_LIMIT,
37 Goal, GoalEvaluation, GoalSource, GoalStalledOn, HasChanged, MaybeCause,
38 NestedNormalizationGoals, NoSolution, QueryInput, QueryResult, Response, VisibleForLeakCheck,
39 inspect,
40};
41
42mod probe;
43mod solver_region_constraints;
44
45#[derive(#[automatically_derived]
impl ::core::fmt::Debug for CurrentGoalKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
CurrentGoalKind::Misc => "Misc",
CurrentGoalKind::CoinductiveTrait => "CoinductiveTrait",
CurrentGoalKind::NormalizesTo => "NormalizesTo",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CurrentGoalKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CurrentGoalKind {
#[inline]
fn clone(&self) -> CurrentGoalKind { *self }
}Clone)]
50enum CurrentGoalKind {
51 Misc,
52 CoinductiveTrait,
57 NormalizesTo,
65}
66
67impl CurrentGoalKind {
68 fn from_query_input<I: Interner>(cx: I, input: QueryInput<I, I::Predicate>) -> CurrentGoalKind {
69 match input.goal.predicate.kind().skip_binder() {
70 ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
71 if cx.trait_is_coinductive(pred.trait_ref.def_id) {
72 CurrentGoalKind::CoinductiveTrait
73 } else {
74 CurrentGoalKind::Misc
75 }
76 }
77 ty::PredicateKind::NormalizesTo(_) => CurrentGoalKind::NormalizesTo,
78 _ => CurrentGoalKind::Misc,
79 }
80 }
81}
82
83#[derive(#[automatically_derived]
impl ::core::fmt::Debug for RerunDecision {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
RerunDecision::Yes => "Yes",
RerunDecision::No => "No",
RerunDecision::EagerlyPropagateToParent =>
"EagerlyPropagateToParent",
})
}
}Debug)]
84enum RerunDecision {
85 Yes,
86 No,
87 EagerlyPropagateToParent,
88}
89pub struct EvalCtxt<'a, D, I = <D as SolverDelegate>::Interner>
90where
91 D: SolverDelegate<Interner = I>,
92 I: Interner,
93{
94 delegate: &'a D,
110
111 var_kinds: I::CanonicalVarKinds,
114
115 current_goal_kind: CurrentGoalKind,
118 pub(super) var_values: CanonicalVarValues<I>,
119
120 pub(super) max_input_universe: ty::UniverseIndex,
130 pub(super) initial_opaque_types_storage_num_entries:
133 <D::Infcx as InferCtxtLike>::OpaqueTypeStorageEntries,
134
135 pub(super) search_graph: &'a mut SearchGraph<D>,
136
137 nested_goals: Vec<(GoalSource, Goal<I, I::Predicate>, Option<GoalStalledOn<I>>)>,
138
139 pub(super) origin_span: I::Span,
140
141 tainted: Result<(), NoSolution>,
148
149 pub(super) opaque_accesses: AccessedOpaques<I>,
151
152 pub(super) inspect: inspect::EvaluationStepBuilder<D>,
153}
154
155#[derive(#[automatically_derived]
impl ::core::cmp::PartialEq for GenerateProofTree {
#[inline]
fn eq(&self, other: &GenerateProofTree) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for GenerateProofTree {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for GenerateProofTree {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
GenerateProofTree::Yes => "Yes",
GenerateProofTree::No => "No",
})
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for GenerateProofTree {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash, #[automatically_derived]
impl ::core::clone::Clone for GenerateProofTree {
#[inline]
fn clone(&self) -> GenerateProofTree { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for GenerateProofTree { }Copy)]
156#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for
GenerateProofTree {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
GenerateProofTree::Yes => {}
GenerateProofTree::No => {}
}
}
}
};StableHash))]
157pub enum GenerateProofTree {
158 Yes,
159 No,
160}
161
162pub trait SolverDelegateEvalExt: SolverDelegate {
163 fn evaluate_root_goal(
168 &self,
169 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
170 span: <Self::Interner as Interner>::Span,
171 stalled_on: Option<GoalStalledOn<Self::Interner>>,
172 ) -> Result<GoalEvaluation<Self::Interner>, NoSolution>;
173
174 fn root_goal_may_hold_opaque_types_jank(
179 &self,
180 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
181 ) -> bool;
182
183 fn root_goal_may_hold_with_depth(
191 &self,
192 root_depth: usize,
193 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
194 ) -> bool;
195
196 fn evaluate_root_goal_for_proof_tree(
199 &self,
200 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
201 span: <Self::Interner as Interner>::Span,
202 ) -> (
203 Result<NestedNormalizationGoals<Self::Interner>, NoSolution>,
204 inspect::GoalEvaluation<Self::Interner>,
205 );
206}
207
208impl<D, I> SolverDelegateEvalExt for D
209where
210 D: SolverDelegate<Interner = I>,
211 I: Interner,
212{
213 x;#[instrument(level = "debug", skip(self), ret)]
214 fn evaluate_root_goal(
215 &self,
216 goal: Goal<I, I::Predicate>,
217 span: I::Span,
218 stalled_on: Option<GoalStalledOn<I>>,
219 ) -> Result<GoalEvaluation<I>, NoSolution> {
220 let result = EvalCtxt::enter_root(self, self.cx().recursion_limit(), span, |ecx| {
221 ecx.evaluate_goal(GoalSource::Misc, goal, stalled_on)
222 });
223
224 match result {
225 Ok(i) => Ok(i),
226 Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
227 Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
228 unreachable!("this never happens at the root, we're never in erased mode here");
229 }
230 }
231 }
232
233 x;#[instrument(level = "debug", skip(self), ret)]
234 fn root_goal_may_hold_opaque_types_jank(
235 &self,
236 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
237 ) -> bool {
238 self.probe(|| {
239 EvalCtxt::enter_root(self, self.cx().recursion_limit(), I::Span::dummy(), |ecx| {
240 ecx.evaluate_goal(GoalSource::Misc, goal, None)
241 })
242 .is_ok_and(|r| match r.certainty {
243 Certainty::Yes => true,
244 Certainty::Maybe(MaybeInfo {
245 cause: _,
246 opaque_types_jank,
247 stalled_on_coroutines: _,
248 }) => match opaque_types_jank {
249 OpaqueTypesJank::AllGood => true,
250 OpaqueTypesJank::ErrorIfRigidSelfTy => false,
251 },
252 })
253 })
254 }
255
256 fn root_goal_may_hold_with_depth(
257 &self,
258 root_depth: usize,
259 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
260 ) -> bool {
261 self.probe(|| {
262 EvalCtxt::enter_root(self, root_depth, I::Span::dummy(), |ecx| {
263 ecx.evaluate_goal(GoalSource::Misc, goal, None)
264 })
265 })
266 .is_ok()
267 }
268
269 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("evaluate_root_goal_for_proof_tree",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(269u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["goal", "span"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
(Result<NestedNormalizationGoals<I>, NoSolution>,
inspect::GoalEvaluation<I>) = loop {};
return __tracing_attr_fake_return;
}
{ evaluate_root_goal_for_proof_tree(self, goal, span) }
}
}#[instrument(level = "debug", skip(self))]
270 fn evaluate_root_goal_for_proof_tree(
271 &self,
272 goal: Goal<I, I::Predicate>,
273 span: I::Span,
274 ) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
275 evaluate_root_goal_for_proof_tree(self, goal, span)
276 }
277}
278
279impl<'a, D, I> EvalCtxt<'a, D>
280where
281 D: SolverDelegate<Interner = I>,
282 I: Interner,
283{
284 pub(super) fn typing_mode(&self) -> TypingMode<I> {
285 self.delegate.typing_mode_raw()
286 }
287
288 pub(super) fn step_kind_for_source(&self, source: GoalSource) -> PathKind {
297 match source {
298 GoalSource::Misc => PathKind::Unknown,
306 GoalSource::NormalizeGoal(path_kind) => path_kind,
307 GoalSource::ImplWhereBound => match self.current_goal_kind {
308 CurrentGoalKind::CoinductiveTrait => PathKind::Coinductive,
311 CurrentGoalKind::NormalizesTo => PathKind::Inductive,
319 CurrentGoalKind::Misc => PathKind::Unknown,
323 },
324 GoalSource::TypeRelating => PathKind::Inductive,
328 GoalSource::AliasBoundConstCondition | GoalSource::AliasWellFormed => PathKind::Unknown,
332 }
333 }
334
335 pub(super) fn enter_root<R>(
339 delegate: &D,
340 root_depth: usize,
341 origin_span: I::Span,
342 f: impl FnOnce(&mut EvalCtxt<'_, D>) -> R,
343 ) -> R {
344 let mut search_graph = SearchGraph::new(root_depth);
345
346 let mut ecx = EvalCtxt {
347 delegate,
348 search_graph: &mut search_graph,
349 nested_goals: Default::default(),
350 inspect: inspect::EvaluationStepBuilder::new_noop(),
351
352 max_input_universe: ty::UniverseIndex::ROOT,
355 initial_opaque_types_storage_num_entries: Default::default(),
356 var_kinds: Default::default(),
357 var_values: CanonicalVarValues::dummy(),
358 current_goal_kind: CurrentGoalKind::Misc,
359 origin_span,
360 tainted: Ok(()),
361 opaque_accesses: AccessedOpaques::default(),
362 };
363 let result = f(&mut ecx);
364 if !ecx.nested_goals.is_empty() {
{
::core::panicking::panic_fmt(format_args!("root `EvalCtxt` should not have any goals added to it"));
}
};assert!(
365 ecx.nested_goals.is_empty(),
366 "root `EvalCtxt` should not have any goals added to it"
367 );
368 if !!ecx.opaque_accesses.might_rerun() {
::core::panicking::panic("assertion failed: !ecx.opaque_accesses.might_rerun()")
};assert!(!ecx.opaque_accesses.might_rerun());
369 if !search_graph.is_empty() {
::core::panicking::panic("assertion failed: search_graph.is_empty()")
};assert!(search_graph.is_empty());
370 result
371 }
372
373 pub(super) fn enter_canonical<T>(
381 cx: I,
382 search_graph: &'a mut SearchGraph<D>,
383 canonical_input: CanonicalInput<I>,
384 proof_tree_builder: &mut inspect::ProofTreeBuilder<D>,
385 f: impl FnOnce(
386 &mut EvalCtxt<'_, D>,
387 Goal<I, I::Predicate>,
388 ) -> Result<T, NoSolutionOrRerunNonErased>,
389 ) -> (Result<T, NoSolution>, AccessedOpaques<I>) {
390 let (ref delegate, input, var_values) = D::build_with_canonical(cx, &canonical_input);
391 for (key, ty) in input.predefined_opaques_in_body.iter() {
392 let prev = delegate.register_hidden_type_in_storage(key, ty, I::Span::dummy());
393 if let Some(prev) = prev {
405 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:405",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(405u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message", "key",
"ty", "prev"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("ignore duplicate in `opaque_types_storage`")
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&key) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&ty) as
&dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&prev) as
&dyn Value))])
});
} else { ; }
};debug!(?key, ?ty, ?prev, "ignore duplicate in `opaque_types_storage`");
406 }
407 }
408
409 let initial_opaque_types_storage_num_entries = delegate.opaque_types_storage_num_entries();
410 if truecfg!(debug_assertions) && delegate.typing_mode_raw().is_erased_not_coherence() {
411 if !delegate.clone_opaque_types_lookup_table().is_empty() {
::core::panicking::panic("assertion failed: delegate.clone_opaque_types_lookup_table().is_empty()")
};assert!(delegate.clone_opaque_types_lookup_table().is_empty());
412 }
413
414 let mut ecx = EvalCtxt {
415 delegate,
416 var_kinds: canonical_input.canonical.var_kinds,
417 var_values,
418 current_goal_kind: CurrentGoalKind::from_query_input(cx, input),
419 max_input_universe: canonical_input.canonical.max_universe,
420 initial_opaque_types_storage_num_entries,
421 search_graph,
422 nested_goals: Default::default(),
423 origin_span: I::Span::dummy(),
424 tainted: Ok(()),
425 inspect: proof_tree_builder.new_evaluation_step(var_values),
426 opaque_accesses: AccessedOpaques::default(),
427 };
428
429 let result = f(&mut ecx, input.goal);
430 ecx.inspect.probe_final_state(ecx.delegate, ecx.max_input_universe);
431 proof_tree_builder.finish_evaluation_step(ecx.inspect);
432
433 if canonical_input.typing_mode.0.is_erased_not_coherence() {
434 if true {
if !delegate.clone_opaque_types_lookup_table().is_empty() {
::core::panicking::panic("assertion failed: delegate.clone_opaque_types_lookup_table().is_empty()")
};
};debug_assert!(delegate.clone_opaque_types_lookup_table().is_empty());
435 }
436
437 delegate.reset_opaque_types();
443
444 let opaque_accesses = ecx.opaque_accesses;
445 (
446 match result {
447 Ok(i) => Ok(i),
448 Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
449 Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
450 if !opaque_accesses.should_bail().is_err() {
::core::panicking::panic("assertion failed: opaque_accesses.should_bail().is_err()")
};assert!(opaque_accesses.should_bail().is_err());
452 Err(NoSolution)
453 }
454 },
455 opaque_accesses,
456 )
457 }
458
459 pub(super) fn ignore_candidate_head_usages(&mut self, usages: CandidateHeadUsages) {
460 self.search_graph.ignore_candidate_head_usages(usages);
461 }
462
463 fn evaluate_goal(
466 &mut self,
467 source: GoalSource,
468 goal: Goal<I, I::Predicate>,
469 stalled_on: Option<GoalStalledOn<I>>,
470 ) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
471 let (normalization_nested_goals, goal_evaluation) =
472 self.evaluate_goal_raw(source, goal, stalled_on)?;
473 if !normalization_nested_goals.is_empty() {
::core::panicking::panic("assertion failed: normalization_nested_goals.is_empty()")
};assert!(normalization_nested_goals.is_empty());
474 Ok(goal_evaluation)
475 }
476
477 pub(super) fn evaluate_goal_raw(
485 &mut self,
486 source: GoalSource,
487 goal: Goal<I, I::Predicate>,
488 stalled_on: Option<GoalStalledOn<I>>,
489 ) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> {
490 if let Some(GoalStalledOn {
494 num_opaques,
495 ref stalled_vars,
496 ref sub_roots,
497 stalled_certainty,
498 }) = stalled_on
499 && !self.delegate.disable_trait_solver_fast_paths()
500 && !stalled_vars.iter().any(|value| self.delegate.is_changed_arg(*value))
501 && !sub_roots
502 .iter()
503 .any(|&vid| self.delegate.sub_unification_table_root_var(vid) != vid)
504 && !self.delegate.opaque_types_storage_num_entries().needs_reevaluation(num_opaques)
505 {
506 return Ok((
507 NestedNormalizationGoals::empty(),
508 GoalEvaluation {
509 goal,
510 certainty: stalled_certainty,
511 has_changed: HasChanged::No,
512 stalled_on,
513 },
514 ));
515 }
516
517 let opaque_types = self.delegate.clone_opaque_types_lookup_table();
521 let (goal, opaque_types) = eager_resolve_vars(self.delegate, (goal, opaque_types));
522 let typing_mode = self.typing_mode();
523 let step_kind = self.step_kind_for_source(source);
524
525 let tracing_span = {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("evaluate_goal_raw in typing mode",
"rustc_next_trait_solver::solve::eval_ctxt", Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(525u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() } &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("{0:?} opaques={1:?}",
typing_mode, opaque_types) as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
}tracing::span!(
526 Level::DEBUG,
527 "evaluate_goal_raw in typing mode",
528 "{:?} opaques={:?}",
529 typing_mode,
530 opaque_types
531 )
532 .entered();
533
534 let (result, orig_values, canonical_goal) = 'retry_canonicalize: {
535 let skip_erased_attempt = if typing_mode.is_coherence() {
536 true
537 } else {
538 let mut skip = false;
539 if opaque_types.iter().any(|(_, ty)| ty.is_ty_var())
540 && let PredicateKind::Clause(ClauseKind::Trait(..)) =
541 goal.predicate.kind().skip_binder()
542 {
543 skip = true;
544 }
545
546 if let PredicateKind::Clause(ClauseKind::Trait(tr)) =
547 goal.predicate.kind().skip_binder()
548 && tr.self_ty().has_coroutines()
549 && self.cx().trait_is_auto(tr.trait_ref.def_id)
550 {
551 }
555
556 skip
557 };
558
559 if skip_erased_attempt {
560 if typing_mode.is_erased_not_coherence() {
561 match self.opaque_accesses.rerun_always(RerunReason::SkipErasedAttempt)? {}
562 } else {
563 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:563",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(563u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("running in original typing mode")
as &dyn Value))])
});
} else { ; }
};debug!("running in original typing mode");
564 }
565 } else {
566 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:566",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(566u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("trying without opaques: {0:?}",
goal) as &dyn Value))])
});
} else { ; }
};debug!("trying without opaques: {goal:?}");
567
568 let (orig_values, canonical_goal) = canonicalize_goal(
569 self.delegate,
570 goal,
571 &[],
572 TypingMode::ErasedNotCoherence(MayBeErased),
573 );
574
575 let (canonical_result, accessed_opaques) = self.search_graph.evaluate_goal(
576 self.cx(),
577 canonical_goal,
578 step_kind,
579 &mut inspect::ProofTreeBuilder::new_noop(),
580 );
581
582 let should_rerun = self.should_rerun_after_erased_canonicalization(
583 accessed_opaques,
584 self.typing_mode(),
585 &opaque_types,
586 );
587 match should_rerun {
588 RerunDecision::Yes => {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:588",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(588u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("rerunning in original typing mode")
as &dyn Value))])
});
} else { ; }
}debug!("rerunning in original typing mode"),
589 RerunDecision::No => {
590 break 'retry_canonicalize (canonical_result, orig_values, canonical_goal);
591 }
592 RerunDecision::EagerlyPropagateToParent => {
593 self.opaque_accesses.update(accessed_opaques)?;
594 break 'retry_canonicalize (canonical_result, orig_values, canonical_goal);
595 }
596 }
597 }
598
599 let (orig_values, canonical_goal) =
600 canonicalize_goal(self.delegate, goal, &opaque_types, typing_mode);
601
602 let (canonical_result, accessed_opaques) = self.search_graph.evaluate_goal(
603 self.cx(),
604 canonical_goal,
605 step_kind,
606 &mut inspect::ProofTreeBuilder::new_noop(),
607 );
608 if !!accessed_opaques.might_rerun() {
{
::core::panicking::panic_fmt(format_args!("we run without TypingMode::ErasedNotCoherence, so opaques are available, and we don\'t retry if the outer typing mode is ErasedNotCoherence: {0:?} after {1:?}",
accessed_opaques, goal));
}
};assert!(
609 !accessed_opaques.might_rerun(),
610 "we run without TypingMode::ErasedNotCoherence, so opaques are available, and we don't retry if the outer typing mode is ErasedNotCoherence: {accessed_opaques:?} after {goal:?}"
611 );
612
613 (canonical_result, orig_values, canonical_goal)
614 };
615
616 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:616",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(616u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["result"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&result) as
&dyn Value))])
});
} else { ; }
};debug!(?result);
617 let response = match result {
618 Ok(response) => {
619 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:619",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(619u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("success")
as &dyn Value))])
});
} else { ; }
};debug!("success");
620 response
621 }
622 Err(NoSolution) => {
623 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:623",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(623u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("normal failure")
as &dyn Value))])
});
} else { ; }
};debug!("normal failure");
624 return Err(NoSolution.into());
625 }
626 };
627
628 drop(tracing_span);
629
630 let has_changed =
631 if !has_only_region_constraints(response) { HasChanged::Yes } else { HasChanged::No };
632
633 let vis = match goal.predicate.kind().skip_binder() {
640 ty::PredicateKind::Clause(_)
641 | ty::PredicateKind::DynCompatible(_)
642 | ty::PredicateKind::Subtype(_)
643 | ty::PredicateKind::Coerce(_)
644 | ty::PredicateKind::ConstEquate(_, _)
645 | ty::PredicateKind::Ambiguous
646 | ty::PredicateKind::NormalizesTo(_) => VisibleForLeakCheck::No,
647 ty::PredicateKind::AliasRelate(_, _, _) => VisibleForLeakCheck::Yes,
648 };
649
650 let (normalization_nested_goals, certainty) = instantiate_and_apply_query_response(
651 self.delegate,
652 goal.param_env,
653 &orig_values,
654 response,
655 vis,
656 self.origin_span,
657 );
658
659 let stalled_on = match certainty {
670 Certainty::Yes => None,
671 Certainty::Maybe { .. } => match has_changed {
672 HasChanged::Yes => None,
677 HasChanged::No => {
678 let mut stalled_vars = orig_values;
679
680 if let Some(normalizes_to) = goal.predicate.as_normalizes_to() {
682 let normalizes_to = normalizes_to.skip_binder();
683 let rhs_arg: I::GenericArg = normalizes_to.term.into();
684 let idx = stalled_vars
685 .iter()
686 .rposition(|arg| *arg == rhs_arg)
687 .expect("expected unconstrained arg");
688 stalled_vars.swap_remove(idx);
689 }
690
691 let mut sub_roots = Vec::new();
693 stalled_vars.retain(|arg| match arg.kind() {
694 ty::GenericArgKind::Lifetime(_) => false,
696 ty::GenericArgKind::Type(ty) => match ty.kind() {
697 ty::Infer(ty::TyVar(vid)) => {
698 sub_roots.push(self.delegate.sub_unification_table_root_var(vid));
699 true
700 }
701 ty::Infer(_) => true,
702 ty::Param(_) | ty::Placeholder(_) => false,
703 _ => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("unexpected orig_value: {0:?}", ty)));
}unreachable!("unexpected orig_value: {ty:?}"),
704 },
705 ty::GenericArgKind::Const(ct) => match ct.kind() {
706 ty::ConstKind::Infer(_) => true,
707 ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => false,
708 _ => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("unexpected orig_value: {0:?}", ct)));
}unreachable!("unexpected orig_value: {ct:?}"),
709 },
710 });
711
712 Some(GoalStalledOn {
713 num_opaques: canonical_goal
714 .canonical
715 .value
716 .predefined_opaques_in_body
717 .len(),
718 stalled_vars,
719 sub_roots,
720 stalled_certainty: certainty,
721 })
722 }
723 },
724 };
725
726 Ok((
727 normalization_nested_goals,
728 GoalEvaluation { goal, certainty, has_changed, stalled_on },
729 ))
730 }
731
732 fn should_rerun_after_erased_canonicalization(
733 &self,
734 AccessedOpaques { reason: _, rerun }: AccessedOpaques<I>,
735 original_typing_mode: TypingMode<I>,
736 parent_opaque_types: &[(OpaqueTypeKey<I>, I::Ty)],
737 ) -> RerunDecision {
738 let parent_opaque_defids = parent_opaque_types.iter().map(|(key, _)| key.def_id.into());
739 let opaque_in_storage = |opaques: I::LocalDefIds, defids: SmallCopyList<_>| {
740 if defids.as_ref().is_empty() {
741 RerunDecision::No
742 } else if opaques
743 .iter()
744 .chain(parent_opaque_defids)
745 .any(|opaque| defids.as_ref().contains(&opaque))
746 {
747 RerunDecision::Yes
748 } else {
749 RerunDecision::No
750 }
751 };
752 let any_opaque_has_infer_as_hidden = || {
753 if parent_opaque_types.iter().any(|(_, ty)| ty.is_ty_var()) {
754 RerunDecision::Yes
755 } else {
756 RerunDecision::No
757 }
758 };
759
760 let res = match (rerun, original_typing_mode) {
761 (RerunCondition::Never, _) => RerunDecision::No,
763 (_, TypingMode::ErasedNotCoherence(MayBeErased)) => {
765 RerunDecision::EagerlyPropagateToParent
766 }
767 (_, TypingMode::Coherence) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
771 (RerunCondition::Always, _) => RerunDecision::Yes,
773 (RerunCondition::OpaqueInStorage(..), TypingMode::PostAnalysis) => RerunDecision::Yes,
775 (
776 RerunCondition::OpaqueInStorage(defids),
777 TypingMode::PostBorrowckAnalysis { defined_opaque_types: opaques }
778 | TypingMode::Analysis { defining_opaque_types_and_generators: opaques }
779 | TypingMode::Borrowck { defining_opaque_types: opaques },
780 ) => opaque_in_storage(opaques, defids),
781 (RerunCondition::AnyOpaqueHasInferAsHidden, TypingMode::Analysis { .. }) => {
783 any_opaque_has_infer_as_hidden()
784 }
785 (
786 RerunCondition::AnyOpaqueHasInferAsHidden,
787 TypingMode::PostBorrowckAnalysis { .. }
788 | TypingMode::PostAnalysis
789 | TypingMode::Borrowck { .. },
790 ) => RerunDecision::No,
791 (
793 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_),
794 TypingMode::PostAnalysis,
795 ) => RerunDecision::No,
796 (
797 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
798 TypingMode::Analysis { defining_opaque_types_and_generators: opaques },
799 ) => {
800 if let RerunDecision::Yes = any_opaque_has_infer_as_hidden() {
801 RerunDecision::Yes
802 } else if let RerunDecision::Yes = opaque_in_storage(opaques, defids) {
803 RerunDecision::Yes
804 } else {
805 RerunDecision::No
806 }
807 }
808 (
809 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
810 TypingMode::PostBorrowckAnalysis { defined_opaque_types: opaques }
811 | TypingMode::Borrowck { defining_opaque_types: opaques },
812 ) => opaque_in_storage(opaques, defids),
813 };
814
815 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:815",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(815u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("checking whether to rerun {0:?} in outer typing mode {1:?} and opaques {2:?}: {3:?}",
rerun, original_typing_mode, parent_opaque_types, res) as
&dyn Value))])
});
} else { ; }
};debug!(
816 "checking whether to rerun {rerun:?} in outer typing mode {original_typing_mode:?} and opaques {parent_opaque_types:?}: {res:?}"
817 );
818
819 res
820 }
821
822 pub(super) fn compute_goal(
823 &mut self,
824 goal: Goal<I, I::Predicate>,
825 ) -> QueryResultOrRerunNonErased<I> {
826 let Goal { param_env, predicate } = goal;
827 let kind = predicate.kind();
828 self.enter_forall_with_assumptions(kind, param_env, |ecx, kind| {
829 Ok(match kind {
830 ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
831 ecx.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r)?
832 }
833 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
834 ecx.compute_host_effect_goal(Goal { param_env, predicate })?
835 }
836 ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => {
837 ecx.compute_projection_goal(Goal { param_env, predicate })?
838 }
839 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => {
840 ecx.compute_type_outlives_goal(Goal { param_env, predicate })?
841 }
842 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => {
843 ecx.compute_region_outlives_goal(Goal { param_env, predicate })?
844 }
845 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
846 ecx.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })?
847 }
848 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
849 ecx.compute_unstable_feature_goal(param_env, symbol)?
850 }
851 ty::PredicateKind::Subtype(predicate) => {
852 ecx.compute_subtype_goal(Goal { param_env, predicate })?
853 }
854 ty::PredicateKind::Coerce(predicate) => {
855 ecx.compute_coerce_goal(Goal { param_env, predicate })?
856 }
857 ty::PredicateKind::DynCompatible(trait_def_id) => {
858 ecx.compute_dyn_compatible_goal(trait_def_id)?
859 }
860 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
861 ecx.compute_well_formed_goal(Goal { param_env, predicate: term })?
862 }
863 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => {
864 ecx.compute_const_evaluatable_goal(Goal { param_env, predicate: ct })?
865 }
866 ty::PredicateKind::ConstEquate(_, _) => {
867 {
::core::panicking::panic_fmt(format_args!("ConstEquate should not be emitted when `-Znext-solver` is active"));
}panic!("ConstEquate should not be emitted when `-Znext-solver` is active")
868 }
869 ty::PredicateKind::NormalizesTo(predicate) => {
870 ecx.compute_normalizes_to_goal(Goal { param_env, predicate })?
871 }
872 ty::PredicateKind::AliasRelate(lhs, rhs, direction) => ecx
873 .compute_alias_relate_goal(Goal {
874 param_env,
875 predicate: (lhs, rhs, direction),
876 })?,
877 ty::PredicateKind::Ambiguous => {
878 ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)?
879 }
880 })
881 })
882 }
883
884 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("try_evaluate_added_goals",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(886u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&[],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{ meta.fields().value_set(&[]) })
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<Certainty, NoSolutionOrRerunNonErased> = loop {};
return __tracing_attr_fake_return;
}
{
for _ in 0..FIXPOINT_STEP_LIMIT {
match self.evaluate_added_goals_step().map_err_to_rerun()? {
Ok(None) => {}
Ok(Some(cert)) => return Ok(cert),
Err(NoSolution) => {
self.tainted = Err(NoSolution);
return Err(NoSolution.into());
}
}
}
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:901",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(901u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["message"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&format_args!("try_evaluate_added_goals: encountered overflow")
as &dyn Value))])
});
} else { ; }
};
Ok(Certainty::overflow(false))
}
}
}#[instrument(level = "trace", skip(self))]
887 pub(super) fn try_evaluate_added_goals(
888 &mut self,
889 ) -> Result<Certainty, NoSolutionOrRerunNonErased> {
890 for _ in 0..FIXPOINT_STEP_LIMIT {
891 match self.evaluate_added_goals_step().map_err_to_rerun()? {
892 Ok(None) => {}
893 Ok(Some(cert)) => return Ok(cert),
894 Err(NoSolution) => {
895 self.tainted = Err(NoSolution);
896 return Err(NoSolution.into());
897 }
898 }
899 }
900
901 debug!("try_evaluate_added_goals: encountered overflow");
902 Ok(Certainty::overflow(false))
903 }
904
905 fn evaluate_added_goals_step(
909 &mut self,
910 ) -> Result<Option<Certainty>, NoSolutionOrRerunNonErased> {
911 let cx = self.cx();
912 let mut unchanged_certainty = Some(Certainty::Yes);
914 for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) {
915 if !self.delegate.disable_trait_solver_fast_paths()
916 && let Some(certainty) =
917 self.delegate.compute_goal_fast_path(goal, self.origin_span)
918 {
919 match certainty {
920 Certainty::Yes => {}
921 Certainty::Maybe { .. } => {
922 self.nested_goals.push((source, goal, None));
923 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
924 }
925 }
926 continue;
927 }
928
929 if let Some(pred) = goal.predicate.as_normalizes_to() {
940 let pred = pred.no_bound_vars().unwrap();
942 let unconstrained_rhs = self.next_term_infer_of_kind(pred.term);
945 let unconstrained_goal =
946 goal.with(cx, ty::NormalizesTo { alias: pred.alias, term: unconstrained_rhs });
947
948 let (
949 NestedNormalizationGoals(nested_goals),
950 GoalEvaluation { goal, certainty, stalled_on, has_changed: _ },
951 ) = self.evaluate_goal_raw(source, unconstrained_goal, stalled_on)?;
952 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs:953",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(953u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["nested_goals"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = __CALLSITE.metadata().fields().iter();
__CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&debug(&nested_goals)
as &dyn Value))])
});
} else { ; }
};trace!(?nested_goals);
954 self.nested_goals.extend(nested_goals.into_iter().map(|(s, g)| (s, g, None)));
955
956 self.eq_structurally_relating_aliases(
971 goal.param_env,
972 pred.term,
973 unconstrained_rhs,
974 )?;
975
976 let with_resolved_vars = self.resolve_vars_if_possible(goal);
983 if pred.alias
984 != with_resolved_vars
985 .predicate
986 .as_normalizes_to()
987 .unwrap()
988 .no_bound_vars()
989 .unwrap()
990 .alias
991 {
992 unchanged_certainty = None;
993 }
994
995 match certainty {
996 Certainty::Yes => {}
997 Certainty::Maybe { .. } => {
998 self.nested_goals.push((source, with_resolved_vars, stalled_on));
999 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1000 }
1001 }
1002 } else {
1003 let GoalEvaluation { goal, certainty, has_changed, stalled_on } =
1004 self.evaluate_goal(source, goal, stalled_on)?;
1005 if has_changed == HasChanged::Yes {
1006 unchanged_certainty = None;
1007 }
1008
1009 match certainty {
1010 Certainty::Yes => {}
1011 Certainty::Maybe { .. } => {
1012 self.nested_goals.push((source, goal, stalled_on));
1013 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1014 }
1015 }
1016 }
1017 }
1018
1019 Ok(unchanged_certainty)
1020 }
1021
1022 pub(crate) fn record_impl_args(&mut self, impl_args: I::GenericArgs) {
1024 self.inspect.record_impl_args(self.delegate, self.max_input_universe, impl_args)
1025 }
1026
1027 pub(super) fn cx(&self) -> I {
1028 self.delegate.cx()
1029 }
1030
1031 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("add_goal",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(1031u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["source", "goal"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
as &dyn Value)),
(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{
goal.predicate =
goal.predicate.fold_with(&mut ReplaceAliasWithInfer::new(self,
source, goal.param_env));
self.inspect.add_goal(self.delegate, self.max_input_universe,
source, goal);
self.nested_goals.push((source, goal, None));
}
}
}#[instrument(level = "debug", skip(self))]
1032 pub(super) fn add_goal(&mut self, source: GoalSource, mut goal: Goal<I, I::Predicate>) {
1033 goal.predicate =
1034 goal.predicate.fold_with(&mut ReplaceAliasWithInfer::new(self, source, goal.param_env));
1035 self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1036 self.nested_goals.push((source, goal, None));
1037 }
1038
1039 #[allow(clippy :: suspicious_else_formatting)]
{
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() ||
{ false } {
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("add_goals",
"rustc_next_trait_solver::solve::eval_ctxt",
::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs"),
::tracing_core::__macro_support::Option::Some(1039u32),
::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::eval_ctxt"),
::tracing_core::field::FieldSet::new(&["source"],
::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::TRACE <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::TRACE <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
let mut iter = meta.fields().iter();
meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
as &dyn Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: () = loop {};
return __tracing_attr_fake_return;
}
{ for goal in goals { self.add_goal(source, goal); } }
}
}#[instrument(level = "trace", skip(self, goals))]
1040 pub(super) fn add_goals(
1041 &mut self,
1042 source: GoalSource,
1043 goals: impl IntoIterator<Item = Goal<I, I::Predicate>>,
1044 ) {
1045 for goal in goals {
1046 self.add_goal(source, goal);
1047 }
1048 }
1049
1050 pub(super) fn next_region_var(&mut self) -> I::Region {
1051 let region = self.delegate.next_region_infer();
1052 self.inspect.add_var_value(region);
1053 region
1054 }
1055
1056 pub(super) fn next_ty_infer(&mut self) -> I::Ty {
1057 let ty = self.delegate.next_ty_infer();
1058 self.inspect.add_var_value(ty);
1059 ty
1060 }
1061
1062 pub(super) fn next_const_infer(&mut self) -> I::Const {
1063 let ct = self.delegate.next_const_infer();
1064 self.inspect.add_var_value(ct);
1065 ct
1066 }
1067
1068 pub(super) fn next_term_infer_of_kind(&mut self, term: I::Term) -> I::Term {
1071 match term.kind() {
1072 ty::TermKind::Ty(_) => self.next_ty_infer().into(),
1073 ty::TermKind::Const(_) => self.next_const_infer().into(),
1074 }
1075 }
1076
1077 x;#[instrument(level = "trace", skip(self), ret)]
1082 pub(super) fn term_is_fully_unconstrained(&self, goal: Goal<I, ty::NormalizesTo<I>>) -> bool {
1083 let universe_of_term = match goal.predicate.term.kind() {
1084 ty::TermKind::Ty(ty) => {
1085 if let ty::Infer(ty::TyVar(vid)) = ty.kind() {
1086 self.delegate.universe_of_ty(vid).unwrap()
1087 } else {
1088 return false;
1089 }
1090 }
1091 ty::TermKind::Const(ct) => {
1092 if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = ct.kind() {
1093 self.delegate.universe_of_ct(vid).unwrap()
1094 } else {
1095 return false;
1096 }
1097 }
1098 };
1099
1100 struct ContainsTermOrNotNameable<'a, D: SolverDelegate<Interner = I>, I: Interner> {
1101 term: I::Term,
1102 universe_of_term: ty::UniverseIndex,
1103 delegate: &'a D,
1104 cache: HashSet<I::Ty>,
1105 }
1106
1107 impl<D: SolverDelegate<Interner = I>, I: Interner> ContainsTermOrNotNameable<'_, D, I> {
1108 fn check_nameable(&self, universe: ty::UniverseIndex) -> ControlFlow<()> {
1109 if self.universe_of_term.can_name(universe) {
1110 ControlFlow::Continue(())
1111 } else {
1112 ControlFlow::Break(())
1113 }
1114 }
1115 }
1116
1117 impl<D: SolverDelegate<Interner = I>, I: Interner> TypeVisitor<I>
1118 for ContainsTermOrNotNameable<'_, D, I>
1119 {
1120 type Result = ControlFlow<()>;
1121 fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
1122 if self.cache.contains(&t) {
1123 return ControlFlow::Continue(());
1124 }
1125
1126 match t.kind() {
1127 ty::Infer(ty::TyVar(vid)) => {
1128 if let ty::TermKind::Ty(term) = self.term.kind()
1129 && let ty::Infer(ty::TyVar(term_vid)) = term.kind()
1130 && self.delegate.root_ty_var(vid) == self.delegate.root_ty_var(term_vid)
1131 {
1132 return ControlFlow::Break(());
1133 }
1134
1135 self.check_nameable(self.delegate.universe_of_ty(vid).unwrap())?;
1136 }
1137 ty::Placeholder(p) => self.check_nameable(p.universe())?,
1138 _ => {
1139 if t.has_non_region_infer() || t.has_placeholders() {
1140 t.super_visit_with(self)?
1141 }
1142 }
1143 }
1144
1145 assert!(self.cache.insert(t));
1146 ControlFlow::Continue(())
1147 }
1148
1149 fn visit_const(&mut self, c: I::Const) -> Self::Result {
1150 match c.kind() {
1151 ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
1152 if let ty::TermKind::Const(term) = self.term.kind()
1153 && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
1154 && self.delegate.root_const_var(vid)
1155 == self.delegate.root_const_var(term_vid)
1156 {
1157 return ControlFlow::Break(());
1158 }
1159
1160 self.check_nameable(self.delegate.universe_of_ct(vid).unwrap())
1161 }
1162 ty::ConstKind::Placeholder(p) => self.check_nameable(p.universe()),
1163 _ => {
1164 if c.has_non_region_infer() || c.has_placeholders() {
1165 c.super_visit_with(self)
1166 } else {
1167 ControlFlow::Continue(())
1168 }
1169 }
1170 }
1171 }
1172
1173 fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result {
1174 if p.has_non_region_infer() || p.has_placeholders() {
1175 p.super_visit_with(self)
1176 } else {
1177 ControlFlow::Continue(())
1178 }
1179 }
1180
1181 fn visit_clauses(&mut self, c: I::Clauses) -> Self::Result {
1182 if c.has_non_region_infer() || c.has_placeholders() {
1183 c.super_visit_with(self)
1184 } else {
1185 ControlFlow::Continue(())
1186 }
1187 }
1188 }
1189
1190 let mut visitor = ContainsTermOrNotNameable {
1191 delegate: self.delegate,
1192 universe_of_term,
1193 term: goal.predicate.term,
1194 cache: Default::default(),
1195 };
1196 goal.predicate.alias.visit_with(&mut visitor).is_continue()
1197 && goal.param_env.visit_with(&mut visitor).is_continue()
1198 }
1199
1200 pub(super) fn sub_unify_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
1201 self.delegate.sub_unify_ty_vids_raw(a, b)
1202 }
1203
1204 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1205 pub(super) fn eq<T: Relate<I>>(
1206 &mut self,
1207 param_env: I::ParamEnv,
1208 lhs: T,
1209 rhs: T,
1210 ) -> Result<(), NoSolution> {
1211 self.relate(param_env, lhs, ty::Variance::Invariant, rhs)
1212 }
1213
1214 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1220 pub(super) fn relate_rigid_alias_non_alias(
1221 &mut self,
1222 param_env: I::ParamEnv,
1223 alias: ty::AliasTerm<I>,
1224 variance: ty::Variance,
1225 term: I::Term,
1226 ) -> Result<(), NoSolution> {
1227 if term.is_infer() {
1230 let cx = self.cx();
1231 let identity_args = self.fresh_args_for_item(alias.def_id());
1240 let rigid_ctor = alias.with_args(cx, identity_args);
1241 let ctor_term = rigid_ctor.to_term(cx);
1242 let obligations = self.delegate.eq_structurally_relating_aliases(
1243 param_env,
1244 term,
1245 ctor_term,
1246 self.origin_span,
1247 )?;
1248 debug_assert!(obligations.is_empty());
1249 self.relate(param_env, alias, variance, rigid_ctor)
1250 } else {
1251 Err(NoSolution)
1252 }
1253 }
1254
1255 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1259 pub(super) fn eq_structurally_relating_aliases<T: Relate<I>>(
1260 &mut self,
1261 param_env: I::ParamEnv,
1262 lhs: T,
1263 rhs: T,
1264 ) -> Result<(), NoSolution> {
1265 let result = self.delegate.eq_structurally_relating_aliases(
1266 param_env,
1267 lhs,
1268 rhs,
1269 self.origin_span,
1270 )?;
1271 assert_eq!(result, vec![]);
1272 Ok(())
1273 }
1274
1275 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1276 pub(super) fn sub<T: Relate<I>>(
1277 &mut self,
1278 param_env: I::ParamEnv,
1279 sub: T,
1280 sup: T,
1281 ) -> Result<(), NoSolution> {
1282 self.relate(param_env, sub, ty::Variance::Covariant, sup)
1283 }
1284
1285 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1286 pub(super) fn relate<T: Relate<I>>(
1287 &mut self,
1288 param_env: I::ParamEnv,
1289 lhs: T,
1290 variance: ty::Variance,
1291 rhs: T,
1292 ) -> Result<(), NoSolution> {
1293 let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
1294 for &goal in goals.iter() {
1295 let source = match goal.predicate.kind().skip_binder() {
1296 ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {
1297 GoalSource::TypeRelating
1298 }
1299 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
1301 p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
1302 };
1303 self.add_goal(source, goal);
1304 }
1305 Ok(())
1306 }
1307
1308 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1314 pub(super) fn eq_and_get_goals<T: Relate<I>>(
1315 &self,
1316 param_env: I::ParamEnv,
1317 lhs: T,
1318 rhs: T,
1319 ) -> Result<Vec<Goal<I, I::Predicate>>, NoSolution> {
1320 Ok(self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs, self.origin_span)?)
1321 }
1322
1323 pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<I> + Copy>(
1324 &self,
1325 value: ty::Binder<I, T>,
1326 ) -> T {
1327 self.delegate.instantiate_binder_with_infer(value)
1328 }
1329
1330 pub(super) fn enter_forall_with_assumptions<T: TypeFoldable<I>, U>(
1338 &mut self,
1339 value: ty::Binder<I, T>,
1340 param_env: I::ParamEnv,
1341 f: impl FnOnce(&mut Self, T) -> U,
1342 ) -> U {
1343 self.delegate.enter_forall(value, |value| {
1344 let u = self.delegate.universe();
1345 let assumptions = if self.cx().assumptions_on_binders() {
1346 self.region_assumptions_for_placeholders_in_universe(value.clone(), u, param_env)
1347 } else {
1348 None
1349 };
1350 self.delegate.insert_placeholder_assumptions(u, assumptions);
1351 f(self, value)
1352 })
1353 }
1354
1355 pub(super) fn resolve_vars_if_possible<T>(&self, value: T) -> T
1356 where
1357 T: TypeFoldable<I>,
1358 {
1359 self.delegate.resolve_vars_if_possible(value)
1360 }
1361
1362 pub(super) fn shallow_resolve(&self, ty: I::Ty) -> I::Ty {
1363 self.delegate.shallow_resolve(ty)
1364 }
1365
1366 pub(super) fn eager_resolve_region(&self, r: I::Region) -> I::Region {
1367 if let ty::ReVar(vid) = r.kind() {
1368 self.delegate.opportunistic_resolve_lt_var(vid)
1369 } else {
1370 r
1371 }
1372 }
1373
1374 pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs {
1375 let args = self.delegate.fresh_args_for_item(def_id);
1376 for arg in args.iter() {
1377 self.inspect.add_var_value(arg);
1378 }
1379 args
1380 }
1381
1382 pub(super) fn register_solver_region_constraint(&self, c: RegionConstraint<I>) {
1383 self.delegate.register_solver_region_constraint(c);
1384 }
1385
1386 pub(super) fn register_ty_outlives(&self, ty: I::Ty, lt: I::Region) {
1387 self.delegate.register_ty_outlives(ty, lt, self.origin_span);
1388 }
1389
1390 pub(super) fn register_region_outlives(
1391 &self,
1392 a: I::Region,
1393 b: I::Region,
1394 vis: VisibleForLeakCheck,
1395 ) {
1396 self.delegate.sub_regions(b, a, vis, self.origin_span);
1398 }
1399
1400 pub(super) fn well_formed_goals(
1402 &self,
1403 param_env: I::ParamEnv,
1404 term: I::Term,
1405 ) -> Option<Vec<Goal<I, I::Predicate>>> {
1406 self.delegate.well_formed_goals(param_env, term)
1407 }
1408
1409 pub(super) fn trait_ref_is_knowable(
1410 &mut self,
1411 param_env: I::ParamEnv,
1412 trait_ref: ty::TraitRef<I>,
1413 ) -> Result<bool, NoSolutionOrRerunNonErased> {
1414 let delegate = self.delegate;
1415 let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
1416 coherence::trait_ref_is_knowable(&**delegate, trait_ref, lazily_normalize_ty)
1417 .map(|is_knowable| is_knowable.is_ok())
1418 }
1419
1420 pub(super) fn fetch_eligible_assoc_item(
1421 &self,
1422 goal_trait_ref: ty::TraitRef<I>,
1423 trait_assoc_def_id: I::TraitAssocTermId,
1424 impl_def_id: I::ImplId,
1425 ) -> FetchEligibleAssocItemResponse<I> {
1426 self.delegate.fetch_eligible_assoc_item(goal_trait_ref, trait_assoc_def_id, impl_def_id)
1427 }
1428
1429 x;#[instrument(level = "debug", skip(self), ret)]
1430 pub(super) fn register_hidden_type_in_storage(
1431 &mut self,
1432 opaque_type_key: ty::OpaqueTypeKey<I>,
1433 hidden_ty: I::Ty,
1434 ) -> Option<I::Ty> {
1435 self.delegate.register_hidden_type_in_storage(opaque_type_key, hidden_ty, self.origin_span)
1436 }
1437
1438 pub(super) fn add_item_bounds_for_hidden_type(
1439 &mut self,
1440 opaque_def_id: I::OpaqueTyId,
1441 opaque_args: I::GenericArgs,
1442 param_env: I::ParamEnv,
1443 hidden_ty: I::Ty,
1444 ) {
1445 let mut goals = Vec::new();
1446 self.delegate.add_item_bounds_for_hidden_type(
1447 opaque_def_id,
1448 opaque_args,
1449 param_env,
1450 hidden_ty,
1451 &mut goals,
1452 );
1453 self.add_goals(GoalSource::AliasWellFormed, goals);
1454 }
1455
1456 pub(super) fn evaluate_const(
1460 &mut self,
1461 param_env: I::ParamEnv,
1462 uv: ty::UnevaluatedConst<I>,
1463 ) -> Result<Option<I::Const>, RerunNonErased> {
1464 if self.typing_mode().is_erased_not_coherence() {
1465 self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)?;
1466 }
1467
1468 Ok(self.delegate.evaluate_const(param_env, uv))
1469 }
1470
1471 pub(super) fn evaluate_const_and_instantiate_normalizes_to_term(
1472 &mut self,
1473 goal: Goal<I, ty::NormalizesTo<I>>,
1474 uv: ty::UnevaluatedConst<I>,
1475 ) -> QueryResultOrRerunNonErased<I> {
1476 match self.evaluate_const(goal.param_env, uv)? {
1477 Some(evaluated) => {
1478 self.instantiate_normalizes_to_term(goal, evaluated.into());
1479 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1480 }
1481 None if self.cx().features().generic_const_args() => {
1482 if self.resolve_vars_if_possible(uv).has_non_region_infer() {
1490 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1491 } else {
1492 self.structurally_instantiate_normalizes_to_term(goal, goal.predicate.alias);
1499 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1500 }
1501 }
1502 None => {
1503 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1505 }
1506 }
1507 }
1508
1509 pub(super) fn is_transmutable(
1510 &mut self,
1511 src: I::Ty,
1512 dst: I::Ty,
1513 assume: I::Const,
1514 ) -> Result<Certainty, NoSolution> {
1515 self.delegate.is_transmutable(dst, src, assume)
1516 }
1517
1518 pub(super) fn replace_bound_vars<T: TypeFoldable<I>>(
1519 &self,
1520 t: T,
1521 universes: &mut Vec<Option<ty::UniverseIndex>>,
1522 ) -> T {
1523 BoundVarReplacer::replace_bound_vars(&**self.delegate, universes, t).0
1524 }
1525
1526 pub(super) fn may_use_unstable_feature(
1527 &mut self,
1528 param_env: I::ParamEnv,
1529 symbol: I::Symbol,
1530 ) -> Result<bool, RerunNonErased> {
1531 if self.typing_mode().is_erased_not_coherence() {
1532 self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)?;
1533 }
1534
1535 Ok(may_use_unstable_feature(&**self.delegate, param_env, symbol))
1536 }
1537
1538 pub(crate) fn opaques_with_sub_unified_hidden_type(
1539 &self,
1540 self_ty: I::Ty,
1541 ) -> Vec<ty::AliasTy<I>> {
1542 if let ty::Infer(ty::TyVar(vid)) = self_ty.kind() {
1543 self.delegate.opaques_with_sub_unified_hidden_type(vid)
1544 } else {
1545 ::alloc::vec::Vec::new()vec![]
1546 }
1547 }
1548
1549 x;#[instrument(level = "trace", skip(self), ret)]
1563 pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
1564 &mut self,
1565 shallow_certainty: Certainty,
1566 ) -> QueryResultOrRerunNonErased<I> {
1567 self.inspect.make_canonical_response(shallow_certainty);
1568
1569 let goals_certainty = self.try_evaluate_added_goals()?;
1570 assert_eq!(
1571 self.tainted,
1572 Ok(()),
1573 "EvalCtxt is tainted -- nested goals may have been dropped in a \
1574 previous call to `try_evaluate_added_goals!`"
1575 );
1576
1577 let goals_certainty = match self.delegate.cx().assumptions_on_binders() {
1578 true => {
1579 let certainty = self.eagerly_handle_placeholders()?;
1580 certainty.and(goals_certainty)
1581 }
1582 false => {
1583 self.delegate.leak_check(self.max_input_universe).map_err(|NoSolution| {
1586 trace!("failed the leak check");
1587 NoSolution
1588 })?;
1589
1590 goals_certainty
1591 }
1592 };
1593
1594 let (certainty, normalization_nested_goals) =
1595 match (self.current_goal_kind, shallow_certainty) {
1596 (CurrentGoalKind::NormalizesTo, Certainty::Yes) => {
1604 let goals = std::mem::take(&mut self.nested_goals);
1605 if goals.is_empty() {
1608 assert!(matches!(goals_certainty, Certainty::Yes));
1609 }
1610 (
1611 Certainty::Yes,
1612 NestedNormalizationGoals(
1613 goals.into_iter().map(|(s, g, _)| (s, g)).collect(),
1614 ),
1615 )
1616 }
1617 _ => {
1618 let certainty = shallow_certainty.and(goals_certainty);
1619 (certainty, NestedNormalizationGoals::empty())
1620 }
1621 };
1622
1623 if let Certainty::Maybe(
1624 maybe_info @ MaybeInfo {
1625 cause: MaybeCause::Overflow { keep_constraints: false, .. },
1626 opaque_types_jank: _,
1627 stalled_on_coroutines: _,
1628 },
1629 ) = certainty
1630 {
1631 return Ok(self.make_ambiguous_response_no_constraints(maybe_info));
1643 }
1644
1645 let external_constraints =
1646 self.compute_external_query_constraints(certainty, normalization_nested_goals);
1647 let (var_values, mut external_constraints) =
1648 eager_resolve_vars(self.delegate, (self.var_values, external_constraints));
1649
1650 let mut unique = HashSet::default();
1652 if let ExternalRegionConstraints::Old(r) = &mut external_constraints.region_constraints {
1653 r.retain(|(outlives, _)| !outlives.is_trivial() && unique.insert(*outlives));
1654 }
1655
1656 let canonical = canonicalize_response(
1657 self.delegate,
1658 self.max_input_universe,
1659 Response {
1660 var_values,
1661 certainty,
1662 external_constraints: self.cx().mk_external_constraints(external_constraints),
1663 },
1664 );
1665
1666 Ok(canonical)
1667 }
1668
1669 pub(in crate::solve) fn make_ambiguous_response_no_constraints(
1674 &self,
1675 maybe: MaybeInfo,
1676 ) -> CanonicalResponse<I> {
1677 response_no_constraints_raw(
1678 self.cx(),
1679 self.max_input_universe,
1680 self.var_kinds,
1681 Certainty::Maybe(maybe),
1682 )
1683 }
1684
1685 x;#[instrument(level = "trace", skip(self), ret)]
1693 fn compute_external_query_constraints(
1694 &self,
1695 certainty: Certainty,
1696 normalization_nested_goals: NestedNormalizationGoals<I>,
1697 ) -> ExternalConstraintsData<I> {
1698 let region_constraints = if self.cx().assumptions_on_binders() {
1707 ExternalRegionConstraints::NextGen(if let Certainty::Yes = certainty {
1708 self.delegate.get_solver_region_constraint()
1709 } else {
1710 RegionConstraint::new_true()
1711 })
1712 } else {
1713 ExternalRegionConstraints::Old(if let Certainty::Yes = certainty {
1714 self.delegate.make_deduplicated_region_constraints()
1715 } else {
1716 vec![]
1717 })
1718 };
1719
1720 let opaque_types = self
1725 .delegate
1726 .clone_opaque_types_added_since(self.initial_opaque_types_storage_num_entries);
1727
1728 if self.typing_mode().is_erased_not_coherence() {
1729 assert!(opaque_types.is_empty());
1730 }
1731
1732 ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
1733 }
1734}
1735
1736struct ReplaceAliasWithInfer<'me, 'a, D, I>
1751where
1752 D: SolverDelegate<Interner = I>,
1753 I: Interner,
1754{
1755 ecx: &'me mut EvalCtxt<'a, D>,
1756 param_env: I::ParamEnv,
1757 normalization_goal_source: GoalSource,
1758 cache: HashMap<I::Ty, I::Ty>,
1759}
1760
1761impl<'me, 'a, D, I> ReplaceAliasWithInfer<'me, 'a, D, I>
1762where
1763 D: SolverDelegate<Interner = I>,
1764 I: Interner,
1765{
1766 fn new(
1767 ecx: &'me mut EvalCtxt<'a, D>,
1768 for_goal_source: GoalSource,
1769 param_env: I::ParamEnv,
1770 ) -> Self {
1771 let step_kind = ecx.step_kind_for_source(for_goal_source);
1772 ReplaceAliasWithInfer {
1773 ecx,
1774 param_env,
1775 normalization_goal_source: GoalSource::NormalizeGoal(step_kind),
1776 cache: Default::default(),
1777 }
1778 }
1779}
1780
1781impl<D, I> TypeFolder<I> for ReplaceAliasWithInfer<'_, '_, D, I>
1782where
1783 D: SolverDelegate<Interner = I>,
1784 I: Interner,
1785{
1786 fn cx(&self) -> I {
1787 self.ecx.cx()
1788 }
1789
1790 fn fold_ty(&mut self, ty: I::Ty) -> I::Ty {
1791 match ty.kind() {
1792 ty::Alias(..) if !ty.has_escaping_bound_vars() => {
1793 let infer_ty = self.ecx.next_ty_infer();
1794 let normalizes_to = ty::PredicateKind::AliasRelate(
1795 ty.into(),
1796 infer_ty.into(),
1797 ty::AliasRelationDirection::Equate,
1798 );
1799 self.ecx.add_goal(
1800 self.normalization_goal_source,
1801 Goal::new(self.cx(), self.param_env, normalizes_to),
1802 );
1803 infer_ty
1804 }
1805 _ => {
1806 if !ty.has_aliases() {
1807 ty
1808 } else if let Some(&entry) = self.cache.get(&ty) {
1809 return entry;
1810 } else {
1811 let res = ty.super_fold_with(self);
1812 if !self.cache.insert(ty, res).is_none() {
::core::panicking::panic("assertion failed: self.cache.insert(ty, res).is_none()")
};assert!(self.cache.insert(ty, res).is_none());
1813 res
1814 }
1815 }
1816 }
1817 }
1818
1819 fn fold_const(&mut self, ct: I::Const) -> I::Const {
1820 match ct.kind() {
1821 ty::ConstKind::Unevaluated(..) if !ct.has_escaping_bound_vars() => {
1822 let infer_ct = self.ecx.next_const_infer();
1823 let normalizes_to = ty::PredicateKind::AliasRelate(
1824 ct.into(),
1825 infer_ct.into(),
1826 ty::AliasRelationDirection::Equate,
1827 );
1828 self.ecx.add_goal(
1829 self.normalization_goal_source,
1830 Goal::new(self.cx(), self.param_env, normalizes_to),
1831 );
1832 infer_ct
1833 }
1834 _ => ct.super_fold_with(self),
1835 }
1836 }
1837
1838 fn fold_predicate(&mut self, predicate: I::Predicate) -> I::Predicate {
1839 if predicate.allow_normalization() { predicate.super_fold_with(self) } else { predicate }
1840 }
1841}
1842
1843pub fn evaluate_root_goal_for_proof_tree_raw_provider<
1845 D: SolverDelegate<Interner = I>,
1846 I: Interner,
1847>(
1848 cx: I,
1849 canonical_goal: CanonicalInput<I>,
1850) -> (QueryResult<I>, I::Probe) {
1851 let mut inspect = inspect::ProofTreeBuilder::new();
1852 let (canonical_result, accessed_opaques) = SearchGraph::<D>::evaluate_root_goal_for_proof_tree(
1853 cx,
1854 cx.recursion_limit(),
1855 canonical_goal,
1856 &mut inspect,
1857 );
1858 let final_revision = inspect.unwrap();
1859
1860 if !!accessed_opaques.might_rerun() {
::core::panicking::panic("assertion failed: !accessed_opaques.might_rerun()")
};assert!(!accessed_opaques.might_rerun());
1861 (canonical_result, cx.mk_probe(final_revision))
1862}
1863
1864pub(super) fn evaluate_root_goal_for_proof_tree<D: SolverDelegate<Interner = I>, I: Interner>(
1869 delegate: &D,
1870 goal: Goal<I, I::Predicate>,
1871 origin_span: I::Span,
1872) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
1873 let opaque_types = delegate.clone_opaque_types_lookup_table();
1874 let (goal, opaque_types) = eager_resolve_vars(delegate, (goal, opaque_types));
1875 let typing_mode = delegate.typing_mode_raw().assert_not_erased();
1876
1877 let (orig_values, canonical_goal) =
1878 canonicalize_goal(delegate, goal, &opaque_types, typing_mode.into());
1879
1880 let (canonical_result, final_revision) =
1881 delegate.cx().evaluate_root_goal_for_proof_tree_raw(canonical_goal);
1882
1883 let proof_tree = inspect::GoalEvaluation {
1884 uncanonicalized_goal: goal,
1885 orig_values,
1886 final_revision,
1887 result: canonical_result,
1888 };
1889
1890 let response = match canonical_result {
1891 Err(e) => return (Err(e), proof_tree),
1892 Ok(response) => response,
1893 };
1894
1895 let (normalization_nested_goals, _certainty) = instantiate_and_apply_query_response(
1896 delegate,
1897 goal.param_env,
1898 &proof_tree.orig_values,
1899 response,
1900 VisibleForLeakCheck::Yes,
1901 origin_span,
1902 );
1903
1904 (Ok(normalization_nested_goals), proof_tree)
1905}