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 (
775 RerunCondition::OpaqueInStorage(..),
776 TypingMode::PostAnalysis | TypingMode::Codegen,
777 ) => RerunDecision::Yes,
778 (
779 RerunCondition::OpaqueInStorage(defids),
780 TypingMode::PostBorrowck { defined_opaque_types: opaques }
781 | TypingMode::Typeck { defining_opaque_types_and_generators: opaques }
782 | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
783 ) => opaque_in_storage(opaques, defids),
784 (RerunCondition::AnyOpaqueHasInferAsHidden, TypingMode::Typeck { .. }) => {
786 any_opaque_has_infer_as_hidden()
787 }
788 (
789 RerunCondition::AnyOpaqueHasInferAsHidden,
790 TypingMode::PostBorrowck { .. }
791 | TypingMode::PostAnalysis
792 | TypingMode::Codegen
793 | TypingMode::PostTypeckUntilBorrowck { .. },
794 ) => RerunDecision::No,
795 (
797 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(_),
798 TypingMode::PostAnalysis | TypingMode::Codegen,
799 ) => RerunDecision::No,
800 (
801 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
802 TypingMode::Typeck { defining_opaque_types_and_generators: opaques },
803 ) => {
804 if let RerunDecision::Yes = any_opaque_has_infer_as_hidden() {
805 RerunDecision::Yes
806 } else if let RerunDecision::Yes = opaque_in_storage(opaques, defids) {
807 RerunDecision::Yes
808 } else {
809 RerunDecision::No
810 }
811 }
812 (
813 RerunCondition::OpaqueInStorageOrAnyOpaqueHasInferAsHidden(defids),
814 TypingMode::PostBorrowck { defined_opaque_types: opaques }
815 | TypingMode::PostTypeckUntilBorrowck { defining_opaque_types: opaques },
816 ) => opaque_in_storage(opaques, defids),
817 };
818
819 {
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:819",
"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(819u32),
::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!(
820 "checking whether to rerun {rerun:?} in outer typing mode {original_typing_mode:?} and opaques {parent_opaque_types:?}: {res:?}"
821 );
822
823 res
824 }
825
826 pub(super) fn compute_goal(
827 &mut self,
828 goal: Goal<I, I::Predicate>,
829 ) -> QueryResultOrRerunNonErased<I> {
830 let Goal { param_env, predicate } = goal;
831 let kind = predicate.kind();
832 self.enter_forall_with_assumptions(kind, param_env, |ecx, kind| {
833 Ok(match kind {
834 ty::PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
835 ecx.compute_trait_goal(Goal { param_env, predicate }).map(|(r, _via)| r)?
836 }
837 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => {
838 ecx.compute_host_effect_goal(Goal { param_env, predicate })?
839 }
840 ty::PredicateKind::Clause(ty::ClauseKind::Projection(predicate)) => {
841 ecx.compute_projection_goal(Goal { param_env, predicate })?
842 }
843 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(predicate)) => {
844 ecx.compute_type_outlives_goal(Goal { param_env, predicate })?
845 }
846 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(predicate)) => {
847 ecx.compute_region_outlives_goal(Goal { param_env, predicate })?
848 }
849 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
850 ecx.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })?
851 }
852 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
853 ecx.compute_unstable_feature_goal(param_env, symbol)?
854 }
855 ty::PredicateKind::Subtype(predicate) => {
856 ecx.compute_subtype_goal(Goal { param_env, predicate })?
857 }
858 ty::PredicateKind::Coerce(predicate) => {
859 ecx.compute_coerce_goal(Goal { param_env, predicate })?
860 }
861 ty::PredicateKind::DynCompatible(trait_def_id) => {
862 ecx.compute_dyn_compatible_goal(trait_def_id)?
863 }
864 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
865 ecx.compute_well_formed_goal(Goal { param_env, predicate: term })?
866 }
867 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(ct)) => {
868 ecx.compute_const_evaluatable_goal(Goal { param_env, predicate: ct })?
869 }
870 ty::PredicateKind::ConstEquate(_, _) => {
871 {
::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")
872 }
873 ty::PredicateKind::NormalizesTo(predicate) => {
874 ecx.compute_normalizes_to_goal(Goal { param_env, predicate })?
875 }
876 ty::PredicateKind::AliasRelate(lhs, rhs, direction) => ecx
877 .compute_alias_relate_goal(Goal {
878 param_env,
879 predicate: (lhs, rhs, direction),
880 })?,
881 ty::PredicateKind::Ambiguous => {
882 ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)?
883 }
884 })
885 })
886 }
887
888 #[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(890u32),
::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:905",
"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(905u32),
::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))]
891 pub(super) fn try_evaluate_added_goals(
892 &mut self,
893 ) -> Result<Certainty, NoSolutionOrRerunNonErased> {
894 for _ in 0..FIXPOINT_STEP_LIMIT {
895 match self.evaluate_added_goals_step().map_err_to_rerun()? {
896 Ok(None) => {}
897 Ok(Some(cert)) => return Ok(cert),
898 Err(NoSolution) => {
899 self.tainted = Err(NoSolution);
900 return Err(NoSolution.into());
901 }
902 }
903 }
904
905 debug!("try_evaluate_added_goals: encountered overflow");
906 Ok(Certainty::overflow(false))
907 }
908
909 fn evaluate_added_goals_step(
913 &mut self,
914 ) -> Result<Option<Certainty>, NoSolutionOrRerunNonErased> {
915 let cx = self.cx();
916 let mut unchanged_certainty = Some(Certainty::Yes);
918 for (source, goal, stalled_on) in mem::take(&mut self.nested_goals) {
919 if !self.delegate.disable_trait_solver_fast_paths()
920 && let Some(certainty) =
921 self.delegate.compute_goal_fast_path(goal, self.origin_span)
922 {
923 match certainty {
924 Certainty::Yes => {}
925 Certainty::Maybe { .. } => {
926 self.nested_goals.push((source, goal, None));
927 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
928 }
929 }
930 continue;
931 }
932
933 if let Some(pred) = goal.predicate.as_normalizes_to() {
944 let pred = pred.no_bound_vars().unwrap();
946 let unconstrained_rhs = self.next_term_infer_of_kind(pred.term);
949 let unconstrained_goal =
950 goal.with(cx, ty::NormalizesTo { alias: pred.alias, term: unconstrained_rhs });
951
952 let (
953 NestedNormalizationGoals(nested_goals),
954 GoalEvaluation { goal, certainty, stalled_on, has_changed: _ },
955 ) = self.evaluate_goal_raw(source, unconstrained_goal, stalled_on)?;
956 {
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:957",
"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(957u32),
::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);
958 self.nested_goals.extend(nested_goals.into_iter().map(|(s, g)| (s, g, None)));
959
960 self.eq_structurally_relating_aliases(
975 goal.param_env,
976 pred.term,
977 unconstrained_rhs,
978 )?;
979
980 let with_resolved_vars = self.resolve_vars_if_possible(goal);
987 if pred.alias
988 != with_resolved_vars
989 .predicate
990 .as_normalizes_to()
991 .unwrap()
992 .no_bound_vars()
993 .unwrap()
994 .alias
995 {
996 unchanged_certainty = None;
997 }
998
999 match certainty {
1000 Certainty::Yes => {}
1001 Certainty::Maybe { .. } => {
1002 self.nested_goals.push((source, with_resolved_vars, stalled_on));
1003 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1004 }
1005 }
1006 } else {
1007 let GoalEvaluation { goal, certainty, has_changed, stalled_on } =
1008 self.evaluate_goal(source, goal, stalled_on)?;
1009 if has_changed == HasChanged::Yes {
1010 unchanged_certainty = None;
1011 }
1012
1013 match certainty {
1014 Certainty::Yes => {}
1015 Certainty::Maybe { .. } => {
1016 self.nested_goals.push((source, goal, stalled_on));
1017 unchanged_certainty = unchanged_certainty.map(|c| c.and(certainty));
1018 }
1019 }
1020 }
1021 }
1022
1023 Ok(unchanged_certainty)
1024 }
1025
1026 pub(crate) fn record_impl_args(&mut self, impl_args: I::GenericArgs) {
1028 self.inspect.record_impl_args(self.delegate, self.max_input_universe, impl_args)
1029 }
1030
1031 pub(super) fn cx(&self) -> I {
1032 self.delegate.cx()
1033 }
1034
1035 #[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(1035u32),
::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))]
1036 pub(super) fn add_goal(&mut self, source: GoalSource, mut goal: Goal<I, I::Predicate>) {
1037 goal.predicate =
1038 goal.predicate.fold_with(&mut ReplaceAliasWithInfer::new(self, source, goal.param_env));
1039 self.inspect.add_goal(self.delegate, self.max_input_universe, source, goal);
1040 self.nested_goals.push((source, goal, None));
1041 }
1042
1043 #[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(1043u32),
::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))]
1044 pub(super) fn add_goals(
1045 &mut self,
1046 source: GoalSource,
1047 goals: impl IntoIterator<Item = Goal<I, I::Predicate>>,
1048 ) {
1049 for goal in goals {
1050 self.add_goal(source, goal);
1051 }
1052 }
1053
1054 pub(super) fn next_region_var(&mut self) -> I::Region {
1055 let region = self.delegate.next_region_infer();
1056 self.inspect.add_var_value(region);
1057 region
1058 }
1059
1060 pub(super) fn next_ty_infer(&mut self) -> I::Ty {
1061 let ty = self.delegate.next_ty_infer();
1062 self.inspect.add_var_value(ty);
1063 ty
1064 }
1065
1066 pub(super) fn next_const_infer(&mut self) -> I::Const {
1067 let ct = self.delegate.next_const_infer();
1068 self.inspect.add_var_value(ct);
1069 ct
1070 }
1071
1072 pub(super) fn next_term_infer_of_kind(&mut self, term: I::Term) -> I::Term {
1075 match term.kind() {
1076 ty::TermKind::Ty(_) => self.next_ty_infer().into(),
1077 ty::TermKind::Const(_) => self.next_const_infer().into(),
1078 }
1079 }
1080
1081 x;#[instrument(level = "trace", skip(self), ret)]
1086 pub(super) fn term_is_fully_unconstrained(&self, goal: Goal<I, ty::NormalizesTo<I>>) -> bool {
1087 let universe_of_term = match goal.predicate.term.kind() {
1088 ty::TermKind::Ty(ty) => {
1089 if let ty::Infer(ty::TyVar(vid)) = ty.kind() {
1090 self.delegate.universe_of_ty(vid).unwrap()
1091 } else {
1092 return false;
1093 }
1094 }
1095 ty::TermKind::Const(ct) => {
1096 if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = ct.kind() {
1097 self.delegate.universe_of_ct(vid).unwrap()
1098 } else {
1099 return false;
1100 }
1101 }
1102 };
1103
1104 struct ContainsTermOrNotNameable<'a, D: SolverDelegate<Interner = I>, I: Interner> {
1105 term: I::Term,
1106 universe_of_term: ty::UniverseIndex,
1107 delegate: &'a D,
1108 cache: HashSet<I::Ty>,
1109 }
1110
1111 impl<D: SolverDelegate<Interner = I>, I: Interner> ContainsTermOrNotNameable<'_, D, I> {
1112 fn check_nameable(&self, universe: ty::UniverseIndex) -> ControlFlow<()> {
1113 if self.universe_of_term.can_name(universe) {
1114 ControlFlow::Continue(())
1115 } else {
1116 ControlFlow::Break(())
1117 }
1118 }
1119 }
1120
1121 impl<D: SolverDelegate<Interner = I>, I: Interner> TypeVisitor<I>
1122 for ContainsTermOrNotNameable<'_, D, I>
1123 {
1124 type Result = ControlFlow<()>;
1125 fn visit_ty(&mut self, t: I::Ty) -> Self::Result {
1126 if self.cache.contains(&t) {
1127 return ControlFlow::Continue(());
1128 }
1129
1130 match t.kind() {
1131 ty::Infer(ty::TyVar(vid)) => {
1132 if let ty::TermKind::Ty(term) = self.term.kind()
1133 && let ty::Infer(ty::TyVar(term_vid)) = term.kind()
1134 && self.delegate.root_ty_var(vid) == self.delegate.root_ty_var(term_vid)
1135 {
1136 return ControlFlow::Break(());
1137 }
1138
1139 self.check_nameable(self.delegate.universe_of_ty(vid).unwrap())?;
1140 }
1141 ty::Placeholder(p) => self.check_nameable(p.universe())?,
1142 _ => {
1143 if t.has_non_region_infer() || t.has_placeholders() {
1144 t.super_visit_with(self)?
1145 }
1146 }
1147 }
1148
1149 assert!(self.cache.insert(t));
1150 ControlFlow::Continue(())
1151 }
1152
1153 fn visit_const(&mut self, c: I::Const) -> Self::Result {
1154 match c.kind() {
1155 ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
1156 if let ty::TermKind::Const(term) = self.term.kind()
1157 && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
1158 && self.delegate.root_const_var(vid)
1159 == self.delegate.root_const_var(term_vid)
1160 {
1161 return ControlFlow::Break(());
1162 }
1163
1164 self.check_nameable(self.delegate.universe_of_ct(vid).unwrap())
1165 }
1166 ty::ConstKind::Placeholder(p) => self.check_nameable(p.universe()),
1167 _ => {
1168 if c.has_non_region_infer() || c.has_placeholders() {
1169 c.super_visit_with(self)
1170 } else {
1171 ControlFlow::Continue(())
1172 }
1173 }
1174 }
1175 }
1176
1177 fn visit_predicate(&mut self, p: I::Predicate) -> Self::Result {
1178 if p.has_non_region_infer() || p.has_placeholders() {
1179 p.super_visit_with(self)
1180 } else {
1181 ControlFlow::Continue(())
1182 }
1183 }
1184
1185 fn visit_clauses(&mut self, c: I::Clauses) -> Self::Result {
1186 if c.has_non_region_infer() || c.has_placeholders() {
1187 c.super_visit_with(self)
1188 } else {
1189 ControlFlow::Continue(())
1190 }
1191 }
1192 }
1193
1194 let mut visitor = ContainsTermOrNotNameable {
1195 delegate: self.delegate,
1196 universe_of_term,
1197 term: goal.predicate.term,
1198 cache: Default::default(),
1199 };
1200 goal.predicate.alias.visit_with(&mut visitor).is_continue()
1201 && goal.param_env.visit_with(&mut visitor).is_continue()
1202 }
1203
1204 pub(super) fn sub_unify_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
1205 self.delegate.sub_unify_ty_vids_raw(a, b)
1206 }
1207
1208 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1209 pub(super) fn eq<T: Relate<I>>(
1210 &mut self,
1211 param_env: I::ParamEnv,
1212 lhs: T,
1213 rhs: T,
1214 ) -> Result<(), NoSolution> {
1215 self.relate(param_env, lhs, ty::Variance::Invariant, rhs)
1216 }
1217
1218 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1224 pub(super) fn relate_rigid_alias_non_alias(
1225 &mut self,
1226 param_env: I::ParamEnv,
1227 alias: ty::AliasTerm<I>,
1228 variance: ty::Variance,
1229 term: I::Term,
1230 ) -> Result<(), NoSolution> {
1231 if term.is_infer() {
1234 let cx = self.cx();
1235 let def_id = match alias.kind {
1244 ty::AliasTermKind::ProjectionTy { def_id } => def_id.into(),
1245 ty::AliasTermKind::InherentTy { def_id } => def_id.into(),
1246 ty::AliasTermKind::OpaqueTy { def_id } => def_id.into(),
1247 ty::AliasTermKind::FreeTy { def_id } => def_id.into(),
1248 ty::AliasTermKind::AnonConst { def_id } => def_id.into(),
1249 ty::AliasTermKind::ProjectionConst { def_id } => def_id.into(),
1250 ty::AliasTermKind::FreeConst { def_id } => def_id.into(),
1251 ty::AliasTermKind::InherentConst { def_id } => def_id.into(),
1252 };
1253 let identity_args = self.fresh_args_for_item(def_id);
1254 let rigid_ctor = alias.with_args(cx, identity_args);
1255 let ctor_term = rigid_ctor.to_term(cx);
1256 let obligations = self.delegate.eq_structurally_relating_aliases(
1257 param_env,
1258 term,
1259 ctor_term,
1260 self.origin_span,
1261 )?;
1262 debug_assert!(obligations.is_empty());
1263 self.relate(param_env, alias, variance, rigid_ctor)
1264 } else {
1265 Err(NoSolution)
1266 }
1267 }
1268
1269 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1273 pub(super) fn eq_structurally_relating_aliases<T: Relate<I>>(
1274 &mut self,
1275 param_env: I::ParamEnv,
1276 lhs: T,
1277 rhs: T,
1278 ) -> Result<(), NoSolution> {
1279 let result = self.delegate.eq_structurally_relating_aliases(
1280 param_env,
1281 lhs,
1282 rhs,
1283 self.origin_span,
1284 )?;
1285 assert_eq!(result, vec![]);
1286 Ok(())
1287 }
1288
1289 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1290 pub(super) fn sub<T: Relate<I>>(
1291 &mut self,
1292 param_env: I::ParamEnv,
1293 sub: T,
1294 sup: T,
1295 ) -> Result<(), NoSolution> {
1296 self.relate(param_env, sub, ty::Variance::Covariant, sup)
1297 }
1298
1299 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1300 pub(super) fn relate<T: Relate<I>>(
1301 &mut self,
1302 param_env: I::ParamEnv,
1303 lhs: T,
1304 variance: ty::Variance,
1305 rhs: T,
1306 ) -> Result<(), NoSolution> {
1307 let goals = self.delegate.relate(param_env, lhs, variance, rhs, self.origin_span)?;
1308 for &goal in goals.iter() {
1309 let source = match goal.predicate.kind().skip_binder() {
1310 ty::PredicateKind::Subtype { .. } | ty::PredicateKind::AliasRelate(..) => {
1311 GoalSource::TypeRelating
1312 }
1313 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
1315 p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
1316 };
1317 self.add_goal(source, goal);
1318 }
1319 Ok(())
1320 }
1321
1322 x;#[instrument(level = "trace", skip(self, param_env), ret)]
1328 pub(super) fn eq_and_get_goals<T: Relate<I>>(
1329 &self,
1330 param_env: I::ParamEnv,
1331 lhs: T,
1332 rhs: T,
1333 ) -> Result<Vec<Goal<I, I::Predicate>>, NoSolution> {
1334 Ok(self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs, self.origin_span)?)
1335 }
1336
1337 pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<I> + Copy>(
1338 &self,
1339 value: ty::Binder<I, T>,
1340 ) -> T {
1341 self.delegate.instantiate_binder_with_infer(value)
1342 }
1343
1344 pub(super) fn enter_forall_with_assumptions<T: TypeFoldable<I>, U>(
1352 &mut self,
1353 value: ty::Binder<I, T>,
1354 param_env: I::ParamEnv,
1355 f: impl FnOnce(&mut Self, T) -> U,
1356 ) -> U {
1357 self.delegate.enter_forall_without_assumptions(value, |value| {
1358 let u = self.delegate.universe();
1359 let assumptions = if self.cx().assumptions_on_binders() {
1360 self.region_assumptions_for_placeholders_in_universe(value.clone(), u, param_env)
1361 } else {
1362 None
1363 };
1364 self.delegate.insert_placeholder_assumptions(u, assumptions);
1365 f(self, value)
1366 })
1367 }
1368
1369 pub(super) fn resolve_vars_if_possible<T>(&self, value: T) -> T
1370 where
1371 T: TypeFoldable<I>,
1372 {
1373 self.delegate.resolve_vars_if_possible(value)
1374 }
1375
1376 pub(super) fn shallow_resolve(&self, ty: I::Ty) -> I::Ty {
1377 self.delegate.shallow_resolve(ty)
1378 }
1379
1380 pub(super) fn eager_resolve_region(&self, r: I::Region) -> I::Region {
1381 if let ty::ReVar(vid) = r.kind() {
1382 self.delegate.opportunistic_resolve_lt_var(vid)
1383 } else {
1384 r
1385 }
1386 }
1387
1388 pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs {
1389 let args = self.delegate.fresh_args_for_item(def_id);
1390 for arg in args.iter() {
1391 self.inspect.add_var_value(arg);
1392 }
1393 args
1394 }
1395
1396 pub(super) fn register_solver_region_constraint(&self, c: RegionConstraint<I>) {
1397 self.delegate.register_solver_region_constraint(c);
1398 }
1399
1400 pub(super) fn register_ty_outlives(&self, ty: I::Ty, lt: I::Region) {
1401 self.delegate.register_ty_outlives(ty, lt, self.origin_span);
1402 }
1403
1404 pub(super) fn register_region_outlives(
1405 &self,
1406 a: I::Region,
1407 b: I::Region,
1408 vis: VisibleForLeakCheck,
1409 ) {
1410 self.delegate.sub_regions(b, a, vis, self.origin_span);
1412 }
1413
1414 pub(super) fn well_formed_goals(
1416 &self,
1417 param_env: I::ParamEnv,
1418 term: I::Term,
1419 ) -> Option<Vec<Goal<I, I::Predicate>>> {
1420 self.delegate.well_formed_goals(param_env, term)
1421 }
1422
1423 pub(super) fn trait_ref_is_knowable(
1424 &mut self,
1425 param_env: I::ParamEnv,
1426 trait_ref: ty::TraitRef<I>,
1427 ) -> Result<bool, NoSolutionOrRerunNonErased> {
1428 let delegate = self.delegate;
1429 let lazily_normalize_ty = |ty| self.structurally_normalize_ty(param_env, ty);
1430 coherence::trait_ref_is_knowable(&**delegate, trait_ref, lazily_normalize_ty)
1431 .map(|is_knowable| is_knowable.is_ok())
1432 }
1433
1434 pub(super) fn fetch_eligible_assoc_item(
1435 &self,
1436 goal_trait_ref: ty::TraitRef<I>,
1437 trait_assoc_def_id: I::TraitAssocTermId,
1438 impl_def_id: I::ImplId,
1439 ) -> FetchEligibleAssocItemResponse<I> {
1440 self.delegate.fetch_eligible_assoc_item(goal_trait_ref, trait_assoc_def_id, impl_def_id)
1441 }
1442
1443 x;#[instrument(level = "debug", skip(self), ret)]
1444 pub(super) fn register_hidden_type_in_storage(
1445 &mut self,
1446 opaque_type_key: ty::OpaqueTypeKey<I>,
1447 hidden_ty: I::Ty,
1448 ) -> Option<I::Ty> {
1449 self.delegate.register_hidden_type_in_storage(opaque_type_key, hidden_ty, self.origin_span)
1450 }
1451
1452 pub(super) fn add_item_bounds_for_hidden_type(
1453 &mut self,
1454 opaque_def_id: I::OpaqueTyId,
1455 opaque_args: I::GenericArgs,
1456 param_env: I::ParamEnv,
1457 hidden_ty: I::Ty,
1458 ) {
1459 let mut goals = Vec::new();
1460 self.delegate.add_item_bounds_for_hidden_type(
1461 opaque_def_id,
1462 opaque_args,
1463 param_env,
1464 hidden_ty,
1465 &mut goals,
1466 );
1467 self.add_goals(GoalSource::AliasWellFormed, goals);
1468 }
1469
1470 pub(super) fn evaluate_const(
1474 &mut self,
1475 param_env: I::ParamEnv,
1476 uv: ty::UnevaluatedConst<I>,
1477 ) -> Result<Option<I::Const>, RerunNonErased> {
1478 if self.typing_mode().is_erased_not_coherence() {
1479 self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)?;
1480 }
1481
1482 Ok(self.delegate.evaluate_const(param_env, uv))
1483 }
1484
1485 pub(super) fn evaluate_const_and_instantiate_normalizes_to_term(
1486 &mut self,
1487 goal: Goal<I, ty::NormalizesTo<I>>,
1488 uv: ty::UnevaluatedConst<I>,
1489 ) -> QueryResultOrRerunNonErased<I> {
1490 match self.evaluate_const(goal.param_env, uv)? {
1491 Some(evaluated) => {
1492 self.instantiate_normalizes_to_term(goal, evaluated.into());
1493 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1494 }
1495 None if self.cx().features().generic_const_args() => {
1496 if self.resolve_vars_if_possible(uv).has_non_region_infer() {
1504 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1505 } else {
1506 self.structurally_instantiate_normalizes_to_term(goal, goal.predicate.alias);
1513 self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
1514 }
1515 }
1516 None => {
1517 self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
1519 }
1520 }
1521 }
1522
1523 pub(super) fn is_transmutable(
1524 &mut self,
1525 src: I::Ty,
1526 dst: I::Ty,
1527 assume: I::Const,
1528 ) -> Result<Certainty, NoSolution> {
1529 self.delegate.is_transmutable(dst, src, assume)
1530 }
1531
1532 pub(super) fn replace_bound_vars<T: TypeFoldable<I>>(
1533 &self,
1534 t: T,
1535 universes: &mut Vec<Option<ty::UniverseIndex>>,
1536 ) -> T {
1537 BoundVarReplacer::replace_bound_vars(&**self.delegate, universes, t).0
1538 }
1539
1540 pub(super) fn may_use_unstable_feature(
1541 &mut self,
1542 param_env: I::ParamEnv,
1543 symbol: I::Symbol,
1544 ) -> Result<bool, RerunNonErased> {
1545 if self.typing_mode().is_erased_not_coherence() {
1546 self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)?;
1547 }
1548
1549 Ok(may_use_unstable_feature(&**self.delegate, param_env, symbol))
1550 }
1551
1552 pub(crate) fn opaques_with_sub_unified_hidden_type(
1553 &self,
1554 self_ty: I::Ty,
1555 ) -> Vec<ty::AliasTy<I>> {
1556 if let ty::Infer(ty::TyVar(vid)) = self_ty.kind() {
1557 self.delegate.opaques_with_sub_unified_hidden_type(vid)
1558 } else {
1559 ::alloc::vec::Vec::new()vec![]
1560 }
1561 }
1562
1563 x;#[instrument(level = "trace", skip(self), ret)]
1577 pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response(
1578 &mut self,
1579 shallow_certainty: Certainty,
1580 ) -> QueryResultOrRerunNonErased<I> {
1581 self.inspect.make_canonical_response(shallow_certainty);
1582
1583 let goals_certainty = self.try_evaluate_added_goals()?;
1584 assert_eq!(
1585 self.tainted,
1586 Ok(()),
1587 "EvalCtxt is tainted -- nested goals may have been dropped in a \
1588 previous call to `try_evaluate_added_goals!`"
1589 );
1590
1591 let goals_certainty = match self.delegate.cx().assumptions_on_binders() {
1592 true => {
1593 let certainty = self.eagerly_handle_placeholders()?;
1594 certainty.and(goals_certainty)
1595 }
1596 false => {
1597 self.delegate.leak_check(self.max_input_universe).map_err(|NoSolution| {
1600 trace!("failed the leak check");
1601 NoSolution
1602 })?;
1603
1604 goals_certainty
1605 }
1606 };
1607
1608 let (certainty, normalization_nested_goals) =
1609 match (self.current_goal_kind, shallow_certainty) {
1610 (CurrentGoalKind::NormalizesTo, Certainty::Yes) => {
1618 let goals = std::mem::take(&mut self.nested_goals);
1619 if goals.is_empty() {
1622 assert!(matches!(goals_certainty, Certainty::Yes));
1623 }
1624 (
1625 Certainty::Yes,
1626 NestedNormalizationGoals(
1627 goals.into_iter().map(|(s, g, _)| (s, g)).collect(),
1628 ),
1629 )
1630 }
1631 _ => {
1632 let certainty = shallow_certainty.and(goals_certainty);
1633 (certainty, NestedNormalizationGoals::empty())
1634 }
1635 };
1636
1637 if let Certainty::Maybe(
1638 maybe_info @ MaybeInfo {
1639 cause: MaybeCause::Overflow { keep_constraints: false, .. },
1640 opaque_types_jank: _,
1641 stalled_on_coroutines: _,
1642 },
1643 ) = certainty
1644 {
1645 return Ok(self.make_ambiguous_response_no_constraints(maybe_info));
1657 }
1658
1659 let external_constraints =
1660 self.compute_external_query_constraints(certainty, normalization_nested_goals);
1661 let (var_values, mut external_constraints) =
1662 eager_resolve_vars(self.delegate, (self.var_values, external_constraints));
1663
1664 let mut unique = HashSet::default();
1666 if let ExternalRegionConstraints::Old(r) = &mut external_constraints.region_constraints {
1667 r.retain(|(outlives, _)| !outlives.is_trivial() && unique.insert(*outlives));
1668 }
1669
1670 let canonical = canonicalize_response(
1671 self.delegate,
1672 self.max_input_universe,
1673 Response {
1674 var_values,
1675 certainty,
1676 external_constraints: self.cx().mk_external_constraints(external_constraints),
1677 },
1678 );
1679
1680 Ok(canonical)
1681 }
1682
1683 pub(in crate::solve) fn make_ambiguous_response_no_constraints(
1688 &self,
1689 maybe: MaybeInfo,
1690 ) -> CanonicalResponse<I> {
1691 response_no_constraints_raw(
1692 self.cx(),
1693 self.max_input_universe,
1694 self.var_kinds,
1695 Certainty::Maybe(maybe),
1696 )
1697 }
1698
1699 x;#[instrument(level = "trace", skip(self), ret)]
1707 fn compute_external_query_constraints(
1708 &self,
1709 certainty: Certainty,
1710 normalization_nested_goals: NestedNormalizationGoals<I>,
1711 ) -> ExternalConstraintsData<I> {
1712 let region_constraints = if self.cx().assumptions_on_binders() {
1721 ExternalRegionConstraints::NextGen(if let Certainty::Yes = certainty {
1722 self.delegate.get_solver_region_constraint()
1723 } else {
1724 RegionConstraint::new_true()
1725 })
1726 } else {
1727 ExternalRegionConstraints::Old(if let Certainty::Yes = certainty {
1728 self.delegate.make_deduplicated_region_constraints()
1729 } else {
1730 vec![]
1731 })
1732 };
1733
1734 let opaque_types = self
1739 .delegate
1740 .clone_opaque_types_added_since(self.initial_opaque_types_storage_num_entries);
1741
1742 if self.typing_mode().is_erased_not_coherence() {
1743 assert!(opaque_types.is_empty());
1744 }
1745
1746 ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
1747 }
1748}
1749
1750struct ReplaceAliasWithInfer<'me, 'a, D, I>
1765where
1766 D: SolverDelegate<Interner = I>,
1767 I: Interner,
1768{
1769 ecx: &'me mut EvalCtxt<'a, D>,
1770 param_env: I::ParamEnv,
1771 normalization_goal_source: GoalSource,
1772 cache: HashMap<I::Ty, I::Ty>,
1773}
1774
1775impl<'me, 'a, D, I> ReplaceAliasWithInfer<'me, 'a, D, I>
1776where
1777 D: SolverDelegate<Interner = I>,
1778 I: Interner,
1779{
1780 fn new(
1781 ecx: &'me mut EvalCtxt<'a, D>,
1782 for_goal_source: GoalSource,
1783 param_env: I::ParamEnv,
1784 ) -> Self {
1785 let step_kind = ecx.step_kind_for_source(for_goal_source);
1786 ReplaceAliasWithInfer {
1787 ecx,
1788 param_env,
1789 normalization_goal_source: GoalSource::NormalizeGoal(step_kind),
1790 cache: Default::default(),
1791 }
1792 }
1793}
1794
1795impl<D, I> TypeFolder<I> for ReplaceAliasWithInfer<'_, '_, D, I>
1796where
1797 D: SolverDelegate<Interner = I>,
1798 I: Interner,
1799{
1800 fn cx(&self) -> I {
1801 self.ecx.cx()
1802 }
1803
1804 fn fold_ty(&mut self, ty: I::Ty) -> I::Ty {
1805 match ty.kind() {
1806 ty::Alias(..) if !ty.has_escaping_bound_vars() => {
1807 let infer_ty = self.ecx.next_ty_infer();
1808 let normalizes_to = ty::PredicateKind::AliasRelate(
1809 ty.into(),
1810 infer_ty.into(),
1811 ty::AliasRelationDirection::Equate,
1812 );
1813 self.ecx.add_goal(
1814 self.normalization_goal_source,
1815 Goal::new(self.cx(), self.param_env, normalizes_to),
1816 );
1817 infer_ty
1818 }
1819 _ => {
1820 if !ty.has_aliases() {
1821 ty
1822 } else if let Some(&entry) = self.cache.get(&ty) {
1823 return entry;
1824 } else {
1825 let res = ty.super_fold_with(self);
1826 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());
1827 res
1828 }
1829 }
1830 }
1831 }
1832
1833 fn fold_const(&mut self, ct: I::Const) -> I::Const {
1834 match ct.kind() {
1835 ty::ConstKind::Unevaluated(..) if !ct.has_escaping_bound_vars() => {
1836 let infer_ct = self.ecx.next_const_infer();
1837 let normalizes_to = ty::PredicateKind::AliasRelate(
1838 ct.into(),
1839 infer_ct.into(),
1840 ty::AliasRelationDirection::Equate,
1841 );
1842 self.ecx.add_goal(
1843 self.normalization_goal_source,
1844 Goal::new(self.cx(), self.param_env, normalizes_to),
1845 );
1846 infer_ct
1847 }
1848 _ => ct.super_fold_with(self),
1849 }
1850 }
1851
1852 fn fold_predicate(&mut self, predicate: I::Predicate) -> I::Predicate {
1853 if predicate.allow_normalization() { predicate.super_fold_with(self) } else { predicate }
1854 }
1855}
1856
1857pub fn evaluate_root_goal_for_proof_tree_raw_provider<
1859 D: SolverDelegate<Interner = I>,
1860 I: Interner,
1861>(
1862 cx: I,
1863 canonical_goal: CanonicalInput<I>,
1864) -> (QueryResult<I>, I::Probe) {
1865 let mut inspect = inspect::ProofTreeBuilder::new();
1866 let (canonical_result, accessed_opaques) = SearchGraph::<D>::evaluate_root_goal_for_proof_tree(
1867 cx,
1868 cx.recursion_limit(),
1869 canonical_goal,
1870 &mut inspect,
1871 );
1872 let final_revision = inspect.unwrap();
1873
1874 if !!accessed_opaques.might_rerun() {
::core::panicking::panic("assertion failed: !accessed_opaques.might_rerun()")
};assert!(!accessed_opaques.might_rerun());
1875 (canonical_result, cx.mk_probe(final_revision))
1876}
1877
1878pub(super) fn evaluate_root_goal_for_proof_tree<D: SolverDelegate<Interner = I>, I: Interner>(
1883 delegate: &D,
1884 goal: Goal<I, I::Predicate>,
1885 origin_span: I::Span,
1886) -> (Result<NestedNormalizationGoals<I>, NoSolution>, inspect::GoalEvaluation<I>) {
1887 let opaque_types = delegate.clone_opaque_types_lookup_table();
1888 let (goal, opaque_types) = eager_resolve_vars(delegate, (goal, opaque_types));
1889 let typing_mode = delegate.typing_mode_raw().assert_not_erased();
1890
1891 let (orig_values, canonical_goal) =
1892 canonicalize_goal(delegate, goal, &opaque_types, typing_mode.into());
1893
1894 let (canonical_result, final_revision) =
1895 delegate.cx().evaluate_root_goal_for_proof_tree_raw(canonical_goal);
1896
1897 let proof_tree = inspect::GoalEvaluation {
1898 uncanonicalized_goal: goal,
1899 orig_values,
1900 final_revision,
1901 result: canonical_result,
1902 };
1903
1904 let response = match canonical_result {
1905 Err(e) => return (Err(e), proof_tree),
1906 Ok(response) => response,
1907 };
1908
1909 let (normalization_nested_goals, _certainty) = instantiate_and_apply_query_response(
1910 delegate,
1911 goal.param_env,
1912 &proof_tree.orig_values,
1913 response,
1914 VisibleForLeakCheck::Yes,
1915 origin_span,
1916 );
1917
1918 (Ok(normalization_nested_goals), proof_tree)
1919}