@@ -3,9 +3,11 @@ use rustc_middle::traits::solve::inspect::{self, CacheHit, CandidateKind};
33use rustc_middle:: traits:: solve:: {
44 CanonicalInput , Certainty , Goal , IsNormalizesToHack , QueryInput , QueryResult ,
55} ;
6- use rustc_middle:: ty;
6+ use rustc_middle:: ty:: { self , TyCtxt } ;
7+ use rustc_session:: config:: SolverProofTreeCondition ;
78
89use super :: eval_ctxt:: DisableGlobalCache ;
10+ use super :: GenerateProofTree ;
911
1012#[ derive( Eq , PartialEq , Debug , Hash , HashStable ) ]
1113pub struct WipGoalEvaluation < ' tcx > {
@@ -173,6 +175,37 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
173175 self . disable_global_cache
174176 }
175177
178+ pub fn new_maybe_root (
179+ tcx : TyCtxt < ' tcx > ,
180+ generate_proof_tree : GenerateProofTree ,
181+ ) -> ProofTreeBuilder < ' tcx > {
182+ let generate_proof_tree = match (
183+ tcx. sess . opts . unstable_opts . dump_solver_proof_tree ,
184+ tcx. sess . opts . unstable_opts . dump_solver_proof_tree_use_cache ,
185+ generate_proof_tree,
186+ ) {
187+ ( _, Some ( use_cache) , GenerateProofTree :: Yes ( _) ) => {
188+ GenerateProofTree :: Yes ( DisableGlobalCache :: from_bool ( !use_cache) )
189+ }
190+
191+ ( SolverProofTreeCondition :: Always , use_cache, GenerateProofTree :: No ) => {
192+ let use_cache = use_cache. unwrap_or ( true ) ;
193+ GenerateProofTree :: Yes ( DisableGlobalCache :: from_bool ( !use_cache) )
194+ }
195+
196+ ( _, None , GenerateProofTree :: Yes ( _) ) => generate_proof_tree,
197+ ( SolverProofTreeCondition :: OnRequest , _, _) => generate_proof_tree,
198+ ( SolverProofTreeCondition :: OnError , _, _) => generate_proof_tree,
199+ } ;
200+
201+ match generate_proof_tree {
202+ GenerateProofTree :: No => ProofTreeBuilder :: new_noop ( ) ,
203+ GenerateProofTree :: Yes ( global_cache_disabled) => {
204+ ProofTreeBuilder :: new_root ( global_cache_disabled)
205+ }
206+ }
207+ }
208+
176209 pub fn new_root ( disable_global_cache : DisableGlobalCache ) -> ProofTreeBuilder < ' tcx > {
177210 ProofTreeBuilder :: new ( DebugSolver :: Root , disable_global_cache)
178211 }
0 commit comments