Skip to content

Commit f872c47

Browse files
committed
Rename PkgId to CrateId
1 parent 4bc0971 commit f872c47

File tree

12 files changed

+100
-100
lines changed

12 files changed

+100
-100
lines changed

src/librustc/back/link.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use syntax::ast;
4141
use syntax::ast_map::{path, path_mod, path_name, path_pretty_name};
4242
use syntax::attr;
4343
use syntax::attr::AttrMetaMethods;
44-
use syntax::pkgid::PkgId;
44+
use syntax::crateid::CrateId;
4545

4646
#[deriving(Clone, Eq)]
4747
pub enum output_type {
@@ -444,13 +444,13 @@ pub mod write {
444444
*
445445
* So here is what we do:
446446
*
447-
* - Consider the package id; every crate has one (specified with pkgid
447+
* - Consider the package id; every crate has one (specified with crate_id
448448
* attribute). If a package id isn't provided explicitly, we infer a
449449
* versionless one from the output name. The version will end up being 0.0
450450
* in this case. CNAME and CVERS are taken from this package id. For
451451
* example, github.com/mozilla/CNAME#CVERS.
452452
*
453-
* - Define CMH as SHA256(pkgid).
453+
* - Define CMH as SHA256(crateid).
454454
*
455455
* - Define CMH8 as the first 8 characters of CMH.
456456
*
@@ -469,9 +469,9 @@ pub fn build_link_meta(sess: Session,
469469
symbol_hasher: &mut Sha256)
470470
-> LinkMeta {
471471
// This calculates CMH as defined above
472-
fn crate_hash(symbol_hasher: &mut Sha256, pkgid: &PkgId) -> @str {
472+
fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> @str {
473473
symbol_hasher.reset();
474-
symbol_hasher.input_str(pkgid.to_str());
474+
symbol_hasher.input_str(crateid.to_str());
475475
truncated_hash_result(symbol_hasher).to_managed()
476476
}
477477

@@ -487,10 +487,10 @@ pub fn build_link_meta(sess: Session,
487487
Some(s) => s,
488488
};
489489

490-
let hash = crate_hash(symbol_hasher, &pkgid);
490+
let hash = crate_hash(symbol_hasher, &crateid);
491491

492492
LinkMeta {
493-
pkgid: pkgid,
493+
crateid: crateid,
494494
crate_hash: hash,
495495
}
496496
}
@@ -509,7 +509,7 @@ pub fn symbol_hash(tcx: ty::ctxt,
509509
// to be independent of one another in the crate.
510510

511511
symbol_hasher.reset();
512-
symbol_hasher.input_str(link_meta.pkgid.name);
512+
symbol_hasher.input_str(link_meta.crateid.name);
513513
symbol_hasher.input_str("-");
514514
symbol_hasher.input_str(link_meta.crate_hash);
515515
symbol_hasher.input_str("-");
@@ -669,7 +669,7 @@ pub fn mangle_exported_name(ccx: &CrateContext,
669669
let hash = get_symbol_hash(ccx, t);
670670
return exported_name(ccx.sess, path,
671671
hash,
672-
ccx.link_meta.pkgid.version_or_default());
672+
ccx.link_meta.crateid.version_or_default());
673673
}
674674

675675
pub fn mangle_internal_name_by_type_only(ccx: &CrateContext,
@@ -710,9 +710,9 @@ pub fn mangle_internal_name_by_path(ccx: &CrateContext, path: path) -> ~str {
710710

711711
pub fn output_lib_filename(lm: &LinkMeta) -> ~str {
712712
format!("{}-{}-{}",
713-
lm.pkgid.name,
713+
lm.crateid.name,
714714
lm.crate_hash.slice_chars(0, 8),
715-
lm.pkgid.version_or_default())
715+
lm.crateid.version_or_default())
716716
}
717717

718718
pub fn get_cc_prog(sess: Session) -> ~str {

src/librustc/metadata/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use std::cast;
12-
use syntax::pkgid::PkgId;
12+
use syntax::crateid::CrateId;
1313

1414
// EBML enum definitions and utils shared by the encoder and decoder
1515

@@ -206,6 +206,6 @@ pub static tag_native_libraries_kind: uint = 0x106;
206206

207207
#[deriving(Clone)]
208208
pub struct LinkMeta {
209-
pkgid: PkgId,
209+
crateid: CrateId,
210210
crate_hash: @str,
211211
}

src/librustc/metadata/creader.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use syntax::codemap::{Span, dummy_sp};
2525
use syntax::diagnostic::span_handler;
2626
use syntax::parse::token;
2727
use syntax::parse::token::ident_interner;
28-
use syntax::pkgid::PkgId;
28+
use syntax::crateid::CrateId;
2929
use syntax::visit;
3030

3131
// Traverses an AST, reading all the information about use'd crates and extern
@@ -73,7 +73,7 @@ struct cache_entry {
7373
cnum: ast::CrateNum,
7474
span: Span,
7575
hash: @str,
76-
pkgid: PkgId,
76+
crateid: CrateId,
7777
}
7878

7979
fn dump_crates(crate_cache: &[cache_entry]) {
@@ -89,10 +89,10 @@ fn warn_if_multiple_versions(e: &mut Env,
8989
diag: @mut span_handler,
9090
crate_cache: &[cache_entry]) {
9191
if crate_cache.len() != 0u {
92-
let name = crate_cache[crate_cache.len() - 1].pkgid.name.clone();
92+
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
9393

9494
let (matches, non_matches) = crate_cache.partitioned(|entry|
95-
name == entry.pkgid.name);
95+
name == entry.crateid.name);
9696

9797
assert!(!matches.is_empty());
9898

@@ -101,7 +101,7 @@ fn warn_if_multiple_versions(e: &mut Env,
101101
format!("using multiple versions of crate `{}`", name));
102102
for match_ in matches.iter() {
103103
diag.span_note(match_.span, "used here");
104-
loader::note_pkgid_attr(diag, &match_.pkgid);
104+
loader::note_crateid_attr(diag, &match_.crateid);
105105
}
106106
}
107107

@@ -138,7 +138,7 @@ fn visit_view_item(e: &mut Env, i: &ast::view_item) {
138138
ident, path_opt);
139139
let (name, version) = match path_opt {
140140
Some((path_str, _)) => {
141-
let crateid: Option<PkgId> = from_str(path_str);
141+
let crateid: Option<CrateId> = from_str(path_str);
142142
match crateid {
143143
None => (@"", @""),
144144
Some(crateid) => {
@@ -245,12 +245,12 @@ fn visit_item(e: &Env, i: @ast::item) {
245245
fn existing_match(e: &Env, name: @str, version: @str, hash: &str) -> Option<ast::CrateNum> {
246246
let crate_cache = e.crate_cache.borrow();
247247
for c in crate_cache.get().iter() {
248-
let pkgid_version = match c.pkgid.version {
248+
let crateid_version = match c.crateid.version {
249249
None => @"0.0",
250250
Some(ref ver) => ver.to_managed(),
251251
};
252-
if (name.is_empty() || c.pkgid.name.to_managed() == name) &&
253-
(version.is_empty() || pkgid_version == version) &&
252+
if (name.is_empty() || c.crateid.name.to_managed() == name) &&
253+
(version.is_empty() || crateid_version == version) &&
254254
(hash.is_empty() || c.hash.as_slice() == hash) {
255255
return Some(c.cnum);
256256
}
@@ -293,7 +293,7 @@ fn resolve_crate(e: &mut Env,
293293
cnum: cnum,
294294
span: span,
295295
hash: hash,
296-
pkgid: pkgid,
296+
crateid: crateid,
297297
});
298298
}
299299
e.next_crate_num += 1;

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ pub fn get_crate_vers(data: &[u8]) -> @str {
11751175
let attrs = decoder::get_crate_attributes(data);
11761176
match attr::find_crateid(attrs) {
11771177
None => @"0.0",
1178-
Some(pkgid) => pkgid.version_or_default().to_managed(),
1178+
Some(crateid) => crateid.version_or_default().to_managed(),
11791179
}
11801180
}
11811181

src/librustc/metadata/encoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,19 +1559,19 @@ fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[Attribute]) {
15591559
ebml_w.end_tag();
15601560
}
15611561

1562-
// So there's a special crate attribute called 'pkgid' which defines the
1562+
// So there's a special crate attribute called 'crate_id' which defines the
15631563
// metadata that Rust cares about for linking crates. If the user didn't
15641564
// provide it we will throw it in anyway with a default value.
15651565
fn synthesize_crate_attrs(ecx: &EncodeContext,
15661566
crate: &Crate) -> ~[Attribute] {
15671567

1568-
fn synthesize_pkgid_attr(ecx: &EncodeContext) -> Attribute {
1569-
assert!(!ecx.link_meta.pkgid.name.is_empty());
1568+
fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute {
1569+
assert!(!ecx.link_meta.crateid.name.is_empty());
15701570

15711571
attr::mk_attr(
15721572
attr::mk_name_value_item_str(
15731573
@"crate_id",
1574-
ecx.link_meta.pkgid.to_str().to_managed()))
1574+
ecx.link_meta.crateid.to_str().to_managed()))
15751575
}
15761576

15771577
let mut attrs = ~[];
@@ -1580,7 +1580,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext,
15801580
attrs.push(*attr);
15811581
}
15821582
}
1583-
attrs.push(synthesize_pkgid_attr(ecx));
1583+
attrs.push(synthesize_crateid_attr(ecx));
15841584

15851585
attrs
15861586
}

src/librustc/metadata/loader.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use metadata::filesearch;
2121
use syntax::codemap::Span;
2222
use syntax::diagnostic::span_handler;
2323
use syntax::parse::token::ident_interner;
24-
use syntax::pkgid::PkgId;
24+
use syntax::crateid::CrateId;
2525
use syntax::attr;
2626
use syntax::attr::AttrMetaMethods;
2727

@@ -112,7 +112,7 @@ impl Context {
112112
Some(cvec) =>
113113
if crate_matches(cvec.as_slice(), self.name,
114114
self.version, self.hash) {
115-
debug!("found {} with matching pkgid",
115+
debug!("found {} with matching crate_id",
116116
path.display());
117117
let (rlib, dylib) = if file.ends_with(".rlib") {
118118
(Some(path.clone()), None)
@@ -126,7 +126,7 @@ impl Context {
126126
});
127127
FileMatches
128128
} else {
129-
debug!("skipping {}, pkgid doesn't match",
129+
debug!("skipping {}, crate_id doesn't match",
130130
path.display());
131131
FileDoesntMatch
132132
},
@@ -167,8 +167,8 @@ impl Context {
167167
let attrs = decoder::get_crate_attributes(data);
168168
match attr::find_crateid(attrs) {
169169
None => {}
170-
Some(pkgid) => {
171-
note_pkgid_attr(self.sess.diagnostic(), &pkgid);
170+
Some(crateid) => {
171+
note_crateid_attr(self.sess.diagnostic(), &crateid);
172172
}
173173
}
174174
}
@@ -231,9 +231,9 @@ impl Context {
231231
}
232232
}
233233

234-
pub fn note_pkgid_attr(diag: @mut span_handler,
235-
pkgid: &PkgId) {
236-
diag.handler().note(format!("pkgid: {}", pkgid.to_str()));
234+
pub fn note_crateid_attr(diag: @mut span_handler,
235+
crateid: &CrateId) {
236+
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
237237
}
238238

239239
fn crate_matches(crate_data: &[u8],
@@ -243,13 +243,13 @@ fn crate_matches(crate_data: &[u8],
243243
let attrs = decoder::get_crate_attributes(crate_data);
244244
match attr::find_crateid(attrs) {
245245
None => false,
246-
Some(pkgid) => {
246+
Some(crateid) => {
247247
if !hash.is_empty() {
248248
let chash = decoder::get_crate_hash(crate_data);
249249
if chash != hash { return false; }
250250
}
251-
name == pkgid.name.to_managed() &&
252-
(version.is_empty() || version == pkgid.version_or_default().to_managed())
251+
name == crateid.name.to_managed() &&
252+
(version.is_empty() || version == crateid.version_or_default().to_managed())
253253
}
254254
}
255255
}

src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,8 +3048,8 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
30483048
let sym_name = if is_top {
30493049
~"_rust_crate_map_toplevel"
30503050
} else {
3051-
symname(sess, "_rust_crate_map_" + mapmeta.pkgid.name, mapmeta.crate_hash,
3052-
mapmeta.pkgid.version_or_default())
3051+
symname(sess, "_rust_crate_map_" + mapmeta.crateid.name, mapmeta.crate_hash,
3052+
mapmeta.crateid.version_or_default())
30533053
};
30543054

30553055
let slicetype = Type::struct_([int_type, int_type], false);
@@ -3168,8 +3168,8 @@ pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] {
31683168
flate::deflate_bytes(metadata);
31693169
let llmeta = C_bytes(compressed);
31703170
let llconst = C_struct([llmeta], false);
3171-
let name = format!("rust_metadata_{}_{}_{}", cx.link_meta.pkgid.name,
3172-
cx.link_meta.pkgid.version_or_default(), cx.link_meta.crate_hash);
3171+
let name = format!("rust_metadata_{}_{}_{}", cx.link_meta.crateid.name,
3172+
cx.link_meta.crateid.version_or_default(), cx.link_meta.crate_hash);
31733173
let llglobal = name.with_c_str(|buf| {
31743174
unsafe {
31753175
llvm::LLVMAddGlobal(cx.metadata_llmod, val_ty(llconst).to_ref(), buf)
@@ -3205,7 +3205,7 @@ pub fn trans_crate(sess: session::Session,
32053205
// crashes if the module identifer is same as other symbols
32063206
// such as a function name in the module.
32073207
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
3208-
let llmod_id = link_meta.pkgid.name.clone() + ".rc";
3208+
let llmod_id = link_meta.crateid.name.clone() + ".rc";
32093209

32103210
let ccx = @CrateContext::new(sess,
32113211
llmod_id,

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2827,7 +2827,7 @@ fn namespace_for_item(cx: &CrateContext,
28272827

28282828
if def_id.crate == ast::LOCAL_CRATE {
28292829
// prepend crate name if not already present
2830-
let crate_namespace_ident = token::str_to_ident(cx.link_meta.pkgid.name);
2830+
let crate_namespace_ident = token::str_to_ident(cx.link_meta.crateid.name);
28312831
item_path.insert(0, ast_map::path_mod(crate_namespace_ident));
28322832
}
28332833

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ pub fn trans_log_level(bcx: @Block) -> DatumBlock {
18551855
Some(&src) => {
18561856
ccx.sess.cstore.get_crate_data(src.crate).name
18571857
}
1858-
None => ccx.link_meta.pkgid.name.to_managed(),
1858+
None => ccx.link_meta.crateid.name.to_managed(),
18591859
};
18601860
};
18611861
let mut modpath = ~[path_mod(ccx.sess.ident_of(srccrate))];

src/libsyntax/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use codemap::{Span, Spanned, spanned, dummy_spanned};
1616
use codemap::BytePos;
1717
use diagnostic::span_handler;
1818
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
19-
use pkgid::PkgId;
19+
use crateid::CrateId;
2020

2121
use std::hashmap::HashSet;
2222

0 commit comments

Comments
 (0)