Skip to content

Commit f37b746

Browse files
committed
auto merge of #11182 : luisbg/rust/crateid, r=cmr
Issue #11048
2 parents ac0c376 + 51b5f32 commit f37b746

31 files changed

+432
-430
lines changed

doc/rust.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ the behavior of the compiler.
610610

611611
~~~~
612612
// Package ID
613-
#[ pkgid = "projx#2.5" ];
613+
#[ crate_id = "projx#2.5" ];
614614
615615
// Additional metadata attributes
616616
#[ desc = "Project X" ];
@@ -776,9 +776,9 @@ as the `ident` provided in the `extern_mod_decl`.
776776
The external crate is resolved to a specific `soname` at compile time, and a
777777
runtime linkage requirement to that `soname` is passed to the linker for
778778
loading at runtime. The `soname` is resolved at compile time by scanning the
779-
compiler's library path and matching the optional `pkgid` provided as a string literal
780-
against the `pkgid` attributes that were declared on the external crate when
781-
it was compiled. If no `pkgid` is provided, a default `name` attribute is
779+
compiler's library path and matching the optional `crateid` provided as a string literal
780+
against the `crateid` attributes that were declared on the external crate when
781+
it was compiled. If no `crateid` is provided, a default `name` attribute is
782782
assumed, equal to the `ident` given in the `extern_mod_decl`.
783783

784784
Four examples of `extern mod` declarations:
@@ -1729,7 +1729,7 @@ names are effectively reserved. Some significant attributes include:
17291729
* The `cfg` attribute, for conditional-compilation by build-configuration.
17301730
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
17311731
* The `link` attribute, for describing linkage metadata for a extern blocks.
1732-
* The `pkgid` attribute, for describing the package ID of a crate.
1732+
* The `crate_id` attribute, for describing the package ID of a crate.
17331733
* The `test` attribute, for marking functions as unit tests.
17341734
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
17351735
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
@@ -3792,7 +3792,7 @@ specified then log level 4 is assumed. Debug messages can be omitted
37923792
by passing `--cfg ndebug` to `rustc`.
37933793

37943794
As an example, to see all the logs generated by the compiler, you would set
3795-
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `pkgid`
3795+
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `crate_id`
37963796
[attribute](#attributes)). To narrow down the logs to just crate resolution,
37973797
you would set it to `rustc::metadata::creader`. To see just error logging
37983798
use `rustc=0`.

doc/rustdoc.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ comments":
1313
~~~
1414
// the "link" crate attribute is currently required for rustdoc, but normally
1515
// isn't needed.
16-
#[pkgid = "universe"];
16+
#[crate_id = "universe"];
1717
#[crate_type="lib"];
1818
1919
//! Tools for dealing with universes (this is a doc comment, and is shown on

doc/rustpkg.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ then both `bar` and `bar/extras/baz` are valid package identifiers
9090
in the workspace `foo`.
9191

9292
Because rustpkg uses generic source file names as the main inputs, you will
93-
need to specify the package identifier in them using the `pkgid` attribute
93+
need to specify the package identifier in them using the `crate_id` attribute
9494
on the crate.
9595

9696
## Source files

src/etc/combine-tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def scrub(b):
4545
"""
4646
// AUTO-GENERATED FILE: DO NOT EDIT
4747
#[crate_id=\"run_pass_stage2#0.1\"];
48-
#[pkgid=\"run_pass_stage2#0.1\"];
48+
#[crate_id=\"run_pass_stage2#0.1\"];
4949
#[feature(globs, macro_rules, struct_variant, managed_boxes)];
5050
#[allow(warnings)];
5151
"""

src/librustc/back/link.rs

+12-12
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,13 +469,13 @@ 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

478-
let pkgid = match attr::find_pkgid(attrs) {
478+
let crateid = match attr::find_crateid(attrs) {
479479
None => {
480480
let stem = session::expect(
481481
sess,
@@ -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/driver/driver.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1030,12 +1030,12 @@ pub fn build_output_filenames(input: &input,
10301030
str_input(_) => @"rust_out"
10311031
};
10321032

1033-
// If a pkgid is present, we use it as the link name
1034-
let pkgid = attr::find_pkgid(attrs);
1035-
match pkgid {
1033+
// If a crateid is present, we use it as the link name
1034+
let crateid = attr::find_crateid(attrs);
1035+
match crateid {
10361036
None => {}
1037-
Some(pkgid) => {
1038-
stem = pkgid.name.to_managed()
1037+
Some(crateid) => {
1038+
stem = crateid.name.to_managed()
10391039
}
10401040
}
10411041

src/librustc/front/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item {
384384
}
385385

386386
fn is_extra(crate: &ast::Crate) -> bool {
387-
match attr::find_pkgid(crate.attrs) {
387+
match attr::find_crateid(crate.attrs) {
388388
Some(ref s) if "extra" == s.name => true,
389389
_ => false
390390
}

src/librustc/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,18 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
292292
let t_outputs = d::build_output_filenames(&input, &odir, &ofile,
293293
attrs, sess);
294294
if crate_id || crate_name {
295-
let pkgid = match attr::find_pkgid(attrs) {
296-
Some(pkgid) => pkgid,
295+
let crateid = match attr::find_crateid(attrs) {
296+
Some(crateid) => crateid,
297297
None => {
298298
sess.fatal("No crate_id and --crate-id or \
299299
--crate-name requested")
300300
}
301301
};
302302
if crate_id {
303-
println(pkgid.to_str());
303+
println(crateid.to_str());
304304
}
305305
if crate_name {
306-
println(pkgid.name);
306+
println(crateid.name);
307307
}
308308
}
309309

src/librustc/metadata/common.rs

+2-2
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

+15-15
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,15 +138,15 @@ 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 pkgid: Option<PkgId> = from_str(path_str);
142-
match pkgid {
141+
let crateid: Option<CrateId> = from_str(path_str);
142+
match crateid {
143143
None => (@"", @""),
144-
Some(pkgid) => {
145-
let version = match pkgid.version {
144+
Some(crateid) => {
145+
let version = match crateid.version {
146146
None => @"",
147147
Some(ref ver) => ver.to_managed(),
148148
};
149-
(pkgid.name.to_managed(), version)
149+
(crateid.name.to_managed(), version)
150150
}
151151
}
152152
}
@@ -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
}
@@ -282,7 +282,7 @@ fn resolve_crate(e: &mut Env,
282282
} = load_ctxt.load_library_crate();
283283

284284
let attrs = decoder::get_crate_attributes(metadata.as_slice());
285-
let pkgid = attr::find_pkgid(attrs).unwrap();
285+
let crateid = attr::find_crateid(attrs).unwrap();
286286
let hash = decoder::get_crate_hash(metadata.as_slice());
287287

288288
// Claim this crate number and cache it
@@ -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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,9 @@ pub fn get_crate_hash(data: &[u8]) -> @str {
11731173

11741174
pub fn get_crate_vers(data: &[u8]) -> @str {
11751175
let attrs = decoder::get_crate_attributes(data);
1176-
match attr::find_pkgid(attrs) {
1176+
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

+5-5
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
}

0 commit comments

Comments
 (0)