about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-07-05 16:09:32 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-07-05 16:09:32 +0200
commit4349eaed8417a39eb54ea952ce86c7c585be6e90 (patch)
treeef1855443643956dfb09cb4894ebbc10a993018f
parent6fd6fdea93fca19f168526943c177f942212cbc6 (diff)
Don't thread the local crate number through the session
It's a constant, anyway.
-rw-r--r--src/comp/driver/rustc.rs5
-rw-r--r--src/comp/driver/session.rs4
-rw-r--r--src/comp/middle/trans.rs4
-rw-r--r--src/comp/middle/ty.rs4
-rw-r--r--src/comp/middle/typeck.rs3
5 files changed, 7 insertions, 13 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 9ad42103a90..ce422742b45 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -344,11 +344,8 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
 fn build_session(@session::options sopts) -> session::session {
     auto target_cfg = build_target_config();
     auto crate_cache = syntax::_std::new_int_hash[session::crate_metadata]();
-    auto target_crate_num = 0;
-    auto sess =
-        session::session(target_crate_num, target_cfg, sopts, crate_cache, [],
+    ret session::session(target_cfg, sopts, crate_cache, [],
                          [], [], codemap::new_codemap(), 0u);
-    ret sess;
 }
 
 fn parse_pretty(session::session sess, &str name) -> pp_mode {
diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs
index 8ef558f2fde..3dc947477b8 100644
--- a/src/comp/driver/session.rs
+++ b/src/comp/driver/session.rs
@@ -41,8 +41,7 @@ type options =
 
 type crate_metadata = rec(str name, vec[u8] data);
 
-obj session(ast::crate_num cnum,
-            @config targ_cfg,
+obj session(@config targ_cfg,
             @options opts,
             map::hashmap[int, crate_metadata] crates,
             mutable vec[str] used_crate_files,
@@ -52,7 +51,6 @@ obj session(ast::crate_num cnum,
             mutable uint err_count) {
     fn get_targ_cfg() -> @config { ret targ_cfg; }
     fn get_opts() -> @options { ret opts; }
-    fn get_targ_crate_num() -> ast::crate_num { ret cnum; }
     fn span_fatal(span sp, str msg) -> ! {
         // FIXME: Use constants, but rustboot doesn't know how to export them.
         codemap::emit_error(some(sp), msg, cm);
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index f2c00abd6f1..aa8da0a7683 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -4816,7 +4816,7 @@ fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
 fn lval_generic_fn(&@block_ctxt cx, &ty::ty_param_count_and_ty tpt,
                    &ast::def_id fn_id, ast::node_id id) -> lval_result {
     auto lv;
-    if (cx.fcx.lcx.ccx.sess.get_targ_crate_num() == fn_id._0) {
+    if (fn_id._0 == ast::local_crate) {
         // Internal reference.
         assert (cx.fcx.lcx.ccx.fn_pairs.contains_key(fn_id._1));
         lv = lval_val(cx, cx.fcx.lcx.ccx.fn_pairs.get(fn_id._1));
@@ -4851,7 +4851,7 @@ fn lookup_discriminant(&@local_ctxt lcx, &ast::def_id tid, &ast::def_id vid)
         case (none) {
             // It's an external discriminant that we haven't seen yet.
 
-            assert (lcx.ccx.sess.get_targ_crate_num() != vid._0);
+            assert (vid._0 != ast::local_crate);
             auto sym = decoder::get_symbol(lcx.ccx.sess, vid);
             auto gvar =
                 llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(sym));
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 760a9b2fa94..5ef38434e5d 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -2802,7 +2802,7 @@ fn def_has_ty_params(&ast::def def) -> bool {
 type variant_info = rec(vec[ty::t] args, ty::t ctor_ty, ast::def_id id);
 
 fn tag_variants(&ctxt cx, &ast::def_id id) -> vec[variant_info] {
-    if (cx.sess.get_targ_crate_num() != id._0) {
+    if (ast::local_crate != id._0) {
         ret decoder::get_tag_variants(cx, id);
     }
     auto item = alt (cx.items.find(id._1)) {
@@ -2857,7 +2857,7 @@ fn tag_variant_with_id(&ctxt cx, &ast::def_id tag_id, &ast::def_id variant_id)
 // If the given item is in an external crate, looks up its type and adds it to
 // the type cache. Returns the type parameters and type.
 fn lookup_item_type(ctxt cx, ast::def_id did) -> ty_param_count_and_ty {
-    if (did._0 == cx.sess.get_targ_crate_num()) {
+    if (did._0 == ast::local_crate) {
         // The item is in this crate. The caller should have added it to the
         // type cache already; we simply return it.
 
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 5c4e4f1572b..214d2f9581e 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -521,9 +521,8 @@ mod collect {
         ret tpt;
     }
     fn getter(@ctxt cx, &ast::def_id id) -> ty::ty_param_count_and_ty {
-        if (id._0 != cx.tcx.sess.get_targ_crate_num()) {
+        if (id._0 != ast::local_crate) {
             // This is a type we need to load in from the crate reader.
-
             ret decoder::get_type(cx.tcx, id);
         }
         auto it = cx.tcx.items.find(id._1);