about summary refs log tree commit diff
path: root/src/librustc/front
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-06 13:21:18 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-07-05 12:38:42 -0700
commit50ee1ec1b4f107122d8037ac7b0b312afa6eb0ac (patch)
tree6e812d9727a61ccea67f3bc922557d6d45736fbd /src/librustc/front
parentaaff4e05e19b48d81e4ecb3337f288f42d06edd0 (diff)
rustc: Remove CrateId and all related support
This commit removes all support in the compiler for the #[crate_id] attribute
and all of its derivative infrastructure. A list of the functionality removed is:

* The #[crate_id] attribute no longer exists
* There is no longer the concept of a version of a crate
* Version numbers are no longer appended to symbol names
* The --crate-id command line option has been removed

To migrate forward, rename #[crate_id] to #[crate_name] and only the name of the
crate itself should be mentioned. The version/path of the old crate id should be
removed.

For a transitionary state, the #[crate_id] attribute is still accepted if
the #[crate_name] is not present, but it is warned about if it is the only
identifier present.

RFC: 0035-remove-crate-id
[breaking-change]
Diffstat (limited to 'src/librustc/front')
-rw-r--r--src/librustc/front/std_inject.rs22
-rw-r--r--src/librustc/front/test.rs11
2 files changed, 8 insertions, 25 deletions
diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs
index 54ba9db570e..351c9a6b771 100644
--- a/src/librustc/front/std_inject.rs
+++ b/src/librustc/front/std_inject.rs
@@ -25,8 +25,6 @@ use syntax::util::small_vector::SmallVector;
 use std::mem;
 use std::gc::{Gc, GC};
 
-pub static VERSION: &'static str = "0.11.0";
-
 pub fn maybe_inject_crates_ref(sess: &Session, krate: ast::Crate)
                                -> ast::Crate {
     if use_std(&krate) {
@@ -60,24 +58,12 @@ struct StandardLibraryInjector<'a> {
     sess: &'a Session,
 }
 
-pub fn with_version(krate: &str) -> Option<(InternedString, ast::StrStyle)> {
-    match option_env!("CFG_DISABLE_INJECT_STD_VERSION") {
-        Some("1") => None,
-        _ => {
-            Some((token::intern_and_get_ident(format!("{}#{}",
-                                                      krate,
-                                                      VERSION).as_slice()),
-                  ast::CookedStr))
-        }
-    }
-}
-
 impl<'a> fold::Folder for StandardLibraryInjector<'a> {
     fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
         let mut vis = vec!(ast::ViewItem {
             node: ast::ViewItemExternCrate(token::str_to_ident("std"),
-                                         with_version("std"),
-                                         ast::DUMMY_NODE_ID),
+                                           None,
+                                           ast::DUMMY_NODE_ID),
             attrs: vec!(
                 attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_list_item(
                         InternedString::new("phase"),
@@ -95,8 +81,8 @@ impl<'a> fold::Folder for StandardLibraryInjector<'a> {
         if use_start(&krate) && any_exe {
             vis.push(ast::ViewItem {
                 node: ast::ViewItemExternCrate(token::str_to_ident("native"),
-                                             with_version("native"),
-                                             ast::DUMMY_NODE_ID),
+                                               None,
+                                               ast::DUMMY_NODE_ID),
                 attrs: Vec::new(),
                 vis: ast::Inherited,
                 span: DUMMY_SP
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs
index d33b76ae08c..b2c6840ad22 100644
--- a/src/librustc/front/test.rs
+++ b/src/librustc/front/test.rs
@@ -15,7 +15,6 @@
 
 use driver::session::Session;
 use front::config;
-use front::std_inject::with_version;
 
 use std::cell::RefCell;
 use std::gc::{Gc, GC};
@@ -154,7 +153,7 @@ fn generate_test_harness(sess: &Session, krate: ast::Crate)
         ext_cx: ExtCtxt::new(&sess.parse_sess, sess.opts.cfg.clone(),
                              ExpansionConfig {
                                  deriving_hash_type_parameter: false,
-                                 crate_id: from_str("test").unwrap(),
+                                 crate_name: "test".to_string(),
                              }),
         path: RefCell::new(Vec::new()),
         testfns: RefCell::new(Vec::new()),
@@ -298,9 +297,7 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
                                         ast::DUMMY_NODE_ID))),
          ast::Public)
     } else {
-        (ast::ViewItemExternCrate(id_test,
-                               with_version("test"),
-                               ast::DUMMY_NODE_ID),
+        (ast::ViewItemExternCrate(id_test, None, ast::DUMMY_NODE_ID),
          ast::Inherited)
     };
     ast::ViewItem {
@@ -395,8 +392,8 @@ fn mk_tests(cx: &TestCtxt) -> Gc<ast::Item> {
 }
 
 fn is_test_crate(krate: &ast::Crate) -> bool {
-    match attr::find_crateid(krate.attrs.as_slice()) {
-        Some(ref s) if "test" == s.name.as_slice() => true,
+    match attr::find_crate_name(krate.attrs.as_slice()) {
+        Some(ref s) if "test" == s.get().as_slice() => true,
         _ => false
     }
 }