From 55ce7a266958aaed4774927ed1765576f561aa2d Mon Sep 17 00:00:00 2001 From: scalexm Date: Sat, 13 Oct 2018 17:10:56 +0200 Subject: [PATCH] Re-use memory in `program_clauses_for_env` --- src/librustc/ich/impls_ty.rs | 3 --- src/librustc_traits/lowering/environment.rs | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 36c0f30f0bf1..43448ad0d15a 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -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 diff --git a/src/librustc_traits/lowering/environment.rs b/src/librustc_traits/lowering/environment.rs index f0ce2037723a..3d1e7cf17a65 100644 --- a/src/librustc_traits/lowering/environment.rs +++ b/src/librustc_traits/lowering/environment.rs @@ -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>, } @@ -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);