diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index c1c750c62426..32cdbfe59fa1 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -520,7 +520,7 @@ pub fn symbol_hash(tcx: ty::ctxt, hash.to_managed() } -pub fn get_symbol_hash(ccx: &mut CrateContext, t: ty::t) -> @str { +pub fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> @str { { let type_hashcodes = ccx.type_hashcodes.borrow(); match type_hashcodes.get().find(&t) { @@ -662,7 +662,7 @@ pub fn exported_name(sess: Session, mangle(sess, path, Some(hash), Some(vers.as_slice())) } -pub fn mangle_exported_name(ccx: &mut CrateContext, +pub fn mangle_exported_name(ccx: &CrateContext, path: path, t: ty::t) -> ~str { let hash = get_symbol_hash(ccx, t); @@ -671,7 +671,7 @@ pub fn mangle_exported_name(ccx: &mut CrateContext, ccx.link_meta.pkgid.version_or_default()); } -pub fn mangle_internal_name_by_type_only(ccx: &mut CrateContext, +pub fn mangle_internal_name_by_type_only(ccx: &CrateContext, t: ty::t, name: &str) -> ~str { let s = ppaux::ty_to_short_str(ccx.tcx, t); @@ -683,7 +683,7 @@ pub fn mangle_internal_name_by_type_only(ccx: &mut CrateContext, None); } -pub fn mangle_internal_name_by_type_and_seq(ccx: &mut CrateContext, +pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext, t: ty::t, name: &str) -> ~str { let s = ppaux::ty_to_str(ccx.tcx, t); @@ -695,7 +695,7 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &mut CrateContext, None); } -pub fn mangle_internal_name_by_path_and_seq(ccx: &mut CrateContext, +pub fn mangle_internal_name_by_path_and_seq(ccx: &CrateContext, mut path: path, flav: &str) -> ~str { let (_, name) = gensym_name(flav); @@ -703,7 +703,7 @@ pub fn mangle_internal_name_by_path_and_seq(ccx: &mut CrateContext, mangle(ccx.sess, path, None, None) } -pub fn mangle_internal_name_by_path(ccx: &mut CrateContext, path: path) -> ~str { +pub fn mangle_internal_name_by_path(ccx: &CrateContext, path: path) -> ~str { mangle(ccx.sess, path, None, None) } diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index e06dae6654c8..5d70a3ad2664 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -116,7 +116,7 @@ pub fn represent_node(bcx: @Block, node: ast::NodeId) -> @Repr { } /// Decides how to represent a given type. -pub fn represent_type(cx: &mut CrateContext, t: ty::t) -> @Repr { +pub fn represent_type(cx: &CrateContext, t: ty::t) -> @Repr { debug!("Representing: {}", ty_to_str(cx.tcx, t)); { let adt_reprs = cx.adt_reprs.borrow(); @@ -133,7 +133,7 @@ pub fn represent_type(cx: &mut CrateContext, t: ty::t) -> @Repr { return repr; } -fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr { +fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { match ty::get(t).sty { ty::ty_tup(ref elems) => { return Univariant(mk_struct(cx, *elems, false), false) @@ -255,7 +255,7 @@ pub fn is_ffi_safe(tcx: ty::ctxt, def_id: ast::DefId) -> bool { // this should probably all be in ty struct Case { discr: Disr, tys: ~[ty::t] } impl Case { - fn is_zerolen(&self, cx: &mut CrateContext) -> bool { + fn is_zerolen(&self, cx: &CrateContext) -> bool { mk_struct(cx, self.tys, false).size == 0 } fn find_ptr(&self) -> Option { @@ -273,7 +273,7 @@ fn get_cases(tcx: ty::ctxt, def_id: ast::DefId, substs: &ty::substs) -> ~[Case] } -fn mk_struct(cx: &mut CrateContext, tys: &[ty::t], packed: bool) -> Struct { +fn mk_struct(cx: &CrateContext, tys: &[ty::t], packed: bool) -> Struct { let lltys = tys.map(|&ty| type_of::sizing_type_of(cx, ty)); let llty_rec = Type::struct_(lltys, packed); Struct { @@ -291,7 +291,7 @@ struct IntBounds { uhi: u64 } -fn mk_cenum(cx: &mut CrateContext, hint: Hint, bounds: &IntBounds) -> Repr { +fn mk_cenum(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> Repr { let it = range_to_inttype(cx, hint, bounds); match it { attr::SignedInt(_) => CEnum(it, bounds.slo as Disr, bounds.shi as Disr), @@ -299,7 +299,7 @@ fn mk_cenum(cx: &mut CrateContext, hint: Hint, bounds: &IntBounds) -> Repr { } } -fn range_to_inttype(cx: &mut CrateContext, hint: Hint, bounds: &IntBounds) -> IntType { +fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntType { debug!("range_to_inttype: {:?} {:?}", hint, bounds); // Lists of sizes to try. u64 is always allowed as a fallback. static choose_shortest: &'static[IntType] = &[ @@ -339,14 +339,14 @@ fn range_to_inttype(cx: &mut CrateContext, hint: Hint, bounds: &IntBounds) -> In return attr::UnsignedInt(ast::ty_u64); } -pub fn ll_inttype(cx: &mut CrateContext, ity: IntType) -> Type { +pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type { match ity { attr::SignedInt(t) => Type::int_from_ty(cx, t), attr::UnsignedInt(t) => Type::uint_from_ty(cx, t) } } -fn bounds_usable(cx: &mut CrateContext, ity: IntType, bounds: &IntBounds) -> bool { +fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool { debug!("bounds_usable: {:?} {:?}", ity, bounds); match ity { attr::SignedInt(_) => { @@ -380,16 +380,16 @@ pub fn ty_of_inttype(ity: IntType) -> ty::t { * and fill in the actual contents in a second pass to prevent * unbounded recursion; see also the comments in `trans::type_of`. */ -pub fn type_of(cx: &mut CrateContext, r: &Repr) -> Type { +pub fn type_of(cx: &CrateContext, r: &Repr) -> Type { generic_type_of(cx, r, None, false) } -pub fn sizing_type_of(cx: &mut CrateContext, r: &Repr) -> Type { +pub fn sizing_type_of(cx: &CrateContext, r: &Repr) -> Type { generic_type_of(cx, r, None, true) } -pub fn incomplete_type_of(cx: &mut CrateContext, r: &Repr, name: &str) -> Type { +pub fn incomplete_type_of(cx: &CrateContext, r: &Repr, name: &str) -> Type { generic_type_of(cx, r, Some(name), false) } -pub fn finish_type_of(cx: &mut CrateContext, r: &Repr, llty: &mut Type) { +pub fn finish_type_of(cx: &CrateContext, r: &Repr, llty: &mut Type) { match *r { CEnum(..) | General(..) => { } Univariant(ref st, _) | NullablePointer{ nonnull: ref st, .. } => @@ -397,7 +397,7 @@ pub fn finish_type_of(cx: &mut CrateContext, r: &Repr, llty: &mut Type) { } } -fn generic_type_of(cx: &mut CrateContext, r: &Repr, name: Option<&str>, sizing: bool) -> Type { +fn generic_type_of(cx: &CrateContext, r: &Repr, name: Option<&str>, sizing: bool) -> Type { match *r { CEnum(ity, _, _) => ll_inttype(cx, ity), Univariant(ref st, _) | NullablePointer{ nonnull: ref st, .. } => { @@ -449,7 +449,7 @@ fn generic_type_of(cx: &mut CrateContext, r: &Repr, name: Option<&str>, sizing: } } -fn struct_llfields(cx: &mut CrateContext, st: &Struct, sizing: bool) -> ~[Type] { +fn struct_llfields(cx: &CrateContext, st: &Struct, sizing: bool) -> ~[Type] { if sizing { st.fields.map(|&ty| type_of::sizing_type_of(cx, ty)) } else { @@ -705,7 +705,7 @@ pub fn trans_drop_flag_ptr(bcx: @Block, r: &Repr, val: ValueRef) -> ValueRef { * this could be changed in the future to avoid allocating unnecessary * space after values of shorter-than-maximum cases. */ -pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr, +pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr, vals: &[ValueRef]) -> ValueRef { match *r { CEnum(ity, min, max) => { @@ -750,7 +750,7 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr, * a two-element struct will locate it at offset 4, and accesses to it * will read the wrong memory. */ -fn build_const_struct(ccx: &mut CrateContext, st: &Struct, vals: &[ValueRef]) +fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef]) -> ~[ValueRef] { assert_eq!(vals.len(), st.fields.len()); @@ -791,7 +791,7 @@ fn padding(size: u64) -> ValueRef { fn roundup(x: u64, a: u64) -> u64 { ((x + (a - 1)) / a) * a } /// Get the discriminant of a constant value. (Not currently used.) -pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef) +pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef) -> Disr { match *r { CEnum(ity, _, _) => { @@ -825,7 +825,7 @@ pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef) * (Not to be confused with `common::const_get_elt`, which operates on * raw LLVM-level structs and arrays.) */ -pub fn const_get_field(ccx: &mut CrateContext, r: &Repr, val: ValueRef, +pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef, _discr: Disr, ix: uint) -> ValueRef { match *r { CEnum(..) => ccx.sess.bug("element access in C-like enum const"), @@ -836,7 +836,7 @@ pub fn const_get_field(ccx: &mut CrateContext, r: &Repr, val: ValueRef, } /// Extract field of struct-like const, skipping our alignment padding. -fn const_struct_field(ccx: &mut CrateContext, val: ValueRef, ix: uint) +fn const_struct_field(ccx: &CrateContext, val: ValueRef, ix: uint) -> ValueRef { // Get the ix-th non-undef element of the struct. let mut real_ix = 0; // actual position in the struct diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0babc88661cf..d0675620dea8 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -131,14 +131,14 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt { } pub struct StatRecorder<'a> { - ccx: @mut CrateContext, + ccx: @CrateContext, name: &'a str, start: u64, istart: uint, } impl<'a> StatRecorder<'a> { - pub fn new(ccx: @mut CrateContext, + pub fn new(ccx: @CrateContext, name: &'a str) -> StatRecorder<'a> { let start = if ccx.sess.trans_stats() { time::precise_time_ns() @@ -203,7 +203,7 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str, f } -fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, +fn get_extern_rust_fn(ccx: &CrateContext, inputs: &[ty::t], output: ty::t, name: &str, did: ast::DefId) -> ValueRef { { let externs = ccx.externs.borrow(); @@ -223,7 +223,7 @@ fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, f } -fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, name: &str) -> ValueRef { +fn decl_rust_fn(ccx: &CrateContext, inputs: &[ty::t], output: ty::t, name: &str) -> ValueRef { let llfty = type_of_rust_fn(ccx, inputs, output); let llfn = decl_cdecl_fn(ccx.llmod, name, llfty); @@ -276,7 +276,7 @@ fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, name: & llfn } -pub fn decl_internal_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, +pub fn decl_internal_rust_fn(ccx: &CrateContext, inputs: &[ty::t], output: ty::t, name: &str) -> ValueRef { let llfn = decl_rust_fn(ccx, inputs, output, name); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); @@ -440,11 +440,11 @@ pub fn maybe_set_managed_unique_rc(bcx: @Block, bx: ValueRef, heap: heap) { // Type descriptor and type glue stuff -pub fn get_tydesc_simple(ccx: &mut CrateContext, t: ty::t) -> ValueRef { +pub fn get_tydesc_simple(ccx: &CrateContext, t: ty::t) -> ValueRef { get_tydesc(ccx, t).tydesc } -pub fn get_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info { +pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> @mut tydesc_info { { let tydescs = ccx.tydescs.borrow(); match tydescs.get().find(&t) { @@ -515,7 +515,7 @@ pub fn set_no_split_stack(f: ValueRef) { // Double-check that we never ask LLVM to declare the same symbol twice. It // silently mangles such symbols, breaking our linkage model. -pub fn note_unique_llvm_symbol(ccx: &mut CrateContext, sym: @str) { +pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: @str) { let mut all_llvm_symbols = ccx.all_llvm_symbols.borrow_mut(); if all_llvm_symbols.get().contains(&sym) { ccx.sess.bug(~"duplicate LLVM symbol: " + sym); @@ -524,7 +524,7 @@ pub fn note_unique_llvm_symbol(ccx: &mut CrateContext, sym: @str) { } -pub fn get_res_dtor(ccx: @mut CrateContext, +pub fn get_res_dtor(ccx: @CrateContext, did: ast::DefId, parent_id: ast::DefId, substs: &[ty::t]) @@ -862,7 +862,7 @@ pub fn null_env_ptr(ccx: &CrateContext) -> ValueRef { C_null(Type::opaque_box(ccx).ptr_to()) } -pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) -> ValueRef { +pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> ValueRef { let name = csearch::get_symbol(ccx.sess.cstore, did); match ty::get(t).sty { ty::ty_bare_fn(ref fn_ty) => { @@ -1652,7 +1652,7 @@ pub fn make_return_pointer(fcx: @mut FunctionContext, output_type: ty::t) -> Val // - create_llargs_for_fn_args. // - new_fn_ctxt // - trans_args -pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext, +pub fn new_fn_ctxt_w_id(ccx: @CrateContext, path: path, llfndecl: ValueRef, id: ast::NodeId, @@ -1726,7 +1726,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext, fcx } -pub fn new_fn_ctxt(ccx: @mut CrateContext, +pub fn new_fn_ctxt(ccx: @CrateContext, path: path, llfndecl: ValueRef, output_type: ty::t, @@ -1888,7 +1888,7 @@ pub enum self_arg { impl_self(ty::t, ty::SelfMode), no_self, } // trans_closure: Builds an LLVM function out of a source function. // If the function closes over its environment a closure will be // returned. -pub fn trans_closure(ccx: @mut CrateContext, +pub fn trans_closure(ccx: @CrateContext, path: path, decl: &ast::fn_decl, body: &ast::Block, @@ -1965,7 +1965,7 @@ pub fn trans_closure(ccx: @mut CrateContext, // trans_fn: creates an LLVM function corresponding to a source language // function. -pub fn trans_fn(ccx: @mut CrateContext, +pub fn trans_fn(ccx: @CrateContext, path: path, decl: &ast::fn_decl, body: &ast::Block, @@ -2022,7 +2022,7 @@ fn insert_synthetic_type_entries(bcx: @Block, } } -pub fn trans_enum_variant(ccx: @mut CrateContext, +pub fn trans_enum_variant(ccx: @CrateContext, _enum_id: ast::NodeId, variant: &ast::variant, args: &[ast::variant_arg], @@ -2040,7 +2040,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext, llfndecl); } -pub fn trans_tuple_struct(ccx: @mut CrateContext, +pub fn trans_tuple_struct(ccx: @CrateContext, fields: &[ast::struct_field], ctor_id: ast::NodeId, param_substs: Option<@param_substs>, @@ -2072,7 +2072,7 @@ impl IdAndTy for ast::struct_field { } pub fn trans_enum_variant_or_tuple_like_struct( - ccx: @mut CrateContext, + ccx: @CrateContext, ctor_id: ast::NodeId, args: &[A], disr: ty::Disr, @@ -2150,7 +2150,7 @@ pub fn trans_enum_variant_or_tuple_like_struct( finish_fn(fcx, bcx); } -pub fn trans_enum_def(ccx: @mut CrateContext, enum_definition: &ast::enum_def, +pub fn trans_enum_def(ccx: @CrateContext, enum_definition: &ast::enum_def, id: ast::NodeId, vi: @~[@ty::VariantInfo], i: &mut uint) { for &variant in enum_definition.variants.iter() { @@ -2174,7 +2174,7 @@ pub fn trans_enum_def(ccx: @mut CrateContext, enum_definition: &ast::enum_def, } pub struct TransItemVisitor { - ccx: @mut CrateContext, + ccx: @CrateContext, } impl Visitor<()> for TransItemVisitor { @@ -2183,7 +2183,7 @@ impl Visitor<()> for TransItemVisitor { } } -pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) { +pub fn trans_item(ccx: @CrateContext, item: &ast::item) { let _icx = push_ctxt("trans_item"); let path = match ccx.tcx.items.get_copy(&item.id) { ast_map::node_item(_, p) => p, @@ -2279,7 +2279,7 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) { } } -pub fn trans_struct_def(ccx: @mut CrateContext, struct_def: @ast::struct_def) { +pub fn trans_struct_def(ccx: @CrateContext, struct_def: @ast::struct_def) { // If this is a tuple-like struct, translate the constructor. match struct_def.ctor_id { // We only need to translate a constructor if there are fields; @@ -2298,14 +2298,14 @@ pub fn trans_struct_def(ccx: @mut CrateContext, struct_def: @ast::struct_def) { // separate modules in the compiled program. That's because modules exist // only as a convenience for humans working with the code, to organize names // and control visibility. -pub fn trans_mod(ccx: @mut CrateContext, m: &ast::_mod) { +pub fn trans_mod(ccx: @CrateContext, m: &ast::_mod) { let _icx = push_ctxt("trans_mod"); for item in m.items.iter() { trans_item(ccx, *item); } } -fn finish_register_fn(ccx: @mut CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId, +fn finish_register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId, llfn: ValueRef) { { let mut item_symbols = ccx.item_symbols.borrow_mut(); @@ -2321,7 +2321,7 @@ fn finish_register_fn(ccx: @mut CrateContext, sp: Span, sym: ~str, node_id: ast: } } -pub fn register_fn(ccx: @mut CrateContext, +pub fn register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId, @@ -2341,7 +2341,7 @@ pub fn register_fn(ccx: @mut CrateContext, } // only use this for foreign function ABIs and glue, use `register_fn` for Rust functions -pub fn register_fn_llvmty(ccx: @mut CrateContext, +pub fn register_fn_llvmty(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId, @@ -2366,7 +2366,7 @@ pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool { // Create a _rust_main(args: ~[str]) function which will be called from the // runtime rust_start function -pub fn create_entry_wrapper(ccx: @mut CrateContext, +pub fn create_entry_wrapper(ccx: @CrateContext, _sp: Span, main_llfn: ValueRef) { let et = ccx.sess.entry_type.unwrap(); @@ -2378,7 +2378,7 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext, session::EntryNone => {} // Do nothing. } - fn create_entry_fn(ccx: @mut CrateContext, + fn create_entry_fn(ccx: @CrateContext, rust_main: ValueRef, use_start_lang_item: bool) { let llfty = Type::func([ccx.int_type, Type::i8().ptr_to().ptr_to()], @@ -2454,7 +2454,7 @@ pub fn item_path(ccx: &CrateContext, id: &ast::NodeId) -> path { ty::item_path(ccx.tcx, ast_util::local_def(*id)) } -fn exported_name(ccx: &mut CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str { +fn exported_name(ccx: &CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str { match attr::first_attr_value_str_by_name(attrs, "export_name") { // Use provided name Some(name) => name.to_owned(), @@ -2468,7 +2468,7 @@ fn exported_name(ccx: &mut CrateContext, path: path, ty: ty::t, attrs: &[ast::At } } -pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { +pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef { debug!("get_item_val(id=`{:?}`)", id); let val = { @@ -2736,7 +2736,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { } } -pub fn register_method(ccx: @mut CrateContext, +pub fn register_method(ccx: @CrateContext, id: ast::NodeId, path: @ast_map::path, m: @ast::method) -> ValueRef { @@ -2927,7 +2927,7 @@ pub fn trap(bcx: @Block) { } } -pub fn decl_gc_metadata(ccx: &mut CrateContext, llmod_id: &str) { +pub fn decl_gc_metadata(ccx: &CrateContext, llmod_id: &str) { if !ccx.sess.opts.gc || !ccx.uses_gc { return; } @@ -2947,7 +2947,7 @@ pub fn decl_gc_metadata(ccx: &mut CrateContext, llmod_id: &str) { } } -pub fn create_module_map(ccx: &mut CrateContext) -> (ValueRef, uint) { +pub fn create_module_map(ccx: &CrateContext) -> (ValueRef, uint) { let str_slice_type = Type::struct_([Type::i8p(), ccx.int_type], false); let elttype = Type::struct_([str_slice_type, ccx.int_type], false); let maptype = { @@ -3035,7 +3035,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta, return (sym_name, map); } -pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) { +pub fn fill_crate_map(ccx: @CrateContext, map: ValueRef) { let mut subcrates: ~[ValueRef] = ~[]; let mut i = 1; let cstore = ccx.sess.cstore; @@ -3165,7 +3165,7 @@ pub fn trans_crate(sess: session::Session, // 1. http://llvm.org/bugs/show_bug.cgi?id=11479 let llmod_id = link_meta.pkgid.name.clone() + ".rc"; - let ccx = @mut CrateContext::new(sess, + let ccx = @CrateContext::new(sess, llmod_id, analysis.ty_cx, analysis.exp_map2, diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index 02e2232bfc8f..d2677294945c 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -25,7 +25,7 @@ use std::ptr::is_not_null; pub struct Builder { llbuilder: BuilderRef, - ccx: @mut CrateContext, + ccx: @CrateContext, } // This is a really awful way to get a zero-length c-string, but better (and a @@ -38,7 +38,7 @@ pub fn noname() -> *c_char { } impl Builder { - pub fn new(ccx: @mut CrateContext) -> Builder { + pub fn new(ccx: @CrateContext) -> Builder { Builder { llbuilder: ccx.builder.B, ccx: ccx, diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index 8648bf6f3480..bb05221ae101 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -89,7 +89,7 @@ pub struct FnType { ret_ty: ArgType, } -pub fn compute_abi_info(ccx: &mut CrateContext, +pub fn compute_abi_info(ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs index 736feeb0618a..a73c098805d6 100644 --- a/src/librustc/middle/trans/cabi_arm.rs +++ b/src/librustc/middle/trans/cabi_arm.rs @@ -127,7 +127,7 @@ fn is_reg_ty(ty: Type) -> bool { } } -pub fn compute_abi_info(_ccx: &mut CrateContext, +pub fn compute_abi_info(_ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { diff --git a/src/librustc/middle/trans/cabi_mips.rs b/src/librustc/middle/trans/cabi_mips.rs index e98618c4e010..54155cd3f782 100644 --- a/src/librustc/middle/trans/cabi_mips.rs +++ b/src/librustc/middle/trans/cabi_mips.rs @@ -158,7 +158,7 @@ fn struct_ty(ty: Type) -> Type { return Type::struct_(fields, false); } -pub fn compute_abi_info(_ccx: &mut CrateContext, +pub fn compute_abi_info(_ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { diff --git a/src/librustc/middle/trans/cabi_x86.rs b/src/librustc/middle/trans/cabi_x86.rs index f8cc246f6828..616dc0703a73 100644 --- a/src/librustc/middle/trans/cabi_x86.rs +++ b/src/librustc/middle/trans/cabi_x86.rs @@ -16,7 +16,7 @@ use super::common::*; use super::machine::*; use middle::trans::type_::Type; -pub fn compute_abi_info(ccx: &mut CrateContext, +pub fn compute_abi_info(ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 329651cb1941..564efa8c0686 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -332,7 +332,7 @@ fn llreg_ty(cls: &[RegClass]) -> Type { return Type::struct_(tys, false); } -pub fn compute_abi_info(_ccx: &mut CrateContext, +pub fn compute_abi_info(_ccx: &CrateContext, atys: &[Type], rty: Type, ret_def: bool) -> FnType { diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 9f81aa00193e..7f9451859c7a 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -47,7 +47,7 @@ use syntax::{ast, ast_map}; pub use middle::trans::context::CrateContext; -fn type_is_newtype_immediate(ccx: &mut CrateContext, ty: ty::t) -> bool { +fn type_is_newtype_immediate(ccx: &CrateContext, ty: ty::t) -> bool { match ty::get(ty).sty { ty::ty_struct(def_id, ref substs) => { let fields = ty::struct_fields(ccx.tcx, def_id, substs); @@ -59,7 +59,7 @@ fn type_is_newtype_immediate(ccx: &mut CrateContext, ty: ty::t) -> bool { } } -pub fn type_is_immediate(ccx: &mut CrateContext, ty: ty::t) -> bool { +pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool { use middle::trans::machine::llsize_of_alloc; use middle::trans::type_of::sizing_type_of; let tcx = ccx.tcx; @@ -261,7 +261,7 @@ pub struct FunctionContext { path: path, // This function's enclosing crate context. - ccx: @mut CrateContext, + ccx: @CrateContext, // Used and maintained by the debuginfo module. debug_context: debuginfo::FunctionDebugContext, @@ -306,7 +306,7 @@ impl FunctionContext { } } -pub fn warn_not_to_commit(ccx: &mut CrateContext, msg: &str) { +pub fn warn_not_to_commit(ccx: &CrateContext, msg: &str) { if !ccx.do_not_commit_warning_issued.get() { ccx.do_not_commit_warning_issued.set(true); ccx.sess.warn(msg.to_str() + " -- do not commit like this!"); @@ -692,7 +692,7 @@ impl Block { } } - pub fn ccx(&self) -> @mut CrateContext { self.fcx.ccx } + pub fn ccx(&self) -> @CrateContext { self.fcx.ccx } pub fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx } pub fn sess(&self) -> Session { self.fcx.ccx.sess } @@ -888,7 +888,7 @@ pub fn C_u8(i: uint) -> ValueRef { // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. -pub fn C_cstr(cx: &mut CrateContext, s: @str) -> ValueRef { +pub fn C_cstr(cx: &CrateContext, s: @str) -> ValueRef { unsafe { { let const_cstr_cache = cx.const_cstr_cache.borrow(); @@ -918,7 +918,7 @@ pub fn C_cstr(cx: &mut CrateContext, s: @str) -> ValueRef { // NB: Do not use `do_spill_noroot` to make this into a constant string, or // you will be kicked off fast isel. See issue #4352 for an example of this. -pub fn C_estr_slice(cx: &mut CrateContext, s: @str) -> ValueRef { +pub fn C_estr_slice(cx: &CrateContext, s: @str) -> ValueRef { unsafe { let len = s.len(); let cs = llvm::LLVMConstPointerCast(C_cstr(cx, s), Type::i8p().to_ref()); @@ -926,7 +926,7 @@ pub fn C_estr_slice(cx: &mut CrateContext, s: @str) -> ValueRef { } } -pub fn C_binary_slice(cx: &mut CrateContext, data: &[u8]) -> ValueRef { +pub fn C_binary_slice(cx: &CrateContext, data: &[u8]) -> ValueRef { unsafe { let len = data.len(); let lldata = C_bytes(data); diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 51b373eb0cc7..91e737b2cd12 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -35,7 +35,7 @@ use std::libc::c_uint; use std::vec; use syntax::{ast, ast_util, ast_map}; -pub fn const_lit(cx: &mut CrateContext, e: &ast::Expr, lit: ast::lit) +pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::lit) -> ValueRef { let _icx = push_ctxt("trans_lit"); match lit.node { @@ -76,7 +76,7 @@ pub fn const_lit(cx: &mut CrateContext, e: &ast::Expr, lit: ast::lit) } } -pub fn const_ptrcast(cx: &mut CrateContext, a: ValueRef, t: Type) -> ValueRef { +pub fn const_ptrcast(cx: &CrateContext, a: ValueRef, t: Type) -> ValueRef { unsafe { let b = llvm::LLVMConstPointerCast(a, t.ptr_to().to_ref()); let mut const_globals = cx.const_globals.borrow_mut(); @@ -85,7 +85,7 @@ pub fn const_ptrcast(cx: &mut CrateContext, a: ValueRef, t: Type) -> ValueRef { } } -fn const_vec(cx: @mut CrateContext, e: &ast::Expr, es: &[@ast::Expr]) -> (ValueRef, Type, bool) { +fn const_vec(cx: @CrateContext, e: &ast::Expr, es: &[@ast::Expr]) -> (ValueRef, Type, bool) { let vec_ty = ty::expr_ty(cx.tcx, e); let unit_ty = ty::sequence_element_type(cx.tcx, vec_ty); let llunitty = type_of::type_of(cx, unit_ty); @@ -99,7 +99,7 @@ fn const_vec(cx: @mut CrateContext, e: &ast::Expr, es: &[@ast::Expr]) -> (ValueR (v, llunitty, inlineable.iter().fold(true, |a, &b| a && b)) } -fn const_addr_of(cx: &mut CrateContext, cv: ValueRef) -> ValueRef { +fn const_addr_of(cx: &CrateContext, cv: ValueRef) -> ValueRef { unsafe { let gv = "const".with_c_str(|name| { llvm::LLVMAddGlobal(cx.llmod, val_ty(cv).to_ref(), name) @@ -111,7 +111,7 @@ fn const_addr_of(cx: &mut CrateContext, cv: ValueRef) -> ValueRef { } } -fn const_deref_ptr(cx: &mut CrateContext, v: ValueRef) -> ValueRef { +fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef { let const_globals = cx.const_globals.borrow(); let v = match const_globals.get().find(&(v as int)) { Some(&v) => v, @@ -123,13 +123,13 @@ fn const_deref_ptr(cx: &mut CrateContext, v: ValueRef) -> ValueRef { } } -fn const_deref_newtype(cx: &mut CrateContext, v: ValueRef, t: ty::t) +fn const_deref_newtype(cx: &CrateContext, v: ValueRef, t: ty::t) -> ValueRef { let repr = adt::represent_type(cx, t); adt::const_get_field(cx, repr, v, 0, 0) } -fn const_deref(cx: &mut CrateContext, v: ValueRef, t: ty::t, explicit: bool) +fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool) -> (ValueRef, ty::t) { match ty::deref(cx.tcx, t, explicit) { Some(ref mt) => { @@ -155,7 +155,7 @@ fn const_deref(cx: &mut CrateContext, v: ValueRef, t: ty::t, explicit: bool) } } -pub fn get_const_val(cx: @mut CrateContext, +pub fn get_const_val(cx: @CrateContext, mut def_id: ast::DefId) -> (ValueRef, bool) { let contains_key = { let const_values = cx.const_values.borrow(); @@ -181,7 +181,7 @@ pub fn get_const_val(cx: @mut CrateContext, !non_inlineable_statics.get().contains(&def_id.node)) } -pub fn const_expr(cx: @mut CrateContext, e: &ast::Expr) -> (ValueRef, bool) { +pub fn const_expr(cx: @CrateContext, e: &ast::Expr) -> (ValueRef, bool) { let (llconst, inlineable) = const_expr_unadjusted(cx, e); let mut llconst = llconst; let mut inlineable = inlineable; @@ -265,9 +265,9 @@ pub fn const_expr(cx: @mut CrateContext, e: &ast::Expr) -> (ValueRef, bool) { // the bool returned is whether this expression can be inlined into other crates // if it's assigned to a static. -fn const_expr_unadjusted(cx: @mut CrateContext, +fn const_expr_unadjusted(cx: @CrateContext, e: &ast::Expr) -> (ValueRef, bool) { - fn map_list(cx: @mut CrateContext, + fn map_list(cx: @CrateContext, exprs: &[@ast::Expr]) -> (~[ValueRef], bool) { exprs.iter().map(|&e| const_expr(cx, e)) .fold((~[], true), |(L, all_inlineable), (val, inlineable)| { @@ -642,7 +642,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, } } -pub fn trans_const(ccx: @mut CrateContext, m: ast::Mutability, id: ast::NodeId) { +pub fn trans_const(ccx: @CrateContext, m: ast::Mutability, id: ast::NodeId) { unsafe { let _icx = push_ctxt("trans_const"); let g = base::get_item_val(ccx, id); diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 7d0eb7361958..0c492eac6250 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -237,7 +237,7 @@ impl CrateContext { } } - pub fn builder(@mut self) -> Builder { + pub fn builder(@self) -> Builder { Builder::new(self) } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index f606a2e2769c..6b8ff815a836 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -188,7 +188,7 @@ pub fn scratch_datum(bcx: @Block, ty: ty::t, name: &str, zero: bool) -> Datum { Datum { val: scratch, ty: ty, mode: ByRef(RevokeClean) } } -pub fn appropriate_mode(ccx: &mut CrateContext, ty: ty::t) -> DatumMode { +pub fn appropriate_mode(ccx: &CrateContext, ty: ty::t) -> DatumMode { /*! * Indicates the "appropriate" mode for this value, * which is either by ref or by value, depending @@ -492,7 +492,7 @@ impl Datum { } } - pub fn appropriate_mode(&self, ccx: &mut CrateContext) -> DatumMode { + pub fn appropriate_mode(&self, ccx: &CrateContext) -> DatumMode { /*! See the `appropriate_mode()` function */ appropriate_mode(ccx, self.ty) @@ -857,7 +857,7 @@ impl DatumBlock { rslt(self.bcx, self.datum.to_appropriate_llval(self.bcx)) } - pub fn ccx(&self) -> @mut CrateContext { + pub fn ccx(&self) -> @CrateContext { self.bcx.ccx() } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 097b23ea6b25..edbd2f77272f 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -269,7 +269,7 @@ enum VariableKind { } /// Create any deferred debug metadata nodes -pub fn finalize(cx: @mut CrateContext) { +pub fn finalize(cx: @CrateContext) { if cx.dbg_cx.is_none() { return; } @@ -593,7 +593,7 @@ pub fn start_emitting_source_locations(fcx: &mut FunctionContext) { /// Returns the FunctionDebugContext for the function which holds state needed for debug info /// creation. The function may also return another variant of the FunctionDebugContext enum which /// indicates why no debuginfo should be created for the function. -pub fn create_function_debug_context(cx: &mut CrateContext, +pub fn create_function_debug_context(cx: &CrateContext, fn_ast_id: ast::NodeId, param_substs: Option<@param_substs>, llfn: ValueRef) -> FunctionDebugContext { @@ -758,7 +758,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext, return FunctionDebugContext(fn_debug_context); - fn get_function_signature(cx: &mut CrateContext, + fn get_function_signature(cx: &CrateContext, fn_ast_id: ast::NodeId, fn_decl: &ast::fn_decl, param_substs: Option<@param_substs>, @@ -806,7 +806,7 @@ pub fn create_function_debug_context(cx: &mut CrateContext, return create_DIArray(DIB(cx), signature); } - fn get_template_parameters(cx: &mut CrateContext, + fn get_template_parameters(cx: &CrateContext, generics: &ast::Generics, param_substs: Option<@param_substs>, file_metadata: DIFile, @@ -918,7 +918,7 @@ fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray { }; } -fn compile_unit_metadata(cx: @mut CrateContext) { +fn compile_unit_metadata(cx: @CrateContext) { let dcx = debug_context(cx); let crate_name: &str = dcx.crate_file; @@ -959,7 +959,7 @@ fn declare_local(bcx: @Block, variable_access: VariableAccess, variable_kind: VariableKind, span: Span) { - let cx: &mut CrateContext = bcx.ccx(); + let cx: &CrateContext = bcx.ccx(); let filename = span_start(cx, span).file.name; let file_metadata = file_metadata(cx, filename); @@ -1031,7 +1031,7 @@ fn declare_local(bcx: @Block, } } -fn file_metadata(cx: &mut CrateContext, full_path: &str) -> DIFile { +fn file_metadata(cx: &CrateContext, full_path: &str) -> DIFile { { let created_files = debug_context(cx).created_files.borrow(); match created_files.get().find_equiv(&full_path) { @@ -1083,7 +1083,7 @@ fn scope_metadata(fcx: &FunctionContext, } } -fn basic_type_metadata(cx: &mut CrateContext, t: ty::t) -> DIType { +fn basic_type_metadata(cx: &CrateContext, t: ty::t) -> DIType { debug!("basic_type_metadata: {:?}", ty::get(t)); @@ -1129,7 +1129,7 @@ fn basic_type_metadata(cx: &mut CrateContext, t: ty::t) -> DIType { return ty_metadata; } -fn pointer_type_metadata(cx: &mut CrateContext, +fn pointer_type_metadata(cx: &CrateContext, pointer_type: ty::t, pointee_type_metadata: DIType) -> DIType { @@ -1150,7 +1150,7 @@ fn pointer_type_metadata(cx: &mut CrateContext, } trait MemberDescriptionFactory { - fn create_member_descriptions(&self, cx: &mut CrateContext) + fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription]; } @@ -1160,7 +1160,7 @@ struct StructMemberDescriptionFactory { } impl MemberDescriptionFactory for StructMemberDescriptionFactory { - fn create_member_descriptions(&self, cx: &mut CrateContext) + fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { self.fields.map(|field| { let name = if field.ident.name == special_idents::unnamed_field.name { @@ -1179,7 +1179,7 @@ impl MemberDescriptionFactory for StructMemberDescriptionFactory { } } -fn prepare_struct_metadata(cx: &mut CrateContext, +fn prepare_struct_metadata(cx: &CrateContext, struct_type: ty::t, def_id: ast::DefId, substs: &ty::substs, @@ -1227,7 +1227,7 @@ enum RecursiveTypeDescription { impl RecursiveTypeDescription { - fn finalize(&self, cx: &mut CrateContext) -> DICompositeType { + fn finalize(&self, cx: &CrateContext) -> DICompositeType { match *self { FinalMetadata(metadata) => metadata, UnfinishedMetadata { @@ -1267,7 +1267,7 @@ struct TupleMemberDescriptionFactory { } impl MemberDescriptionFactory for TupleMemberDescriptionFactory { - fn create_member_descriptions(&self, cx: &mut CrateContext) + fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { self.component_types.map(|&component_type| { MemberDescription { @@ -1280,7 +1280,7 @@ impl MemberDescriptionFactory for TupleMemberDescriptionFactory { } } -fn prepare_tuple_metadata(cx: &mut CrateContext, +fn prepare_tuple_metadata(cx: &CrateContext, tuple_type: ty::t, component_types: &[ty::t], span: Span) @@ -1318,7 +1318,7 @@ struct GeneralMemberDescriptionFactory { } impl MemberDescriptionFactory for GeneralMemberDescriptionFactory { - fn create_member_descriptions(&self, cx: &mut CrateContext) + fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { // Capture type_rep, so we don't have to copy the struct_defs array let struct_defs = match *self.type_rep { @@ -1365,7 +1365,7 @@ struct EnumVariantMemberDescriptionFactory { } impl MemberDescriptionFactory for EnumVariantMemberDescriptionFactory { - fn create_member_descriptions(&self, cx: &mut CrateContext) + fn create_member_descriptions(&self, cx: &CrateContext) -> ~[MemberDescription] { self.args.iter().enumerate().map(|(i, &(name, ty))| { MemberDescription { @@ -1381,7 +1381,7 @@ impl MemberDescriptionFactory for EnumVariantMemberDescriptionFactory { } } -fn describe_variant(cx: &mut CrateContext, +fn describe_variant(cx: &CrateContext, struct_def: &adt::Struct, variant_info: &ty::VariantInfo, discriminant_type_metadata: Option, @@ -1444,7 +1444,7 @@ fn describe_variant(cx: &mut CrateContext, (metadata_stub, variant_llvm_type, member_description_factory) } -fn prepare_enum_metadata(cx: &mut CrateContext, +fn prepare_enum_metadata(cx: &CrateContext, enum_type: ty::t, enum_def_id: ast::DefId, span: Span) @@ -1609,7 +1609,7 @@ struct MemberDescription { /// Creates debug information for a composite type, that is, anything that results in a LLVM struct. /// /// Examples of Rust types to use this are: structs, tuples, boxes, vecs, and enums. -fn composite_type_metadata(cx: &mut CrateContext, +fn composite_type_metadata(cx: &CrateContext, composite_llvm_type: Type, composite_type_name: &str, member_descriptions: &[MemberDescription], @@ -1636,7 +1636,7 @@ fn composite_type_metadata(cx: &mut CrateContext, return composite_type_metadata; } -fn set_members_of_composite_type(cx: &mut CrateContext, +fn set_members_of_composite_type(cx: &CrateContext, composite_type_metadata: DICompositeType, composite_llvm_type: Type, member_descriptions: &[MemberDescription], @@ -1696,7 +1696,7 @@ fn set_members_of_composite_type(cx: &mut CrateContext, // A convenience wrapper around LLVMDIBuilderCreateStructType(). Does not do any caching, does not // add any fields to the struct. This can be done later with set_members_of_composite_type(). -fn create_struct_stub(cx: &mut CrateContext, +fn create_struct_stub(cx: &CrateContext, struct_llvm_type: Type, struct_type_name: &str, containing_scope: DIScope, @@ -1739,7 +1739,7 @@ fn create_struct_stub(cx: &mut CrateContext, }; } -fn boxed_type_metadata(cx: &mut CrateContext, +fn boxed_type_metadata(cx: &CrateContext, content_type_name: Option<&str>, content_llvm_type: Type, content_type_metadata: DIType, @@ -1818,7 +1818,7 @@ fn boxed_type_metadata(cx: &mut CrateContext, } } -fn fixed_vec_metadata(cx: &mut CrateContext, +fn fixed_vec_metadata(cx: &CrateContext, element_type: ty::t, len: uint, span: Span) @@ -1845,7 +1845,7 @@ fn fixed_vec_metadata(cx: &mut CrateContext, }; } -fn vec_metadata(cx: &mut CrateContext, +fn vec_metadata(cx: &CrateContext, element_type: ty::t, span: Span) -> DICompositeType { @@ -1905,7 +1905,7 @@ fn vec_metadata(cx: &mut CrateContext, span); } -fn boxed_vec_metadata(cx: &mut CrateContext, +fn boxed_vec_metadata(cx: &CrateContext, element_type: ty::t, span: Span) -> DICompositeType { @@ -1922,7 +1922,7 @@ fn boxed_vec_metadata(cx: &mut CrateContext, span); } -fn vec_slice_metadata(cx: &mut CrateContext, +fn vec_slice_metadata(cx: &CrateContext, vec_type: ty::t, element_type: ty::t, span: Span) @@ -1967,7 +1967,7 @@ fn vec_slice_metadata(cx: &mut CrateContext, file_metadata, span); - fn slice_layout_is_correct(cx: &mut CrateContext, + fn slice_layout_is_correct(cx: &CrateContext, member_llvm_types: &[Type], element_type: ty::t) -> bool { @@ -1977,7 +1977,7 @@ fn vec_slice_metadata(cx: &mut CrateContext, } } -fn subroutine_type_metadata(cx: &mut CrateContext, +fn subroutine_type_metadata(cx: &CrateContext, signature: &ty::FnSig, span: Span) -> DICompositeType { @@ -2005,7 +2005,7 @@ fn subroutine_type_metadata(cx: &mut CrateContext, }; } -fn trait_metadata(cx: &mut CrateContext, +fn trait_metadata(cx: &CrateContext, def_id: ast::DefId, trait_type: ty::t, substs: &ty::substs, @@ -2046,7 +2046,7 @@ fn cache_id_for_type(t: ty::t) -> uint { ty::type_id(t) } -fn type_metadata(cx: &mut CrateContext, +fn type_metadata(cx: &CrateContext, t: ty::t, usage_site_span: Span) -> DIType { @@ -2060,7 +2060,7 @@ fn type_metadata(cx: &mut CrateContext, } } - fn create_pointer_to_box_metadata(cx: &mut CrateContext, + fn create_pointer_to_box_metadata(cx: &CrateContext, pointer_type: ty::t, type_in_box: ty::t) -> DIType { @@ -2192,7 +2192,7 @@ impl DebugLocation { } } -fn set_debug_location(cx: &mut CrateContext, debug_location: DebugLocation) { +fn set_debug_location(cx: &CrateContext, debug_location: DebugLocation) { if debug_location == debug_context(cx).current_debug_location.get() { return; } @@ -2232,7 +2232,7 @@ fn span_start(cx: &CrateContext, span: Span) -> codemap::Loc { cx.sess.codemap.lookup_char_pos(span.lo) } -fn size_and_align_of(cx: &mut CrateContext, llvm_type: Type) -> (uint, uint) { +fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (uint, uint) { (machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type)) } @@ -2241,8 +2241,8 @@ fn bytes_to_bits(bytes: uint) -> c_ulonglong { } #[inline] -fn debug_context<'a>(cx: &'a mut CrateContext) -> &'a CrateDebugContext { - let debug_context: &'a CrateDebugContext = cx.dbg_cx.get_mut_ref(); +fn debug_context<'a>(cx: &'a CrateContext) -> &'a CrateDebugContext { + let debug_context: &'a CrateDebugContext = cx.dbg_cx.get_ref(); debug_context } @@ -2264,7 +2264,7 @@ fn assert_type_for_node_id(cx: &CrateContext, node_id: ast::NodeId, error_span: } } -fn get_namespace_and_span_for_item(cx: &mut CrateContext, +fn get_namespace_and_span_for_item(cx: &CrateContext, def_id: ast::DefId, warning_span: Span) -> (DIScope, Span) { @@ -2295,7 +2295,7 @@ fn get_namespace_and_span_for_item(cx: &mut CrateContext, // scope, creating DIScope DIEs along the way, and introducing *artificial* lexical scope // descriptors where necessary. These artificial scopes allow GDB to correctly handle name // shadowing. -fn populate_scope_map(cx: &mut CrateContext, +fn populate_scope_map(cx: &CrateContext, arg_pats: &[@ast::Pat], fn_entry_block: &ast::Block, fn_metadata: DISubprogram, @@ -2328,11 +2328,11 @@ fn populate_scope_map(cx: &mut CrateContext, }); // local helper functions for walking the AST. - fn with_new_scope(cx: &mut CrateContext, + fn with_new_scope(cx: &CrateContext, scope_span: Span, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap, - inner_walk: |&mut CrateContext, + inner_walk: |&CrateContext, &mut ~[ScopeStackEntry], &mut HashMap|) { // Create a new lexical scope and push it onto the stack @@ -2365,7 +2365,7 @@ fn populate_scope_map(cx: &mut CrateContext, scope_stack.pop(); } - fn walk_block(cx: &mut CrateContext, + fn walk_block(cx: &CrateContext, block: &ast::Block, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { @@ -2388,7 +2388,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - fn walk_decl(cx: &mut CrateContext, + fn walk_decl(cx: &CrateContext, decl: &ast::Decl, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { @@ -2406,7 +2406,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - fn walk_pattern(cx: &mut CrateContext, + fn walk_pattern(cx: &CrateContext, pat: @ast::Pat, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { @@ -2553,7 +2553,7 @@ fn populate_scope_map(cx: &mut CrateContext, } } - fn walk_expr(cx: &mut CrateContext, + fn walk_expr(cx: &CrateContext, exp: &ast::Expr, scope_stack: &mut ~[ScopeStackEntry], scope_map: &mut HashMap) { @@ -2791,7 +2791,7 @@ impl NamespaceTreeNode { } } -fn namespace_for_item(cx: &mut CrateContext, +fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId, warning_span: Span) -> @NamespaceTreeNode { diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index d87836072b95..095dee497030 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -997,7 +997,7 @@ fn trans_lvalue_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock { ast::DefStatic(did, _) => { let const_ty = expr_ty(bcx, ref_expr); - fn get_did(ccx: @mut CrateContext, did: ast::DefId) + fn get_did(ccx: @CrateContext, did: ast::DefId) -> ast::DefId { if did.crate != ast::LOCAL_CRATE { inline::maybe_instantiate_inline(ccx, did) diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index f8d3180841b6..21f268fb9471 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -72,7 +72,7 @@ struct LlvmSignature { /////////////////////////////////////////////////////////////////////////// // Calls to external functions -pub fn llvm_calling_convention(ccx: &mut CrateContext, +pub fn llvm_calling_convention(ccx: &CrateContext, abis: AbiSet) -> Option { let os = ccx.sess.targ_cfg.os; let arch = ccx.sess.targ_cfg.arch; @@ -105,7 +105,7 @@ pub fn llvm_calling_convention(ccx: &mut CrateContext, } -pub fn register_foreign_item_fn(ccx: @mut CrateContext, +pub fn register_foreign_item_fn(ccx: @CrateContext, abis: AbiSet, path: &ast_map::path, foreign_item: @ast::foreign_item) -> ValueRef { @@ -349,7 +349,7 @@ pub fn trans_native_call(bcx: @Block, return bcx; } -pub fn trans_foreign_mod(ccx: @mut CrateContext, +pub fn trans_foreign_mod(ccx: @CrateContext, foreign_mod: &ast::foreign_mod) { let _icx = push_ctxt("foreign::trans_foreign_mod"); for &foreign_item in foreign_mod.items.iter() { @@ -398,7 +398,7 @@ pub fn trans_foreign_mod(ccx: @mut CrateContext, // inline the one into the other. Of course we could just generate the // correct code in the first place, but this is much simpler. -pub fn register_rust_fn_with_foreign_abi(ccx: @mut CrateContext, +pub fn register_rust_fn_with_foreign_abi(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::NodeId) @@ -427,7 +427,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: @mut CrateContext, llfn } -pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext, +pub fn trans_rust_fn_with_foreign_abi(ccx: @CrateContext, path: &ast_map::path, decl: &ast::fn_decl, body: &ast::Block, @@ -445,7 +445,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext, return build_wrap_fn(ccx, llrustfn, llwrapfn, &tys); } - fn build_rust_fn(ccx: @mut CrateContext, + fn build_rust_fn(ccx: @CrateContext, path: &ast_map::path, decl: &ast::fn_decl, body: &ast::Block, @@ -494,7 +494,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: @mut CrateContext, return llfndecl; } - unsafe fn build_wrap_fn(ccx: @mut CrateContext, + unsafe fn build_wrap_fn(ccx: @CrateContext, llrustfn: ValueRef, llwrapfn: ValueRef, tys: &ForeignTypes) { @@ -746,7 +746,7 @@ pub fn link_name(ccx: &CrateContext, i: @ast::foreign_item) -> @str { } } -fn foreign_signature(ccx: &mut CrateContext, fn_sig: &ty::FnSig, arg_tys: &[ty::t]) +fn foreign_signature(ccx: &CrateContext, fn_sig: &ty::FnSig, arg_tys: &[ty::t]) -> LlvmSignature { /*! * The ForeignSignature is the LLVM types of the arguments/return type @@ -765,12 +765,12 @@ fn foreign_signature(ccx: &mut CrateContext, fn_sig: &ty::FnSig, arg_tys: &[ty:: } } -fn foreign_types_for_id(ccx: &mut CrateContext, +fn foreign_types_for_id(ccx: &CrateContext, id: ast::NodeId) -> ForeignTypes { foreign_types_for_fn_ty(ccx, ty::node_id_to_type(ccx.tcx, id)) } -fn foreign_types_for_fn_ty(ccx: &mut CrateContext, +fn foreign_types_for_fn_ty(ccx: &CrateContext, ty: ty::t) -> ForeignTypes { let fn_sig = match ty::get(ty).sty { ty::ty_bare_fn(ref fn_ty) => fn_ty.sig.clone(), @@ -842,7 +842,7 @@ fn lltype_for_fn_from_foreign_types(tys: &ForeignTypes) -> Type { } } -pub fn lltype_for_foreign_fn(ccx: &mut CrateContext, ty: ty::t) -> Type { +pub fn lltype_for_foreign_fn(ccx: &CrateContext, ty: ty::t) -> Type { let fn_types = foreign_types_for_fn_ty(ccx, ty); lltype_for_fn_from_foreign_types(&fn_types) } diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index ad5e4e8942c9..a6869dce2133 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -108,7 +108,7 @@ pub fn free_ty_immediate(bcx: @Block, v: ValueRef, t: ty::t) -> @Block { } } -pub fn lazily_emit_all_tydesc_glue(ccx: @mut CrateContext, +pub fn lazily_emit_all_tydesc_glue(ccx: @CrateContext, static_ti: @mut tydesc_info) { lazily_emit_tydesc_glue(ccx, abi::tydesc_field_take_glue, static_ti); lazily_emit_tydesc_glue(ccx, abi::tydesc_field_drop_glue, static_ti); @@ -173,7 +173,7 @@ pub fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t { return t; } -pub fn lazily_emit_simplified_tydesc_glue(ccx: @mut CrateContext, +pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext, field: uint, ti: &mut tydesc_info) -> bool { let _icx = push_ctxt("lazily_emit_simplified_tydesc_glue"); @@ -198,7 +198,7 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @mut CrateContext, } -pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext, +pub fn lazily_emit_tydesc_glue(ccx: @CrateContext, field: uint, ti: @mut tydesc_info) { let _icx = push_ctxt("lazily_emit_tydesc_glue"); @@ -586,7 +586,7 @@ pub fn incr_refcnt_of_boxed(cx: @Block, box_ptr: ValueRef) { // Generates the declaration for (but doesn't emit) a type descriptor. -pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info { +pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @mut tydesc_info { // If emit_tydescs already ran, then we shouldn't be creating any new // tydescs. assert!(!ccx.finished_tydescs.get()); @@ -642,7 +642,7 @@ pub fn declare_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info { pub type glue_helper<'a> = 'a |@Block, ValueRef, ty::t| -> @Block; -pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type, +pub fn declare_generic_glue(ccx: &CrateContext, t: ty::t, llfnty: Type, name: &str) -> ValueRef { let _icx = push_ctxt("declare_generic_glue"); let fn_nm = mangle_internal_name_by_type_and_seq(ccx, t, (~"glue_" + name)).to_managed(); @@ -652,7 +652,7 @@ pub fn declare_generic_glue(ccx: &mut CrateContext, t: ty::t, llfnty: Type, return llfn; } -pub fn make_generic_glue_inner(ccx: @mut CrateContext, +pub fn make_generic_glue_inner(ccx: @CrateContext, t: ty::t, llfn: ValueRef, helper: glue_helper) @@ -679,7 +679,7 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext, return llfn; } -pub fn make_generic_glue(ccx: @mut CrateContext, +pub fn make_generic_glue(ccx: @CrateContext, t: ty::t, llfn: ValueRef, helper: glue_helper, @@ -691,7 +691,7 @@ pub fn make_generic_glue(ccx: @mut CrateContext, make_generic_glue_inner(ccx, t, llfn, helper) } -pub fn emit_tydescs(ccx: &mut CrateContext) { +pub fn emit_tydescs(ccx: &CrateContext) { let _icx = push_ctxt("emit_tydescs"); // As of this point, allow no more tydescs to be created. ccx.finished_tydescs.set(true); diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index f6c424302e3a..81f04d0c373e 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -23,7 +23,7 @@ use syntax::ast_map::path_name; use syntax::ast_util::local_def; use syntax::attr; -pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId) +pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::DefId) -> ast::DefId { let _icx = push_ctxt("maybe_instantiate_inline"); { diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 3aa976dba9aa..cd19bc7be0ca 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -29,7 +29,7 @@ use util::ppaux::ty_to_str; use middle::trans::machine::llsize_of; use middle::trans::type_::Type; -pub fn trans_intrinsic(ccx: @mut CrateContext, +pub fn trans_intrinsic(ccx: @CrateContext, decl: ValueRef, item: &ast::foreign_item, path: ast_map::path, diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index a1639f688243..2fdc444920a7 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -46,7 +46,7 @@ for non-monomorphized methods only. Other methods will be generated once they are invoked with specific type parameters, see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`. */ -pub fn trans_impl(ccx: @mut CrateContext, +pub fn trans_impl(ccx: @CrateContext, path: path, name: ast::Ident, methods: &[@ast::method], @@ -97,7 +97,7 @@ pub fn trans_impl(ccx: @mut CrateContext, /// * `impl_id`: the node ID of the impl this method is inside /// /// XXX(pcwalton) Can we take `path` by reference? -pub fn trans_method(ccx: @mut CrateContext, +pub fn trans_method(ccx: @CrateContext, path: path, method: &ast::method, param_substs: Option<@param_substs>, @@ -293,7 +293,7 @@ pub fn trans_static_method_callee(bcx: @Block, } } -pub fn method_with_name(ccx: &mut CrateContext, +pub fn method_with_name(ccx: &CrateContext, impl_id: ast::DefId, name: ast::Name) -> ast::DefId { { @@ -509,7 +509,7 @@ pub fn trans_trait_callee_from_llval(bcx: @Block, }; } -pub fn vtable_id(ccx: @mut CrateContext, +pub fn vtable_id(ccx: @CrateContext, origin: &typeck::vtable_origin) -> mono_id { match origin { @@ -573,7 +573,7 @@ pub fn get_vtable(bcx: @Block, } /// Helper function to declare and initialize the vtable. -pub fn make_vtable(ccx: &mut CrateContext, +pub fn make_vtable(ccx: &CrateContext, tydesc: &tydesc_info, ptrs: &[ValueRef]) -> ValueRef { diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 75a9ee298a50..1b7f52619a59 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -28,7 +28,7 @@ use syntax::ast; use syntax::ast_map; use syntax::ast_util::local_def; -pub fn monomorphic_fn(ccx: @mut CrateContext, +pub fn monomorphic_fn(ccx: @CrateContext, fn_id: ast::DefId, real_substs: &ty::substs, vtables: Option, @@ -307,7 +307,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext, (lldecl, must_cast) } -pub fn make_mono_id(ccx: @mut CrateContext, +pub fn make_mono_id(ccx: @CrateContext, item: ast::DefId, substs: ¶m_substs) -> mono_id { // FIXME (possibly #5801): Need a lot of type hints to get diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index 4986854dd15f..fae677497b86 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -187,7 +187,7 @@ impl Type { Type::array(&Type::i8().ptr_to(), 1) } - pub fn generic_glue_fn(cx: &mut CrateContext) -> Type { + pub fn generic_glue_fn(cx: &CrateContext) -> Type { match cx.tn.find_type("glue_fn") { Some(ty) => return ty, None => () diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 2270b5aa0581..c1e6e4667618 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -21,15 +21,15 @@ use middle::trans::type_::Type; use syntax::ast; use syntax::opt_vec; -pub fn arg_is_indirect(ccx: &mut CrateContext, arg_ty: ty::t) -> bool { +pub fn arg_is_indirect(ccx: &CrateContext, arg_ty: ty::t) -> bool { !type_is_immediate(ccx, arg_ty) } -pub fn return_uses_outptr(ccx: &mut CrateContext, ty: ty::t) -> bool { +pub fn return_uses_outptr(ccx: &CrateContext, ty: ty::t) -> bool { !type_is_immediate(ccx, ty) } -pub fn type_of_explicit_arg(ccx: &mut CrateContext, arg_ty: ty::t) -> Type { +pub fn type_of_explicit_arg(ccx: &CrateContext, arg_ty: ty::t) -> Type { let llty = type_of(ccx, arg_ty); if arg_is_indirect(ccx, arg_ty) { llty.ptr_to() @@ -38,12 +38,12 @@ pub fn type_of_explicit_arg(ccx: &mut CrateContext, arg_ty: ty::t) -> Type { } } -pub fn type_of_explicit_args(ccx: &mut CrateContext, +pub fn type_of_explicit_args(ccx: &CrateContext, inputs: &[ty::t]) -> ~[Type] { inputs.map(|&arg_ty| type_of_explicit_arg(ccx, arg_ty)) } -pub fn type_of_rust_fn(cx: &mut CrateContext, +pub fn type_of_rust_fn(cx: &CrateContext, inputs: &[ty::t], output: ty::t) -> Type { let mut atys: ~[Type] = ~[]; @@ -71,7 +71,7 @@ pub fn type_of_rust_fn(cx: &mut CrateContext, } // Given a function type and a count of ty params, construct an llvm type -pub fn type_of_fn_from_ty(cx: &mut CrateContext, fty: ty::t) -> Type { +pub fn type_of_fn_from_ty(cx: &CrateContext, fty: ty::t) -> Type { return match ty::get(fty).sty { ty::ty_closure(ref f) => { type_of_rust_fn(cx, f.sig.inputs, f.sig.output) @@ -100,7 +100,7 @@ pub fn type_of_fn_from_ty(cx: &mut CrateContext, fty: ty::t) -> Type { // type behind pointers. This can help prevent infinite loops for // recursive types. For example, enum types rely on this behavior. -pub fn sizing_type_of(cx: &mut CrateContext, t: ty::t) -> Type { +pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type { { let llsizingtypes = cx.llsizingtypes.borrow(); match llsizingtypes.get().find_copy(&t) { @@ -175,7 +175,7 @@ pub fn sizing_type_of(cx: &mut CrateContext, t: ty::t) -> Type { } // NB: If you update this, be sure to update `sizing_type_of()` as well. -pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type { +pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { // Check the cache. { let lltypes = cx.lltypes.borrow(); @@ -359,7 +359,7 @@ pub fn llvm_type_name(cx: &CrateContext, } } -pub fn type_of_dtor(ccx: &mut CrateContext, self_ty: ty::t) -> Type { +pub fn type_of_dtor(ccx: &CrateContext, self_ty: ty::t) -> Type { let self_ty = type_of(ccx, self_ty).ptr_to(); Type::func([self_ty], &Type::void()) }