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, SucceededInErased,
39 VisibleForLeakCheck, 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::ProjectionComputeAssocTermCandidate =>
"ProjectionComputeAssocTermCandidate",
})
}
}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 ProjectionComputeAssocTermCandidate,
71}
72
73impl CurrentGoalKind {
74 fn from_query_input<I: Interner>(cx: I, input: QueryInput<I, I::Predicate>) -> CurrentGoalKind {
75 match input.goal.predicate.kind().skip_binder() {
76 ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => {
77 if cx.trait_is_coinductive(pred.trait_ref.def_id) {
78 CurrentGoalKind::CoinductiveTrait
79 } else {
80 CurrentGoalKind::Misc
81 }
82 }
83 ty::PredicateKind::NormalizesTo(_) => {
84 CurrentGoalKind::ProjectionComputeAssocTermCandidate
85 }
86 _ => CurrentGoalKind::Misc,
87 }
88 }
89}
90
91#[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)]
92enum RerunDecision {
93 Yes,
94 No,
95 EagerlyPropagateToParent,
96}
97pub struct EvalCtxt<'a, D, I = <D as SolverDelegate>::Interner>
98where
99 D: SolverDelegate<Interner = I>,
100 I: Interner,
101{
102 delegate: &'a D,
118
119 var_kinds: I::CanonicalVarKinds,
122
123 current_goal_kind: CurrentGoalKind,
126 pub(super) var_values: CanonicalVarValues<I>,
127
128 pub(super) max_input_universe: ty::UniverseIndex,
138 pub(super) initial_opaque_types_storage_num_entries:
141 <D::Infcx as InferCtxtLike>::OpaqueTypeStorageEntries,
142
143 pub(super) search_graph: &'a mut SearchGraph<D>,
144
145 nested_goals: Vec<(GoalSource, Goal<I, I::Predicate>, Option<GoalStalledOn<I>>)>,
146
147 pub(super) origin_span: I::Span,
148
149 tainted: Result<(), NoSolution>,
156
157 pub(super) opaque_accesses: AccessedOpaques<I>,
159
160 pub(super) inspect: inspect::EvaluationStepBuilder<D>,
161}
162
163#[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)]
164#[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))]
165pub enum GenerateProofTree {
166 Yes,
167 No,
168}
169
170pub trait SolverDelegateEvalExt: SolverDelegate {
171 fn evaluate_root_goal(
176 &self,
177 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
178 span: <Self::Interner as Interner>::Span,
179 stalled_on: Option<GoalStalledOn<Self::Interner>>,
180 ) -> Result<GoalEvaluation<Self::Interner>, NoSolution>;
181
182 fn root_goal_may_hold_opaque_types_jank(
187 &self,
188 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
189 ) -> bool;
190
191 fn root_goal_may_hold_with_depth(
199 &self,
200 root_depth: usize,
201 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
202 ) -> bool;
203
204 fn evaluate_root_goal_for_proof_tree(
207 &self,
208 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
209 span: <Self::Interner as Interner>::Span,
210 ) -> (
211 Result<NestedNormalizationGoals<Self::Interner>, NoSolution>,
212 inspect::GoalEvaluation<Self::Interner>,
213 );
214}
215
216impl<D, I> SolverDelegateEvalExt for D
217where
218 D: SolverDelegate<Interner = I>,
219 I: Interner,
220{
221 x;#[instrument(level = "debug", skip(self), ret)]
222 fn evaluate_root_goal(
223 &self,
224 goal: Goal<I, I::Predicate>,
225 span: I::Span,
226 stalled_on: Option<GoalStalledOn<I>>,
227 ) -> Result<GoalEvaluation<I>, NoSolution> {
228 let result = EvalCtxt::enter_root(self, self.cx().recursion_limit(), span, |ecx| {
229 ecx.evaluate_goal(GoalSource::Misc, goal, stalled_on)
230 });
231
232 match result {
233 Ok(i) => Ok(i),
234 Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
235 Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
236 unreachable!("this never happens at the root, we're never in erased mode here");
237 }
238 }
239 }
240
241 x;#[instrument(level = "debug", skip(self), ret)]
242 fn root_goal_may_hold_opaque_types_jank(
243 &self,
244 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
245 ) -> bool {
246 self.probe(|| {
247 EvalCtxt::enter_root(self, self.cx().recursion_limit(), I::Span::dummy(), |ecx| {
248 ecx.evaluate_goal(GoalSource::Misc, goal, None)
249 })
250 .is_ok_and(|r| match r.certainty {
251 Certainty::Yes => true,
252 Certainty::Maybe(MaybeInfo {
253 cause: _,
254 opaque_types_jank,
255 stalled_on_coroutines: _,
256 }) => match opaque_types_jank {
257 OpaqueTypesJank::AllGood => true,
258 OpaqueTypesJank::ErrorIfRigidSelfTy => false,
259 },
260 })
261 })
262 }
263
264 fn root_goal_may_hold_with_depth(
265 &self,
266 root_depth: usize,
267 goal: Goal<Self::Interner, <Self::Interner as Interner>::Predicate>,
268 ) -> bool {
269 self.probe(|| {
270 EvalCtxt::enter_root(self, root_depth, I::Span::dummy(), |ecx| {
271 ecx.evaluate_goal(GoalSource::Misc, goal, None)
272 })
273 })
274 .is_ok()
275 }
276
277 #[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(277u32),
::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))]
278 fn evaluate_root_goal_for_proof_tree(
279 &self,
280 goal: Goal<I, I::Predicate>,
281 span: I::Span,
282 ) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
283 evaluate_root_goal_for_proof_tree(self, goal, span)
284 }
285}
286
287#[derive(#[automatically_derived]
impl ::core::fmt::Debug for RerunStalled {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
RerunStalled::WontMakeProgress(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"WontMakeProgress", &__self_0),
RerunStalled::MayMakeProgress =>
::core::fmt::Formatter::write_str(f, "MayMakeProgress"),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for RerunStalled {
#[inline]
fn clone(&self) -> RerunStalled {
let _: ::core::clone::AssertParamIsClone<Certainty>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for RerunStalled { }Copy)]
288enum RerunStalled {
289 WontMakeProgress(Certainty),
290 MayMakeProgress,
291}
292
293impl<'a, D, I> EvalCtxt<'a, D>
294where
295 D: SolverDelegate<Interner = I>,
296 I: Interner,
297{
298 pub(super) fn typing_mode(&self) -> TypingMode<I> {
299 self.delegate.typing_mode_raw()
300 }
301
302 pub(super) fn step_kind_for_source(&self, source: GoalSource) -> PathKind {
311 match source {
312 GoalSource::Misc => PathKind::Unknown,
320 GoalSource::NormalizeGoal(path_kind) => path_kind,
321 GoalSource::ImplWhereBound => match self.current_goal_kind {
322 CurrentGoalKind::CoinductiveTrait => PathKind::Coinductive,
325 CurrentGoalKind::ProjectionComputeAssocTermCandidate => PathKind::Inductive,
333 CurrentGoalKind::Misc => PathKind::Unknown,
337 },
338 GoalSource::TypeRelating => PathKind::Inductive,
342 GoalSource::AliasBoundConstCondition | GoalSource::AliasWellFormed => PathKind::Unknown,
346 }
347 }
348
349 pub(super) fn enter_root<R>(
353 delegate: &D,
354 root_depth: usize,
355 origin_span: I::Span,
356 f: impl FnOnce(&mut EvalCtxt<'_, D>) -> R,
357 ) -> R {
358 let mut search_graph = SearchGraph::new(root_depth);
359
360 let mut ecx = EvalCtxt {
361 delegate,
362 search_graph: &mut search_graph,
363 nested_goals: Default::default(),
364 inspect: inspect::EvaluationStepBuilder::new_noop(),
365
366 max_input_universe: ty::UniverseIndex::ROOT,
369 initial_opaque_types_storage_num_entries: Default::default(),
370 var_kinds: Default::default(),
371 var_values: CanonicalVarValues::dummy(),
372 current_goal_kind: CurrentGoalKind::Misc,
373 origin_span,
374 tainted: Ok(()),
375 opaque_accesses: AccessedOpaques::default(),
376 };
377 let result = f(&mut ecx);
378 if !ecx.nested_goals.is_empty() {
{
::core::panicking::panic_fmt(format_args!("root `EvalCtxt` should not have any goals added to it"));
}
};assert!(
379 ecx.nested_goals.is_empty(),
380 "root `EvalCtxt` should not have any goals added to it"
381 );
382 if !!ecx.opaque_accesses.might_rerun() {
::core::panicking::panic("assertion failed: !ecx.opaque_accesses.might_rerun()")
};assert!(!ecx.opaque_accesses.might_rerun());
383 if !search_graph.is_empty() {
::core::panicking::panic("assertion failed: search_graph.is_empty()")
};assert!(search_graph.is_empty());
384 result
385 }
386
387 pub(super) fn enter_canonical<T>(
395 cx: I,
396 search_graph: &'a mut SearchGraph<D>,
397 canonical_input: CanonicalInput<I>,
398 proof_tree_builder: &mut inspect::ProofTreeBuilder<D>,
399 f: impl FnOnce(
400 &mut EvalCtxt<'_, D>,
401 Goal<I, I::Predicate>,
402 ) -> Result<T, NoSolutionOrRerunNonErased>,
403 ) -> (Result<T, NoSolution>, AccessedOpaques<I>) {
404 let (ref delegate, input, var_values) = D::build_with_canonical(cx, &canonical_input);
405 for (key, ty) in input.predefined_opaques_in_body.iter() {
406 let prev = delegate.register_hidden_type_in_storage(key, ty, I::Span::dummy());
407 if let Some(prev) = prev {
419 {
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:419",
"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(419u32),
::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`");
420 }
421 }
422
423 let initial_opaque_types_storage_num_entries = delegate.opaque_types_storage_num_entries();
424 if truecfg!(debug_assertions) && delegate.typing_mode_raw().is_erased_not_coherence() {
425 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());
426 }
427
428 let mut ecx = EvalCtxt {
429 delegate,
430 var_kinds: canonical_input.canonical.var_kinds,
431 var_values,
432 current_goal_kind: CurrentGoalKind::from_query_input(cx, input),
433 max_input_universe: canonical_input.canonical.max_universe,
434 initial_opaque_types_storage_num_entries,
435 search_graph,
436 nested_goals: Default::default(),
437 origin_span: I::Span::dummy(),
438 tainted: Ok(()),
439 inspect: proof_tree_builder.new_evaluation_step(var_values),
440 opaque_accesses: AccessedOpaques::default(),
441 };
442
443 let result = f(&mut ecx, input.goal);
444 ecx.inspect.probe_final_state(ecx.delegate, ecx.max_input_universe);
445 proof_tree_builder.finish_evaluation_step(ecx.inspect);
446
447 if canonical_input.typing_mode.0.is_erased_not_coherence() {
448 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());
449 }
450
451 delegate.reset_opaque_types();
457
458 let opaque_accesses = ecx.opaque_accesses;
459 (
460 match result {
461 Ok(i) => Ok(i),
462 Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
463 Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
464 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());
466 Err(NoSolution)
467 }
468 },
469 opaque_accesses,
470 )
471 }
472
473 pub(super) fn ignore_candidate_head_usages(&mut self, usages: CandidateHeadUsages) {
474 self.search_graph.ignore_candidate_head_usages(usages);
475 }
476
477 fn evaluate_goal(
480 &mut self,
481 source: GoalSource,
482 goal: Goal<I, I::Predicate>,
483 stalled_on: Option<GoalStalledOn<I>>,
484 ) -> Result<GoalEvaluation<I>, NoSolutionOrRerunNonErased> {
485 let (normalization_nested_goals, goal_evaluation) =
486 self.evaluate_goal_raw(source, goal, stalled_on)?;
487 if !normalization_nested_goals.is_empty() {
::core::panicking::panic("assertion failed: normalization_nested_goals.is_empty()")
};assert!(normalization_nested_goals.is_empty());
488 Ok(goal_evaluation)
489 }
490
491 fn rerunning_stalled_goal_may_make_progress(
497 &self,
498 stalled_on: Option<&GoalStalledOn<I>>,
499 ) -> RerunStalled {
500 use RerunStalled::*;
501
502 if self.delegate.disable_trait_solver_fast_paths() {
504 return MayMakeProgress;
505 }
506
507 let Some(&GoalStalledOn {
509 num_opaques,
510 ref stalled_vars,
511 ref sub_roots,
512 stalled_certainty,
513 ref previously_succeeded_in_erased,
514 }) = stalled_on
515 else {
516 return MayMakeProgress;
517 };
518
519 if stalled_vars.iter().any(|value| self.delegate.is_changed_arg(*value)) {
522 return MayMakeProgress;
523 }
524
525 if sub_roots.iter().any(|&vid| self.delegate.sub_unification_table_root_var(vid) != vid) {
528 return MayMakeProgress;
529 }
530
531 if self.delegate.opaque_types_storage_num_entries().needs_reevaluation(num_opaques) {
534 let mut previous_erased_run_is_still_valid = false;
539
540 if let &SucceededInErased::Yes { accessed_opaques } = previously_succeeded_in_erased {
541 match self.should_rerun_after_erased_canonicalization(
542 accessed_opaques,
543 self.typing_mode(),
544 &self.delegate.clone_opaque_types_lookup_table(),
545 ) {
546 RerunDecision::Yes => {}
547 RerunDecision::EagerlyPropagateToParent => {
548 {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("we never retry stalled queries if the parent was erased")));
}unreachable!("we never retry stalled queries if the parent was erased")
549 }
550 RerunDecision::No => {
551 previous_erased_run_is_still_valid = true;
552 }
553 }
554 }
555
556 if !previous_erased_run_is_still_valid {
557 return MayMakeProgress;
558 }
559 }
560
561 WontMakeProgress(stalled_certainty)
564 }
565
566 pub(super) fn evaluate_goal_raw(
574 &mut self,
575 source: GoalSource,
576 goal: Goal<I, I::Predicate>,
577 stalled_on: Option<GoalStalledOn<I>>,
578 ) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> {
579 if let RerunStalled::WontMakeProgress(stalled_certainty) =
580 self.rerunning_stalled_goal_may_make_progress(stalled_on.as_ref())
581 {
582 return Ok((
583 NestedNormalizationGoals::empty(),
584 GoalEvaluation {
585 goal,
586 certainty: stalled_certainty,
587 has_changed: HasChanged::No,
588 stalled_on,
589 },
590 ));
591 }
592
593 self.evaluate_goal_cold(source, goal)
594 }
595
596 #[cold]
597 #[inline(never)]
598 pub(super) fn evaluate_goal_cold(
599 &mut self,
600 source: GoalSource,
601 goal: Goal<I, I::Predicate>,
602 ) -> Result<(NestedNormalizationGoals<I>, GoalEvaluation<I>), NoSolutionOrRerunNonErased> {
603 let opaque_types = self.delegate.clone_opaque_types_lookup_table();
607 let (goal, opaque_types) = eager_resolve_vars(self.delegate, (goal, opaque_types));
608 let typing_mode = self.typing_mode();
609 let step_kind = self.step_kind_for_source(source);
610
611 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(611u32),
::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!(
612 Level::DEBUG,
613 "evaluate_goal_raw in typing mode",
614 "{:?} opaques={:?}",
615 typing_mode,
616 opaque_types
617 )
618 .entered();
619
620 let (result, orig_values, canonical_goal, succeeded_in_erased) = 'retry_canonicalize: {
621 let skip_erased_attempt = if typing_mode.is_coherence() {
622 true
623 } else {
624 let mut skip = false;
625 if opaque_types.iter().any(|(_, ty)| ty.is_ty_var())
626 && let PredicateKind::Clause(ClauseKind::Trait(..)) =
627 goal.predicate.kind().skip_binder()
628 {
629 skip = true;
630 }
631
632 if let PredicateKind::Clause(ClauseKind::Trait(tr)) =
633 goal.predicate.kind().skip_binder()
634 && tr.self_ty().has_coroutines()
635 && self.cx().trait_is_auto(tr.trait_ref.def_id)
636 {
637 }
641
642 skip
643 };
644
645 if skip_erased_attempt {
646 if typing_mode.is_erased_not_coherence() {
647 match self.opaque_accesses.rerun_always(RerunReason::SkipErasedAttempt)? {}
648 } else {
649 {
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:649",
"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(649u32),
::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");
650 }
651 } else {
652 {
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:652",
"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(652u32),
::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:?}");
653
654 let (orig_values, canonical_goal) = canonicalize_goal(
655 self.delegate,
656 goal,
657 &[],
658 TypingMode::ErasedNotCoherence(MayBeErased),
659 );
660
661 let (canonical_result, accessed_opaques) = self.search_graph.evaluate_goal(
662 self.cx(),
663 canonical_goal,
664 step_kind,
665 &mut inspect::ProofTreeBuilder::new_noop(),
666 );
667
668 let should_rerun = self.should_rerun_after_erased_canonicalization(
669 accessed_opaques,
670 self.typing_mode(),
671 &opaque_types,
672 );
673 match should_rerun {
674 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:674",
"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(674u32),
::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"),
675 RerunDecision::No => {
676 break 'retry_canonicalize (
677 canonical_result,
678 orig_values,
679 canonical_goal,
680 SucceededInErased::Yes { accessed_opaques },
681 );
682 }
683 RerunDecision::EagerlyPropagateToParent => {
684 self.opaque_accesses.update(accessed_opaques)?;
685 break 'retry_canonicalize (
686 canonical_result,
687 orig_values,
688 canonical_goal,
689 SucceededInErased::No,
692 );
693 }
694 }
695 }
696
697 let (orig_values, canonical_goal) =
698 canonicalize_goal(self.delegate, goal, &opaque_types, typing_mode);
699
700 let (canonical_result, accessed_opaques) = self.search_graph.evaluate_goal(
701 self.cx(),
702 canonical_goal,
703 step_kind,
704 &mut inspect::ProofTreeBuilder::new_noop(),
705 );
706 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!(
707 !accessed_opaques.might_rerun(),
708 "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:?}"
709 );
710
711 (canonical_result, orig_values, canonical_goal, SucceededInErased::No)
712 };
713
714 {
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:714",
"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(714u32),
::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);
715 let response = match result {
716 Ok(response) => {
717 {
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:717",
"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(717u32),
::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");
718 response
719 }
720 Err(NoSolution) => {
721 {
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:721",
"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(721u32),
::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");
722 return Err(NoSolution.into());
723 }
724 };
725
726 drop(tracing_span);
727
728 let has_changed =
729 if !has_only_region_constraints(response) { HasChanged::Yes } else { HasChanged::No };
730
731 let vis = match goal.predicate.kind().skip_binder() {
738 ty::PredicateKind::Clause(_)
739 | ty::PredicateKind::DynCompatible(_)
740 | ty::PredicateKind::Subtype(_)
741 | ty::PredicateKind::Coerce(_)
742 | ty::PredicateKind::ConstEquate(_, _)
743 | ty::PredicateKind::Ambiguous
744 | ty::PredicateKind::NormalizesTo(_) => VisibleForLeakCheck::No,
745 ty::PredicateKind::AliasRelate(_, _, _) => VisibleForLeakCheck::Yes,
746 };
747
748 let (normalization_nested_goals, certainty) = instantiate_and_apply_query_response(
749 self.delegate,
750 goal.param_env,
751 &orig_values,
752 response,
753 vis,
754 self.origin_span,
755 );
756
757 let stalled_on = match certainty {
768 Certainty::Yes => None,
769 Certainty::Maybe { .. } => match has_changed {
770 HasChanged::Yes => None,
775 HasChanged::No => {
776 let mut sub_roots = Vec::new();
778 let mut stalled_vars = orig_values;
779 stalled_vars.retain(|arg| match arg.kind() {
780 ty::GenericArgKind::Lifetime(_) => false,
782 ty::GenericArgKind::Type(ty) => match ty.kind() {
783 ty::Infer(ty::TyVar(vid)) => {
784 sub_roots.push(self.delegate.sub_unification_table_root_var(vid));
785 true
786 }
787 ty::Infer(_) => true,
788 ty::Param(_) | ty::Placeholder(_) => false,
789 _ => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("unexpected orig_value: {0:?}", ty)));
}unreachable!("unexpected orig_value: {ty:?}"),
790 },
791 ty::GenericArgKind::Const(ct) => match ct.kind() {
792 ty::ConstKind::Infer(_) => true,
793 ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => false,
794 _ => {
::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
format_args!("unexpected orig_value: {0:?}", ct)));
}unreachable!("unexpected orig_value: {ct:?}"),
795 },
796 });
797
798 Some(GoalStalledOn {
799 num_opaques: canonical_goal
800 .canonical
801 .value
802 .predefined_opaques_in_body
803 .len(),
804 stalled_vars,
805 sub_roots,
806 stalled_certainty: certainty,
807 previously_succeeded_in_erased: succeeded_in_erased,
808 })
809 }
810 },
811 };
812
813 Ok((
814 normalization_nested_goals,
815 GoalEvaluation { goal, certainty, has_changed, stalled_on },
816 ))
817 }
818
819 fn should_rerun_after_erased_canonicalization(
820 &self,
821 AccessedOpaques { reason: _, rerun }: AccessedOpaques<I>,
822 original_typing_mode: TypingMode<I>,
823 parent_opaque_types: &[(OpaqueTypeKey<I>, I::Ty)],
824 ) -> RerunDecision {
825 let parent_opaque_defids = parent_opaque_types.iter().map(|(key, _)| key.def_id.into());
826 let opaque_in_storage = |opaques: I::LocalDefIds, defids: SmallCopyList<_>| {
827 if defids.as_ref().is_empty() {
828 RerunDecision::No
829 } else if opaques
830 .iter()
831 .chain(parent_opaque_defids)
832 .any(|opaque| defids.as_ref().contains(&opaque))
833 {
834 RerunDecision::Yes
835 } else {
836 RerunDecision::No
837 }
838 };
839 let any_opaque_has_infer_as_hidden = || {
840 if parent_opaque_types.iter().any(|(_, ty)| ty.is_ty_var()) {
841 RerunDecision::Yes
842 } else {
843 RerunDecision::No
844 }
845 };
846
847 let res = match (rerun, original_typing_mode) {
848 (RerunCondition::Never, _) => RerunDecision::No,
850 (_, TypingMode::ErasedNotCoherence(MayBeErased)) => {
852 RerunDecision::EagerlyPropagateToParent
853 }
854 (_, TypingMode::Coherence) => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
858 (RerunCondition::Always, _) => RerunDecision::Yes,
860 (
862 RerunCondition::OpaqueInStorage(..),
863 TypingMode::PostAnalysis | TypingMode::Codegen,
864 ) => RerunDecision::Yes,
865 (
866 RerunCondition::OpaqueInStorage(defids),
867 TypingMode::PostBorrowck { defined_opaque_types: opaques }
868 | TypingMode::Typeck { defining_opaque_types_and_generators: opaques }
869 | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
870 ) => opaque_in_storage(opaques, defids),
871 (RerunCondition::AnyOpaqueHasInferAsHidden, TypingMode::Typeck { .. }) => {
873 any_opaque_has_infer_as_hidden()
874 }
875 (
876 RerunCondition::AnyOpaqueHasInferAsHidden,
877 TypingMode::PostBorrowck { .. }
878 | TypingMode::PostAnalysis
879 | TypingMode::Codegen
880 | TypingMode::PostTypeckUntilBorrowck { .. },
881 ) => RerunDecision::No,
882 (
884 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_),
885 TypingMode::PostAnalysis | TypingMode::Codegen,
886 ) => RerunDecision::No,
887 (
888 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
889 TypingMode::Typeck { defining_opaque_types_and_generators: opaques },
890 ) => {
891 if let RerunDecision::Yes = any_opaque_has_infer_as_hidden() {
892 RerunDecision::Yes
893 } else if let RerunDecision::Yes = opaque_in_storage(opaques, defids) {
894 RerunDecision::Yes
895 } else {
896 RerunDecision::No
897 }
898 }
899 (
900 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
901 TypingMode::PostBorrowck { defined_opaque_types: opaques }
902 | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
903 ) => opaque_in_storage(opaques, defids),
904 };
905
906 {
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:906",
"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(906u32),
::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!(
907 "checking whether to rerun {rerun:?} in outer typing mode {original_typing_mode:?} and opaques {parent_opaque_types:?}: {res:?}"
908 );
909
910 res
911 }
912
913 pub(super) fn compute_goal(
914 &mut self,
915 goal: Goal<I, I::Predicate>,
916 ) -> QueryResultOrRerunNonErased<I> {
917 let Goal { param_env, predicate } = goal;
918 let kind = predicate.kind();
919 self.enter_forall_with_assumptions(kind, param_env, |ecx, kind| {
920 Ok(match kind {
921 ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
922 ecx.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r)?
923 }
924 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
925 ecx.compute_host_effect_goal(Goal { param_env, predicate })?
926 }
927 ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => {
928 ecx.compute_projection_goal(Goal { param_env, predicate })?
929 }
930 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => {
931 ecx.compute_type_outlives_goal(Goal { param_env, predicate })?
932 }
933 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => {
934 ecx.compute_region_outlives_goal(Goal { param_env, predicate })?
935 }
936 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
937 ecx.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })?
938 }
939 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
940 ecx.compute_unstable_feature_goal(param_env, symbol)?
941 }
942 ty::PredicateKind::Subtype(predicate) => {
943 ecx.compute_subtype_goal(Goal { param_env, predicate })?
944 }
945 ty::PredicateKind::Coerce(predicate) => {
946 ecx.compute_coerce_goal(Goal { param_env, predicate })?
947 }
948 ty::PredicateKind::DynCompatible(trait_def_id) => {
949 ecx.compute_dyn_compatible_goal(trait_def_id)?
950 }
951 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
952 ecx.compute_well_formed_goal(Goal { param_env, predicate: term })?
953 }
954 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => {
955 ecx.compute_const_evaluatable_goal(Goal { param_env, predicate: ct })?
956 }
957 ty::PredicateKind::ConstEquate(_, _) => {
958 {
::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")
959 }
960 ty::PredicateKind::NormalizesTo(predicate) => {
961 ecx.compute_normalizes_to_goal(Goal { param_env, predicate })?
962 }
963 ty::PredicateKind::AliasRelate(lhs, rhs, direction) => ecx
964 .compute_alias_relate_goal(Goal {
965 param_env,
966 predicate: (lhs, rhs, direction),
967 })?,
968 ty::PredicateKind::Ambiguous => {
969 ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)?
970 }
971 })
972 })
973 }
974
975 #[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(977u32),
::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:992",
"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(992u32),
::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))]
978 pub(super) fn try_evaluate_added_goals(
979 &mut self,
980 ) -> Result<Certainty, NoSolutionOrRerunNonErased> {
981 for _ in 0..FIXPOINT_STEP_LIMIT {
982 match self.evaluate_added_goals_step().map_err_to_rerun()? {
983 Ok(None) => {}
984 Ok(Some(cert)) => return Ok(cert),
985 Err(NoSolution) => {
986 self.tainted = Err(NoSolution);
987 return Err(NoSolution.into());
988 }
989 }
990 }
991
992 debug!("try_evaluate_added_goals: encountered overflow");
993 Ok(Certainty::overflow(false))
994 }
995
996 fn evaluate_added_goals_step(
1000 &mut self,
1001 ) -> Result<Option<Certainty>, NoSolutionOrRerunNonErased> {
1002 let mut unchanged_certainty = Some(Certainty::Yes);
1004 for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) {
1005 if true {
if !!#[allow(non_exhaustive_omitted_patterns)] match goal.predicate.kind().skip_binder()
{
PredicateKind::NormalizesTo(_) => true,
_ => false,
} {
::core::panicking::panic("assertion failed: !matches!(goal.predicate.kind().skip_binder(), PredicateKind::NormalizesTo(_))")
};
};debug_assert!(!matches!(
1007 goal.predicate.kind().skip_binder(),
1008 PredicateKind::NormalizesTo(_)
1009 ));
1010
1011 if !self.delegate.disable_trait_solver_fast_paths()
1012 && let Some(certainty) =
1013 self.delegate.compute_goal_fast_path(goal, self.origin_span)
1014 {
1015 match certainty {
1016 Certainty::Yes => {}
1017 Certainty::Maybe { .. } => {
1018 self.nested_goals.push((source, goal, None));
1019 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1020 }
1021 }
1022 continue;
1023 }
1024
1025 let GoalEvaluation { goal, certainty, has_changed, stalled_on } =
1026 self.evaluate_goal(source, goal, stalled_on)?;
1027 if has_changed == HasChanged::Yes {
1028 unchanged_certainty = None;
1029 }
1030
1031 match certainty {
1032 Certainty::Yes => {}
1033 Certainty::Maybe { .. } => {
1034 self.nested_goals.push((source, goal, stalled_on));
1035 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1036 }
1037 }
1038 }
1039
1040 Ok(unchanged_certainty)
1041 }
1042
1043 pub(crate) fn record_impl_args(&mut self, impl_args: I::GenericArgs) {
1045 self.inspect.record_impl_args(self.delegate, self.max_input_universe, impl_args)
1046 }
1047
1048 pub(super) fn cx(&self) -> I {
1049 self.delegate.cx()
1050 }
1051
1052 pub(super) fn add_goal(&mut self, source: GoalSource, mut goal: Goal<I, I::Predicate>) {
1053 goal.predicate = self.replace_alias_with_infer(goal.predicate, source, goal.param_env);
1054 self.add_goal_raw(source, goal);
1055 }
1056
1057 #[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_raw",
"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(1057u32),
::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;
}
{
self.inspect.add_goal(self.delegate, self.max_input_universe,
source, goal);
self.nested_goals.push((source, goal, None));
}
}
}#[instrument(level = "debug", skip(self))]
1058 fn add_goal_raw(&mut self, source: GoalSource, goal: Goal<I, I::Predicate>) {
1059 self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1060 self.nested_goals.push((source, goal, None));
1061 }
1062
1063 #[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(1063u32),
::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))]
1064 pub(super) fn add_goals(
1065 &mut self,
1066 source: GoalSource,
1067 goals: impl IntoIterator<Item = Goal<I, I::Predicate>>,
1068 ) {
1069 for goal in goals {
1070 self.add_goal(source, goal);
1071 }
1072 }
1073
1074 pub(super) fn replace_alias_with_infer<T: TypeFoldable<I>>(
1075 &mut self,
1076 value: T,
1077 source: GoalSource,
1078 param_env: I::ParamEnv,
1079 ) -> T {
1080 value.fold_with(&mut ReplaceAliasWithInfer::new(self, source, param_env))
1081 }
1082
1083 pub(super) fn next_region_var(&mut self) -> I::Region {
1084 let region = self.delegate.next_region_infer();
1085 self.inspect.add_var_value(region);
1086 region
1087 }
1088
1089 pub(super) fn next_ty_infer(&mut self) -> I::Ty {
1090 let ty = self.delegate.next_ty_infer();
1091 self.inspect.add_var_value(ty);
1092 ty
1093 }
1094
1095 pub(super) fn next_const_infer(&mut self) -> I::Const {
1096 let ct = self.delegate.next_const_infer();
1097 self.inspect.add_var_value(ct);
1098 ct
1099 }
1100
1101 pub(super) fn next_term_infer_of_kind(&mut self, term: I::Term) -> I::Term {
1104 match term.kind() {
1105 ty::TermKind::Ty(_) => self.next_ty_infer().into(),
1106 ty::TermKind::Const(_) => self.next_const_infer().into(),
1107 }
1108 }
1109
1110 x;#[instrument(level = "trace", skip(self), ret)]
1115 pub(super) fn term_is_fully_unconstrained(&self, goal: Goal<I, ty::NormalizesTo<I>>) -> bool {
1116 let universe_of_term = match goal.predicate.term.kind() {
1117 ty::TermKind::Ty(ty) => {
1118 if let ty::Infer(ty::TyVar(vid)) = ty.kind() {
1119 self.delegate.universe_of_ty(vid).unwrap()
1120 } else {
1121 return false;
1122 }
1123 }
1124 ty::TermKind::Const(ct) => {
1125 if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = ct.kind() {
1126 self.delegate.universe_of_ct(vid).unwrap()
1127 } else {
1128 return false;
1129 }
1130 }
1131 };
1132
1133 struct ContainsTermOrNotNameable<'a, D: SolverDelegate<Interner = I>, I: Interner> {
1134 term: I::Term,
1135 universe_of_term: ty::UniverseIndex,
1136 delegate: &'a D,
1137 cache: HashSet<I::Ty>,
1138 }
1139
1140 impl<D: SolverDelegate<Interner = I>, I: Interner> ContainsTermOrNotNameable<'_, D, I> {
1141 fn check_nameable(&self, universe: ty::UniverseIndex) -> ControlFlow<()> {
1142 if self.universe_of_term.can_name(universe) {
1143 ControlFlow::Continue(())
1144 } else {
1145 ControlFlow::Break(())
1146 }
1147 }
1148 }
1149
1150 impl<D: SolverDelegate<Interner = I>, I: Interner> TypeVisitor<I>
1151 for ContainsTermOrNotNameable<'_, D, I>
1152 {
1153 type Result = ControlFlow<()>;
1154 fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
1155 if self.cache.contains(&t) {
1156 return ControlFlow::Continue(());
1157 }
1158
1159 match t.kind() {
1160 ty::Infer(ty::TyVar(vid)) => {
1161 if let ty::TermKind::Ty(term) = self.term.kind()
1162 && let ty::Infer(ty::TyVar(term_vid)) = term.kind()
1163 && self.delegate.root_ty_var(vid) == self.delegate.root_ty_var(term_vid)
1164 {
1165 return ControlFlow::Break(());
1166 }
1167
1168 self.check_nameable(self.delegate.universe_of_ty(vid).unwrap())?;
1169 }
1170 ty::Placeholder(p) => self.check_nameable(p.universe())?,
1171 _ => {
1172 if t.has_non_region_infer() || t.has_placeholders() {
1173 t.super_visit_with(self)?
1174 }
1175 }
1176 }
1177
1178 assert!(self.cache.insert(t));
1179 ControlFlow::Continue(())
1180 }
1181
1182 fn visit_const(&mut self, c: I::Const) -> Self::Result {
1183 match c.kind() {
1184 ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
1185 if let ty::TermKind::Const(term) = self.term.kind()
1186 && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
1187 && self.delegate.root_const_var(vid)
1188 == self.delegate.root_const_var(term_vid)
1189 {
1190 return ControlFlow::Break(());
1191 }
1192
1193 self.check_nameable(self.delegate.universe_of_ct(vid).unwrap())
1194 }
1195 ty::ConstKind::Placeholder(p) => self.check_nameable(p.universe()),
1196 _ => {
1197 if c.has_non_region_infer() || c.has_placeholders() {
1198 c.super_visit_with(self)
1199 } else {
1200 ControlFlow::Continue(())
1201 }
1202 }
1203 }
1204 }
1205
1206 fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result {
1207 if p.has_non_region_infer() || p.has_placeholders() {
1208 p.super_visit_with(self)
1209 } else {
1210 ControlFlow::Continue(())
1211 }
1212 }
1213
1214 fn visit_clauses(&mut self, c: I::Clauses) -> Self::Result {
1215 if c.has_non_region_infer() || c.has_placeholders() {
1216 c.super_visit_with(self)
1217 } else {
1218 ControlFlow::Continue(())
1219 }
1220 }
1221 }
1222
1223 let mut visitor = ContainsTermOrNotNameable {
1224 delegate: self.delegate,
1225 universe_of_term,
1226 term: goal.predicate.term,
1227 cache: Default::default(),
1228 };
1229 goal.predicate.alias.visit_with(&mut visitor).is_continue()
1230 && goal.param_env.visit_with(&mut visitor).is_continue()
1231 }
1232
1233 pub(super) fn sub_unify_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
1234 self.delegate.sub_unify_ty_vids_raw(a, b)
1235 }
1236
1237 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1238 pub(super) fn eq<T: Relate<I>>(
1239 &mut self,
1240 param_env: I::ParamEnv,
1241 lhs: T,
1242 rhs: T,
1243 ) -> Result<(), NoSolution> {
1244 self.relate(param_env, lhs, ty::Variance::Invariant, rhs)
1245 }
1246
1247 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1253 pub(super) fn relate_rigid_alias_non_alias(
1254 &mut self,
1255 param_env: I::ParamEnv,
1256 alias: ty::AliasTerm<I>,
1257 variance: ty::Variance,
1258 term: I::Term,
1259 ) -> Result<(), NoSolution> {
1260 if term.is_infer() {
1263 let cx = self.cx();
1264 let def_id = match alias.kind {
1273 ty::AliasTermKind::ProjectionTy { def_id } => def_id.into(),
1274 ty::AliasTermKind::InherentTy { def_id } => def_id.into(),
1275 ty::AliasTermKind::OpaqueTy { def_id } => def_id.into(),
1276 ty::AliasTermKind::FreeTy { def_id } => def_id.into(),
1277 ty::AliasTermKind::AnonConst { def_id } => def_id.into(),
1278 ty::AliasTermKind::ProjectionConst { def_id } => def_id.into(),
1279 ty::AliasTermKind::FreeConst { def_id } => def_id.into(),
1280 ty::AliasTermKind::InherentConst { def_id } => def_id.into(),
1281 };
1282 let identity_args = self.fresh_args_for_item(def_id);
1283 let rigid_ctor = alias.with_args(cx, identity_args);
1284 let ctor_term = rigid_ctor.to_term(cx);
1285 let obligations = self.delegate.eq_structurally_relating_aliases(
1286 param_env,
1287 term,
1288 ctor_term,
1289 self.origin_span,
1290 )?;
1291 debug_assert!(obligations.is_empty());
1292 self.relate(param_env, alias, variance, rigid_ctor)
1293 } else {
1294 Err(NoSolution)
1295 }
1296 }
1297
1298 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1302 pub(super) fn eq_structurally_relating_aliases<T: Relate<I>>(
1303 &mut self,
1304 param_env: I::ParamEnv,
1305 lhs: T,
1306 rhs: T,
1307 ) -> Result<(), NoSolution> {
1308 let result = self.delegate.eq_structurally_relating_aliases(
1309 param_env,
1310 lhs,
1311 rhs,
1312 self.origin_span,
1313 )?;
1314 assert_eq!(result, vec![]);
1315 Ok(())
1316 }
1317
1318 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1319 pub(super) fn sub<T: Relate<I>>(
1320 &mut self,
1321 param_env: I::ParamEnv,
1322 sub: T,
1323 sup: T,
1324 ) -> Result<(), NoSolution> {
1325 self.relate(param_env, sub, ty::Variance::Covariant, sup)
1326 }
1327
1328 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1329 pub(super) fn relate<T: Relate<I>>(
1330 &mut self,
1331 param_env: I::ParamEnv,
1332 lhs: T,
1333 variance: ty::Variance,
1334 rhs: T,
1335 ) -> Result<(), NoSolution> {
1336 let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
1337 for &goal in goals.iter() {
1338 let source = match goal.predicate.kind().skip_binder() {
1339 ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {
1340 GoalSource::TypeRelating
1341 }
1342 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
1344 p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
1345 };
1346 self.add_goal(source, goal);
1347 }
1348 Ok(())
1349 }
1350
1351 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1357 pub(super) fn eq_and_get_goals<T: Relate<I>>(
1358 &self,
1359 param_env: I::ParamEnv,
1360 lhs: T,
1361 rhs: T,
1362 ) -> Result<Vec<Goal<I, I::Predicate>>, NoSolution> {
1363 Ok(self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs, self.origin_span)?)
1364 }
1365
1366 pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<I> + Copy>(
1367 &self,
1368 value: ty::Binder<I, T>,
1369 ) -> T {
1370 self.delegate.instantiate_binder_with_infer(value)
1371 }
1372
1373 pub(super) fn enter_forall_with_assumptions<T: TypeFoldable<I>, U>(
1381 &mut self,
1382 value: ty::Binder<I, T>,
1383 param_env: I::ParamEnv,
1384 f: impl FnOnce(&mut Self, T) -> U,
1385 ) -> U {
1386 self.delegate.enter_forall_without_assumptions(value, |value| {
1387 let u = self.delegate.universe();
1388 let assumptions = if self.cx().assumptions_on_binders() {
1389 self.region_assumptions_for_placeholders_in_universe(value.clone(), u, param_env)
1390 } else {
1391 None
1392 };
1393 self.delegate.insert_placeholder_assumptions(u, assumptions);
1394 f(self, value)
1395 })
1396 }
1397
1398 pub(super) fn resolve_vars_if_possible<T>(&self, value: T) -> T
1399 where
1400 T: TypeFoldable<I>,
1401 {
1402 self.delegate.resolve_vars_if_possible(value)
1403 }
1404
1405 pub(super) fn shallow_resolve(&self, ty: I::Ty) -> I::Ty {
1406 self.delegate.shallow_resolve(ty)
1407 }
1408
1409 pub(super) fn eager_resolve_region(&self, r: I::Region) -> I::Region {
1410 if let ty::ReVar(vid) = r.kind() {
1411 self.delegate.opportunistic_resolve_lt_var(vid)
1412 } else {
1413 r
1414 }
1415 }
1416
1417 pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs {
1418 let args = self.delegate.fresh_args_for_item(def_id);
1419 for arg in args.iter() {
1420 self.inspect.add_var_value(arg);
1421 }
1422 args
1423 }
1424
1425 pub(super) fn register_solver_region_constraint(&self, c: RegionConstraint<I>) {
1426 self.delegate.register_solver_region_constraint(c);
1427 }
1428
1429 pub(super) fn register_ty_outlives(&self, ty: I::Ty, lt: I::Region) {
1430 self.delegate.register_ty_outlives(ty, lt, self.origin_span);
1431 }
1432
1433 pub(super) fn register_region_outlives(
1434 &self,
1435 a: I::Region,
1436 b: I::Region,
1437 vis: VisibleForLeakCheck,
1438 ) {
1439 self.delegate.sub_regions(b, a, vis, self.origin_span);
1441 }
1442
1443 pub(super) fn well_formed_goals(
1445 &self,
1446 param_env: I::ParamEnv,
1447 term: I::Term,
1448 ) -> Option<Vec<Goal<I, I::Predicate>>> {
1449 self.delegate.well_formed_goals(param_env, term)
1450 }
1451
1452 pub(super) fn trait_ref_is_knowable(
1453 &mut self,
1454 param_env: I::ParamEnv,
1455 trait_ref: ty::TraitRef<I>,
1456 ) -> Result<bool, NoSolutionOrRerunNonErased> {
1457 let delegate = self.delegate;
1458 let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
1459 coherence::trait_ref_is_knowable(&**delegate, trait_ref, lazily_normalize_ty)
1460 .map(|is_knowable| is_knowable.is_ok())
1461 }
1462
1463 pub(super) fn fetch_eligible_assoc_item(
1464 &self,
1465 goal_trait_ref: ty::TraitRef<I>,
1466 trait_assoc_def_id: I::TraitAssocTermId,
1467 impl_def_id: I::ImplId,
1468 ) -> FetchEligibleAssocItemResponse<I> {
1469 self.delegate.fetch_eligible_assoc_item(goal_trait_ref, trait_assoc_def_id, impl_def_id)
1470 }
1471
1472 x;#[instrument(level = "debug", skip(self), ret)]
1473 pub(super) fn register_hidden_type_in_storage(
1474 &mut self,
1475 opaque_type_key: ty::OpaqueTypeKey<I>,
1476 hidden_ty: I::Ty,
1477 ) -> Option<I::Ty> {
1478 self.delegate.register_hidden_type_in_storage(opaque_type_key, hidden_ty, self.origin_span)
1479 }
1480
1481 pub(super) fn add_item_bounds_for_hidden_type(
1482 &mut self,
1483 opaque_def_id: I::OpaqueTyId,
1484 opaque_args: I::GenericArgs,
1485 param_env: I::ParamEnv,
1486 hidden_ty: I::Ty,
1487 ) {
1488 let mut goals = Vec::new();
1489 self.delegate.add_item_bounds_for_hidden_type(
1490 opaque_def_id,
1491 opaque_args,
1492 param_env,
1493 hidden_ty,
1494 &mut goals,
1495 );
1496 self.add_goals(GoalSource::AliasWellFormed, goals);
1497 }
1498
1499 pub(super) fn evaluate_const(
1503 &mut self,
1504 param_env: I::ParamEnv,
1505 uv: ty::UnevaluatedConst<I>,
1506 ) -> Result<Option<I::Const>, RerunNonErased> {
1507 if self.typing_mode().is_erased_not_coherence() {
1508 self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)?;
1509 }
1510
1511 Ok(self.delegate.evaluate_const(param_env, uv))
1512 }
1513
1514 pub(super) fn evaluate_const_and_instantiate_projection_term(
1515 &mut self,
1516 param_env: I::ParamEnv,
1517 projection_term: ty::AliasTerm<I>,
1518 expected_term: I::Term,
1519 uv: ty::UnevaluatedConst<I>,
1520 ) -> QueryResultOrRerunNonErased<I> {
1521 match self.evaluate_const(param_env, uv)? {
1522 Some(evaluated) => {
1523 self.eq(param_env, expected_term, evaluated.into())?;
1524 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1525 }
1526 None if self.cx().features().generic_const_args() => {
1527 if self.resolve_vars_if_possible(uv).has_non_region_infer() {
1535 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1536 } else {
1537 self.relate_rigid_alias_non_alias(
1544 param_env,
1545 projection_term,
1546 ty::Invariant,
1547 expected_term,
1548 )?;
1549 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1550 }
1551 }
1552 None => {
1553 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1555 }
1556 }
1557 }
1558
1559 pub(super) fn is_transmutable(
1560 &mut self,
1561 src: I::Ty,
1562 dst: I::Ty,
1563 assume: I::Const,
1564 ) -> Result<Certainty, NoSolution> {
1565 self.delegate.is_transmutable(dst, src, assume)
1566 }
1567
1568 pub(super) fn replace_bound_vars<T: TypeFoldable<I>>(
1569 &self,
1570 t: T,
1571 universes: &mut Vec<Option<ty::UniverseIndex>>,
1572 ) -> T {
1573 BoundVarReplacer::replace_bound_vars(&**self.delegate, universes, t).0
1574 }
1575
1576 pub(super) fn may_use_unstable_feature(
1577 &mut self,
1578 param_env: I::ParamEnv,
1579 symbol: I::Symbol,
1580 ) -> Result<bool, RerunNonErased> {
1581 if self.typing_mode().is_erased_not_coherence() {
1582 self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)?;
1583 }
1584
1585 Ok(may_use_unstable_feature(&**self.delegate, param_env, symbol))
1586 }
1587
1588 pub(crate) fn opaques_with_sub_unified_hidden_type(
1589 &self,
1590 self_ty: I::Ty,
1591 ) -> Vec<ty::OpaqueAliasTy<I>> {
1592 if let ty::Infer(ty::TyVar(vid)) = self_ty.kind() {
1593 self.delegate.opaques_with_sub_unified_hidden_type(vid)
1594 } else {
1595 ::alloc::vec::Vec::new()vec![]
1596 }
1597 }
1598
1599 x;#[instrument(level = "trace", skip(self), ret)]
1613 pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
1614 &mut self,
1615 shallow_certainty: Certainty,
1616 ) -> QueryResultOrRerunNonErased<I> {
1617 self.inspect.make_canonical_response(shallow_certainty);
1618
1619 let goals_certainty = self.try_evaluate_added_goals()?;
1620 assert_eq!(
1621 self.tainted,
1622 Ok(()),
1623 "EvalCtxt is tainted -- nested goals may have been dropped in a \
1624 previous call to `try_evaluate_added_goals!`"
1625 );
1626
1627 let goals_certainty = match self.delegate.cx().assumptions_on_binders() {
1628 true => {
1629 let certainty = self.eagerly_handle_placeholders()?;
1630 certainty.and(goals_certainty)
1631 }
1632 false => {
1633 self.delegate.leak_check(self.max_input_universe).map_err(|NoSolution| {
1636 trace!("failed the leak check");
1637 NoSolution
1638 })?;
1639
1640 goals_certainty
1641 }
1642 };
1643
1644 let (certainty, normalization_nested_goals) =
1645 match (self.current_goal_kind, shallow_certainty) {
1646 (CurrentGoalKind::ProjectionComputeAssocTermCandidate, Certainty::Yes) => {
1654 let goals = std::mem::take(&mut self.nested_goals);
1655 if goals.is_empty() {
1658 assert!(matches!(goals_certainty, Certainty::Yes));
1659 }
1660 (
1661 Certainty::Yes,
1662 NestedNormalizationGoals(
1663 goals.into_iter().map(|(s, g, _)| (s, g)).collect(),
1664 ),
1665 )
1666 }
1667 _ => {
1668 let certainty = shallow_certainty.and(goals_certainty);
1669 (certainty, NestedNormalizationGoals::empty())
1670 }
1671 };
1672
1673 if let Certainty::Maybe(
1674 maybe_info @ MaybeInfo {
1675 cause: MaybeCause::Overflow { keep_constraints: false, .. },
1676 opaque_types_jank: _,
1677 stalled_on_coroutines: _,
1678 },
1679 ) = certainty
1680 {
1681 return Ok(self.make_ambiguous_response_no_constraints(maybe_info));
1693 }
1694
1695 let external_constraints =
1696 self.compute_external_query_constraints(certainty, normalization_nested_goals);
1697 let (var_values, mut external_constraints) =
1698 eager_resolve_vars(self.delegate, (self.var_values, external_constraints));
1699
1700 let mut unique = HashSet::default();
1702 if let ExternalRegionConstraints::Old(r) = &mut external_constraints.region_constraints {
1703 r.retain(|(outlives, _)| !outlives.is_trivial() && unique.insert(*outlives));
1704 }
1705
1706 let canonical = canonicalize_response(
1707 self.delegate,
1708 self.max_input_universe,
1709 Response {
1710 var_values,
1711 certainty,
1712 external_constraints: self.cx().mk_external_constraints(external_constraints),
1713 },
1714 );
1715
1716 Ok(canonical)
1717 }
1718
1719 pub(in crate::solve) fn make_ambiguous_response_no_constraints(
1724 &self,
1725 maybe: MaybeInfo,
1726 ) -> CanonicalResponse<I> {
1727 response_no_constraints_raw(
1728 self.cx(),
1729 self.max_input_universe,
1730 self.var_kinds,
1731 Certainty::Maybe(maybe),
1732 )
1733 }
1734
1735 x;#[instrument(level = "trace", skip(self), ret)]
1743 fn compute_external_query_constraints(
1744 &self,
1745 certainty: Certainty,
1746 normalization_nested_goals: NestedNormalizationGoals<I>,
1747 ) -> ExternalConstraintsData<I> {
1748 let region_constraints = if self.cx().assumptions_on_binders() {
1757 ExternalRegionConstraints::NextGen(if let Certainty::Yes = certainty {
1758 self.delegate.get_solver_region_constraint()
1759 } else {
1760 RegionConstraint::new_true()
1761 })
1762 } else {
1763 ExternalRegionConstraints::Old(if let Certainty::Yes = certainty {
1764 self.delegate.make_deduplicated_region_constraints()
1765 } else {
1766 vec![]
1767 })
1768 };
1769
1770 let opaque_types = self
1775 .delegate
1776 .clone_opaque_types_added_since(self.initial_opaque_types_storage_num_entries);
1777
1778 if self.typing_mode().is_erased_not_coherence() {
1779 assert!(opaque_types.is_empty());
1780 }
1781
1782 ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
1783 }
1784}
1785
1786struct ReplaceAliasWithInfer<'me, 'a, D, I>
1803where
1804 D: SolverDelegate<Interner = I>,
1805 I: Interner,
1806{
1807 ecx: &'me mut EvalCtxt<'a, D>,
1808 param_env: I::ParamEnv,
1809 normalization_goal_source: GoalSource,
1810 cache: HashMap<I::Ty, I::Ty>,
1811}
1812
1813impl<'me, 'a, D, I> ReplaceAliasWithInfer<'me, 'a, D, I>
1814where
1815 D: SolverDelegate<Interner = I>,
1816 I: Interner,
1817{
1818 fn new(
1819 ecx: &'me mut EvalCtxt<'a, D>,
1820 for_goal_source: GoalSource,
1821 param_env: I::ParamEnv,
1822 ) -> Self {
1823 let step_kind = ecx.step_kind_for_source(for_goal_source);
1824 ReplaceAliasWithInfer {
1825 ecx,
1826 param_env,
1827 normalization_goal_source: GoalSource::NormalizeGoal(step_kind),
1828 cache: Default::default(),
1829 }
1830 }
1831}
1832
1833impl<D, I> TypeFolder<I> for ReplaceAliasWithInfer<'_, '_, D, I>
1834where
1835 D: SolverDelegate<Interner = I>,
1836 I: Interner,
1837{
1838 fn cx(&self) -> I {
1839 self.ecx.cx()
1840 }
1841
1842 fn fold_ty(&mut self, ty: I::Ty) -> I::Ty {
1843 match ty.kind() {
1844 ty::Alias(alias) if !ty.has_escaping_bound_vars() => {
1845 let infer_ty = self.ecx.next_ty_infer();
1846 let projection = ty::ProjectionPredicate {
1847 projection_term: alias.into(),
1848 term: infer_ty.into(),
1849 };
1850 self.ecx.add_goal_raw(
1851 self.normalization_goal_source,
1852 Goal::new(self.cx(), self.param_env, projection),
1853 );
1854 infer_ty
1855 }
1856 _ => {
1857 if !ty.has_aliases() {
1858 ty
1859 } else if let Some(&entry) = self.cache.get(&ty) {
1860 return entry;
1861 } else {
1862 let res = ty.super_fold_with(self);
1863 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());
1864 res
1865 }
1866 }
1867 }
1868 }
1869
1870 fn fold_const(&mut self, ct: I::Const) -> I::Const {
1871 match ct.kind() {
1872 ty::ConstKind::Unevaluated(uv) if !ct.has_escaping_bound_vars() => {
1873 let infer_ct = self.ecx.next_const_infer();
1874 let projection =
1875 ty::ProjectionPredicate { projection_term: uv.into(), term: infer_ct.into() };
1876 self.ecx.add_goal_raw(
1877 self.normalization_goal_source,
1878 Goal::new(self.cx(), self.param_env, projection),
1879 );
1880 infer_ct
1881 }
1882 _ => ct.super_fold_with(self),
1883 }
1884 }
1885
1886 fn fold_predicate(&mut self, predicate: I::Predicate) -> I::Predicate {
1887 if predicate.allow_normalization() { predicate.super_fold_with(self) } else { predicate }
1888 }
1889}
1890
1891pub fn evaluate_root_goal_for_proof_tree_raw_provider<
1893 D: SolverDelegate<Interner = I>,
1894 I: Interner,
1895>(
1896 cx: I,
1897 canonical_goal: CanonicalInput<I>,
1898) -> (QueryResult<I>, I::Probe) {
1899 let mut inspect = inspect::ProofTreeBuilder::new();
1900 let (canonical_result, accessed_opaques) = SearchGraph::<D>::evaluate_root_goal_for_proof_tree(
1901 cx,
1902 cx.recursion_limit(),
1903 canonical_goal,
1904 &mut inspect,
1905 );
1906 let final_revision = inspect.unwrap();
1907
1908 if !!accessed_opaques.might_rerun() {
::core::panicking::panic("assertion failed: !accessed_opaques.might_rerun()")
};assert!(!accessed_opaques.might_rerun());
1909 (canonical_result, cx.mk_probe(final_revision))
1910}
1911
1912pub(super) fn evaluate_root_goal_for_proof_tree<D: SolverDelegate<Interner = I>, I: Interner>(
1917 delegate: &D,
1918 goal: Goal<I, I::Predicate>,
1919 origin_span: I::Span,
1920) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
1921 let opaque_types = delegate.clone_opaque_types_lookup_table();
1922 let (goal, opaque_types) = eager_resolve_vars(delegate, (goal, opaque_types));
1923 let typing_mode = delegate.typing_mode_raw().assert_not_erased();
1924
1925 let (orig_values, canonical_goal) =
1926 canonicalize_goal(delegate, goal, &opaque_types, typing_mode.into());
1927
1928 let (canonical_result, final_revision) =
1929 delegate.cx().evaluate_root_goal_for_proof_tree_raw(canonical_goal);
1930
1931 let proof_tree = inspect::GoalEvaluation {
1932 uncanonicalized_goal: goal,
1933 orig_values,
1934 final_revision,
1935 result: canonical_result,
1936 };
1937
1938 let response = match canonical_result {
1939 Err(e) => return (Err(e), proof_tree),
1940 Ok(response) => response,
1941 };
1942
1943 let (normalization_nested_goals, _certainty) = instantiate_and_apply_query_response(
1944 delegate,
1945 goal.param_env,
1946 &proof_tree.orig_values,
1947 response,
1948 VisibleForLeakCheck::Yes,
1949 origin_span,
1950 );
1951
1952 (Ok(normalization_nested_goals), proof_tree)
1953}