diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-09-26 19:40:05 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-09-26 19:42:02 -0700 |
| commit | 996ec62cbfce9f25ecc8b573a0b9eb7f4a1b6db9 (patch) | |
| tree | 9d544b22c33bddfea8376115fb4ee1ac0cd3a078 | |
| parent | 656cbead49f0d7022152887970719f9c95f76419 (diff) | |
| download | rust-996ec62cbfce9f25ecc8b573a0b9eb7f4a1b6db9.tar.gz rust-996ec62cbfce9f25ecc8b573a0b9eb7f4a1b6db9.zip | |
Remove spurious by-ref argument to destructors
Destructors were internally declared with an extra (hidden) nil-typed argument that was passed in by-ref mode. This was causing spurious mode warnings. Deleted it. Also some misc. cleanup because I couldn't help myself.
| -rw-r--r-- | src/libsyntax/ast_util.rs | 6 | ||||
| -rw-r--r-- | src/rustc/middle/trans/base.rs | 10 | ||||
| -rw-r--r-- | src/rustc/middle/trans/datum.rs | 2 | ||||
| -rw-r--r-- | src/rustc/middle/trans/glue.rs | 6 | ||||
| -rw-r--r-- | src/rustc/middle/trans/monomorphize.rs | 4 | ||||
| -rw-r--r-- | src/rustc/middle/trans/type_of.rs | 4 |
6 files changed, 14 insertions, 18 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 329c9f362a4..a2c935ea6f4 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -398,10 +398,8 @@ fn operator_prec(op: ast::binop) -> uint { fn dtor_dec() -> fn_decl { let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()}; - // dtor has one argument, of type () - {inputs: ~[{mode: ast::expl(ast::by_ref), - ty: nil_t, ident: parse::token::special_idents::underscore, - id: 0}], + // dtor has no args + {inputs: ~[], output: nil_t, cf: return_val} } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 94b09a30e4b..47ac8e9ef6a 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -383,7 +383,7 @@ fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id, parent_id: ast::def_id, substs: ~[ty::t]) -> ValueRef { let _icx = ccx.insn_ctxt("trans_res_dtor"); - if (substs.len() > 0u) { + if (substs.is_not_empty()) { let did = if did.crate != ast::local_crate { inline::maybe_instantiate_inline(ccx, did) } else { did }; @@ -1496,7 +1496,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt, // For certain mode/type combinations, the raw llarg values are passed // by value. However, within the fn body itself, we want to always - // have all locals and argumenst be by-ref so that we can cancel the + // have all locals and arguments be by-ref so that we can cancel the // cleanup and for better interaction with LLVM's debug info. So, if // the argument would be passed by value, we store it into an alloca. // This alloca should be optimized away by LLVM's mem-to-reg pass in @@ -1767,9 +1767,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path, /* The dtor takes a (null) output pointer, and a self argument, and returns () */ - let lldty = T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(tcx))), - T_ptr(type_of(ccx, class_ty))], - llvm::LLVMVoidType()); + let lldty = type_of_dtor(ccx, class_ty); let s = get_dtor_symbol(ccx, path, dtor_id, psubsts); @@ -1833,7 +1831,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { *path, ~[path_name(item.ident)]), decl, body, llfndecl, item.id); - } else if tps.len() == 0u { + } else if tps.is_empty() { let llfndecl = get_item_val(ccx, item.id); trans_fn(ccx, vec::append(*path, ~[path_name(item.ident)]), diff --git a/src/rustc/middle/trans/datum.rs b/src/rustc/middle/trans/datum.rs index 3f2705a9bcc..59e8cd72025 100644 --- a/src/rustc/middle/trans/datum.rs +++ b/src/rustc/middle/trans/datum.rs @@ -204,7 +204,7 @@ fn appropriate_mode(ty: ty::t) -> DatumMode { * * Indicates the "appropriate" mode for this value, * which is either by ref or by value, depending - * on whether type is iimmediate or what. */ + * on whether type is immediate or not. */ if ty::type_is_nil(ty) || ty::type_is_bot(ty) { ByValue diff --git a/src/rustc/middle/trans/glue.rs b/src/rustc/middle/trans/glue.rs index 0fc72e8dc15..50a24a1a825 100644 --- a/src/rustc/middle/trans/glue.rs +++ b/src/rustc/middle/trans/glue.rs @@ -426,8 +426,8 @@ fn trans_class_drop(bcx: block, // Class dtors have no explicit args, so the params should // just consist of the output pointer and the environment // (self) - assert(params.len() == 2u); - let self_arg = PointerCast(bcx, v0, params[1u]); + assert(params.len() == 2); + let self_arg = PointerCast(bcx, v0, params[1]); let args = ~[bcx.fcx.llretptr, self_arg]; Call(bcx, dtor_addr, args); @@ -440,7 +440,7 @@ fn trans_class_drop(bcx: block, bcx = drop_ty(bcx, llfld_a, fld.mt.ty); } - Store(bcx, C_u8(0u), drop_flag); + Store(bcx, C_u8(0), drop_flag); bcx } } diff --git a/src/rustc/middle/trans/monomorphize.rs b/src/rustc/middle/trans/monomorphize.rs index 40558e72c80..bbcacec052e 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -103,11 +103,11 @@ fn monomorphic_fn(ccx: @crate_ctxt, // Random cut-off -- code that needs to instantiate the same function // recursively more than ten times can probably safely be assumed to be // causing an infinite expansion. - if depth > 10u { + if depth > 10 { ccx.sess.span_fatal( span, ~"overly deep expansion of inlined function"); } - ccx.monomorphizing.insert(fn_id, depth + 1u); + ccx.monomorphizing.insert(fn_id, depth + 1); let pt = vec::append(*pt, ~[path_name(ccx.names(ccx.sess.str_of(name)))]); diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index 99555d5b294..b45da3b2700 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -254,8 +254,8 @@ fn llvm_type_name(cx: @crate_ctxt, } fn type_of_dtor(ccx: @crate_ctxt, self_ty: ty::t) -> TypeRef { - T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(ccx.tcx))), - T_ptr(type_of(ccx, self_ty))], + T_fn(~[T_ptr(type_of(ccx, ty::mk_nil(ccx.tcx))), // output pointer + T_ptr(type_of(ccx, self_ty))], // self arg llvm::LLVMVoidType()) } |
