rustc: Don't allocate a cnum to syntax crates

Syntax-only crates are no longer registered with the cstore, so there's no need
to allocate crate numbers to them. This ends up leaving gaps in the crate
numbering scheme which is not expected in the rest of the compiler.

Closes #13560
This commit is contained in:
Alex Crichton 2014-04-16 11:42:22 -07:00
parent 12391df5b7
commit 4ba94e2c24
5 changed files with 79 additions and 4 deletions

View file

@ -300,10 +300,6 @@ fn resolve_crate<'a>(e: &mut Env,
dylib, rlib, metadata
} = load_ctxt.load_library_crate(root);
// Claim this crate number and cache it
let cnum = e.next_crate_num;
e.next_crate_num += 1;
// Stash paths for top-most crate locally if necessary.
let crate_paths = if root.is_none() {
Some(CratePaths {
@ -324,6 +320,17 @@ fn resolve_crate<'a>(e: &mut Env,
@RefCell::new(HashMap::new())
};
// Claim this crate number and cache it if we're linking to the
// crate, otherwise it's a syntax-only crate and we don't need to
// reserve a number
let cnum = if should_link {
let n = e.next_crate_num;
e.next_crate_num += 1;
n
} else {
-1
};
let cmeta = @cstore::crate_metadata {
name: load_ctxt.crate_id.name.to_owned(),
data: metadata,