avoid building proof trees in select
This commit is contained in:
parent
a482149598
commit
4965caf9be
@ -116,7 +116,8 @@ impl NestedGoals<'_> {
|
||||
#[derive(PartialEq, Eq, Debug, Hash, HashStable, Clone, Copy)]
|
||||
pub enum GenerateProofTree {
|
||||
Yes(UseGlobalCache),
|
||||
No,
|
||||
IfEnabled,
|
||||
Never,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Hash, HashStable, Clone, Copy)]
|
||||
@ -202,7 +203,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
||||
(&tree, infcx.tcx.sess.opts.unstable_opts.dump_solver_proof_tree)
|
||||
{
|
||||
let mut lock = std::io::stdout().lock();
|
||||
let _ = lock.write_fmt(format_args!("{tree:?}"));
|
||||
let _ = lock.write_fmt(format_args!("{tree:?}\n"));
|
||||
let _ = lock.flush();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl<'tcx> InferCtxtSelectExt<'tcx> for InferCtxt<'tcx> {
|
||||
self.instantiate_binder_with_placeholders(obligation.predicate),
|
||||
);
|
||||
|
||||
let (result, _) = EvalCtxt::enter_root(self, GenerateProofTree::No, |ecx| {
|
||||
let (result, _) = EvalCtxt::enter_root(self, GenerateProofTree::Never, |ecx| {
|
||||
let goal = Goal::new(ecx.tcx(), trait_goal.param_env, trait_goal.predicate);
|
||||
let (orig_values, canonical_goal) = ecx.canonicalize_goal(goal);
|
||||
let mut candidates = ecx.compute_canonical_trait_candidates(canonical_goal);
|
||||
|
@ -57,7 +57,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||
.map(|obligation| {
|
||||
let code = infcx.probe(|_| {
|
||||
match infcx
|
||||
.evaluate_root_goal(obligation.clone().into(), GenerateProofTree::No)
|
||||
.evaluate_root_goal(obligation.clone().into(), GenerateProofTree::IfEnabled)
|
||||
.0
|
||||
{
|
||||
Ok((_, Certainty::Maybe(MaybeCause::Ambiguity), _)) => {
|
||||
@ -96,7 +96,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
|
||||
for obligation in mem::take(&mut self.obligations) {
|
||||
let goal = obligation.clone().into();
|
||||
let (changed, certainty, nested_goals) =
|
||||
match infcx.evaluate_root_goal(goal, GenerateProofTree::No).0 {
|
||||
match infcx.evaluate_root_goal(goal, GenerateProofTree::IfEnabled).0 {
|
||||
Ok(result) => result,
|
||||
Err(NoSolution) => {
|
||||
errors.push(FulfillmentError {
|
||||
|
@ -200,30 +200,23 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
generate_proof_tree: GenerateProofTree,
|
||||
) -> ProofTreeBuilder<'tcx> {
|
||||
let generate_proof_tree = match (
|
||||
tcx.sess.opts.unstable_opts.dump_solver_proof_tree,
|
||||
tcx.sess.opts.unstable_opts.dump_solver_proof_tree_use_cache,
|
||||
generate_proof_tree,
|
||||
) {
|
||||
(_, Some(use_cache), GenerateProofTree::Yes(_)) => {
|
||||
GenerateProofTree::Yes(UseGlobalCache::from_bool(use_cache))
|
||||
}
|
||||
|
||||
(DumpSolverProofTree::Always, use_cache, GenerateProofTree::No) => {
|
||||
let use_cache = use_cache.unwrap_or(true);
|
||||
GenerateProofTree::Yes(UseGlobalCache::from_bool(use_cache))
|
||||
}
|
||||
|
||||
(_, None, GenerateProofTree::Yes(_)) => generate_proof_tree,
|
||||
(DumpSolverProofTree::Never, _, _) => generate_proof_tree,
|
||||
(DumpSolverProofTree::OnError, _, _) => generate_proof_tree,
|
||||
};
|
||||
|
||||
match generate_proof_tree {
|
||||
GenerateProofTree::No => ProofTreeBuilder::new_noop(),
|
||||
GenerateProofTree::Yes(global_cache_disabled) => {
|
||||
ProofTreeBuilder::new_root(global_cache_disabled)
|
||||
GenerateProofTree::Never => ProofTreeBuilder::new_noop(),
|
||||
GenerateProofTree::IfEnabled => {
|
||||
let opts = &tcx.sess.opts.unstable_opts;
|
||||
match opts.dump_solver_proof_tree {
|
||||
DumpSolverProofTree::Always => {
|
||||
let use_cache = opts.dump_solver_proof_tree_use_cache.unwrap_or(true);
|
||||
ProofTreeBuilder::new_root(UseGlobalCache::from_bool(use_cache))
|
||||
}
|
||||
// `OnError` is handled by reevaluating goals in error
|
||||
// reporting with `GenerateProofTree::Yes`.
|
||||
DumpSolverProofTree::OnError | DumpSolverProofTree::Never => {
|
||||
ProofTreeBuilder::new_noop()
|
||||
}
|
||||
}
|
||||
}
|
||||
GenerateProofTree::Yes(use_cache) => ProofTreeBuilder::new_root(use_cache),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3554,7 +3554,7 @@ pub fn dump_proof_tree<'tcx>(o: &Obligation<'tcx, ty::Predicate<'tcx>>, infcx: &
|
||||
.1
|
||||
.expect("proof tree should have been generated");
|
||||
let mut lock = std::io::stdout().lock();
|
||||
let _ = lock.write_fmt(format_args!("{tree:?}"));
|
||||
let _ = lock.write_fmt(format_args!("{tree:?}\n"));
|
||||
let _ = lock.flush();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user