From b078ecefcde4d090ac2d365c5ee0d1314de7a341 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 13 Apr 2017 12:07:25 -0400 Subject: [PATCH] rewrite to pass a ref, not slice + index --- src/librustc_trans/context.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index f080cd3eccf..99ffd789286 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -266,10 +266,7 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> { /// pass around (SharedCrateContext, LocalCrateContext) tuples all over trans. pub struct CrateContext<'a, 'tcx: 'a> { shared: &'a SharedCrateContext<'a, 'tcx>, - local_ccxs: &'a [LocalCrateContext<'tcx>], - /// The index of `local` in `local_ccxs`. This is used in - /// `maybe_iter(true)` to identify the original `LocalCrateContext`. - index: usize, + local_ccx: &'a LocalCrateContext<'tcx>, } impl<'a, 'tcx> DepGraphSafe for CrateContext<'a, 'tcx> { @@ -298,8 +295,7 @@ impl<'a, 'tcx> Iterator for CrateContextIterator<'a,'tcx> { let ccx = CrateContext { shared: self.shared, - index: index, - local_ccxs: self.local_ccxs, + local_ccx: &self.local_ccxs[index], }; if @@ -630,8 +626,7 @@ impl<'tcx> LocalCrateContext<'tcx> { assert!(local_ccxs.len() == 1); CrateContext { shared: shared, - index: 0, - local_ccxs: local_ccxs + local_ccx: &local_ccxs[0] } } } @@ -642,7 +637,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { } fn local(&self) -> &'b LocalCrateContext<'tcx> { - &self.local_ccxs[self.index] + self.local_ccx } pub fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {