]> git.lizzy.rs Git - rust.git/commitdiff
librustc: De-`@mut` `building_library` in the session
authorPatrick Walton <pcwalton@mimiga.net>
Sun, 22 Dec 2013 22:40:03 +0000 (14:40 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Thu, 26 Dec 2013 23:54:36 +0000 (15:54 -0800)
src/librustc/driver/driver.rs
src/librustc/driver/session.rs
src/librustc/front/std_inject.rs
src/librustc/front/test.rs
src/librustc/middle/entry.rs
src/librustc/middle/reachable.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/typeck/mod.rs

index 8d782948c41ed51d3c89f031ec2d8160d7a6872b..9eff923e651edda945c09ebfdbba5e62af25ffb4 100644 (file)
@@ -166,7 +166,7 @@ pub fn phase_2_configure_and_expand(sess: Session,
                                     mut crate: ast::Crate) -> ast::Crate {
     let time_passes = sess.time_passes();
 
-    *sess.building_library = session::building_library(sess.opts, &crate);
+    sess.building_library.set(session::building_library(sess.opts, &crate));
     *sess.outputs = session::collect_outputs(sess.opts, crate.attrs);
 
     time(time_passes, "gated feature checking", (), |_|
@@ -878,7 +878,7 @@ pub fn build_session_(sopts: @session::options,
         entry_type: Cell::new(None),
         span_diagnostic: span_diagnostic_handler,
         filesearch: filesearch,
-        building_library: @mut false,
+        building_library: Cell::new(false),
         working_dir: os::getcwd(),
         lints: RefCell::new(HashMap::new()),
         node_id: Cell::new(1),
@@ -1039,7 +1039,7 @@ pub fn build_output_filenames(input: &input,
               }
           }
 
-          if *sess.building_library {
+          if sess.building_library.get() {
               out_path = dirpath.join(os::dll_filename(stem));
               obj_path = {
                   let mut p = dirpath.join(stem);
@@ -1060,7 +1060,7 @@ pub fn build_output_filenames(input: &input,
             out_file.with_extension(obj_suffix)
         };
 
-        if *sess.building_library {
+        if sess.building_library.get() {
             sess.warn("ignoring specified output filename for library.");
         }
 
index 7880fcec24101c8a50a709c0ba14abf30ce04620..8bcefbd7c76e0db9b6f6415d4464a2eb93f788fd 100644 (file)
@@ -210,7 +210,7 @@ pub struct Session_ {
     entry_type: Cell<Option<EntryFnType>>,
     span_diagnostic: @mut diagnostic::span_handler,
     filesearch: @filesearch::FileSearch,
-    building_library: @mut bool,
+    building_library: Cell<bool>,
     working_dir: Path,
     lints: RefCell<HashMap<ast::NodeId,
                            ~[(lint::lint, codemap::Span, ~str)]>>,
index 1503e4effeb364c59e2e78a8eb155cc236e09855..03f9a3459a3a90243ff68a80acb2325e93ba75a6 100644 (file)
@@ -69,7 +69,7 @@ fn fold_crate(&self, crate: ast::Crate) -> ast::Crate {
             span: dummy_sp()
         }];
 
-        if use_uv(&crate) && !*self.sess.building_library {
+        if use_uv(&crate) && !self.sess.building_library.get() {
             vis.push(ast::view_item {
                 node: ast::view_item_extern_mod(self.sess.ident_of("green"),
                                                 None,
index 86641598a13ad7db922adf4828d4acb61124cde4..47ef4b94058ba1cc32157c3d5753fee2f83dbf00 100644 (file)
@@ -127,7 +127,7 @@ fn fold_mod(&self, m: &ast::_mod) -> ast::_mod {
         // the one we're going to add. Only if compiling an executable.
 
         fn nomain(cx: @TestCtxt, item: @ast::item) -> @ast::item {
-            if !*cx.sess.building_library {
+            if !cx.sess.building_library.get() {
                 @ast::item {
                     attrs: item.attrs.iter().filter_map(|attr| {
                         if "main" != attr.name() {
index 0c50eb294d50924c22e5dd6ead7ca1041eeee3d3..53a8b93c232da086dd394eb4bf3daf9cfa782386 100644 (file)
@@ -45,7 +45,7 @@ fn visit_item(&mut self, item:@item, _:()) {
 }
 
 pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) {
-    if *session.building_library {
+    if session.building_library.get() {
         // No need to find a main function
         return;
     }
@@ -131,7 +131,7 @@ fn configure_main(this: &mut EntryContext) {
         this.session.entry_fn.set(this.main_fn);
         this.session.entry_type.set(Some(session::EntryMain));
     } else {
-        if !*this.session.building_library {
+        if !this.session.building_library.get() {
             // No main function
             this.session.err("main function not found");
             if !this.non_main_fns.is_empty() {
index 958fd20dfca3983971f70544afec09c049217262..9a5e08e41aa238e0c98f52e8a4d063a20b054fbc 100644 (file)
@@ -303,7 +303,7 @@ fn propagate(&self) {
     fn propagate_node(&self, node: &ast_map::ast_node,
                       search_item: ast::NodeId,
                       visitor: &mut MarkSymbolVisitor) {
-        if !*self.tcx.sess.building_library {
+        if !self.tcx.sess.building_library.get() {
             // If we are building an executable, then there's no need to flag
             // anything as external except for `extern fn` types. These
             // functions may still participate in some form of native interface,
index e4bcfd3d1a7530a183b94cf762d0e3012b72ac11..0b2ee710e991324e011b552ddc82f303469f80c5 100644 (file)
@@ -2344,7 +2344,7 @@ fn finish_register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::Nod
         }
     }
 
-    if is_entry_fn(&ccx.sess, node_id) && !*ccx.sess.building_library {
+    if is_entry_fn(&ccx.sess, node_id) && !ccx.sess.building_library.get() {
         create_entry_wrapper(ccx, sp, llfn);
     }
 }
@@ -2678,7 +2678,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
                             // library then we've already declared the crate map
                             // so use that instead.
                             if attr::contains_name(ni.attrs, "crate_map") {
-                                if *ccx.sess.building_library {
+                                if ccx.sess.building_library.get() {
                                     let s = "_rust_crate_map_toplevel";
                                     let g = unsafe {
                                         s.with_c_str(|buf| {
@@ -3044,7 +3044,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
     let mut n_subcrates = 1;
     let cstore = sess.cstore;
     while cstore.have_crate_data(n_subcrates) { n_subcrates += 1; }
-    let is_top = !*sess.building_library || sess.gen_crate_map();
+    let is_top = !sess.building_library.get() || sess.gen_crate_map();
     let sym_name = if is_top {
         ~"_rust_crate_map_toplevel"
     } else {
@@ -3154,7 +3154,9 @@ pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::encode_
 pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] {
     use extra::flate;
 
-    if !*cx.sess.building_library { return ~[]; }
+    if !cx.sess.building_library.get() {
+        return ~[]
+    }
 
     let encode_inlined_item: encoder::encode_inlined_item =
         |ecx, ebml_w, path, ii|
@@ -3227,8 +3229,7 @@ pub fn trans_crate(sess: session::Session,
     // __rust_crate_map_toplevel symbol (extra underscore) which it will
     // subsequently fail to find. So to mitigate that we just introduce
     // an alias from the symbol it expects to the one that actually exists.
-    if ccx.sess.targ_cfg.os == OsWin32 &&
-       !*ccx.sess.building_library {
+    if ccx.sess.targ_cfg.os == OsWin32 && !ccx.sess.building_library.get() {
 
         let maptype = val_ty(ccx.crate_map).to_ref();
 
index 4443fa000e71566c1aa116c064f713186eaf6c84..9a1e6cbeaba039c387887698fbda1f8de48e35e7 100644 (file)
@@ -438,7 +438,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
 
 fn check_for_entry_fn(ccx: &CrateCtxt) {
     let tcx = ccx.tcx;
-    if !*tcx.sess.building_library {
+    if !tcx.sess.building_library.get() {
         match tcx.sess.entry_fn.get() {
           Some((id, sp)) => match tcx.sess.entry_type.get() {
               Some(session::EntryMain) => check_main_fn_ty(ccx, id, sp),