From f236b850c0dc4c1b925e33d1173f359605801307 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 30 Apr 2013 16:35:01 -0400 Subject: [PATCH] remove some unused mut decls --- src/libcore/num/num.rs | 2 +- src/librustc/middle/resolve.rs | 4 ++-- src/librustc/middle/trans/base.rs | 2 +- src/librustc/middle/trans/callee.rs | 2 +- src/librustc/middle/trans/expr.rs | 2 -- src/librustc/middle/typeck/check/method.rs | 4 ++-- src/librustc/middle/typeck/check/mod.rs | 4 ++-- src/librustc/middle/typeck/check/regionck.rs | 2 +- src/test/run-fail/borrowck-wg-fail-2.rs | 3 ++- src/test/run-fail/borrowck-wg-fail-3.rs | 3 ++- src/test/run-fail/borrowck-wg-fail.rs | 6 ++---- 11 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index de7597fa821..96fed51309e 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -385,7 +385,7 @@ pub fn pow_with_uint+Mul>( } #[cfg(test)] -fn test_num(ten: T, two: T) { +pub fn test_num(ten: T, two: T) { assert_eq!(ten.add(&two), cast(12)); assert_eq!(ten.sub(&two), cast(8)); assert_eq!(ten.mul(&two), cast(20)); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index ffc9d1488cf..ff46abaf712 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -5267,7 +5267,7 @@ pub impl Resolver { debug!("Import resolutions:"); for module_.import_resolutions.each |name, import_resolution| { - let mut value_repr; + let value_repr; match import_resolution.target_for_namespace(ValueNS) { None => { value_repr = ~""; } Some(_) => { @@ -5276,7 +5276,7 @@ pub impl Resolver { } } - let mut type_repr; + let type_repr; match import_resolution.target_for_namespace(TypeNS) { None => { type_repr = ~""; } Some(_) => { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 7be6bdb654e..1785feda779 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2366,7 +2366,7 @@ pub fn create_entry_wrapper(ccx: @CrateContext, // Call main. let lloutputarg = C_null(T_ptr(T_i8())); let llenvarg = unsafe { llvm::LLVMGetParam(llfdecl, 1 as c_uint) }; - let mut args = ~[lloutputarg, llenvarg]; + let args = ~[lloutputarg, llenvarg]; let llresult = Call(bcx, main_llfn, args); Store(bcx, llresult, fcx.llretptr.get()); diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index af00257fe16..c4c6133b405 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -722,7 +722,7 @@ pub fn trans_arg_expr(bcx: block, } } }; - let mut arg_datum = arg_datumblock.datum; + let arg_datum = arg_datumblock.datum; let bcx = arg_datumblock.bcx; debug!(" arg datum: %s", arg_datum.to_str(bcx.ccx())); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index ac6fa7a5a1c..fa6f7802e7d 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -563,7 +563,6 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block { fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, dest: Dest) -> block { - let mut bcx = bcx; let _icx = bcx.insn_ctxt("trans_rvalue_dps_unadjusted"); let tcx = bcx.tcx(); @@ -1408,7 +1407,6 @@ fn trans_eager_binop(bcx: block, lhs_datum: &Datum, rhs_datum: &Datum) -> DatumBlock { - let mut bcx = bcx; let _icx = bcx.insn_ctxt("trans_eager_binop"); let lhs = lhs_datum.to_appropriate_llval(bcx); diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index de6530fb464..9f9132fa946 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -120,7 +120,7 @@ pub fn lookup( expr: @ast::expr, // The expression `a.b(...)`. self_expr: @ast::expr, // The expression `a`. callee_id: node_id, /* Where to store `a.b`'s type, - * also the scope of the call */ + * also the scope of the call */ m_name: ast::ident, // The ident `b`. self_ty: ty::t, // The type of `a`. supplied_tps: &[ty::t], // The list of types X, Y, ... . @@ -128,7 +128,7 @@ pub fn lookup( check_traits: CheckTraitsFlag, // Whether we check traits only. autoderef_receiver: AutoderefReceiverFlag) -> Option { - let mut impl_dups = @mut HashSet::new(); + let impl_dups = @mut HashSet::new(); let lcx = LookupContext { fcx: fcx, expr: expr, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index fb58df3d55c..70282fdc57c 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1684,7 +1684,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, }; // construct the function type - let mut fn_ty = astconv::ty_of_closure(fcx, + let fn_ty = astconv::ty_of_closure(fcx, fcx, sigil, purity, @@ -1695,7 +1695,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, &opt_vec::Empty, expr.span); - let mut fty_sig; + let fty_sig; let fty = if error_happened { fty_sig = FnSig { bound_lifetime_names: opt_vec::Empty, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index be513cbb0f3..fd19738b321 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -871,7 +871,7 @@ pub mod guarantor { let tcx = rcx.tcx(); debug!("guarantor::for_by_ref(expr=%s, callee_scope=%?)", expr.repr(tcx), callee_scope); - let mut expr_cat = categorize(rcx, expr); + let expr_cat = categorize(rcx, expr); debug!("guarantor::for_by_ref(expr=%?, callee_scope=%?) category=%?", expr.id, callee_scope, expr_cat); let minimum_lifetime = ty::re_scope(callee_scope); diff --git a/src/test/run-fail/borrowck-wg-fail-2.rs b/src/test/run-fail/borrowck-wg-fail-2.rs index 126135772ad..121ec9c7921 100644 --- a/src/test/run-fail/borrowck-wg-fail-2.rs +++ b/src/test/run-fail/borrowck-wg-fail-2.rs @@ -7,5 +7,6 @@ struct S { fn main() { let x = @mut S { x: 3 }; let y: &S = x; - x.x = 5; + let z = x; + z.x = 5; } diff --git a/src/test/run-fail/borrowck-wg-fail-3.rs b/src/test/run-fail/borrowck-wg-fail-3.rs index ad4c7942121..2b95cf3fe5f 100644 --- a/src/test/run-fail/borrowck-wg-fail-3.rs +++ b/src/test/run-fail/borrowck-wg-fail-3.rs @@ -3,6 +3,7 @@ fn main() { let x = @mut 3; let y: &mut int = x; - *x = 5; + let z = x; + *z = 5; } diff --git a/src/test/run-fail/borrowck-wg-fail.rs b/src/test/run-fail/borrowck-wg-fail.rs index d393832c6e8..fd2d36b895a 100644 --- a/src/test/run-fail/borrowck-wg-fail.rs +++ b/src/test/run-fail/borrowck-wg-fail.rs @@ -1,9 +1,7 @@ // error-pattern:borrowed -fn f(x: &int, y: @mut int) { - unsafe { - *y = 2; - } +fn f(_x: &int, y: @mut int) { + *y = 2; } fn main() {