diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-12-08 20:08:00 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-12-08 20:08:00 -0800 |
| commit | fd81fb6a2418d3cbef5244662573e2b61d5f66a7 (patch) | |
| tree | ffbe0a081e582fd8723269c3aeafd437721c9b90 /src/comp/middle | |
| parent | 9e6ff44d9359ce062fb4f0e29c8f4c33eec7781e (diff) | |
| download | rust-fd81fb6a2418d3cbef5244662573e2b61d5f66a7.tar.gz rust-fd81fb6a2418d3cbef5244662573e2b61d5f66a7.zip | |
rustc: Determine the crate type (lib/bin) in the session, not session opts
This is in preparation for adding a #[crate_type] attribute
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/resolve.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 6 | ||||
| -rw-r--r-- | src/comp/middle/typeck.rs | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 7ed27f2502d..4a8795d9d5e 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -362,7 +362,7 @@ fn visit_fn_with_scope(e: @env, f: ast::_fn, tp: [ast::ty_param], sp: span, // is this a main fn declaration? alt name { some(nm) { - if is_main_name([nm]) && !e.sess.get_opts().library { + if is_main_name([nm]) && !e.sess.building_library() { // This is a main function -- set it in the session // as the main ID e.sess.set_main_id(id); diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 104085579b5..df0de922fa3 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -5528,7 +5528,7 @@ fn register_fn_full(ccx: @crate_ctxt, sp: span, path: [str], _flav: str, ccx.item_ids.insert(node_id, llfn); ccx.item_symbols.insert(node_id, ps); - let is_main: bool = is_main_name(path) && !ccx.sess.get_opts().library; + let is_main: bool = is_main_name(path) && !ccx.sess.building_library(); if is_main { create_main_wrapper(ccx, sp, llfn, node_type); } } @@ -5951,7 +5951,7 @@ fn decl_crate_map(sess: session::session, mapname: str, let n_subcrates = 1; let cstore = sess.get_cstore(); while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; } - let mapname = sess.get_opts().library ? mapname : "toplevel"; + let mapname = sess.building_library() ? mapname : "toplevel"; let sym_name = "_rust_crate_map_" + mapname; let arrtype = T_array(int_type, n_subcrates as uint); let maptype = T_struct([int_type, arrtype]); @@ -5983,7 +5983,7 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { } fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { - if !cx.sess.get_opts().library { ret; } + if !cx.sess.building_library() { ret; } let llmeta = C_postr(metadata::encoder::encode_metadata(cx, crate)); let llconst = trans_common::C_struct([llmeta]); let llglobal = diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 34fc1816c3f..feaa1215d87 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -2720,7 +2720,7 @@ fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) { } fn check_for_main_fn(tcx: ty::ctxt, crate: @ast::crate) { - if !tcx.sess.get_opts().library { + if !tcx.sess.building_library() { alt tcx.sess.get_main_id() { some(id) { check_main_fn_ty(tcx, id); } none. { tcx.sess.span_err(crate.span, "main function not found"); } |
