Skip to content

Commit c998057

Browse files
author
Ariel Ben-Yehuda
committed
add a global evaluation cache
1 parent 8943d5a commit c998057

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/librustc/middle/traits/select.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
659659
}
660660

661661
fn pick_evaluation_cache(&self) -> &EvaluationCache<'tcx> {
662-
&self.param_env().evaluation_cache
662+
// see comment in `pick_candidate_cache`
663+
if self.intercrate ||
664+
!self.param_env().caller_bounds.is_empty()
665+
{
666+
&self.param_env().evaluation_cache
667+
} else
668+
{
669+
&self.tcx().evaluation_cache
670+
}
663671
}
664672

665673
fn check_evaluation_cache(&self, trait_ref: ty::PolyTraitRef<'tcx>)

src/librustc/middle/ty/context.rs

+6
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ pub struct ctxt<'tcx> {
332332
/// for things that do not have to do with the parameters in scope.
333333
pub selection_cache: traits::SelectionCache<'tcx>,
334334

335+
/// Caches the results of trait evaluation. This cache is used
336+
/// for things that do not have to do with the parameters in scope.
337+
/// Merge this with `selection_cache`?
338+
pub evaluation_cache: traits::EvaluationCache<'tcx>,
339+
335340
/// A set of predicates that have been fulfilled *somewhere*.
336341
/// This is used to avoid duplicate work. Predicates are only
337342
/// added to this set when they mention only "global" names
@@ -512,6 +517,7 @@ impl<'tcx> ctxt<'tcx> {
512517
transmute_restrictions: RefCell::new(Vec::new()),
513518
stability: RefCell::new(stability),
514519
selection_cache: traits::SelectionCache::new(),
520+
evaluation_cache: traits::EvaluationCache::new(),
515521
repr_hint_cache: RefCell::new(DefIdMap()),
516522
const_qualif_map: RefCell::new(NodeMap()),
517523
custom_coerce_unsized_kinds: RefCell::new(DefIdMap()),

0 commit comments

Comments
 (0)