1
Fork 0

rewrite to pass a ref, not slice + index

This commit is contained in:
Niko Matsakis 2017-04-13 12:07:25 -04:00
parent 15507bcb64
commit b078ecefcd

View file

@ -266,10 +266,7 @@ impl<'a, 'tcx: 'a> CrateContextList<'a, 'tcx> {
/// pass around (SharedCrateContext, LocalCrateContext) tuples all over trans. /// pass around (SharedCrateContext, LocalCrateContext) tuples all over trans.
pub struct CrateContext<'a, 'tcx: 'a> { pub struct CrateContext<'a, 'tcx: 'a> {
shared: &'a SharedCrateContext<'a, 'tcx>, shared: &'a SharedCrateContext<'a, 'tcx>,
local_ccxs: &'a [LocalCrateContext<'tcx>], local_ccx: &'a LocalCrateContext<'tcx>,
/// The index of `local` in `local_ccxs`. This is used in
/// `maybe_iter(true)` to identify the original `LocalCrateContext`.
index: usize,
} }
impl<'a, 'tcx> DepGraphSafe for CrateContext<'a, 'tcx> { impl<'a, 'tcx> DepGraphSafe for CrateContext<'a, 'tcx> {
@ -298,8 +295,7 @@ impl<'a, 'tcx> Iterator for CrateContextIterator<'a,'tcx> {
let ccx = CrateContext { let ccx = CrateContext {
shared: self.shared, shared: self.shared,
index: index, local_ccx: &self.local_ccxs[index],
local_ccxs: self.local_ccxs,
}; };
if if
@ -630,8 +626,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
assert!(local_ccxs.len() == 1); assert!(local_ccxs.len() == 1);
CrateContext { CrateContext {
shared: shared, shared: shared,
index: 0, local_ccx: &local_ccxs[0]
local_ccxs: local_ccxs
} }
} }
} }
@ -642,7 +637,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
} }
fn local(&self) -> &'b LocalCrateContext<'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> { pub fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> {