Skip to content

Commit 5c63b1f

Browse files
committed
librustc: De-@mut the entry function and entry type in the session
1 parent 522743c commit 5c63b1f

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use middle;
2626
use util::common::time;
2727
use util::ppaux;
2828

29-
use std::cell::RefCell;
29+
use std::cell::{Cell, RefCell};
3030
use std::hashmap::{HashMap,HashSet};
3131
use std::io;
3232
use std::io::fs;
@@ -874,8 +874,8 @@ pub fn build_session_(sopts: @session::options,
874874
parse_sess: p_s,
875875
codemap: cm,
876876
// For a library crate, this is always none
877-
entry_fn: @mut None,
878-
entry_type: @mut None,
877+
entry_fn: RefCell::new(None),
878+
entry_type: Cell::new(None),
879879
span_diagnostic: span_diagnostic_handler,
880880
filesearch: filesearch,
881881
building_library: @mut false,

src/librustc/driver/session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::abi;
2828
use syntax::parse::token;
2929
use syntax;
3030

31-
use std::cell::RefCell;
31+
use std::cell::{Cell, RefCell};
3232
use std::hashmap::{HashMap,HashSet};
3333

3434
pub struct config {
@@ -206,8 +206,8 @@ pub struct Session_ {
206206
parse_sess: @mut ParseSess,
207207
codemap: @codemap::CodeMap,
208208
// For a library crate, this is always none
209-
entry_fn: @mut Option<(NodeId, codemap::Span)>,
210-
entry_type: @mut Option<EntryFnType>,
209+
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
210+
entry_type: Cell<Option<EntryFnType>>,
211211
span_diagnostic: @mut diagnostic::span_handler,
212212
filesearch: @filesearch::FileSearch,
213213
building_library: @mut bool,

src/librustc/middle/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn create_and_seed_worklist(tcx: ty::ctxt,
212212
}
213213

214214
// Seed entry point
215-
match *tcx.sess.entry_fn {
215+
match tcx.sess.entry_fn.get() {
216216
Some((id, _)) => worklist.push(id),
217217
None => ()
218218
}

src/librustc/middle/entry.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map)
5252

5353
// If the user wants no main function at all, then stop here.
5454
if attr::contains_name(crate.attrs, "no_main") {
55-
*session.entry_type = Some(session::EntryNone);
55+
session.entry_type.set(Some(session::EntryNone));
5656
return
5757
}
5858

@@ -122,14 +122,14 @@ fn find_item(item: @item, ctxt: &mut EntryContext) {
122122

123123
fn configure_main(this: &mut EntryContext) {
124124
if this.start_fn.is_some() {
125-
*this.session.entry_fn = this.start_fn;
126-
*this.session.entry_type = Some(session::EntryStart);
125+
this.session.entry_fn.set(this.start_fn);
126+
this.session.entry_type.set(Some(session::EntryStart));
127127
} else if this.attr_main_fn.is_some() {
128-
*this.session.entry_fn = this.attr_main_fn;
129-
*this.session.entry_type = Some(session::EntryMain);
128+
this.session.entry_fn.set(this.attr_main_fn);
129+
this.session.entry_type.set(Some(session::EntryMain));
130130
} else if this.main_fn.is_some() {
131-
*this.session.entry_fn = this.main_fn;
132-
*this.session.entry_type = Some(session::EntryMain);
131+
this.session.entry_fn.set(this.main_fn);
132+
this.session.entry_type.set(Some(session::EntryMain));
133133
} else {
134134
if !*this.session.building_library {
135135
// No main function

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ pub fn register_fn_llvmty(ccx: @CrateContext,
23822382
}
23832383

23842384
pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool {
2385-
match *sess.entry_fn {
2385+
match sess.entry_fn.get() {
23862386
Some((entry_id, _)) => node_id == entry_id,
23872387
None => false
23882388
}
@@ -2393,7 +2393,7 @@ pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool {
23932393
pub fn create_entry_wrapper(ccx: @CrateContext,
23942394
_sp: Span,
23952395
main_llfn: ValueRef) {
2396-
let et = ccx.sess.entry_type.unwrap();
2396+
let et = ccx.sess.entry_type.get().unwrap();
23972397
match et {
23982398
session::EntryMain => {
23992399
create_entry_fn(ccx, main_llfn, true);

src/librustc/middle/typeck/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
439439
fn check_for_entry_fn(ccx: &CrateCtxt) {
440440
let tcx = ccx.tcx;
441441
if !*tcx.sess.building_library {
442-
match *tcx.sess.entry_fn {
443-
Some((id, sp)) => match *tcx.sess.entry_type {
442+
match tcx.sess.entry_fn.get() {
443+
Some((id, sp)) => match tcx.sess.entry_type.get() {
444444
Some(session::EntryMain) => check_main_fn_ty(ccx, id, sp),
445445
Some(session::EntryStart) => check_start_fn_ty(ccx, id, sp),
446446
Some(session::EntryNone) => {}

0 commit comments

Comments
 (0)