@@ -19,7 +19,9 @@ use rustc_middle::ty::{
19
19
self , OpaqueTypeKey , Ty , TyCtxt , TypeFoldable , TypeSuperVisitable , TypeVisitable ,
20
20
TypeVisitableExt , TypeVisitor ,
21
21
} ;
22
+ use rustc_session:: config:: DumpSolverProofTree ;
22
23
use rustc_span:: DUMMY_SP ;
24
+ use std:: io:: Write ;
23
25
use std:: ops:: ControlFlow ;
24
26
25
27
use crate :: traits:: specialization_graph;
@@ -113,9 +115,23 @@ impl NestedGoals<'_> {
113
115
114
116
#[ derive( PartialEq , Eq , Debug , Hash , HashStable , Clone , Copy ) ]
115
117
pub enum GenerateProofTree {
118
+ Yes ( UseGlobalCache ) ,
119
+ No ,
120
+ }
121
+
122
+ #[ derive( PartialEq , Eq , Debug , Hash , HashStable , Clone , Copy ) ]
123
+ pub enum UseGlobalCache {
116
124
Yes ,
117
125
No ,
118
126
}
127
+ impl UseGlobalCache {
128
+ pub fn from_bool ( use_cache : bool ) -> Self {
129
+ match use_cache {
130
+ true => UseGlobalCache :: Yes ,
131
+ false => UseGlobalCache :: No ,
132
+ }
133
+ }
134
+ }
119
135
120
136
pub trait InferCtxtEvalExt < ' tcx > {
121
137
/// Evaluates a goal from **outside** of the trait solver.
@@ -177,17 +193,17 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
177
193
var_values : CanonicalVarValues :: dummy ( ) ,
178
194
nested_goals : NestedGoals :: new ( ) ,
179
195
tainted : Ok ( ( ) ) ,
180
- inspect : ( infcx. tcx . sess . opts . unstable_opts . dump_solver_proof_tree
181
- || matches ! ( generate_proof_tree, GenerateProofTree :: Yes ) )
182
- . then ( ProofTreeBuilder :: new_root)
183
- . unwrap_or_else ( ProofTreeBuilder :: new_noop) ,
196
+ inspect : ProofTreeBuilder :: new_maybe_root ( infcx. tcx , generate_proof_tree) ,
184
197
} ;
185
198
let result = f ( & mut ecx) ;
186
199
187
200
let tree = ecx. inspect . finalize ( ) ;
188
- if let Some ( tree) = & tree {
189
- // module to allow more granular RUSTC_LOG filtering to just proof tree output
190
- super :: inspect:: dump:: print_tree ( tree) ;
201
+ if let ( Some ( tree) , DumpSolverProofTree :: Always ) =
202
+ ( & tree, infcx. tcx . sess . opts . unstable_opts . dump_solver_proof_tree )
203
+ {
204
+ let mut lock = std:: io:: stdout ( ) . lock ( ) ;
205
+ let _ = lock. write_fmt ( format_args ! ( "{tree:?}" ) ) ;
206
+ let _ = lock. flush ( ) ;
191
207
}
192
208
193
209
assert ! (
@@ -425,12 +441,8 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
425
441
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: WellFormed ( arg) ) => {
426
442
self . compute_well_formed_goal ( Goal { param_env, predicate : arg } )
427
443
}
428
- ty:: PredicateKind :: Ambiguous => {
429
- self . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
430
- }
431
- // FIXME: implement this predicate :)
432
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstEvaluatable ( _) ) => {
433
- self . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
444
+ ty:: PredicateKind :: Clause ( ty:: ClauseKind :: ConstEvaluatable ( ct) ) => {
445
+ self . compute_const_evaluatable_goal ( Goal { param_env, predicate : ct } )
434
446
}
435
447
ty:: PredicateKind :: ConstEquate ( _, _) => {
436
448
bug ! ( "ConstEquate should not be emitted when `-Ztrait-solver=next` is active" )
@@ -440,6 +452,9 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
440
452
param_env,
441
453
predicate : ( lhs, rhs, direction) ,
442
454
} ) ,
455
+ ty:: PredicateKind :: Ambiguous => {
456
+ self . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
457
+ }
443
458
}
444
459
} else {
445
460
let kind = self . infcx . instantiate_binder_with_placeholders ( kind) ;
0 commit comments