Store goal source in InspectGoal
This commit is contained in:
parent
837bde11a2
commit
6e3808e274
@ -42,6 +42,7 @@ pub struct InspectGoal<'a, 'tcx> {
|
|||||||
result: Result<Certainty, NoSolution>,
|
result: Result<Certainty, NoSolution>,
|
||||||
evaluation_kind: inspect::CanonicalGoalEvaluationKind<'tcx>,
|
evaluation_kind: inspect::CanonicalGoalEvaluationKind<'tcx>,
|
||||||
normalizes_to_term_hack: Option<NormalizesToTermHack<'tcx>>,
|
normalizes_to_term_hack: Option<NormalizesToTermHack<'tcx>>,
|
||||||
|
source: GoalSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The expected term of a `NormalizesTo` goal gets replaced
|
/// The expected term of a `NormalizesTo` goal gets replaced
|
||||||
@ -92,7 +93,7 @@ impl<'tcx> NormalizesToTermHack<'tcx> {
|
|||||||
pub struct InspectCandidate<'a, 'tcx> {
|
pub struct InspectCandidate<'a, 'tcx> {
|
||||||
goal: &'a InspectGoal<'a, 'tcx>,
|
goal: &'a InspectGoal<'a, 'tcx>,
|
||||||
kind: inspect::ProbeKind<'tcx>,
|
kind: inspect::ProbeKind<'tcx>,
|
||||||
nested_goals: Vec<inspect::CanonicalState<'tcx, Goal<'tcx, ty::Predicate<'tcx>>>>,
|
nested_goals: Vec<(GoalSource, inspect::CanonicalState<'tcx, Goal<'tcx, ty::Predicate<'tcx>>>)>,
|
||||||
final_state: inspect::CanonicalState<'tcx, ()>,
|
final_state: inspect::CanonicalState<'tcx, ()>,
|
||||||
result: QueryResult<'tcx>,
|
result: QueryResult<'tcx>,
|
||||||
shallow_certainty: Certainty,
|
shallow_certainty: Certainty,
|
||||||
@ -145,13 +146,16 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
|
|||||||
let instantiated_goals: Vec<_> = self
|
let instantiated_goals: Vec<_> = self
|
||||||
.nested_goals
|
.nested_goals
|
||||||
.iter()
|
.iter()
|
||||||
.map(|goal| {
|
.map(|(source, goal)| {
|
||||||
|
(
|
||||||
|
*source,
|
||||||
canonical::instantiate_canonical_state(
|
canonical::instantiate_canonical_state(
|
||||||
infcx,
|
infcx,
|
||||||
span,
|
span,
|
||||||
param_env,
|
param_env,
|
||||||
&mut orig_values,
|
&mut orig_values,
|
||||||
*goal,
|
*goal,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
@ -173,7 +177,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
|
|||||||
|
|
||||||
instantiated_goals
|
instantiated_goals
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|goal| match goal.predicate.kind().no_bound_vars() {
|
.map(|(source, goal)| match goal.predicate.kind().no_bound_vars() {
|
||||||
Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => {
|
Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => {
|
||||||
let unconstrained_term = match term.unpack() {
|
let unconstrained_term = match term.unpack() {
|
||||||
ty::TermKind::Ty(_) => infcx
|
ty::TermKind::Ty(_) => infcx
|
||||||
@ -197,6 +201,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
|
|||||||
self.goal.depth + 1,
|
self.goal.depth + 1,
|
||||||
proof_tree.unwrap(),
|
proof_tree.unwrap(),
|
||||||
Some(NormalizesToTermHack { term, unconstrained_term }),
|
Some(NormalizesToTermHack { term, unconstrained_term }),
|
||||||
|
source,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => InspectGoal::new(
|
_ => InspectGoal::new(
|
||||||
@ -204,6 +209,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
|
|||||||
self.goal.depth + 1,
|
self.goal.depth + 1,
|
||||||
infcx.evaluate_root_goal(goal, GenerateProofTree::Yes).1.unwrap(),
|
infcx.evaluate_root_goal(goal, GenerateProofTree::Yes).1.unwrap(),
|
||||||
None,
|
None,
|
||||||
|
source,
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
@ -229,16 +235,23 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
|
|||||||
self.result
|
self.result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn source(&self) -> GoalSource {
|
||||||
|
self.source
|
||||||
|
}
|
||||||
|
|
||||||
fn candidates_recur(
|
fn candidates_recur(
|
||||||
&'a self,
|
&'a self,
|
||||||
candidates: &mut Vec<InspectCandidate<'a, 'tcx>>,
|
candidates: &mut Vec<InspectCandidate<'a, 'tcx>>,
|
||||||
nested_goals: &mut Vec<inspect::CanonicalState<'tcx, Goal<'tcx, ty::Predicate<'tcx>>>>,
|
nested_goals: &mut Vec<(
|
||||||
|
GoalSource,
|
||||||
|
inspect::CanonicalState<'tcx, Goal<'tcx, ty::Predicate<'tcx>>>,
|
||||||
|
)>,
|
||||||
probe: &inspect::Probe<'tcx>,
|
probe: &inspect::Probe<'tcx>,
|
||||||
) {
|
) {
|
||||||
let mut shallow_certainty = None;
|
let mut shallow_certainty = None;
|
||||||
for step in &probe.steps {
|
for step in &probe.steps {
|
||||||
match step {
|
match step {
|
||||||
&inspect::ProbeStep::AddGoal(_source, goal) => nested_goals.push(goal),
|
&inspect::ProbeStep::AddGoal(source, goal) => nested_goals.push((source, goal)),
|
||||||
inspect::ProbeStep::NestedProbe(ref probe) => {
|
inspect::ProbeStep::NestedProbe(ref probe) => {
|
||||||
// Nested probes have to prove goals added in their parent
|
// Nested probes have to prove goals added in their parent
|
||||||
// but do not leak them, so we truncate the added goals
|
// but do not leak them, so we truncate the added goals
|
||||||
@ -321,6 +334,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
|
|||||||
depth: usize,
|
depth: usize,
|
||||||
root: inspect::GoalEvaluation<'tcx>,
|
root: inspect::GoalEvaluation<'tcx>,
|
||||||
normalizes_to_term_hack: Option<NormalizesToTermHack<'tcx>>,
|
normalizes_to_term_hack: Option<NormalizesToTermHack<'tcx>>,
|
||||||
|
source: GoalSource,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let inspect::GoalEvaluation { uncanonicalized_goal, kind, evaluation } = root;
|
let inspect::GoalEvaluation { uncanonicalized_goal, kind, evaluation } = root;
|
||||||
let inspect::GoalEvaluationKind::Root { orig_values } = kind else { unreachable!() };
|
let inspect::GoalEvaluationKind::Root { orig_values } = kind else { unreachable!() };
|
||||||
@ -343,6 +357,7 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
|
|||||||
result,
|
result,
|
||||||
evaluation_kind: evaluation.kind,
|
evaluation_kind: evaluation.kind,
|
||||||
normalizes_to_term_hack,
|
normalizes_to_term_hack,
|
||||||
|
source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,6 +384,6 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
) -> V::Result {
|
) -> V::Result {
|
||||||
let (_, proof_tree) = self.evaluate_root_goal(goal, GenerateProofTree::Yes);
|
let (_, proof_tree) = self.evaluate_root_goal(goal, GenerateProofTree::Yes);
|
||||||
let proof_tree = proof_tree.unwrap();
|
let proof_tree = proof_tree.unwrap();
|
||||||
visitor.visit_goal(&InspectGoal::new(self, 0, proof_tree, None))
|
visitor.visit_goal(&InspectGoal::new(self, 0, proof_tree, None, GoalSource::Misc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user