mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
move logic for flags into separate function
This commit is contained in:
parent
adefeb80c3
commit
276d628cac
@ -180,34 +180,6 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||||||
let mode = if infcx.intercrate { SolverMode::Coherence } else { SolverMode::Normal };
|
let mode = if infcx.intercrate { SolverMode::Coherence } else { SolverMode::Normal };
|
||||||
let mut search_graph = search_graph::SearchGraph::new(infcx.tcx, mode);
|
let mut search_graph = search_graph::SearchGraph::new(infcx.tcx, mode);
|
||||||
|
|
||||||
let inspect = {
|
|
||||||
let generate_proof_tree = match (
|
|
||||||
infcx.tcx.sess.opts.unstable_opts.dump_solver_proof_tree,
|
|
||||||
infcx.tcx.sess.opts.unstable_opts.dump_solver_proof_tree_use_cache,
|
|
||||||
generate_proof_tree,
|
|
||||||
) {
|
|
||||||
(_, Some(use_cache), GenerateProofTree::Yes(_)) => {
|
|
||||||
GenerateProofTree::Yes(DisableGlobalCache::from_bool(!use_cache))
|
|
||||||
}
|
|
||||||
|
|
||||||
(SolverProofTreeCondition::Always, use_cache, GenerateProofTree::No) => {
|
|
||||||
let use_cache = use_cache.unwrap_or(true);
|
|
||||||
GenerateProofTree::Yes(DisableGlobalCache::from_bool(!use_cache))
|
|
||||||
}
|
|
||||||
|
|
||||||
(_, None, GenerateProofTree::Yes(_)) => generate_proof_tree,
|
|
||||||
(SolverProofTreeCondition::OnRequest, _, _) => generate_proof_tree,
|
|
||||||
(SolverProofTreeCondition::OnError, _, _) => generate_proof_tree,
|
|
||||||
};
|
|
||||||
|
|
||||||
match generate_proof_tree {
|
|
||||||
GenerateProofTree::No => ProofTreeBuilder::new_noop(),
|
|
||||||
GenerateProofTree::Yes(global_cache_disabled) => {
|
|
||||||
ProofTreeBuilder::new_root(global_cache_disabled)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut ecx = EvalCtxt {
|
let mut ecx = EvalCtxt {
|
||||||
search_graph: &mut search_graph,
|
search_graph: &mut search_graph,
|
||||||
infcx: infcx,
|
infcx: infcx,
|
||||||
@ -221,7 +193,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||||||
var_values: CanonicalVarValues::dummy(),
|
var_values: CanonicalVarValues::dummy(),
|
||||||
nested_goals: NestedGoals::new(),
|
nested_goals: NestedGoals::new(),
|
||||||
tainted: Ok(()),
|
tainted: Ok(()),
|
||||||
inspect,
|
inspect: ProofTreeBuilder::new_maybe_root(infcx.tcx, generate_proof_tree),
|
||||||
};
|
};
|
||||||
let result = f(&mut ecx);
|
let result = f(&mut ecx);
|
||||||
|
|
||||||
|
@ -3,9 +3,11 @@ use rustc_middle::traits::solve::inspect::{self, CacheHit, CandidateKind};
|
|||||||
use rustc_middle::traits::solve::{
|
use rustc_middle::traits::solve::{
|
||||||
CanonicalInput, Certainty, Goal, IsNormalizesToHack, QueryInput, QueryResult,
|
CanonicalInput, Certainty, Goal, IsNormalizesToHack, QueryInput, QueryResult,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
|
use rustc_session::config::SolverProofTreeCondition;
|
||||||
|
|
||||||
use super::eval_ctxt::DisableGlobalCache;
|
use super::eval_ctxt::DisableGlobalCache;
|
||||||
|
use super::GenerateProofTree;
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug, Hash, HashStable)]
|
#[derive(Eq, PartialEq, Debug, Hash, HashStable)]
|
||||||
pub struct WipGoalEvaluation<'tcx> {
|
pub struct WipGoalEvaluation<'tcx> {
|
||||||
@ -173,6 +175,37 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
|
|||||||
self.disable_global_cache
|
self.disable_global_cache
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_maybe_root(
|
||||||
|
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(DisableGlobalCache::from_bool(!use_cache))
|
||||||
|
}
|
||||||
|
|
||||||
|
(SolverProofTreeCondition::Always, use_cache, GenerateProofTree::No) => {
|
||||||
|
let use_cache = use_cache.unwrap_or(true);
|
||||||
|
GenerateProofTree::Yes(DisableGlobalCache::from_bool(!use_cache))
|
||||||
|
}
|
||||||
|
|
||||||
|
(_, None, GenerateProofTree::Yes(_)) => generate_proof_tree,
|
||||||
|
(SolverProofTreeCondition::OnRequest, _, _) => generate_proof_tree,
|
||||||
|
(SolverProofTreeCondition::OnError, _, _) => generate_proof_tree,
|
||||||
|
};
|
||||||
|
|
||||||
|
match generate_proof_tree {
|
||||||
|
GenerateProofTree::No => ProofTreeBuilder::new_noop(),
|
||||||
|
GenerateProofTree::Yes(global_cache_disabled) => {
|
||||||
|
ProofTreeBuilder::new_root(global_cache_disabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new_root(disable_global_cache: DisableGlobalCache) -> ProofTreeBuilder<'tcx> {
|
pub fn new_root(disable_global_cache: DisableGlobalCache) -> ProofTreeBuilder<'tcx> {
|
||||||
ProofTreeBuilder::new(DebugSolver::Root, disable_global_cache)
|
ProofTreeBuilder::new(DebugSolver::Root, disable_global_cache)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user