1
Fork 0

structurally important functions to debug

This commit is contained in:
lcnr 2024-05-12 03:46:24 +00:00
parent 41ebd16266
commit c66328f9ad
4 changed files with 13 additions and 10 deletions

View file

@ -282,7 +282,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}; };
if normalized_self_ty.is_ty_var() { if normalized_self_ty.is_ty_var() {
trace!("self type has been normalized to infer"); debug!("self type has been normalized to infer");
return self.forced_ambiguity(MaybeCause::Ambiguity).into_iter().collect(); return self.forced_ambiguity(MaybeCause::Ambiguity).into_iter().collect();
} }
@ -785,7 +785,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
// FIXME(@lcnr): The current structure here makes me unhappy and feels ugly. idk how // FIXME(@lcnr): The current structure here makes me unhappy and feels ugly. idk how
// to improve this however. However, this should make it fairly straightforward to refine // to improve this however. However, this should make it fairly straightforward to refine
// the filtering going forward, so it seems alright-ish for now. // the filtering going forward, so it seems alright-ish for now.
#[instrument(level = "trace", skip(self, goal))] #[instrument(level = "debug", skip(self, goal))]
fn discard_impls_shadowed_by_env<G: GoalKind<'tcx>>( fn discard_impls_shadowed_by_env<G: GoalKind<'tcx>>(
&mut self, &mut self,
goal: Goal<'tcx, G>, goal: Goal<'tcx, G>,
@ -814,7 +814,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
Certainty::Yes => { Certainty::Yes => {
candidates.retain(|c| match c.source { candidates.retain(|c| match c.source {
CandidateSource::Impl(_) | CandidateSource::BuiltinImpl(_) => { CandidateSource::Impl(_) | CandidateSource::BuiltinImpl(_) => {
trace!(?c, "discard impl candidate"); debug!(?c, "discard impl candidate");
false false
} }
CandidateSource::ParamEnv(_) | CandidateSource::AliasBound => true, CandidateSource::ParamEnv(_) | CandidateSource::AliasBound => true,
@ -825,7 +825,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
// to be ambig and wait for inference constraints. See // to be ambig and wait for inference constraints. See
// tests/ui/traits/next-solver/env-shadows-impls/ambig-env-no-shadow.rs // tests/ui/traits/next-solver/env-shadows-impls/ambig-env-no-shadow.rs
Certainty::Maybe(cause) => { Certainty::Maybe(cause) => {
trace!(?cause, "force ambiguity"); debug!(?cause, "force ambiguity");
*candidates = self.forced_ambiguity(cause).into_iter().collect(); *candidates = self.forced_ambiguity(cause).into_iter().collect();
} }
} }
@ -836,7 +836,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
/// If there are multiple ways to prove a trait or projection goal, we have /// If there are multiple ways to prove a trait or projection goal, we have
/// to somehow try to merge the candidates into one. If that fails, we return /// to somehow try to merge the candidates into one. If that fails, we return
/// ambiguity. /// ambiguity.
#[instrument(level = "trace", skip(self), ret)] #[instrument(level = "debug", skip(self), ret)]
pub(super) fn merge_candidates( pub(super) fn merge_candidates(
&mut self, &mut self,
candidates: Vec<Candidate<'tcx>>, candidates: Vec<Candidate<'tcx>>,

View file

@ -137,7 +137,7 @@ impl<'tcx> InferCtxt<'tcx> {
/// ///
/// Using this while inside of the solver is wrong as it uses a new /// Using this while inside of the solver is wrong as it uses a new
/// search graph which would break cycle detection. /// search graph which would break cycle detection.
#[instrument(level = "trace", skip(self))] #[instrument(level = "debug", skip(self))]
fn evaluate_root_goal( fn evaluate_root_goal(
&self, &self,
goal: Goal<'tcx, ty::Predicate<'tcx>>, goal: Goal<'tcx, ty::Predicate<'tcx>>,
@ -276,7 +276,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
/// Instead of calling this function directly, use either [EvalCtxt::evaluate_goal] /// Instead of calling this function directly, use either [EvalCtxt::evaluate_goal]
/// if you're inside of the solver or [InferCtxtEvalExt::evaluate_root_goal] if you're /// if you're inside of the solver or [InferCtxtEvalExt::evaluate_root_goal] if you're
/// outside of it. /// outside of it.
#[instrument(level = "trace", skip(tcx, search_graph, goal_evaluation), ret)] #[instrument(level = "debug", skip(tcx, search_graph, goal_evaluation), ret)]
fn evaluate_canonical_goal( fn evaluate_canonical_goal(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
search_graph: &'a mut search_graph::SearchGraph<'tcx>, search_graph: &'a mut search_graph::SearchGraph<'tcx>,
@ -464,7 +464,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
self.nested_goals.normalizes_to_goals.push(goal); self.nested_goals.normalizes_to_goals.push(goal);
} }
#[instrument(level = "trace", skip(self))] #[instrument(level = "debug", skip(self))]
pub(super) fn add_goal(&mut self, source: GoalSource, goal: Goal<'tcx, ty::Predicate<'tcx>>) { pub(super) fn add_goal(&mut self, source: GoalSource, goal: Goal<'tcx, ty::Predicate<'tcx>>) {
self.inspect.add_goal(self.infcx, self.max_input_universe, source, goal); self.inspect.add_goal(self.infcx, self.max_input_universe, source, goal);
self.nested_goals.goals.push((source, goal)); self.nested_goals.goals.push((source, goal));

View file

@ -58,6 +58,7 @@ impl<'tcx, F> TraitProbeCtxt<'_, '_, 'tcx, F>
where where
F: FnOnce(&QueryResult<'tcx>) -> inspect::ProbeKind<'tcx>, F: FnOnce(&QueryResult<'tcx>) -> inspect::ProbeKind<'tcx>,
{ {
#[instrument(level = "debug", skip_all, fields(source = ?self.source))]
pub(in crate::solve) fn enter( pub(in crate::solve) fn enter(
self, self,
f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx>, f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx>,

View file

@ -296,6 +296,7 @@ impl<'tcx> SearchGraph<'tcx> {
} }
self.on_cache_hit(reached_depth, encountered_overflow); self.on_cache_hit(reached_depth, encountered_overflow);
debug!("global cache hit");
return result; return result;
} }
@ -315,6 +316,7 @@ impl<'tcx> SearchGraph<'tcx> {
.filter(|p| !Self::stack_coinductive_from(tcx, &self.stack, p.head)) .filter(|p| !Self::stack_coinductive_from(tcx, &self.stack, p.head))
}) })
{ {
debug!("provisional cache hit");
// We have a nested goal which is already in the provisional cache, use // We have a nested goal which is already in the provisional cache, use
// its result. We do not provide any usage kind as that should have been // its result. We do not provide any usage kind as that should have been
// already set correctly while computing the cache entry. // already set correctly while computing the cache entry.
@ -328,7 +330,7 @@ impl<'tcx> SearchGraph<'tcx> {
); );
return entry.result; return entry.result;
} else if let Some(stack_depth) = cache_entry.stack_depth { } else if let Some(stack_depth) = cache_entry.stack_depth {
trace!("encountered cycle with depth {stack_depth:?}"); debug!("encountered cycle with depth {stack_depth:?}");
// We have a nested goal which directly relies on a goal deeper in the stack. // We have a nested goal which directly relies on a goal deeper in the stack.
// //
// We start by tagging all cycle participants, as that's necessary for caching. // We start by tagging all cycle participants, as that's necessary for caching.
@ -436,7 +438,7 @@ impl<'tcx> SearchGraph<'tcx> {
} }
} }
trace!("canonical cycle overflow"); debug!("canonical cycle overflow");
let current_entry = self.pop_stack(); let current_entry = self.pop_stack();
debug_assert!(current_entry.has_been_used.is_empty()); debug_assert!(current_entry.has_been_used.is_empty());
let result = Self::response_no_constraints(tcx, input, Certainty::overflow(false)); let result = Self::response_no_constraints(tcx, input, Certainty::overflow(false));