allover: numerous unused muts etc

This commit is contained in:
Niko Matsakis
2013-04-30 14:10:21 -04:00
parent 70b9ad1748
commit 418f991118
20 changed files with 41 additions and 53 deletions
+1 -2
View File
@@ -82,14 +82,13 @@ pub fn load_props(testfile: &Path) -> TestProps {
}
pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
let mut found = false;
for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; }
if parse_name_directive(ln, xfail_target()) { return true; }
if config.mode == common::mode_pretty &&
parse_name_directive(ln, ~"xfail-pretty") { return true; }
};
return found;
return false;
fn xfail_target() -> ~str {
~"xfail-" + str::from_slice(os::SYSNAME)
+1 -1
View File
@@ -106,7 +106,7 @@ fn run_rpass_test(config: config, props: TestProps, testfile: &Path) {
fatal_ProcRes(~"test run failed!", ProcRes);
}
} else {
let mut ProcRes = jit_test(config, props, testfile);
let ProcRes = jit_test(config, props, testfile);
if ProcRes.status != 0 { fatal_ProcRes(~"jit failed!", ProcRes); }
}
+2 -2
View File
@@ -42,7 +42,7 @@ pub fn empty_cell<T>() -> Cell<T> {
pub impl<T> Cell<T> {
/// Yields the value, failing if the cell is empty.
fn take(&self) -> T {
let mut self = unsafe { transmute_mut(self) };
let self = unsafe { transmute_mut(self) };
if self.is_empty() {
fail!(~"attempt to take an empty cell");
}
@@ -54,7 +54,7 @@ fn take(&self) -> T {
/// Returns the value, failing if the cell is full.
fn put_back(&self, value: T) {
let mut self = unsafe { transmute_mut(self) };
let self = unsafe { transmute_mut(self) };
if !self.is_empty() {
fail!(~"attempt to put a value back into a full cell");
}
+2 -2
View File
@@ -205,8 +205,8 @@ impl<T: Owned> Selectable for Port<T> {
fn header(&self) -> *PacketHeader {
unsafe {
match self.endp {
Some(ref endp) => endp.header(),
None => fail!(~"peeking empty stream")
Some(ref endp) => endp.header(),
None => fail!(~"peeking empty stream")
}
}
}
+6 -7
View File
@@ -16,7 +16,6 @@
use libc;
use libc::{c_void, size_t, c_int};
use ptr;
use vec;
#[cfg(test)] use rand;
@@ -29,13 +28,13 @@ pub mod rustrt {
pub extern {
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
}
@@ -53,11 +52,11 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
let res =
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
len as size_t,
&outsz,
&mut outsz,
lz_norm);
assert!(res as int != 0);
let out = vec::raw::from_buf_raw(res as *u8,
outsz as uint);
outsz as uint);
libc::free(res);
out
}
@@ -67,11 +66,11 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
do vec::as_const_buf(bytes) |b, len| {
unsafe {
let outsz : size_t = 0;
let mut outsz : size_t = 0;
let res =
rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
len as size_t,
&outsz,
&mut outsz,
0);
assert!(res as int != 0);
let out = vec::raw::from_buf_raw(res as *u8,
+1 -2
View File
@@ -253,8 +253,7 @@ pub mod posix88 {
pub type ssize_t = i32;
}
pub mod posix01 {
use libc::types::os::arch::c95::{c_int, c_short, c_long,
time_t};
use libc::types::os::arch::c95::{c_short, c_long, time_t};
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
use libc::types::os::arch::posix88::{mode_t, off_t};
use libc::types::os::arch::posix88::{uid_t};
+8 -9
View File
@@ -351,13 +351,13 @@ pub fn fsync_fd(fd: c_int, _l: io::fsync::Level) -> c_int {
}
}
pub struct Pipe { mut in: c_int, mut out: c_int }
pub struct Pipe { in: c_int, out: c_int }
#[cfg(unix)]
pub fn pipe() -> Pipe {
unsafe {
let mut fds = Pipe {in: 0 as c_int,
out: 0 as c_int };
out: 0 as c_int };
assert!((libc::pipe(&mut fds.in) == (0 as c_int)));
return Pipe {in: fds.in, out: fds.out};
}
@@ -373,8 +373,7 @@ pub fn pipe() -> Pipe {
// fully understand. Here we explicitly make the pipe non-inheritable,
// which means to pass it to a subprocess they need to be duplicated
// first, as in rust_run_program.
let mut fds = Pipe {in: 0 as c_int,
out: 0 as c_int };
let mut fds = Pipe {in: 0 as c_int, out: 0 as c_int};
let res = libc::pipe(&mut fds.in, 1024 as ::libc::c_uint,
(libc::O_BINARY | libc::O_NOINHERIT) as c_int);
assert!((res == 0 as c_int));
@@ -959,10 +958,10 @@ fn strerror() -> ~str {
#[cfg(target_os = "macos")]
#[cfg(target_os = "android")]
#[cfg(target_os = "freebsd")]
fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int {
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int {
#[nolink]
extern {
unsafe fn strerror_r(errnum: c_int, buf: *c_char,
unsafe fn strerror_r(errnum: c_int, buf: *mut c_char,
buflen: size_t) -> c_int;
}
unsafe {
@@ -974,10 +973,10 @@ unsafe fn strerror_r(errnum: c_int, buf: *c_char,
// and requires macros to instead use the POSIX compliant variant.
// So we just use __xpg_strerror_r which is always POSIX compliant
#[cfg(target_os = "linux")]
fn strerror_r(errnum: c_int, buf: *c_char, buflen: size_t) -> c_int {
fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int {
#[nolink]
extern {
unsafe fn __xpg_strerror_r(errnum: c_int, buf: *c_char,
unsafe fn __xpg_strerror_r(errnum: c_int, buf: *mut c_char,
buflen: size_t) -> c_int;
}
unsafe {
@@ -987,7 +986,7 @@ unsafe fn __xpg_strerror_r(errnum: c_int, buf: *c_char,
let mut buf = [0 as c_char, ..TMPBUF_SZ];
unsafe {
let err = strerror_r(errno() as c_int, &buf[0],
let err = strerror_r(errno() as c_int, &mut buf[0],
TMPBUF_SZ as size_t);
if err < 0 {
fail!(~"strerror_r failure");
-2
View File
@@ -136,7 +136,6 @@ fn resume_task_from_queue(~self) -> bool {
/// Called by a running task to end execution, after which it will
/// be recycled by the scheduler for reuse in a new task.
fn terminate_current_task(~self) {
let mut self = self;
assert!(self.in_task_context());
rtdebug!("ending running task");
@@ -152,7 +151,6 @@ fn terminate_current_task(~self) {
}
fn schedule_new_task(~self, task: ~Task) {
let mut self = self;
assert!(self.in_task_context());
do self.switch_running_tasks_and_then(task) |last_task| {
+3 -3
View File
@@ -501,7 +501,7 @@ pub struct Conv {
pub fn conv_int(cv: Conv, i: int, buf: &mut ~str) {
let radix = 10;
let prec = get_int_precision(cv);
let mut s : ~str = uint_to_str_prec(int::abs(i) as uint, radix, prec);
let s : ~str = uint_to_str_prec(int::abs(i) as uint, radix, prec);
let head = if i >= 0 {
if have_flag(cv.flags, flag_sign_always) {
@@ -516,7 +516,7 @@ pub fn conv_int(cv: Conv, i: int, buf: &mut ~str) {
}
pub fn conv_uint(cv: Conv, u: uint, buf: &mut ~str) {
let prec = get_int_precision(cv);
let mut rs =
let rs =
match cv.ty {
TyDefault => uint_to_str_prec(u, 10, prec),
TyHexLower => uint_to_str_prec(u, 16, prec),
@@ -559,7 +559,7 @@ pub fn conv_float(cv: Conv, f: float, buf: &mut ~str) {
CountIs(c) => (float::to_str_exact, c as uint),
CountImplied => (float::to_str_digits, 6u)
};
let mut s = to_str(f, digits);
let s = to_str(f, digits);
let head = if 0.0 <= f {
if have_flag(cv.flags, flag_sign_always) {
Some('+')
+3 -6
View File
@@ -1826,12 +1826,9 @@ impl<'self,T:Copy> CopyableVector<T> for &'self [T] {
#[inline]
fn to_owned(&self) -> ~[T] {
let mut result = ~[];
// FIXME: #4568
unsafe {
reserve(&mut result, self.len());
for self.each |e| {
result.push(copy *e);
}
reserve(&mut result, self.len());
for self.each |e| {
result.push(copy *e);
}
result
+5 -6
View File
@@ -28,7 +28,6 @@
use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor};
use syntax::visit::visit_crate;
use core::cast::transmute;
use core::hashmap::HashMap;
pub enum LangItem {
@@ -370,7 +369,7 @@ fn match_and_collect_item(&mut self,
}
fn collect_local_language_items(&mut self) {
let this = ptr::addr_of(&self);
let this: *mut LanguageItemCollector = &mut *self;
visit_crate(self.crate, (), mk_simple_visitor(@SimpleVisitor {
visit_item: |item| {
for item.attrs.each |attribute| {
@@ -380,10 +379,10 @@ fn collect_local_language_items(&mut self) {
attribute.node.value
);
}
},
.. *default_simple_visitor()
}));
}
}
},
.. *default_simple_visitor()
}));
}
fn collect_external_language_items(&mut self) {
+1 -1
View File
@@ -299,7 +299,7 @@ pub fn compute_moves(tcx: ty::ctxt,
pub fn moved_variable_node_id_from_def(def: def) -> Option<node_id> {
match def {
def_binding(nid, _) |
def_arg(nid, _, _) |
def_arg(nid, _) |
def_local(nid, _) |
def_self(nid, _) => Some(nid),
+2 -1
View File
@@ -13,7 +13,8 @@
use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid};
use middle::ty::{br_fresh, ctxt, field, method};
use middle::ty::{mt, t, param_bound, param_ty};
use middle::ty::{re_bound, re_free, re_scope, re_infer, re_static, Region};
use middle::ty::{re_bound, re_free, re_scope, re_infer, re_static, Region,
re_empty};
use middle::ty::{ty_bool, ty_bot, ty_box, ty_struct, ty_enum};
use middle::ty::{ty_err, ty_estr, ty_evec, ty_float, ty_bare_fn, ty_closure};
use middle::ty::{ty_nil, ty_opaque_box, ty_opaque_closure_ptr, ty_param};
+1 -1
View File
@@ -617,7 +617,7 @@ fn wr_str(&self, s: &str) {
priv impl Encoder {
// used internally to emit things like the vector length and so on
fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) {
assert!(v <= 0xFFFF_FFFF_u);
assert!(v <= 0xFFFF_FFFF_u); // FIXME(#6130) assert warns on 32-bit
self.wr_tagged_u32(t as uint, v as u32);
}
+1 -1
View File
@@ -23,7 +23,7 @@
use core::cast;
use core::cell::Cell;
use core::comm::{ChanOne, PortOne, oneshot, send_one};
use core::comm::{PortOne, oneshot, send_one};
use core::pipes::recv;
use core::task;
-1
View File
@@ -11,7 +11,6 @@
//! Sorting methods
use core::cmp::{Eq, Ord};
use core::util;
use core::vec::len;
use core::vec;
+1 -1
View File
@@ -17,7 +17,7 @@
use core::cell::Cell;
use core::cmp;
use core::comm::{ChanOne, PortOne, oneshot, send_one};
use core::comm::{PortOne, oneshot, send_one};
use core::either::{Either, Left, Right};
use core::hashmap::HashMap;
use core::io;
+1 -1
View File
@@ -24,7 +24,7 @@
use core::io;
use core::option::{None, Option, Some};
use core::path::Path;
use core::result::{Err, Ok, Result};
use core::result::{Err, Ok};
pub mod lexer;
pub mod parser;
+1 -2
View File
@@ -938,7 +938,7 @@ fn parse_path_non_global(&self) -> (~[ast::ident],span) {
match *self.token {
token::MOD_SEP => {
match self.look_ahead(1u) {
token::IDENT(id,_) => {
token::IDENT(*) => {
self.bump();
ids.push(self.parse_ident());
}
@@ -3728,7 +3728,6 @@ fn parse_foreign_mod_items(&self, sort: ast::foreign_mod_sort,
items: _,
foreign_items: foreign_items
} = self.parse_foreign_items(first_item_attrs, true);
let mut initial_attrs = attrs_remaining;
assert!(*self.token == token::RBRACE);
ast::foreign_mod {
sort: sort,
+1 -2
View File
@@ -1,7 +1,6 @@
// error-pattern:illegal borrow: borrowed value does not live long enough
fn main() {
let v = ~"test";
let sslice = str::slice(v, 0, v.len());
//~^ ERROR borrowed value does not live long enough
fail!(sslice);
}