From dee110757121bfc033dd1e6e2ed6a0a86a3f0a58 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Tue, 17 Dec 2013 16:40:33 -0500 Subject: [PATCH 1/2] Rename pkgid to crate_id Closes #11035 --- src/etc/combine-tests.py | 1 + src/libextra/lib.rs | 2 ++ src/librustc/lib.rs | 2 ++ src/librustc/metadata/encoder.rs | 4 ++-- src/librustc/middle/lint.rs | 3 ++- src/librustdoc/lib.rs | 2 ++ src/librustpkg/lib.rs | 2 ++ src/librustpkg/tests.rs | 6 +++--- src/librustpkg/util.rs | 4 ++-- src/librustuv/lib.rs | 2 ++ src/libstd/lib.rs | 2 ++ src/libsyntax/attr.rs | 2 +- src/libsyntax/lib.rs | 2 ++ src/test/auxiliary/anon-extern-mod-cross-crate-1.rs | 2 +- src/test/auxiliary/cci_impl_lib.rs | 2 +- src/test/auxiliary/cci_iter_lib.rs | 2 +- src/test/auxiliary/cci_no_inline_lib.rs | 2 +- src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs | 2 +- src/test/auxiliary/crateresolve1-1.rs | 2 +- src/test/auxiliary/crateresolve1-2.rs | 2 +- src/test/auxiliary/crateresolve1-3.rs | 2 +- src/test/auxiliary/crateresolve2-1.rs | 2 +- src/test/auxiliary/crateresolve2-2.rs | 2 +- src/test/auxiliary/crateresolve2-3.rs | 2 +- src/test/auxiliary/crateresolve3-1.rs | 2 +- src/test/auxiliary/crateresolve3-2.rs | 2 +- src/test/auxiliary/crateresolve4a-1.rs | 2 +- src/test/auxiliary/crateresolve4a-2.rs | 2 +- src/test/auxiliary/crateresolve4b-1.rs | 2 +- src/test/auxiliary/crateresolve4b-2.rs | 2 +- src/test/auxiliary/crateresolve5-1.rs | 2 +- src/test/auxiliary/crateresolve5-2.rs | 2 +- src/test/auxiliary/crateresolve8-1.rs | 2 +- src/test/auxiliary/crateresolve_calories-1.rs | 2 +- src/test/auxiliary/crateresolve_calories-2.rs | 2 +- src/test/auxiliary/extern-crosscrate-source.rs | 2 +- src/test/auxiliary/foreign_lib.rs | 2 +- src/test/auxiliary/inline_dtor.rs | 2 +- src/test/auxiliary/iss.rs | 2 +- src/test/auxiliary/issue-2380.rs | 2 +- src/test/auxiliary/issue-2414-a.rs | 2 +- src/test/auxiliary/issue-2414-b.rs | 2 +- src/test/auxiliary/issue-2526.rs | 2 +- src/test/auxiliary/issue-2631-a.rs | 2 +- src/test/auxiliary/issue-3012-1.rs | 2 +- src/test/auxiliary/issue-4208-cc.rs | 2 +- src/test/auxiliary/issue_2242_a.rs | 2 +- src/test/auxiliary/issue_2242_c.rs | 2 +- src/test/auxiliary/issue_3979_traits.rs | 2 +- src/test/auxiliary/lint_stability.rs | 2 +- src/test/auxiliary/static-function-pointer-aux.rs | 2 +- src/test/auxiliary/static-methods-crate.rs | 2 +- src/test/auxiliary/struct_variant_xc_aux.rs | 2 +- src/test/auxiliary/trait_default_method_xc_aux.rs | 2 +- src/test/run-make/bootstrap-from-c-with-uvio/lib.rs | 2 +- src/test/run-make/dep-info/lib.rs | 2 +- src/test/run-pass/crateresolve8.rs | 2 +- src/test/run-pass/issue-1251.rs | 2 +- src/test/run-pass/issue-6919.rs | 2 +- src/test/run-pass/item-attributes.rs | 2 +- 60 files changed, 72 insertions(+), 56 deletions(-) diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index 5ada1bfa630..ce788f06c38 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -44,6 +44,7 @@ i = 0 c.write( """ // AUTO-GENERATED FILE: DO NOT EDIT +#[crate_id=\"run_pass_stage2#0.1\"]; #[pkgid=\"run_pass_stage2#0.1\"]; #[link(name=\"run_pass_stage2\", vers=\"0.1\")]; #[feature(globs, macro_rules, struct_variant, managed_boxes)]; diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs index 8e739809b87..82ca4d65b23 100644 --- a/src/libextra/lib.rs +++ b/src/libextra/lib.rs @@ -20,7 +20,9 @@ */ +// NOTE: remove after snapshot #[pkgid = "extra#0.9-pre"]; +#[crate_id = "extra#0.9-pre"]; #[comment = "Rust extras"]; #[license = "MIT/ASL2"]; #[crate_type = "rlib"]; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index c5be6776eef..f0bff76685f 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// NOTE: remove after snapshot #[pkgid = "rustc#0.9-pre"]; +#[crate_id = "rustc#0.9-pre"]; #[comment = "The Rust compiler"]; #[license = "MIT/ASL2"]; #[crate_type = "dylib"]; diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index b27aa11651d..8d8c246f2ca 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1499,13 +1499,13 @@ fn synthesize_pkgid_attr(ecx: &EncodeContext) -> Attribute { attr::mk_attr( attr::mk_name_value_item_str( - @"pkgid", + @"crate_id", ecx.link_meta.pkgid.to_str().to_managed())) } let mut attrs = ~[]; for attr in crate.attrs.iter() { - if "pkgid" != attr.name() { + if "crate_id" != attr.name() { attrs.push(*attr); } } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 8f5ae723c54..bdf4c550378 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -832,7 +832,8 @@ fn check_heap_item(cx: &Context, it: &ast::item) { } static crate_attrs: &'static [&'static str] = &[ - "crate_type", "feature", "no_uv", "no_main", "no_std", "pkgid", +// NOTE: remove pkgid after snapshot + "crate_type", "feature", "no_uv", "no_main", "no_std", "pkgid", "crate_id", "desc", "comment", "license", "copyright", // not used in rustc now ]; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 0727c04f44e..3645161ee1c 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// NOTE: remove after snapshot #[pkgid = "rustdoc#0.9-pre"]; +#[crate_id = "rustdoc#0.9-pre"]; #[desc = "rustdoc, the Rust documentation extractor"]; #[license = "MIT/ASL2"]; #[crate_type = "dylib"]; diff --git a/src/librustpkg/lib.rs b/src/librustpkg/lib.rs index 14c5966aabd..9dbddf78818 100644 --- a/src/librustpkg/lib.rs +++ b/src/librustpkg/lib.rs @@ -10,7 +10,9 @@ // rustpkg - a package manager and build system for Rust +// NOTE: remove after snapshot #[pkgid = "rustpkg#0.9-pre"]; +#[crate_id = "rustpkg#0.9-pre"]; #[license = "MIT/ASL2"]; #[crate_type = "dylib"]; diff --git a/src/librustpkg/tests.rs b/src/librustpkg/tests.rs index 28bf8deb5a7..ecf08df5f18 100644 --- a/src/librustpkg/tests.rs +++ b/src/librustpkg/tests.rs @@ -1892,9 +1892,9 @@ fn pkgid_pointing_to_subdir() { fs::mkdir_recursive(&foo_dir, io::UserRWX); fs::mkdir_recursive(&bar_dir, io::UserRWX); writeFile(&foo_dir.join("lib.rs"), - "#[pkgid=\"mockgithub.com/mozilla/some_repo/extras/foo\"]; pub fn f() {}"); + "#[crate_id=\"mockgithub.com/mozilla/some_repo/extras/foo\"]; pub fn f() {}"); writeFile(&bar_dir.join("lib.rs"), - "#[pkgid=\"mockgithub.com/mozilla/some_repo/extras/bar\"]; pub fn g() {}"); + "#[crate_id=\"mockgithub.com/mozilla/some_repo/extras/bar\"]; pub fn g() {}"); debug!("Creating a file in {}", workspace.display()); let testpkg_dir = workspace.join_many(["src", "testpkg-0.0"]); @@ -2316,7 +2316,7 @@ fn find_sources_in_cwd() { let source_dir = temp_dir.join("foo"); fs::mkdir_recursive(&source_dir, io::UserRWX); writeFile(&source_dir.join("main.rs"), - "fn main() { let _x = (); }"); + r#"#[crate_id="foo"]; fn main() { let _x = (); }"#); command_line_test([~"install", ~"foo"], &source_dir); assert_executable_exists(&source_dir.join(".rust"), "foo"); } diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index 296021204bf..7a68ae8b15c 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -291,10 +291,10 @@ pub fn compile_input(context: &BuildContext, }); // Inject the pkgid attribute so we get the right package name and version - if !attr::contains_name(crate.attrs, "pkgid") { + if !attr::contains_name(crate.attrs, "crate_id") { // FIXME (#9639): This needs to handle non-utf8 paths let pkgid_attr = - attr::mk_name_value_item_str(@"pkgid", + attr::mk_name_value_item_str(@"crate_id", format!("{}\\#{}", pkg_id.path.as_str().unwrap(), pkg_id.version.to_str()).to_managed()); diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 9f2b19ac5fd..2e5b7254769 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -34,7 +34,9 @@ */ +// NOTE: remove after snapshot #[pkgid = "rustuv#0.9-pre"]; +#[crate_id = "rustuv#0.9-pre"]; #[license = "MIT/ASL2"]; #[crate_type = "rlib"]; #[crate_type = "dylib"]; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 53e26e435b7..b2b856c5c83 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -43,7 +43,9 @@ //! //! use std::prelude::*; +// NOTE: remove after snapshot #[pkgid = "std#0.9-pre"]; +#[crate_id = "std#0.9-pre"]; #[comment = "The Rust standard library"]; #[license = "MIT/ASL2"]; #[crate_type = "rlib"]; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index ac5254f1aba..5e16213190c 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -237,7 +237,7 @@ pub fn find_linkage_metas(attrs: &[Attribute]) -> ~[@MetaItem] { } pub fn find_pkgid(attrs: &[Attribute]) -> Option { - match first_attr_value_str_by_name(attrs, "pkgid") { + match first_attr_value_str_by_name(attrs, "crate_id") { None => None, Some(id) => from_str::(id), } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 9599f27af04..25986f67c69 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -13,7 +13,9 @@ * macros. */ +// NOTE: remove pkgid after snapshot #[pkgid = "syntax#0.9-pre"]; +#[crate_id = "syntax#0.9-pre"]; #[license = "MIT/ASL2"]; #[crate_type = "dylib"]; #[crate_type = "rlib"]; diff --git a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs index 0c1906500c0..aa6ee35a077 100644 --- a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="anonexternmod#0.1"]; +#[crate_id="anonexternmod#0.1"]; use std::libc; diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index 16c03fa8e3b..1f5c98cd7e1 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="cci_impl_lib"]; +#[crate_id="cci_impl_lib"]; // NOTE: remove after the next snapshot #[link(name="cci_impl_lib", vers="0.0")]; diff --git a/src/test/auxiliary/cci_iter_lib.rs b/src/test/auxiliary/cci_iter_lib.rs index 903563055b7..672d06f1ccb 100644 --- a/src/test/auxiliary/cci_iter_lib.rs +++ b/src/test/auxiliary/cci_iter_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="cci_iter_lib"]; +#[crate_id="cci_iter_lib"]; // NOTE: remove after the next snapshot #[link(name="cci_iter_lib", vers="0.0")]; diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index ea06cbf793a..ef832d8e443 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="cci_no_inline_lib"]; +#[crate_id="cci_no_inline_lib"]; // NOTE: remove after the next snapshot #[link(name="cci_no_inline_lib", vers="0.0")]; diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index 921082440d8..a5e10eaaf68 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -9,7 +9,7 @@ // except according to those terms. #[feature(managed_boxes)]; -#[pkgid="crate_method_reexport_grrrrrrr2"]; +#[crate_id="crate_method_reexport_grrrrrrr2"]; // NOTE: remove after the next snapshot #[link(name = "crate_method_reexport_grrrrrrr2")]; diff --git a/src/test/auxiliary/crateresolve1-1.rs b/src/test/auxiliary/crateresolve1-1.rs index d7600f95ecd..1188626242b 100644 --- a/src/test/auxiliary/crateresolve1-1.rs +++ b/src/test/auxiliary/crateresolve1-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve1#0.1"]; +#[crate_id="crateresolve1#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve1", vers = "0.1")]; diff --git a/src/test/auxiliary/crateresolve1-2.rs b/src/test/auxiliary/crateresolve1-2.rs index 239d11b1985..f0d69b3eaaf 100644 --- a/src/test/auxiliary/crateresolve1-2.rs +++ b/src/test/auxiliary/crateresolve1-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve1#0.2"]; +#[crate_id="crateresolve1#0.2"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve1", vers = "0.2")]; diff --git a/src/test/auxiliary/crateresolve1-3.rs b/src/test/auxiliary/crateresolve1-3.rs index 7acb3804fd3..fe62de2d409 100644 --- a/src/test/auxiliary/crateresolve1-3.rs +++ b/src/test/auxiliary/crateresolve1-3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve1#0.3"]; +#[crate_id="crateresolve1#0.3"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve1", vers = "0.3")]; diff --git a/src/test/auxiliary/crateresolve2-1.rs b/src/test/auxiliary/crateresolve2-1.rs index 149314e5a07..7d64c24798b 100644 --- a/src/test/auxiliary/crateresolve2-1.rs +++ b/src/test/auxiliary/crateresolve2-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve2#0.1"]; +#[crate_id="crateresolve2#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve2", vers = "0.1")]; diff --git a/src/test/auxiliary/crateresolve2-2.rs b/src/test/auxiliary/crateresolve2-2.rs index 9286b68586a..bd7fb7cfa81 100644 --- a/src/test/auxiliary/crateresolve2-2.rs +++ b/src/test/auxiliary/crateresolve2-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve2#0.2"]; +#[crate_id="crateresolve2#0.2"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve2", vers = "0.2")]; diff --git a/src/test/auxiliary/crateresolve2-3.rs b/src/test/auxiliary/crateresolve2-3.rs index 37ccbbd40d7..64aeca48608 100644 --- a/src/test/auxiliary/crateresolve2-3.rs +++ b/src/test/auxiliary/crateresolve2-3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve2#0.3"]; +#[crate_id="crateresolve2#0.3"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve2", vers = "0.3")]; diff --git a/src/test/auxiliary/crateresolve3-1.rs b/src/test/auxiliary/crateresolve3-1.rs index e2c46a9a88d..ae6fe53ab47 100644 --- a/src/test/auxiliary/crateresolve3-1.rs +++ b/src/test/auxiliary/crateresolve3-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve3#0.1"]; +#[crate_id="crateresolve3#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve3", vers = "0.1")]; diff --git a/src/test/auxiliary/crateresolve3-2.rs b/src/test/auxiliary/crateresolve3-2.rs index cda986f21cb..b77e147c635 100644 --- a/src/test/auxiliary/crateresolve3-2.rs +++ b/src/test/auxiliary/crateresolve3-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve3#0.2"]; +#[crate_id="crateresolve3#0.2"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve3", vers = "0.2")]; diff --git a/src/test/auxiliary/crateresolve4a-1.rs b/src/test/auxiliary/crateresolve4a-1.rs index eeb946b1da7..683a46ceecd 100644 --- a/src/test/auxiliary/crateresolve4a-1.rs +++ b/src/test/auxiliary/crateresolve4a-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve4a#0.1"]; +#[crate_id="crateresolve4a#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve4a", vers = "0.1")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/crateresolve4a-2.rs b/src/test/auxiliary/crateresolve4a-2.rs index 9c089fd2141..6facf02d923 100644 --- a/src/test/auxiliary/crateresolve4a-2.rs +++ b/src/test/auxiliary/crateresolve4a-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve4a#0.2"]; +#[crate_id="crateresolve4a#0.2"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve4a", vers= "0.2")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/crateresolve4b-1.rs b/src/test/auxiliary/crateresolve4b-1.rs index 9fbfdcf1687..e19cd6c73d2 100644 --- a/src/test/auxiliary/crateresolve4b-1.rs +++ b/src/test/auxiliary/crateresolve4b-1.rs @@ -10,7 +10,7 @@ // aux-build:crateresolve4a-1.rs // aux-build:crateresolve4a-2.rs -#[pkgid="crateresolve4b#0.1"]; +#[crate_id="crateresolve4b#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve4b", vers = "0.1")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/crateresolve4b-2.rs b/src/test/auxiliary/crateresolve4b-2.rs index 73484ab2232..2c00d9aab8d 100644 --- a/src/test/auxiliary/crateresolve4b-2.rs +++ b/src/test/auxiliary/crateresolve4b-2.rs @@ -10,7 +10,7 @@ // aux-build:crateresolve4a-1.rs // aux-build:crateresolve4a-2.rs -#[pkgid="crateresolve4b#0.2"]; +#[crate_id="crateresolve4b#0.2"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve4b", vers = "0.2")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/crateresolve5-1.rs b/src/test/auxiliary/crateresolve5-1.rs index 726b3919f7f..f619499f4f4 100644 --- a/src/test/auxiliary/crateresolve5-1.rs +++ b/src/test/auxiliary/crateresolve5-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve5#0.1"]; +#[crate_id="crateresolve5#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve5", vers = "0.1")]; diff --git a/src/test/auxiliary/crateresolve5-2.rs b/src/test/auxiliary/crateresolve5-2.rs index 05a760dea73..d0164d77e66 100644 --- a/src/test/auxiliary/crateresolve5-2.rs +++ b/src/test/auxiliary/crateresolve5-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve5#0.2"]; +#[crate_id="crateresolve5#0.2"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve5", vers = "0.2")]; diff --git a/src/test/auxiliary/crateresolve8-1.rs b/src/test/auxiliary/crateresolve8-1.rs index b0990d2e303..aa3babea58f 100644 --- a/src/test/auxiliary/crateresolve8-1.rs +++ b/src/test/auxiliary/crateresolve8-1.rs @@ -9,7 +9,7 @@ // except according to those terms. // default link meta for 'package_id' will be equal to filestem -#[pkgid="crateresolve8#0.1"]; +#[crate_id="crateresolve8#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve8", vers = "0.1")]; diff --git a/src/test/auxiliary/crateresolve_calories-1.rs b/src/test/auxiliary/crateresolve_calories-1.rs index 0f000716e4d..39328f28bea 100644 --- a/src/test/auxiliary/crateresolve_calories-1.rs +++ b/src/test/auxiliary/crateresolve_calories-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve_calories#0.1"]; +#[crate_id="crateresolve_calories#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve_calories", vers = "0.1", diff --git a/src/test/auxiliary/crateresolve_calories-2.rs b/src/test/auxiliary/crateresolve_calories-2.rs index 4d3ff1e2071..edf90589db7 100644 --- a/src/test/auxiliary/crateresolve_calories-2.rs +++ b/src/test/auxiliary/crateresolve_calories-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="crateresolve_calories#0.1"]; +#[crate_id="crateresolve_calories#0.1"]; // NOTE: remove after the next snapshot #[link(name = "crateresolve_calories", vers = "0.1", diff --git a/src/test/auxiliary/extern-crosscrate-source.rs b/src/test/auxiliary/extern-crosscrate-source.rs index d6bf2dda9ce..7a7d0c453a7 100644 --- a/src/test/auxiliary/extern-crosscrate-source.rs +++ b/src/test/auxiliary/extern-crosscrate-source.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="externcallback#0.1"]; +#[crate_id="externcallback#0.1"]; // NOTE: remove after the next snapshot #[link(name = "externcallback", vers = "0.1")]; diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index 4a92a8dd566..bc2ef7262a6 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="foreign_lib"]; +#[crate_id="foreign_lib"]; // NOTE: remove after the next snapshot #[link(name="foreign_lib", vers="0.0")]; diff --git a/src/test/auxiliary/inline_dtor.rs b/src/test/auxiliary/inline_dtor.rs index 67db37234cf..83f2cee0a54 100644 --- a/src/test/auxiliary/inline_dtor.rs +++ b/src/test/auxiliary/inline_dtor.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="inline_dtor#0.1"]; +#[crate_id="inline_dtor#0.1"]; // NOTE: remove after the next snapshot #[link(name="inline_dtor", vers="0.1")]; diff --git a/src/test/auxiliary/iss.rs b/src/test/auxiliary/iss.rs index 6be7d7ab214..b7cffa4c378 100644 --- a/src/test/auxiliary/iss.rs +++ b/src/test/auxiliary/iss.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="issue6919_3#0.1"]; +#[crate_id="issue6919_3#0.1"]; // NOTE: remove after the next snapshot #[link(name="iss6919_3", vers="0.1")]; diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index a1534aa25e4..24c8edbc800 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -9,7 +9,7 @@ // except according to those terms. #[feature(managed_boxes)]; -#[pkgid="a"]; +#[crate_id="a"]; // NOTE: remove after the next snapshot #[link(name = "a", vers = "0.0")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 9caf89deb49..c9779a0040d 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="a#0.1"]; +#[crate_id="a#0.1"]; // NOTE: remove after the next snapshot #[link(name = "a", vers = "0.1")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue-2414-b.rs b/src/test/auxiliary/issue-2414-b.rs index 726f8cc29ab..33cb5d5fb6c 100644 --- a/src/test/auxiliary/issue-2414-b.rs +++ b/src/test/auxiliary/issue-2414-b.rs @@ -10,7 +10,7 @@ // xfail-fast -#[pkgid="b#0.1"]; +#[crate_id="b#0.1"]; // NOTE: remove after the next snapshot #[link(name = "b", vers = "0.1")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index cdbb081f902..5948a492305 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="issue_2526#0.2"]; +#[crate_id="issue_2526#0.2"]; // NOTE: remove after the next snapshot #[link(name = "issue_2526", vers = "0.2", diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 451fde61ce7..e5457e46d33 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -9,7 +9,7 @@ // except according to those terms. #[feature(managed_boxes)]; -#[pkgid="req"]; +#[crate_id="req"]; // NOTE: remove after the next snapshot #[link(name = "req")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue-3012-1.rs b/src/test/auxiliary/issue-3012-1.rs index f206911a7c0..40ae334ef72 100644 --- a/src/test/auxiliary/issue-3012-1.rs +++ b/src/test/auxiliary/issue-3012-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="socketlib"]; +#[crate_id="socketlib"]; // NOTE: remove after the next snapshot #[link(name="socketlib", vers="0.0")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue-4208-cc.rs b/src/test/auxiliary/issue-4208-cc.rs index 35b19c6558c..71db81459b0 100644 --- a/src/test/auxiliary/issue-4208-cc.rs +++ b/src/test/auxiliary/issue-4208-cc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="numeric#0.1"]; +#[crate_id="numeric#0.1"]; // NOTE: remove after the next snapshot #[link(name = "numeric", vers = "0.1")]; diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs index cfa75be5b0e..4d21abe64ef 100644 --- a/src/test/auxiliary/issue_2242_a.rs +++ b/src/test/auxiliary/issue_2242_a.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="a#0.1"]; +#[crate_id="a#0.1"]; // NOTE: remove after the next snapshot #[link(name = "a", vers = "0.1")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue_2242_c.rs b/src/test/auxiliary/issue_2242_c.rs index 331d2535893..60054cd2218 100644 --- a/src/test/auxiliary/issue_2242_c.rs +++ b/src/test/auxiliary/issue_2242_c.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="c#0.1"]; +#[crate_id="c#0.1"]; // NOTE: remove after the next snapshot #[link(name = "c", vers = "0.1")]; #[crate_type = "lib"]; diff --git a/src/test/auxiliary/issue_3979_traits.rs b/src/test/auxiliary/issue_3979_traits.rs index e800e59b997..08f83d9d206 100644 --- a/src/test/auxiliary/issue_3979_traits.rs +++ b/src/test/auxiliary/issue_3979_traits.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="issue_3979_traits#0.1"]; +#[crate_id="issue_3979_traits#0.1"]; // NOTE: remove after the next snapshot #[link(name = "issue_3979_traits", vers = "0.1")]; diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index 398d0268bc5..8b821c65622 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -7,7 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="lint_stability#0.1"]; +#[crate_id="lint_stability#0.1"]; // NOTE: remove after the next snapshot #[link(name = "lint_stability", vers = "0.1")]; diff --git a/src/test/auxiliary/static-function-pointer-aux.rs b/src/test/auxiliary/static-function-pointer-aux.rs index b80ac427dc2..b257f4578a5 100644 --- a/src/test/auxiliary/static-function-pointer-aux.rs +++ b/src/test/auxiliary/static-function-pointer-aux.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="static-function-pointer-aux"]; +#[crate_id="static-function-pointer-aux"]; pub fn f(x: int) -> int { -x } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index c6f27ebb971..648c9ca7320 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="static_methods_crate#0.1"]; +#[crate_id="static_methods_crate#0.1"]; // NOTE: remove after the next snapshot #[link(name = "static_methods_crate", vers = "0.1")]; diff --git a/src/test/auxiliary/struct_variant_xc_aux.rs b/src/test/auxiliary/struct_variant_xc_aux.rs index a090b052016..fc258a8a527 100644 --- a/src/test/auxiliary/struct_variant_xc_aux.rs +++ b/src/test/auxiliary/struct_variant_xc_aux.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="struct_variant_xc_aux#0.1"]; +#[crate_id="struct_variant_xc_aux#0.1"]; // NOTE: remove after the next snapshot #[link(name = "struct_variant_xc_aux", vers = "0.1")]; diff --git a/src/test/auxiliary/trait_default_method_xc_aux.rs b/src/test/auxiliary/trait_default_method_xc_aux.rs index a0b50f860dd..9ed45da9e17 100644 --- a/src/test/auxiliary/trait_default_method_xc_aux.rs +++ b/src/test/auxiliary/trait_default_method_xc_aux.rs @@ -1,4 +1,4 @@ -#[pkgid="trait_default_method_xc_aux"]; +#[crate_id="trait_default_method_xc_aux"]; pub struct Something { x: int } diff --git a/src/test/run-make/bootstrap-from-c-with-uvio/lib.rs b/src/test/run-make/bootstrap-from-c-with-uvio/lib.rs index e42382fa84c..06a06c967f4 100644 --- a/src/test/run-make/bootstrap-from-c-with-uvio/lib.rs +++ b/src/test/run-make/bootstrap-from-c-with-uvio/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="boot#0.1"]; +#[crate_id="boot#0.1"]; #[crate_type="lib"]; extern mod rustuv; // pull in uvio diff --git a/src/test/run-make/dep-info/lib.rs b/src/test/run-make/dep-info/lib.rs index d08a0fbcb60..937118269a7 100644 --- a/src/test/run-make/dep-info/lib.rs +++ b/src/test/run-make/dep-info/lib.rs @@ -1,4 +1,4 @@ -#[pkgid="foo#0.1"]; +#[crate_id="foo#0.1"]; pub mod foo; pub mod bar; diff --git a/src/test/run-pass/crateresolve8.rs b/src/test/run-pass/crateresolve8.rs index ad716edd5ef..1dd1b9c098b 100644 --- a/src/test/run-pass/crateresolve8.rs +++ b/src/test/run-pass/crateresolve8.rs @@ -11,7 +11,7 @@ // xfail-fast // aux-build:crateresolve8-1.rs -#[pkgid="crateresolve8#0.1"]; +#[crate_id="crateresolve8#0.1"]; extern mod crateresolve8(vers = "0.1", package_id="crateresolve8#0.1"); //extern mod crateresolve8(vers = "0.1"); diff --git a/src/test/run-pass/issue-1251.rs b/src/test/run-pass/issue-1251.rs index 7fb897f9f20..27ea0d394b8 100644 --- a/src/test/run-pass/issue-1251.rs +++ b/src/test/run-pass/issue-1251.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[pkgid="rust_get_test_int"]; +#[crate_id="rust_get_test_int"]; // NOTE: remove after the next snapshot #[link(name = "rust_get_test_int")]; diff --git a/src/test/run-pass/issue-6919.rs b/src/test/run-pass/issue-6919.rs index 041c0609dcd..8482af9e7c4 100644 --- a/src/test/run-pass/issue-6919.rs +++ b/src/test/run-pass/issue-6919.rs @@ -11,7 +11,7 @@ // aux-build:iss.rs // xfail-fast -#[pkgid="issue-6919"]; +#[crate_id="issue-6919"]; extern mod issue6919_3; diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 99ada9cc650..b453dca1800 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -16,7 +16,7 @@ #[attr3]; #[attr4(attr5)]; -#[pkgid="extra#0.1"]; +#[crate_id="extra#0.1"]; // NOTE: remove after the next snapshot // Special linkage attributes for the crate #[link(name = "extra", From b25a0524dcb1e46b9c55266ebc0ab36cce5d2099 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Thu, 19 Dec 2013 10:18:37 -0500 Subject: [PATCH 2/2] Add some things to inspect crate-id's --- src/librustc/back/link.rs | 22 +++++++----- src/librustc/driver/driver.rs | 48 ++++++++++++++++++++++++-- src/librustc/driver/session.rs | 5 ++- src/librustdoc/clean.rs | 2 +- src/test/run-make/rustdoc-smoke/foo.rs | 2 +- 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index b5f0a5713bd..6c5b3341587 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -753,14 +753,10 @@ fn is_writeable(p: &Path) -> bool { } } -fn link_binary_output(sess: Session, - trans: &CrateTranslation, - output: session::OutputStyle, - obj_filename: &Path, - out_filename: &Path, - lm: &LinkMeta) -> Path { +pub fn filename_for_input(sess: &Session, output: session::OutputStyle, lm: &LinkMeta, + out_filename: &Path) -> Path { let libname = output_lib_filename(lm); - let out_filename = match output { + match output { session::OutputRlib => { out_filename.with_filename(format!("lib{}.rlib", libname)) } @@ -778,7 +774,17 @@ fn link_binary_output(sess: Session, out_filename.with_filename(format!("lib{}.a", libname)) } session::OutputExecutable => out_filename.clone(), - }; + } + +} + +fn link_binary_output(sess: Session, + trans: &CrateTranslation, + output: session::OutputStyle, + obj_filename: &Path, + out_filename: &Path, + lm: &LinkMeta) -> Path { + let out_filename = filename_for_input(&sess, output, lm, out_filename); // Make sure the output and obj_filename are both writeable. // Mac, FreeBSD, and Windows system linkers check this already -- diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index afc910056eb..070aed3aa79 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -446,13 +446,49 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input, let (outputs, trans) = { let expanded_crate = { let crate = phase_1_parse_input(sess, cfg.clone(), input); + let (crate_id, crate_name, crate_file_name) = sess.opts.print_metas; + // these nasty nested conditions are to avoid doing extra work + if crate_id || crate_name || crate_file_name { + let t_outputs = build_output_filenames(input, outdir, output, crate.attrs, sess); + if crate_id || crate_name { + let pkgid = match attr::find_pkgid(crate.attrs) { + Some(pkgid) => pkgid, + None => fail!("No crate_id and --crate-id or --crate-name requested") + }; + if crate_id { + println(pkgid.to_str()); + } + if crate_name { + println(pkgid.name); + } + } + + if crate_file_name { + let lm = link::build_link_meta(sess, &crate, &t_outputs.obj_filename, + &mut ::util::sha2::Sha256::new()); + // if the vector is empty we default to OutputExecutable. + let style = sess.opts.outputs.get_opt(0).unwrap_or(&OutputExecutable); + let fname = link::filename_for_input(&sess, *style, &lm, + &t_outputs.out_filename); + println!("{}", fname.display()); + + // we already maybe printed the first one, so skip it + for style in sess.opts.outputs.iter().skip(1) { + let fname = link::filename_for_input(&sess, *style, &lm, + &t_outputs.out_filename); + println!("{}", fname.display()); + } + } + + return; + } if stop_after_phase_1(sess) { return; } phase_2_configure_and_expand(sess, cfg, crate) }; - let analysis = phase_3_run_analysis_passes(sess, &expanded_crate); - if stop_after_phase_3(sess) { return; } let outputs = build_output_filenames(input, outdir, output, expanded_crate.attrs, sess); + let analysis = phase_3_run_analysis_passes(sess, &expanded_crate); + if stop_after_phase_3(sess) { return; } let trans = phase_4_translate_to_llvm(sess, expanded_crate, &analysis, outputs); (outputs, trans) @@ -789,6 +825,9 @@ pub fn build_session_options(binary: @str, }).collect() } }; + let print_metas = (matches.opt_present("crate-id"), + matches.opt_present("crate-name"), + matches.opt_present("crate-file-name")); let sopts = @session::options { outputs: outputs, @@ -817,6 +856,7 @@ pub fn build_session_options(binary: @str, debugging_opts: debugging_opts, android_cross_path: android_cross_path, write_dependency_info: write_dependency_info, + print_metas: print_metas, }; return sopts; } @@ -897,6 +937,10 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] { optflag("", "dylib", "Compile a dynamic library crate"), optopt("", "linker", "Program to use for linking instead of the default.", "LINKER"), optopt("", "ar", "Program to use for managing archives instead of the default.", "AR"), + optflag("", "crate-id", "Output the crate id and exit"), + optflag("", "crate-name", "Output the crate name and exit"), + optflag("", "crate-file-name", "Output the file(s) that would be written if compilation \ + continued and exit"), optmulti("", "link-args", "FLAGS is a space-separated list of flags passed to the linker", "FLAGS"), optflag("", "ls", "List the symbols defined by a library crate"), diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 78b59f49341..58f09a52f23 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -168,8 +168,10 @@ pub struct options { no_trans: bool, debugging_opts: uint, android_cross_path: Option<~str>, - // Whether to write .d dependency files + /// Whether to write .d dependency files write_dependency_info: bool, + /// Crate id-related things to maybe print. It's (crate_id, crate_name, crate_file_name). + print_metas: (bool, bool, bool), } pub struct crate_metadata { @@ -396,6 +398,7 @@ pub fn basic_options() -> @options { debugging_opts: 0u, android_cross_path: None, write_dependency_info: false, + print_metas: (false, false, false), } } diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 443293818af..028e622c057 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -84,7 +84,7 @@ fn clean(&self) -> Crate { Crate { name: match find_pkgid(self.attrs) { Some(n) => n.name, - None => fail!("rustdoc requires a `pkgid` crate attribute"), + None => fail!("rustdoc requires a `crate_id` crate attribute"), }, module: Some(self.module.clean()), externs: externs, diff --git a/src/test/run-make/rustdoc-smoke/foo.rs b/src/test/run-make/rustdoc-smoke/foo.rs index 7a86bf4d1e8..ef407ed2987 100644 --- a/src/test/run-make/rustdoc-smoke/foo.rs +++ b/src/test/run-make/rustdoc-smoke/foo.rs @@ -1,4 +1,4 @@ -#[pkgid = "foo#0.1"]; +#[crate_id = "foo#0.1"]; //! Very docs