From 4537025c7193b4f1412807ab15f723f51ff0b01e Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 9 May 2018 21:32:18 +0200 Subject: [PATCH] Add comment about first element in CStore::metas. --- src/librustc_metadata/cstore.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index 4872d560d27f0..0c54ec7c27ab2 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -96,6 +96,10 @@ pub struct CStore { impl CStore { pub fn new(metadata_loader: Box) -> CStore { CStore { + // We add an empty entry for LOCAL_CRATE (which maps to zero) in + // order to make array indices in `metas` match with the + // corresponding `CrateNum`. This first entry will always remain + // `None`. metas: RwLock::new(IndexVec::from_elem_n(None, 1)), extern_mod_crate_map: Lock::new(FxHashMap()), metadata_loader,