Create new CrateNum
only after knowing it's going to succeed
This commit is contained in:
parent
43a0686f8d
commit
10be74569c
@ -167,7 +167,6 @@ pub fn from_tcx_mut(tcx: TyCtxt<'_>) -> FreezeWriteGuard<'_, CStore> {
|
||||
|
||||
fn intern_stable_crate_id(&mut self, root: &CrateRoot) -> Result<CrateNum, CrateError> {
|
||||
assert_eq!(self.metas.len(), self.stable_crate_ids.len());
|
||||
let num = CrateNum::new(self.stable_crate_ids.len());
|
||||
if let Some(&existing) = self.stable_crate_ids.get(&root.stable_crate_id()) {
|
||||
// Check for (potential) conflicts with the local crate
|
||||
if existing == LOCAL_CRATE {
|
||||
@ -181,6 +180,7 @@ fn intern_stable_crate_id(&mut self, root: &CrateRoot) -> Result<CrateNum, Crate
|
||||
}
|
||||
} else {
|
||||
self.metas.push(None);
|
||||
let num = CrateNum::new(self.stable_crate_ids.len());
|
||||
self.stable_crate_ids.insert(root.stable_crate_id(), num);
|
||||
Ok(num)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user