summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-01-26 16:23:34 -0800
committerBrian Anderson <banderson@mozilla.com>2012-01-26 16:43:33 -0800
commit28fbb19664db24c9d40e81f74bf75ac1d5d0f36b (patch)
treef11aafd32c44b3f90c981668f6e2fe2533a0ffe0 /src/comp
parent2220d0f20f7faf63de3bb805fcfa0fa7a4c416ee (diff)
rustc: Switch the --no-core switch to a #[no_core] attribute
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/driver/driver.rs7
-rw-r--r--src/comp/driver/rustc.rs1
-rw-r--r--src/comp/driver/session.rs1
-rw-r--r--src/comp/front/attr.rs5
-rw-r--r--src/comp/front/core_inject.rs9
5 files changed, 15 insertions, 8 deletions
diff --git a/src/comp/driver/driver.rs b/src/comp/driver/driver.rs
index 92275d360ed..1b57c627455 100644
--- a/src/comp/driver/driver.rs
+++ b/src/comp/driver/driver.rs
@@ -366,7 +366,6 @@ fn build_session_options(match: getopts::match,
         } else if opt_present(match, "emit-llvm") {
             link::output_type_bitcode
         } else { link::output_type_exe };
-    let libcore = !opt_present(match, "no-core");
     let verify = !opt_present(match, "no-verify");
     let save_temps = opt_present(match, "save-temps");
     let extra_debuginfo = opt_present(match, "xg");
@@ -414,7 +413,6 @@ fn build_session_options(match: getopts::match,
     let sopts: @session::options =
         @{crate_type: crate_type,
           static: static,
-          libcore: libcore,
           optimize: opt_level,
           debuginfo: debuginfo,
           extra_debuginfo: extra_debuginfo,
@@ -494,10 +492,11 @@ fn opts() -> [getopts::opt] {
          optflag("no-verify"),
          optflag("no-lint-ctypes"),
          optmulti("cfg"), optflag("test"),
-         optflag("no-core"),
          optflag("lib"), optflag("bin"), optflag("static"), optflag("gc"),
          optflag("no-asm-comments"),
-         optflag("warn-unused-imports")];
+         optflag("warn-unused-imports"),
+         // FIXME: Transitional. Please remove
+         optflag("no-core")];
 }
 
 type output_filenames = @{out_filename: str, obj_filename:str};
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 4ab6b3491ad..12d10e80653 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -33,7 +33,6 @@ options:
     --lib              compile a library crate
     --bin              compile an executable crate (default)
     --static           use or produce static libraries
-    --no-core          omit the 'core' library (used and imported by default)
     --pretty [type]    pretty-print the input instead of compiling
     --ls               list the symbols defined by a crate file
     -L <path>          add a directory to the library search path
diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs
index 31ddd3d241f..b570744a665 100644
--- a/src/comp/driver/session.rs
+++ b/src/comp/driver/session.rs
@@ -29,7 +29,6 @@ type options =
     // with additional crate configurations during the compile process
     {crate_type: crate_type,
      static: bool,
-     libcore: bool,
      optimize: uint,
      debuginfo: bool,
      extra_debuginfo: bool,
diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs
index 75ee1e822a4..54960d65360 100644
--- a/src/comp/front/attr.rs
+++ b/src/comp/front/attr.rs
@@ -9,6 +9,7 @@ export attr_meta;
 export attr_metas;
 export find_linkage_metas;
 export find_attrs_by_name;
+export attrs_contains_name;
 export find_meta_items_by_name;
 export contains;
 export contains_name;
@@ -56,6 +57,10 @@ fn find_attrs_by_name(attrs: [ast::attribute], name: ast::ident) ->
     ret vec::filter_map(attrs, filter);
 }
 
+fn attrs_contains_name(attrs: [ast::attribute], name: ast::ident) -> bool {
+    vec::is_not_empty(find_attrs_by_name(attrs, name))
+}
+
 fn get_attr_name(attr: ast::attribute) -> ast::ident {
     get_meta_item_name(@attr.node.value)
 }
diff --git a/src/comp/front/core_inject.rs b/src/comp/front/core_inject.rs
index 8e88bd50068..f285d4bf67b 100644
--- a/src/comp/front/core_inject.rs
+++ b/src/comp/front/core_inject.rs
@@ -1,18 +1,23 @@
 import driver::session::session;
-import syntax::ast;
 import syntax::codemap;
+import syntax::ast;
+import front::attr;
 
 export maybe_inject_libcore_ref;
 
 fn maybe_inject_libcore_ref(sess: session,
                             crate: @ast::crate) -> @ast::crate {
-    if sess.opts.libcore {
+    if use_core(crate) {
         inject_libcore_ref(sess, crate)
     } else {
         crate
     }
 }
 
+fn use_core(crate: @ast::crate) -> bool {
+    !attr::attrs_contains_name(crate.node.attrs, "no_core")
+}
+
 fn inject_libcore_ref(sess: session,
                       crate: @ast::crate) -> @ast::crate {