Re-use memory in program_clauses_for_env

This commit is contained in:
scalexm 2018-10-13 17:10:56 +02:00
parent 7ec8269d0a
commit 55ce7a2669
2 changed files with 5 additions and 8 deletions

View File

@ -1424,15 +1424,12 @@ impl_stable_hash_for!(enum traits::QuantifierKind {
Existential
});
<<<<<<< HEAD
impl_stable_hash_for!(struct ty::subst::UserSubsts<'tcx> { substs, user_self_ty });
impl_stable_hash_for!(struct ty::subst::UserSelfTy<'tcx> { impl_def_id, self_ty });
=======
impl_stable_hash_for!(
impl<'tcx> for struct traits::Environment<'tcx> {
clauses,
}
);
>>>>>>> Use `Environment` instead of `ty::ParamEnv` in chalk context

View File

@ -21,7 +21,7 @@ use rustc::ty::{self, TyCtxt, Ty};
use rustc::hir::def_id::DefId;
use rustc_data_structures::fx::FxHashSet;
struct ClauseVisitor<'set, 'a, 'tcx: 'a> {
struct ClauseVisitor<'set, 'a, 'tcx: 'a + 'set> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
round: &'set mut FxHashSet<Clause<'tcx>>,
}
@ -154,12 +154,12 @@ crate fn program_clauses_for_env<'a, 'tcx>(
let mut next_round = FxHashSet();
while !last_round.is_empty() {
let mut visitor = ClauseVisitor::new(tcx, &mut next_round);
for clause in last_round {
for clause in last_round.drain() {
visitor.visit_clause(clause);
}
last_round = next_round.drain()
.filter(|&clause| closure.insert(clause))
.collect();
last_round.extend(
next_round.drain().filter(|&clause| closure.insert(clause))
);
}
debug!("program_clauses_for_env: closure = {:#?}", closure);