@@ -3,9 +3,11 @@ use rustc_middle::traits::solve::inspect::{self, CacheHit, CandidateKind};
3
3
use rustc_middle:: traits:: solve:: {
4
4
CanonicalInput , Certainty , Goal , IsNormalizesToHack , QueryInput , QueryResult ,
5
5
} ;
6
- use rustc_middle:: ty;
6
+ use rustc_middle:: ty:: { self , TyCtxt } ;
7
+ use rustc_session:: config:: SolverProofTreeCondition ;
7
8
8
9
use super :: eval_ctxt:: DisableGlobalCache ;
10
+ use super :: GenerateProofTree ;
9
11
10
12
#[ derive( Eq , PartialEq , Debug , Hash , HashStable ) ]
11
13
pub struct WipGoalEvaluation < ' tcx > {
@@ -173,6 +175,37 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
173
175
self . disable_global_cache
174
176
}
175
177
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
+
176
209
pub fn new_root ( disable_global_cache : DisableGlobalCache ) -> ProofTreeBuilder < ' tcx > {
177
210
ProofTreeBuilder :: new ( DebugSolver :: Root , disable_global_cache)
178
211
}
0 commit comments