diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index d8fd682387b4..8a176d1b0e91 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -392,7 +392,7 @@ fn truncated_sha1_result(sha: sha1) -> str { // This calculates STH for a symbol, as defined above -fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: &ty::t, link_meta: &link_meta) -> +fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, link_meta: &link_meta) -> str { // NB: do *not* use abbrevs here as we want the symbol names // to be independent of one another in the crate. @@ -410,7 +410,7 @@ fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: &ty::t, link_meta: &link_meta) -> ret "_" + hash; } -fn get_symbol_hash(ccx: &@crate_ctxt, t: &ty::t) -> str { +fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> str { let hash = ""; alt ccx.type_sha1s.find(t) { some(h) { hash = h; } @@ -440,12 +440,12 @@ fn exported_name(path: &[str], hash: &str, _vers: &str) -> str { } -fn mangle_exported_name(ccx: &@crate_ctxt, path: &[str], t: &ty::t) -> str { +fn mangle_exported_name(ccx: &@crate_ctxt, path: &[str], t: ty::t) -> str { let hash = get_symbol_hash(ccx, t); ret exported_name(path, hash, ccx.link_meta.vers); } -fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: &ty::t, name: &str) +fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &str) -> str { let s = util::ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index babfc2ce77cd..02427fa0321f 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -193,7 +193,7 @@ fn encode_variant_id(ebml_w: &ebml::writer, vid: &def_id) { ebml::end_tag(ebml_w); } -fn encode_type(ecx: &@encode_ctxt, ebml_w: &ebml::writer, typ: &ty::t) { +fn encode_type(ecx: &@encode_ctxt, ebml_w: &ebml::writer, typ: ty::t) { ebml::start_tag(ebml_w, tag_items_data_item_type); let f = def_to_str; let ty_str_ctxt = @@ -618,7 +618,7 @@ fn encode_metadata(cx: &@crate_ctxt, crate: &@crate) -> str { } // Get the encoded string for a type -fn encoded_ty(tcx: &ty::ctxt, t: &ty::t) -> str { +fn encoded_ty(tcx: &ty::ctxt, t: ty::t) -> str { let cx = @{ds: def_to_str, tcx: tcx, abbrevs: tyencode::ac_no_abbrevs}; let sw = io::string_writer(); tyencode::enc_ty(sw.get_writer(), cx, t); diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index 5568804c0563..7b0915ba7b79 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -36,7 +36,7 @@ fn cx_uses_abbrevs(cx: &@ctxt) -> bool { } } -fn enc_ty(w: &io::writer, cx: &@ctxt, t: &ty::t) { +fn enc_ty(w: &io::writer, cx: &@ctxt, t: ty::t) { alt cx.abbrevs { ac_no_abbrevs. { let result_str; @@ -202,7 +202,7 @@ fn enc_proto(w: &io::writer, proto: proto) { } } -fn enc_ty_fn(w: &io::writer, cx: &@ctxt, args: &[ty::arg], out: &ty::t, +fn enc_ty_fn(w: &io::writer, cx: &@ctxt, args: &[ty::arg], out: ty::t, cf: &controlflow, constrs: &[@ty::constr]) { w.write_char('['); for arg: ty::arg in args { diff --git a/src/comp/middle/gc.rs b/src/comp/middle/gc.rs index 103ce9eb47dd..92c29b15e4fa 100644 --- a/src/comp/middle/gc.rs +++ b/src/comp/middle/gc.rs @@ -94,7 +94,7 @@ fn add_gc_root(cx: &@block_ctxt, llval: ValueRef, ty: ty::t) -> @block_ctxt { ret bcx; } -fn type_is_gc_relevant(cx: &ty::ctxt, ty: &ty::t) -> bool { +fn type_is_gc_relevant(cx: &ty::ctxt, ty: ty::t) -> bool { alt ty::struct(cx, ty) { ty::ty_nil. | ty::ty_bot. | ty::ty_bool. | ty::ty_int. | ty::ty_float. | ty::ty_uint. | ty::ty_machine(_) | ty::ty_char. | ty::ty_istr. | diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 6707480f9c58..ddb855e97c84 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -78,7 +78,7 @@ import trans_objects::trans_obj; // return value was always meaningless in that case anyhow). Beware! // // TODO: Enforce via a predicate. -fn type_of(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef { +fn type_of(cx: &@crate_ctxt, sp: &span, t: ty::t) -> TypeRef { if ty::type_has_dynamic_size(cx.tcx, t) { cx.sess.span_fatal(sp, "type_of() called on a type with dynamic size: " + @@ -113,7 +113,7 @@ fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &[ty::arg]) -> // - new_fn_ctxt // - trans_args fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto, - is_method: bool, inputs: &[ty::arg], output: &ty::t, + is_method: bool, inputs: &[ty::arg], output: ty::t, ty_param_count: uint) -> TypeRef { let atys: [TypeRef] = []; @@ -145,13 +145,13 @@ fn type_of_fn_full(cx: &@crate_ctxt, sp: &span, proto: ast::proto, } fn type_of_fn(cx: &@crate_ctxt, sp: &span, proto: ast::proto, - inputs: &[ty::arg], output: &ty::t, ty_param_count: uint) -> + inputs: &[ty::arg], output: ty::t, ty_param_count: uint) -> TypeRef { ret type_of_fn_full(cx, sp, proto, false, inputs, output, ty_param_count); } // Given a function type and a count of ty params, construct an llvm type -fn type_of_fn_from_ty(cx: &@crate_ctxt, sp: &span, fty: &ty::t, +fn type_of_fn_from_ty(cx: &@crate_ctxt, sp: &span, fty: ty::t, ty_param_count: uint) -> TypeRef { ret type_of_fn(cx, sp, ty::ty_fn_proto(cx.tcx, fty), ty::ty_fn_args(cx.tcx, fty), ty::ty_fn_ret(cx.tcx, fty), @@ -159,7 +159,7 @@ fn type_of_fn_from_ty(cx: &@crate_ctxt, sp: &span, fty: &ty::t, } fn type_of_native_fn(cx: &@crate_ctxt, sp: &span, abi: ast::native_abi, - inputs: &[ty::arg], output: &ty::t, ty_param_count: uint) + inputs: &[ty::arg], output: ty::t, ty_param_count: uint) -> TypeRef { let atys: [TypeRef] = []; if abi == ast::native_abi_rust { @@ -171,7 +171,7 @@ fn type_of_native_fn(cx: &@crate_ctxt, sp: &span, abi: ast::native_abi, ret T_fn(atys, type_of_inner(cx, sp, output)); } -fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef { +fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: ty::t) -> TypeRef { // Check the cache. if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); } @@ -248,7 +248,7 @@ fn type_of_inner(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> TypeRef { ret llty; } -fn type_of_tag(cx: &@crate_ctxt, sp: &span, did: &ast::def_id, t: &ty::t) -> +fn type_of_tag(cx: &@crate_ctxt, sp: &span, did: &ast::def_id, t: ty::t) -> TypeRef { let degen = std::vec::len(ty::tag_variants(cx.tcx, did)) == 1u; if ty::type_has_dynamic_size(cx.tcx, t) { @@ -437,14 +437,14 @@ fn llalign_of(t: TypeRef) -> ValueRef { False); } -fn size_of(cx: &@block_ctxt, t: &ty::t) -> result { +fn size_of(cx: &@block_ctxt, t: ty::t) -> result { if !ty::type_has_dynamic_size(bcx_tcx(cx), t) { ret rslt(cx, llsize_of(type_of(bcx_ccx(cx), cx.sp, t))); } ret dynamic_size_of(cx, t); } -fn align_of(cx: &@block_ctxt, t: &ty::t) -> result { +fn align_of(cx: &@block_ctxt, t: ty::t) -> result { if !ty::type_has_dynamic_size(bcx_tcx(cx), t) { ret rslt(cx, llalign_of(type_of(bcx_ccx(cx), cx.sp, t))); } @@ -485,7 +485,7 @@ fn mk_obstack_token(ccx: &@crate_ctxt, lldynamicallocas: BasicBlockRef, // to have (a) the same size as the type that was passed in; (b) to be non- // recursive. This is done by replacing all boxes in a type with boxed unit // types. -fn simplify_type(ccx: &@crate_ctxt, typ: &ty::t) -> ty::t { +fn simplify_type(ccx: &@crate_ctxt, typ: ty::t) -> ty::t { fn simplifier(ccx: @crate_ctxt, typ: ty::t) -> ty::t { alt ty::struct(ccx.tcx, typ) { ty::ty_box(_) { ret ty::mk_imm_box(ccx.tcx, ty::mk_nil(ccx.tcx)); } @@ -513,7 +513,7 @@ fn simplify_type(ccx: &@crate_ctxt, typ: &ty::t) -> ty::t { // Computes the size of the data part of a non-dynamically-sized tag. -fn static_size_of_tag(cx: &@crate_ctxt, sp: &span, t: &ty::t) -> uint { +fn static_size_of_tag(cx: &@crate_ctxt, sp: &span, t: ty::t) -> uint { if ty::type_has_dynamic_size(cx.tcx, t) { cx.tcx.sess.span_fatal(sp, "dynamically sized type passed to \ @@ -628,7 +628,7 @@ fn dynamic_size_of(cx: &@block_ctxt, t: ty::t) -> result { } } -fn dynamic_align_of(cx: &@block_ctxt, t: &ty::t) -> result { +fn dynamic_align_of(cx: &@block_ctxt, t: ty::t) -> result { alt ty::struct(bcx_tcx(cx), t) { ty::ty_param(p, _) { let aptr = field_of_tydesc(cx, t, false, abi::tydesc_field_align); @@ -677,7 +677,7 @@ fn GEPi(cx: &@block_ctxt, base: ValueRef, ixs: &[int]) -> ValueRef { // Increment a pointer by a given amount and then cast it to be a pointer // to a given type. -fn bump_ptr(bcx: &@block_ctxt, t: &ty::t, base: ValueRef, sz: ValueRef) -> +fn bump_ptr(bcx: &@block_ctxt, t: ty::t, base: ValueRef, sz: ValueRef) -> ValueRef { let raw = bcx.build.PointerCast(base, T_ptr(T_i8())); let bumped = bcx.build.GEP(raw, [sz]); @@ -691,7 +691,7 @@ fn bump_ptr(bcx: &@block_ctxt, t: &ty::t, base: ValueRef, sz: ValueRef) -> // ty::struct and knows what to do when it runs into a ty_param stuck in the // middle of the thing it's GEP'ing into. Much like size_of and align_of, // above. -fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &[int]) -> +fn GEP_tup_like(cx: &@block_ctxt, t: ty::t, base: ValueRef, ixs: &[int]) -> result { assert (ty::type_is_tup_like(bcx_tcx(cx), t)); // It might be a static-known type. Handle this. @@ -714,7 +714,7 @@ fn GEP_tup_like(cx: &@block_ctxt, t: &ty::t, base: ValueRef, ixs: &[int]) -> // elements of the type and splitting the Xth off. Return the prefix as // well as the innermost Xth type. - fn split_type(ccx: &@crate_ctxt, t: &ty::t, ixs: &[int], n: uint) -> + fn split_type(ccx: &@crate_ctxt, t: ty::t, ixs: &[int], n: uint) -> {prefix: [ty::t], target: ty::t} { let len: uint = std::vec::len::(ixs); // We don't support 0-index or 1-index GEPs: The former is nonsense @@ -879,7 +879,7 @@ fn trans_malloc_boxed(cx: &@block_ctxt, t: ty::t) -> // Given a type and a field index into its corresponding type descriptor, // returns an LLVM ValueRef of that field from the tydesc, generating the // tydesc if necessary. -fn field_of_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool, field: int) -> +fn field_of_tydesc(cx: &@block_ctxt, t: ty::t, escapes: bool, field: int) -> result { let ti = none::<@tydesc_info>; let tydesc = get_tydesc(cx, t, escapes, ti).result; @@ -892,7 +892,7 @@ fn field_of_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool, field: int) -> // each of the ty params it uses (from the current frame) and a vector of the // indices of the ty params present in the type. This is used solely for // constructing derived tydescs. -fn linearize_ty_params(cx: &@block_ctxt, t: &ty::t) -> +fn linearize_ty_params(cx: &@block_ctxt, t: ty::t) -> {params: [uint], descs: [ValueRef]} { let param_vals: [ValueRef] = []; let param_defs: [uint] = []; @@ -938,7 +938,7 @@ fn trans_stack_local_derived_tydesc(cx: &@block_ctxt, llsz: ValueRef, ret llmyroottydesc; } -fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool, +fn get_derived_tydesc(cx: &@block_ctxt, t: ty::t, escapes: bool, static_ti: &mutable option::t<@tydesc_info>) -> result { alt cx.fcx.derived_tydescs.find(t) { some(info) { @@ -1008,7 +1008,7 @@ fn get_derived_tydesc(cx: &@block_ctxt, t: &ty::t, escapes: bool, type get_tydesc_result = {kind: tydesc_kind, result: result}; -fn get_tydesc(cx: &@block_ctxt, orig_t: &ty::t, escapes: bool, +fn get_tydesc(cx: &@block_ctxt, orig_t: ty::t, escapes: bool, static_ti: &mutable option::t<@tydesc_info>) -> get_tydesc_result { @@ -1043,7 +1043,7 @@ fn get_tydesc(cx: &@block_ctxt, orig_t: &ty::t, escapes: bool, ret {kind: tk_static, result: rslt(cx, info.tydesc)}; } -fn get_static_tydesc(cx: &@block_ctxt, orig_t: &ty::t, ty_params: &[uint]) -> +fn get_static_tydesc(cx: &@block_ctxt, orig_t: ty::t, ty_params: &[uint]) -> @tydesc_info { let t = ty::strip_cname(bcx_tcx(cx), orig_t); @@ -1079,7 +1079,7 @@ fn set_always_inline(f: ValueRef) { lib::llvm::llvm::Attribute); } -fn set_glue_inlining(cx: &@local_ctxt, f: ValueRef, t: &ty::t) { +fn set_glue_inlining(cx: &@local_ctxt, f: ValueRef, t: ty::t) { if ty::type_is_structural(cx.ccx.tcx, t) { set_no_inline(f); } else { set_always_inline(f); } @@ -1087,7 +1087,7 @@ fn set_glue_inlining(cx: &@local_ctxt, f: ValueRef, t: &ty::t) { // Generates the declaration for (but doesn't emit) a type descriptor. -fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &[uint]) +fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: ty::t, ty_params: &[uint]) -> @tydesc_info { log "+++ declare_tydesc " + ty_to_str(cx.ccx.tcx, t); let ccx = cx.ccx; @@ -1127,11 +1127,11 @@ fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: &ty::t, ty_params: &[uint]) } tag glue_helper { - default_helper(fn(&@block_ctxt, ValueRef, &ty::t)); - copy_helper(fn(&@block_ctxt, ValueRef, ValueRef, &ty::t)); + default_helper(fn(&@block_ctxt, ValueRef, ty::t)); + copy_helper(fn(&@block_ctxt, ValueRef, ValueRef, ty::t)); } -fn declare_generic_glue(cx: &@local_ctxt, t: &ty::t, llfnty: TypeRef, +fn declare_generic_glue(cx: &@local_ctxt, t: ty::t, llfnty: TypeRef, name: &str) -> ValueRef { let fn_nm; if cx.ccx.sess.get_opts().debuginfo { @@ -1143,7 +1143,7 @@ fn declare_generic_glue(cx: &@local_ctxt, t: &ty::t, llfnty: TypeRef, ret llfn; } -fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t, +fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: ty::t, llfn: ValueRef, helper: &glue_helper, ty_params: &[uint]) -> ValueRef { @@ -1195,7 +1195,7 @@ fn make_generic_glue_inner(cx: &@local_ctxt, sp: &span, t: &ty::t, ret llfn; } -fn make_generic_glue(cx: &@local_ctxt, sp: &span, t: &ty::t, llfn: ValueRef, +fn make_generic_glue(cx: &@local_ctxt, sp: &span, t: ty::t, llfn: ValueRef, helper: &glue_helper, ty_params: &[uint], name: &str) -> ValueRef { if !cx.ccx.sess.get_opts().stats { @@ -1272,12 +1272,12 @@ fn emit_tydescs(ccx: &@crate_ctxt) { } } -fn make_copy_glue(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: &ty::t) { +fn make_copy_glue(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: ty::t) { let bcx = memmove_ty(cx, dst, src, t).bcx; build_return(bcx); } -fn make_take_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t) { +fn make_take_glue(cx: &@block_ctxt, v: ValueRef, t: ty::t) { // NB: v is an *alias* of type t here, not a direct value. let bcx; @@ -1308,7 +1308,7 @@ fn incr_refcnt_of_boxed(cx: &@block_ctxt, box_ptr: ValueRef) -> result { ret rslt(next_cx, C_nil()); } -fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) { +fn make_free_glue(cx: &@block_ctxt, v0: ValueRef, t: ty::t) { // NB: v is an *alias* of type t here, not a direct value. let rs = alt ty::struct(bcx_tcx(cx), t) { @@ -1407,7 +1407,7 @@ fn maybe_free_ivec_heap_part(cx: &@block_ctxt, v0: ValueRef, unit_ty: ty::t) ret rslt(next_cx, C_nil()); } -fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: &ty::t) { +fn make_drop_glue(cx: &@block_ctxt, v0: ValueRef, t: ty::t) { // NB: v0 is an *alias* of type t here, not a direct value. let ccx = bcx_ccx(cx); let rs = @@ -1495,7 +1495,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: &ast::def_id, } fn decr_refcnt_maybe_free(cx: &@block_ctxt, box_ptr_alias: ValueRef, - full_alias: ValueRef, t: &ty::t) -> result { + full_alias: ValueRef, t: ty::t) -> result { let ccx = bcx_ccx(cx); let load_rc_cx = new_sub_block_ctxt(cx, "load rc"); let rc_adj_cx = new_sub_block_ctxt(cx, "rc--"); @@ -1544,7 +1544,7 @@ tag scalar_type { nil_type; signed_int; unsigned_int; floating_point; } fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef, - t: &ty::t, llop: ValueRef) -> result { + t: ty::t, llop: ValueRef) -> result { let f = bind compare_scalar_values(cx, lhs, rhs, _, llop); alt ty::struct(bcx_tcx(cx), t) { @@ -1662,7 +1662,7 @@ type val_and_ty_fn = fn(&@block_ctxt, ValueRef, ty::t) -> result; // Iterates through the elements of a structural type. -fn iter_structural_ty(cx: &@block_ctxt, v: ValueRef, t: &ty::t, +fn iter_structural_ty(cx: &@block_ctxt, v: ValueRef, t: ty::t, f: val_and_ty_fn) -> result { fn adaptor_fn(f: val_and_ty_fn, cx: &@block_ctxt, av: ValueRef, t: ty::t) -> result { @@ -1687,7 +1687,7 @@ fn incr_ptr(cx: &@block_ctxt, p: ValueRef, incr: ValueRef, pp: ValueRef) { cx.build.Store(cx.build.InBoundsGEP(p, [incr]), pp); } -fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: &ty::t, +fn iter_structural_ty_full(cx: &@block_ctxt, av: ValueRef, t: ty::t, f: &val_and_ty_fn) -> result { fn iter_boxpp(cx: @block_ctxt, box_cell: ValueRef, f: &val_and_ty_fn) -> result { @@ -1936,9 +1936,9 @@ fn iter_sequence_inner(cx: &@block_ctxt, src: ValueRef, // Iterates through the elements of a vec or str. -fn iter_sequence(cx: @block_ctxt, v: ValueRef, t: &ty::t, f: &val_and_ty_fn) +fn iter_sequence(cx: @block_ctxt, v: ValueRef, t: ty::t, f: &val_and_ty_fn) -> result { - fn iter_sequence_body(cx: @block_ctxt, v: ValueRef, elt_ty: &ty::t, + fn iter_sequence_body(cx: @block_ctxt, v: ValueRef, elt_ty: ty::t, f: &val_and_ty_fn, trailing_null: bool, interior: bool) -> result { let p0; @@ -2131,7 +2131,7 @@ fn call_tydesc_glue_full(cx: &@block_ctxt, v: ValueRef, tydesc: ValueRef, C_null(T_ptr(T_nil())), lltydescs, llrawptr]); } -fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t, field: int) -> +fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: ty::t, field: int) -> result { let ti: option::t<@tydesc_info> = none::<@tydesc_info>; let td = get_tydesc(cx, t, false, ti).result; @@ -2140,7 +2140,7 @@ fn call_tydesc_glue(cx: &@block_ctxt, v: ValueRef, t: &ty::t, field: int) -> ret rslt(td.bcx, C_nil()); } -fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t, +fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: ty::t, llop: ValueRef) -> result { // We can't use call_tydesc_glue_full() and friends here because compare // glue has a special signature. @@ -2177,7 +2177,7 @@ fn call_cmp_glue(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t, ret rslt(r.bcx, r.bcx.build.Load(llcmpresultptr)); } -fn call_copy_glue(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: &ty::t, +fn call_copy_glue(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: ty::t, take: bool) -> @block_ctxt { // You can't call this on immediate types. Those are simply copied with // Load/Store. @@ -2218,7 +2218,7 @@ fn call_copy_glue(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: &ty::t, // Compares two values. Performs the simple scalar comparison if the types are // scalar and calls to comparison glue otherwise. -fn compare(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: &ty::t, +fn compare(cx: &@block_ctxt, lhs: ValueRef, rhs: ValueRef, t: ty::t, llop: ValueRef) -> result { if ty::type_is_scalar(bcx_tcx(cx), t) { ret compare_scalar_types(cx, lhs, rhs, t, llop); @@ -2234,7 +2234,7 @@ fn take_ty(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> result { ret rslt(cx, C_nil()); } -fn drop_slot(cx: &@block_ctxt, slot: ValueRef, t: &ty::t) -> result { +fn drop_slot(cx: &@block_ctxt, slot: ValueRef, t: ty::t) -> result { let llptr = load_if_immediate(cx, slot, t); ret drop_ty(cx, llptr, t); } @@ -2292,7 +2292,7 @@ fn call_bzero(cx: &@block_ctxt, dst: ValueRef, n_bytes: ValueRef, [dst_ptr, C_u8(0u), size, align, volatile])); } -fn memmove_ty(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: &ty::t) -> +fn memmove_ty(cx: &@block_ctxt, dst: ValueRef, src: ValueRef, t: ty::t) -> result { if ty::type_has_dynamic_size(bcx_tcx(cx), t) { let llsz = size_of(cx, t); @@ -2328,7 +2328,7 @@ fn type_is_structural_or_param(tcx: &ty::ctxt, t: ty::t) -> bool { } fn copy_val(cx: &@block_ctxt, action: copy_action, dst: ValueRef, - src: ValueRef, t: &ty::t) -> @block_ctxt { + src: ValueRef, t: ty::t) -> @block_ctxt { if type_is_structural_or_param(bcx_ccx(cx).tcx, t) && action == DROP_EXISTING { let do_copy_cx = new_sub_block_ctxt(cx, "do_copy"); @@ -2345,7 +2345,7 @@ fn copy_val(cx: &@block_ctxt, action: copy_action, dst: ValueRef, } fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef, - src: ValueRef, t: &ty::t) -> @block_ctxt { + src: ValueRef, t: ty::t) -> @block_ctxt { let ccx = bcx_ccx(cx); // FIXME this is just a clunky stopgap. we should do proper checking in an // earlier pass. @@ -2384,7 +2384,7 @@ fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef, // case where a variable is always deinitialized by block exit and thus // doesn't need to be dropped. fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef, - src: &lval_result, t: &ty::t) -> @block_ctxt { + src: &lval_result, t: ty::t) -> @block_ctxt { let src_val = src.res.val; if ty::type_is_scalar(bcx_tcx(cx), t) || ty::type_is_native(bcx_tcx(cx), t) { @@ -2422,7 +2422,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef, } fn move_val_if_temp(cx: @block_ctxt, action: copy_action, dst: ValueRef, - src: &lval_result, t: &ty::t) -> @block_ctxt { + src: &lval_result, t: ty::t) -> @block_ctxt { // Lvals in memory are not temporaries. Copy them. if src.is_mem { @@ -2606,7 +2606,7 @@ fn trans_compare(cx: &@block_ctxt, op: ast::binop, lhs: ValueRef, } } -fn trans_evec_append(cx: &@block_ctxt, t: &ty::t, lhs: ValueRef, +fn trans_evec_append(cx: &@block_ctxt, t: ty::t, lhs: ValueRef, rhs: ValueRef) -> result { let elt_ty = ty::sequence_element_type(bcx_tcx(cx), t); let skip_null = C_bool(false); @@ -2847,7 +2847,7 @@ mod ivec { stack_no_spill_cx.llbb, stack_spill_cx.llbb]); ret rslt(next_cx, data_ptr); } - fn trans_append(cx: &@block_ctxt, t: &ty::t, orig_lhs: ValueRef, + fn trans_append(cx: &@block_ctxt, t: ty::t, orig_lhs: ValueRef, orig_rhs: ValueRef) -> result { // Cast to opaque interior vector types if necessary. let lhs; @@ -3231,7 +3231,7 @@ mod ivec { } } -fn trans_evec_add(cx: &@block_ctxt, t: &ty::t, lhs: ValueRef, rhs: ValueRef) +fn trans_evec_add(cx: &@block_ctxt, t: ty::t, lhs: ValueRef, rhs: ValueRef) -> result { let r = alloc_ty(cx, t); let tmp = r.val; @@ -3306,7 +3306,7 @@ fn trans_eager_binop(cx: &@block_ctxt, op: ast::binop, lhs: ValueRef, } } -fn autoderef(cx: &@block_ctxt, v: ValueRef, t: &ty::t) -> result_t { +fn autoderef(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> result_t { let v1: ValueRef = v; let t1: ty::t = t; let ccx = bcx_ccx(cx); @@ -3644,7 +3644,7 @@ fn build_closure(cx: &@block_ctxt, upvars: &@[ast::node_id], copying: bool) -> // be dynamically sized, we can't skip past them to get to the tydescs until // we have loaded the tydescs. Thus we use the stored size of the bindings // in the tydesc for the closure to skip over them. Ugh. -fn find_environment_tydescs(bcx: &@block_ctxt, envty: &ty::t, +fn find_environment_tydescs(bcx: &@block_ctxt, envty: ty::t, closure: ValueRef) -> ValueRef { ret if !ty::type_has_dynamic_size(bcx_tcx(bcx), envty) { @@ -3675,7 +3675,7 @@ fn find_environment_tydescs(bcx: &@block_ctxt, envty: &ty::t, // Given an enclosing block context, a new function context, a closure type, // and a list of upvars, generate code to load and populate the environment // with the upvars and type descriptors. -fn load_environment(enclosing_cx: &@block_ctxt, fcx: &@fn_ctxt, envty: &ty::t, +fn load_environment(enclosing_cx: &@block_ctxt, fcx: &@fn_ctxt, envty: ty::t, upvars: &@[ast::node_id], copying: bool) { let bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs); @@ -4003,7 +4003,7 @@ fn trans_path(cx: &@block_ctxt, p: &ast::path, id: ast::node_id) -> ret trans_var(cx, p.span, id); } -fn trans_field(cx: &@block_ctxt, sp: &span, v: ValueRef, t0: &ty::t, +fn trans_field(cx: &@block_ctxt, sp: &span, v: ValueRef, t0: ty::t, field: &ast::ident) -> lval_result { let r = autoderef(cx, v, t0); let t = r.ty; @@ -4270,9 +4270,9 @@ fn trans_cast(cx: &@block_ctxt, e: &@ast::expr, id: ast::node_id) -> result { ret rslt(e_res.bcx, newval); } -fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: &ty::t, - outgoing_fty: &ty::t, args: &[option::t<@ast::expr>], - env_ty: &ty::t, ty_param_count: uint, +fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: ty::t, + outgoing_fty: ty::t, args: &[option::t<@ast::expr>], + env_ty: ty::t, ty_param_count: uint, target_fn: &option::t) -> {val: ValueRef, ty: TypeRef} { @@ -4594,7 +4594,7 @@ fn trans_arg_expr(cx: &@block_ctxt, arg: &ty::arg, lldestty0: TypeRef, // - trans_args fn trans_args(cx: &@block_ctxt, llenv: ValueRef, gen: &option::t, lliterbody: &option::t, - es: &[@ast::expr], fn_ty: &ty::t) -> + es: &[@ast::expr], fn_ty: ty::t) -> {bcx: @block_ctxt, args: [ValueRef], retslot: ValueRef, @@ -5176,7 +5176,7 @@ fn with_out_method(work: fn(&out_method) -> result, cx: @block_ctxt, // latter group "immediates" and, in some circumstances when we know we have a // pointer (or need one), perform load/store operations based on the // immediate-ness of the type. -fn type_is_immediate(ccx: &@crate_ctxt, t: &ty::t) -> bool { +fn type_is_immediate(ccx: &@crate_ctxt, t: ty::t) -> bool { ret ty::type_is_scalar(ccx.tcx, t) || ty::type_is_boxed(ccx.tcx, t) || ty::type_is_native(ccx.tcx, t); } @@ -5188,12 +5188,12 @@ fn do_spill(cx: &@block_ctxt, v: ValueRef) -> ValueRef { ret llptr; } -fn spill_if_immediate(cx: &@block_ctxt, v: ValueRef, t: &ty::t) -> ValueRef { +fn spill_if_immediate(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> ValueRef { if type_is_immediate(bcx_ccx(cx), t) { ret do_spill(cx, v); } ret v; } -fn load_if_immediate(cx: &@block_ctxt, v: ValueRef, t: &ty::t) -> ValueRef { +fn load_if_immediate(cx: &@block_ctxt, v: ValueRef, t: ty::t) -> ValueRef { if type_is_immediate(bcx_ccx(cx), t) { ret cx.build.Load(v); } ret v; } @@ -5665,7 +5665,7 @@ fn llderivedtydescs_block_ctxt(fcx: &@fn_ctxt) -> @block_ctxt { } -fn alloc_ty(cx: &@block_ctxt, t: &ty::t) -> result { +fn alloc_ty(cx: &@block_ctxt, t: ty::t) -> result { let bcx = cx; let val = C_int(0); if ty::type_has_dynamic_size(bcx_tcx(bcx), t) { diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index c2594c98f2da..b2fb3a92750b 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -428,7 +428,7 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t) -> @raw_t { let has_params: bool = false; let has_vars: bool = false; fn derive_flags_t(cx: &ctxt, has_params: &mutable bool, - has_vars: &mutable bool, tt: &t) { + has_vars: &mutable bool, tt: t) { let rt = interner::get::<@raw_t>(*cx.ts, tt); has_params = has_params || rt.has_params; has_vars = has_vars || rt.has_vars; @@ -442,7 +442,7 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t) -> @raw_t { derive_flags_t(cx, has_params, has_vars, a.ty); } fn derive_flags_sig(cx: &ctxt, has_params: &mutable bool, - has_vars: &mutable bool, args: &[arg], tt: &t) { + has_vars: &mutable bool, args: &[arg], tt: t) { for a: arg in args { derive_flags_arg(cx, has_params, has_vars, a); } derive_flags_t(cx, has_params, has_vars, tt); } @@ -553,15 +553,15 @@ fn mk_tag(cx: &ctxt, did: &ast::def_id, tys: &[t]) -> t { fn mk_box(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_box(tm)); } -fn mk_uniq(cx: &ctxt, typ: &t) -> t { ret gen_ty(cx, ty_uniq(typ)); } +fn mk_uniq(cx: &ctxt, typ: t) -> t { ret gen_ty(cx, ty_uniq(typ)); } fn mk_ptr(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_ptr(tm)); } -fn mk_imm_box(cx: &ctxt, ty: &t) -> t { +fn mk_imm_box(cx: &ctxt, ty: t) -> t { ret mk_box(cx, {ty: ty, mut: ast::imm}); } -fn mk_mut_ptr(cx: &ctxt, ty: &t) -> t { +fn mk_mut_ptr(cx: &ctxt, ty: t) -> t { ret mk_ptr(cx, {ty: ty, mut: ast::mut}); } @@ -569,24 +569,24 @@ fn mk_vec(cx: &ctxt, tm: &mt) -> t { ret gen_ty(cx, ty_vec(tm)); } fn mk_rec(cx: &ctxt, fs: &[field]) -> t { ret gen_ty(cx, ty_rec(fs)); } -fn mk_constr(cx: &ctxt, t: &t, cs: &[@type_constr]) -> t { +fn mk_constr(cx: &ctxt, t: t, cs: &[@type_constr]) -> t { ret gen_ty(cx, ty_constr(t, cs)); } fn mk_tup(cx: &ctxt, ts: &[t]) -> t { ret gen_ty(cx, ty_tup(ts)); } -fn mk_fn(cx: &ctxt, proto: &ast::proto, args: &[arg], ty: &t, +fn mk_fn(cx: &ctxt, proto: &ast::proto, args: &[arg], ty: t, cf: &controlflow, constrs: &[@constr]) -> t { ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs)); } -fn mk_native_fn(cx: &ctxt, abi: &ast::native_abi, args: &[arg], ty: &t) -> t { +fn mk_native_fn(cx: &ctxt, abi: &ast::native_abi, args: &[arg], ty: t) -> t { ret gen_ty(cx, ty_native_fn(abi, args, ty)); } fn mk_obj(cx: &ctxt, meths: &[method]) -> t { ret gen_ty(cx, ty_obj(meths)); } -fn mk_res(cx: &ctxt, did: &ast::def_id, inner: &t, tps: &[t]) -> t { +fn mk_res(cx: &ctxt, did: &ast::def_id, inner: t, tps: &[t]) -> t { ret gen_ty(cx, ty_res(did, inner, tps)); } @@ -600,19 +600,19 @@ fn mk_type(_cx: &ctxt) -> t { ret idx_type; } fn mk_native(cx: &ctxt, did: &def_id) -> t { ret gen_ty(cx, ty_native(did)); } -fn mk_iter_body_fn(cx: &ctxt, output: &t) -> t { +fn mk_iter_body_fn(cx: &ctxt, output: t) -> t { ret mk_fn(cx, ast::proto_block, [{mode: ty::mo_alias(false), ty: output}], ty::mk_nil(cx), ast::return, []); } // Returns the one-level-deep type structure of the given type. -fn struct(cx: &ctxt, typ: &t) -> sty { +fn struct(cx: &ctxt, typ: t) -> sty { ret interner::get(*cx.ts, typ).struct; } // Returns the canonical name of the given type. -fn cname(cx: &ctxt, typ: &t) -> option::t { +fn cname(cx: &ctxt, typ: t) -> option::t { ret interner::get(*cx.ts, typ).cname; } @@ -803,19 +803,19 @@ fn copy_cname(cx: &ctxt, struct_ty: t, cname_ty: t) -> t { ret gen_ty_full(cx, struct(cx, struct_ty), cname(cx, cname_ty)); } -fn type_is_nil(cx: &ctxt, ty: &t) -> bool { +fn type_is_nil(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_nil. { ret true; } _ { ret false; } } } -fn type_is_bot(cx: &ctxt, ty: &t) -> bool { +fn type_is_bot(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_bot. { ret true; } _ { ret false; } } } -fn type_is_bool(cx: &ctxt, ty: &t) -> bool { +fn type_is_bool(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_bool. { ret true; } _ { ret false; } } } -fn type_is_structural(cx: &ctxt, ty: &t) -> bool { +fn type_is_structural(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_rec(_) { ret true; } ty_tup(_) { ret true; } @@ -829,7 +829,7 @@ fn type_is_structural(cx: &ctxt, ty: &t) -> bool { } } -fn type_is_copyable(cx: &ctxt, ty: &t) -> bool { +fn type_is_copyable(cx: &ctxt, ty: t) -> bool { ret alt struct(cx, ty) { ty_res(_, _, _) { false } ty_fn(proto_block., _, _, _, _) { false } @@ -837,7 +837,7 @@ fn type_is_copyable(cx: &ctxt, ty: &t) -> bool { }; } -fn type_is_sequence(cx: &ctxt, ty: &t) -> bool { +fn type_is_sequence(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_str. { ret true; } ty_istr. { ret true; } @@ -846,7 +846,7 @@ fn type_is_sequence(cx: &ctxt, ty: &t) -> bool { } } -fn type_is_str(cx: &ctxt, ty: &t) -> bool { +fn type_is_str(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_str. { ret true; } ty_istr. { ret true; } @@ -854,7 +854,7 @@ fn type_is_str(cx: &ctxt, ty: &t) -> bool { } } -fn sequence_is_interior(cx: &ctxt, ty: &t) -> bool { +fn sequence_is_interior(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { @@ -867,7 +867,7 @@ fn sequence_is_interior(cx: &ctxt, ty: &t) -> bool { } } -fn sequence_element_type(cx: &ctxt, ty: &t) -> t { +fn sequence_element_type(cx: &ctxt, ty: t) -> t { alt struct(cx, ty) { ty_str. { ret mk_mach(cx, ast::ty_u8); } ty_istr. { ret mk_mach(cx, ast::ty_u8); } @@ -876,7 +876,7 @@ fn sequence_element_type(cx: &ctxt, ty: &t) -> t { } } -fn type_is_tup_like(cx: &ctxt, ty: &t) -> bool { +fn type_is_tup_like(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_box(_) { ret true; } ty_rec(_) { ret true; } @@ -886,7 +886,7 @@ fn type_is_tup_like(cx: &ctxt, ty: &t) -> bool { } } -fn get_element_type(cx: &ctxt, ty: &t, i: uint) -> t { +fn get_element_type(cx: &ctxt, ty: t, i: uint) -> t { alt struct(cx, ty) { ty_rec(flds) { ret flds[i].mt.ty; } ty_tup(ts) { ret ts[i]; } @@ -900,11 +900,11 @@ fn get_element_type(cx: &ctxt, ty: &t, i: uint) -> t { // tag. } -fn type_is_box(cx: &ctxt, ty: &t) -> bool { +fn type_is_box(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_box(_) { ret true; } _ { ret false; } } } -fn type_is_boxed(cx: &ctxt, ty: &t) -> bool { +fn type_is_boxed(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_str. { ret true; } ty_box(_) { ret true; } @@ -912,11 +912,11 @@ fn type_is_boxed(cx: &ctxt, ty: &t) -> bool { } } -fn type_is_unique(cx: &ctxt, ty: &t) -> bool { +fn type_is_unique(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_uniq(_) { ret true; } _ { ret false; } } } -fn type_is_scalar(cx: &ctxt, ty: &t) -> bool { +fn type_is_scalar(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_nil. { ret true; } ty_bool. { ret true; } @@ -932,7 +932,7 @@ fn type_is_scalar(cx: &ctxt, ty: &t) -> bool { } } -fn type_has_pointers(cx: &ctxt, ty: &t) -> bool { +fn type_has_pointers(cx: &ctxt, ty: t) -> bool { alt cx.has_pointer_cache.find(ty) { some(result) { ret result; } none. {/* fall through */ } @@ -986,14 +986,14 @@ fn type_has_pointers(cx: &ctxt, ty: &t) -> bool { ret result; } -fn type_needs_drop(cx: &ctxt, ty: &t) -> bool { +fn type_needs_drop(cx: &ctxt, ty: t) -> bool { ret alt struct(cx, ty) { ty_res(_, _, _) { true } _ { type_has_pointers(cx, ty) } }; } -fn type_kind(cx: &ctxt, ty: &t) -> ast::kind { +fn type_kind(cx: &ctxt, ty: t) -> ast::kind { alt cx.kind_cache.find(ty) { some(result) { ret result; } none. {/* fall through */ } @@ -1127,11 +1127,11 @@ fn type_kind(cx: &ctxt, ty: &t) -> ast::kind { // FIXME: should we just return true for native types in // type_is_scalar? -fn type_is_native(cx: &ctxt, ty: &t) -> bool { +fn type_is_native(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_native(_) { ret true; } _ { ret false; } } } -fn type_has_dynamic_size(cx: &ctxt, ty: &t) -> bool { +fn type_has_dynamic_size(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_nil. { ret false; } ty_bot. { ret false; } @@ -1181,7 +1181,7 @@ fn type_has_dynamic_size(cx: &ctxt, ty: &t) -> bool { } } -fn type_is_integral(cx: &ctxt, ty: &t) -> bool { +fn type_is_integral(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_int. { ret true; } ty_uint. { ret true; } @@ -1204,7 +1204,7 @@ fn type_is_integral(cx: &ctxt, ty: &t) -> bool { } } -fn type_is_fp(cx: &ctxt, ty: &t) -> bool { +fn type_is_fp(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_machine(tm) { alt tm { @@ -1218,7 +1218,7 @@ fn type_is_fp(cx: &ctxt, ty: &t) -> bool { } } -fn type_is_signed(cx: &ctxt, ty: &t) -> bool { +fn type_is_signed(cx: &ctxt, ty: t) -> bool { alt struct(cx, ty) { ty_int. { ret true; } ty_machine(tm) { @@ -1234,7 +1234,7 @@ fn type_is_signed(cx: &ctxt, ty: &t) -> bool { } } -fn type_owns_heap_mem(cx: &ctxt, ty: &t) -> bool { +fn type_owns_heap_mem(cx: &ctxt, ty: t) -> bool { alt cx.owns_heap_mem_cache.find(ty) { some(result) { ret result; } none. {/* fall through */ } @@ -1311,7 +1311,7 @@ fn type_owns_heap_mem(cx: &ctxt, ty: &t) -> bool { } // Whether a type is Plain Old Data (i.e. can be safely memmoved). -fn type_is_pod(cx: &ctxt, ty: &t) -> bool { +fn type_is_pod(cx: &ctxt, ty: t) -> bool { let result = true; alt struct(cx, ty) { @@ -1363,7 +1363,7 @@ fn type_is_pod(cx: &ctxt, ty: &t) -> bool { ret result; } -fn type_param(cx: &ctxt, ty: &t) -> option::t { +fn type_param(cx: &ctxt, ty: t) -> option::t { alt struct(cx, ty) { ty_param(id, _) { ret some(id); } _ {/* fall through */ } @@ -1373,7 +1373,7 @@ fn type_param(cx: &ctxt, ty: &t) -> option::t { // Returns a vec of all the type variables // occurring in t. It may contain duplicates. -fn vars_in_type(cx: &ctxt, ty: &t) -> [int] { +fn vars_in_type(cx: &ctxt, ty: t) -> [int] { fn collect_var(cx: &ctxt, vars: &@mutable [int], ty: t) { alt struct(cx, ty) { ty_var(v) { *vars += [v]; } _ { } } } @@ -1384,7 +1384,7 @@ fn vars_in_type(cx: &ctxt, ty: &t) -> [int] { ret *rslt; } -fn type_autoderef(cx: &ctxt, t: &ty::t) -> ty::t { +fn type_autoderef(cx: &ctxt, t: ty::t) -> ty::t { let t1: ty::t = t; while true { alt struct(cx, t1) { @@ -1419,7 +1419,7 @@ fn hash_type_structure(st: &sty) -> uint { h += h << 5u + (did.node as uint); ret h; } - fn hash_subty(id: uint, subty: &t) -> uint { + fn hash_subty(id: uint, subty: t) -> uint { let h = id; h += h << 5u + hash_ty(subty); ret h; @@ -1448,7 +1448,7 @@ fn hash_type_structure(st: &sty) -> uint { } - fn hash_fn(id: uint, args: &[arg], rty: &t) -> uint { + fn hash_fn(id: uint, args: &[arg], rty: t) -> uint { let h = id; for a: arg in args { h += h << 5u + hash_ty(a.ty); } h += h << 5u + hash_ty(rty); @@ -1681,17 +1681,17 @@ fn count_ty_params(cx: &ctxt, ty: t) -> uint { ret vec::len::(*param_indices); } -fn type_contains_vars(cx: &ctxt, typ: &t) -> bool { +fn type_contains_vars(cx: &ctxt, typ: t) -> bool { ret interner::get(*cx.ts, typ).has_vars; } -fn type_contains_params(cx: &ctxt, typ: &t) -> bool { +fn type_contains_params(cx: &ctxt, typ: t) -> bool { ret interner::get(*cx.ts, typ).has_params; } // Type accessors for substructures of types -fn ty_fn_args(cx: &ctxt, fty: &t) -> [arg] { +fn ty_fn_args(cx: &ctxt, fty: t) -> [arg] { alt struct(cx, fty) { ty::ty_fn(_, a, _, _, _) { ret a; } ty::ty_native_fn(_, a, _) { ret a; } @@ -1699,21 +1699,21 @@ fn ty_fn_args(cx: &ctxt, fty: &t) -> [arg] { } } -fn ty_fn_proto(cx: &ctxt, fty: &t) -> ast::proto { +fn ty_fn_proto(cx: &ctxt, fty: t) -> ast::proto { alt struct(cx, fty) { ty::ty_fn(p, _, _, _, _) { ret p; } _ { cx.sess.bug("ty_fn_proto() called on non-fn type"); } } } -fn ty_fn_abi(cx: &ctxt, fty: &t) -> ast::native_abi { +fn ty_fn_abi(cx: &ctxt, fty: t) -> ast::native_abi { alt struct(cx, fty) { ty::ty_native_fn(a, _, _) { ret a; } _ { cx.sess.bug("ty_fn_abi() called on non-native-fn type"); } } } -fn ty_fn_ret(cx: &ctxt, fty: &t) -> t { +fn ty_fn_ret(cx: &ctxt, fty: t) -> t { alt struct(cx, fty) { ty::ty_fn(_, _, r, _, _) { ret r; } ty::ty_native_fn(_, _, r) { ret r; } @@ -1721,7 +1721,7 @@ fn ty_fn_ret(cx: &ctxt, fty: &t) -> t { } } -fn is_fn_ty(cx: &ctxt, fty: &t) -> bool { +fn is_fn_ty(cx: &ctxt, fty: t) -> bool { alt struct(cx, fty) { ty::ty_fn(_, _, _, _, _) { ret true; } ty::ty_native_fn(_, _, _) { ret true; } @@ -1754,7 +1754,7 @@ fn pat_ty(cx: &ctxt, pat: &@ast::pat) -> t { // // NB: This type doesn't provide type parameter substitutions; e.g. if you // ask for the type of "id" in "id(3)", it will return "fn(&int) -> int" -// instead of "fn(&T) -> T with T = int". If this isn't what you want, see +// instead of "fn(t) -> T with T = int". If this isn't what you want, see // expr_ty_params_and_ty() below. fn expr_ty(cx: &ctxt, expr: &@ast::expr) -> t { ret node_id_to_monotype(cx, expr.id); @@ -1812,7 +1812,7 @@ fn is_lval(expr: &@ast::expr) -> bool { } } -fn occurs_check_fails(tcx: &ctxt, sp: &option::t, vid: int, rt: &t) -> +fn occurs_check_fails(tcx: &ctxt, sp: &option::t, vid: int, rt: t) -> bool { if !type_contains_vars(tcx, rt) { // Fast path @@ -1947,7 +1947,7 @@ mod unify { // Right now this just checks that the lists of constraints are // pairwise equal. - fn unify_constrs(base_t: &t, expected: [@type_constr], + fn unify_constrs(base_t: t, expected: [@type_constr], actual: &[@type_constr]) -> result { let expected_len = vec::len(expected); let actual_len = vec::len(actual); @@ -1964,7 +1964,7 @@ mod unify { } ret ures_ok(base_t); } - fn unify_constr(base_t: &t, expected: @type_constr, + fn unify_constr(base_t: t, expected: @type_constr, actual_constr: &@type_constr) -> result { let ok_res = ures_ok(base_t); let err_res = ures_err(terr_constr_mismatch(expected, actual_constr)); @@ -2010,9 +2010,9 @@ mod unify { fn_common_res_err(result); fn_common_res_ok([arg], t); } - fn unify_fn_common(cx: &@ctxt, _expected: &t, _actual: &t, - expected_inputs: &[arg], expected_output: &t, - actual_inputs: &[arg], actual_output: &t) -> + fn unify_fn_common(cx: &@ctxt, _expected: t, _actual: t, + expected_inputs: &[arg], expected_output: t, + actual_inputs: &[arg], actual_output: t) -> fn_common_res { let expected_len = vec::len::(expected_inputs); let actual_len = vec::len::(actual_inputs); @@ -2050,8 +2050,8 @@ mod unify { } } fn unify_fn(cx: &@ctxt, e_proto: &ast::proto, a_proto: &ast::proto, - expected: &t, actual: &t, expected_inputs: &[arg], - expected_output: &t, actual_inputs: &[arg], actual_output: &t, + expected: t, actual: t, expected_inputs: &[arg], + expected_output: t, actual_inputs: &[arg], actual_output: t, expected_cf: &controlflow, actual_cf: &controlflow, _expected_constrs: &[@constr], actual_constrs: &[@constr]) -> result { @@ -2092,9 +2092,9 @@ mod unify { } } fn unify_native_fn(cx: &@ctxt, e_abi: &ast::native_abi, - a_abi: &ast::native_abi, expected: &t, actual: &t, - expected_inputs: &[arg], expected_output: &t, - actual_inputs: &[arg], actual_output: &t) -> result { + a_abi: &ast::native_abi, expected: t, actual: t, + expected_inputs: &[arg], expected_output: t, + actual_inputs: &[arg], actual_output: t) -> result { if e_abi != a_abi { ret ures_err(terr_mismatch); } let t = unify_fn_common(cx, expected, actual, expected_inputs, @@ -2107,7 +2107,7 @@ mod unify { } } } - fn unify_obj(cx: &@ctxt, expected: &t, actual: &t, + fn unify_obj(cx: &@ctxt, expected: t, actual: t, expected_meths: &[method], actual_meths: &[method]) -> result { let result_meths: [method] = []; @@ -2159,7 +2159,7 @@ mod unify { _ { ret fix_ok(typ); } } } - fn unify_step(cx: &@ctxt, expected: &t, actual: &t) -> result { + fn unify_step(cx: &@ctxt, expected: t, actual: t) -> result { // TODO: rewrite this using tuple pattern matching when available, to // avoid all this rightward drift and spikiness. @@ -2506,7 +2506,7 @@ mod unify { } } } - fn unify(expected: &t, actual: &t, vb: &@var_bindings, tcx: &ty_ctxt) -> + fn unify(expected: t, actual: t, vb: &@var_bindings, tcx: &ty_ctxt) -> result { let cx = @{vb: vb, tcx: tcx}; ret unify_step(cx, expected, actual); diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 9e9d06822499..ff5de77ba0b5 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -883,7 +883,7 @@ mod collect { // Type unification mod unify { - fn unify(fcx: &@fn_ctxt, expected: &ty::t, actual: &ty::t) -> + fn unify(fcx: &@fn_ctxt, expected: ty::t, actual: ty::t) -> ty::unify::result { ret ty::unify::unify(expected, actual, fcx.var_bindings, fcx.ccx.tcx); } @@ -892,7 +892,7 @@ mod unify { // FIXME This is almost a duplicate of ty::type_autoderef, with structure_of // instead of ty::struct. -fn do_autoderef(fcx: &@fn_ctxt, sp: &span, t: &ty::t) -> ty::t { +fn do_autoderef(fcx: &@fn_ctxt, sp: &span, t: ty::t) -> ty::t { let t1 = t; while true { alt structure_of(fcx, sp, t1) { @@ -926,8 +926,8 @@ fn do_autoderef(fcx: &@fn_ctxt, sp: &span, t: &ty::t) -> ty::t { fail; } -fn do_fn_block_coerce(fcx: &@fn_ctxt, sp: &span, actual: &ty::t, - expected: &ty::t) -> ty::t { +fn do_fn_block_coerce(fcx: &@fn_ctxt, sp: &span, actual: ty::t, + expected: ty::t) -> ty::t { // fns can be silently coerced to blocks when being used as // function call or bind arguments, but not the reverse. @@ -963,17 +963,17 @@ fn resolve_type_vars_if_possible(fcx: &@fn_ctxt, typ: ty::t) -> ty::t { type ty_param_substs_and_ty = {substs: [ty::t], ty: ty::t}; mod demand { - fn simple(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, actual: &ty::t) -> + fn simple(fcx: &@fn_ctxt, sp: &span, expected: ty::t, actual: ty::t) -> ty::t { full(fcx, sp, expected, actual, [], false).ty } - fn block_coerce(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, - actual: &ty::t) -> ty::t { + fn block_coerce(fcx: &@fn_ctxt, sp: &span, expected: ty::t, + actual: ty::t) -> ty::t { full(fcx, sp, expected, actual, [], true).ty } - fn with_substs(fcx: &@fn_ctxt, sp: &span, expected: &ty::t, - actual: &ty::t, ty_param_substs_0: &[ty::t]) -> + fn with_substs(fcx: &@fn_ctxt, sp: &span, expected: ty::t, + actual: ty::t, ty_param_substs_0: &[ty::t]) -> ty_param_substs_and_ty { full(fcx, sp, expected, actual, ty_param_substs_0, false) } @@ -998,7 +998,7 @@ mod demand { simple(fcx, sp, ty_param_subst, t_0); } - fn mk_result(fcx: &@fn_ctxt, result_ty: &ty::t, + fn mk_result(fcx: &@fn_ctxt, result_ty: ty::t, ty_param_subst_var_ids: &[int]) -> ty_param_substs_and_ty { let result_ty_param_substs: [ty::t] = []; @@ -1029,7 +1029,7 @@ mod demand { // Returns true if the two types unify and false if they don't. -fn are_compatible(fcx: &@fn_ctxt, expected: &ty::t, actual: &ty::t) -> bool { +fn are_compatible(fcx: &@fn_ctxt, expected: ty::t, actual: ty::t) -> bool { alt unify::unify(fcx, expected, actual) { ures_ok(_) { ret true; } ures_err(_) { ret false; } @@ -1519,22 +1519,22 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: &ast::purity, } } -type unifier = fn(&@fn_ctxt, &span, &ty::t, &ty::t) -> ty::t; +type unifier = fn(&@fn_ctxt, &span, ty::t, ty::t) -> ty::t; fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool { - fn dummy_unify(_fcx: &@fn_ctxt, _sp: &span, _expected: &ty::t, - actual: &ty::t) -> ty::t { + fn dummy_unify(_fcx: &@fn_ctxt, _sp: &span, _expected: ty::t, + actual: ty::t) -> ty::t { actual } ret check_expr_with_unifier(fcx, expr, dummy_unify, 0u); } -fn check_expr_with(fcx: &@fn_ctxt, expr: &@ast::expr, expected: &ty::t) -> +fn check_expr_with(fcx: &@fn_ctxt, expr: &@ast::expr, expected: ty::t) -> bool { ret check_expr_with_unifier(fcx, expr, demand::simple, expected); } fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr, unify: &unifier, - expected: &ty::t) -> bool { + expected: ty::t) -> bool { //log_err "typechecking expr " + syntax::print::pprust::expr_to_str(expr); // A generic function to factor out common logic from call and bind