Skip to content

Commit 10be745

Browse files
committed
Create new CrateNum only after knowing it's going to succeed
1 parent 43a0686 commit 10be745

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/rustc_metadata/src/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ impl CStore {
167167

168168
fn intern_stable_crate_id(&mut self, root: &CrateRoot) -> Result<CrateNum, CrateError> {
169169
assert_eq!(self.metas.len(), self.stable_crate_ids.len());
170-
let num = CrateNum::new(self.stable_crate_ids.len());
171170
if let Some(&existing) = self.stable_crate_ids.get(&root.stable_crate_id()) {
172171
// Check for (potential) conflicts with the local crate
173172
if existing == LOCAL_CRATE {
@@ -181,6 +180,7 @@ impl CStore {
181180
}
182181
} else {
183182
self.metas.push(None);
183+
let num = CrateNum::new(self.stable_crate_ids.len());
184184
self.stable_crate_ids.insert(root.stable_crate_id(), num);
185185
Ok(num)
186186
}

0 commit comments

Comments
 (0)