1
Fork 0

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

View file

@ -82,14 +82,13 @@ pub fn load_props(testfile: &Path) -> TestProps {
} }
pub fn is_test_ignored(config: config, testfile: &Path) -> bool { pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
let mut found = false;
for iter_header(testfile) |ln| { for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; } if parse_name_directive(ln, ~"xfail-test") { return true; }
if parse_name_directive(ln, xfail_target()) { return true; } if parse_name_directive(ln, xfail_target()) { return true; }
if config.mode == common::mode_pretty && if config.mode == common::mode_pretty &&
parse_name_directive(ln, ~"xfail-pretty") { return true; } parse_name_directive(ln, ~"xfail-pretty") { return true; }
}; };
return found; return false;
fn xfail_target() -> ~str { fn xfail_target() -> ~str {
~"xfail-" + str::from_slice(os::SYSNAME) ~"xfail-" + str::from_slice(os::SYSNAME)

View file

@ -106,7 +106,7 @@ fn run_rpass_test(config: config, props: TestProps, testfile: &Path) {
fatal_ProcRes(~"test run failed!", ProcRes); fatal_ProcRes(~"test run failed!", ProcRes);
} }
} else { } 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); } if ProcRes.status != 0 { fatal_ProcRes(~"jit failed!", ProcRes); }
} }

View file

@ -42,7 +42,7 @@ pub fn empty_cell<T>() -> Cell<T> {
pub impl<T> Cell<T> { pub impl<T> Cell<T> {
/// Yields the value, failing if the cell is empty. /// Yields the value, failing if the cell is empty.
fn take(&self) -> T { fn take(&self) -> T {
let mut self = unsafe { transmute_mut(self) }; let self = unsafe { transmute_mut(self) };
if self.is_empty() { if self.is_empty() {
fail!(~"attempt to take an empty cell"); fail!(~"attempt to take an empty cell");
} }
@ -54,7 +54,7 @@ pub impl<T> Cell<T> {
/// Returns the value, failing if the cell is full. /// Returns the value, failing if the cell is full.
fn put_back(&self, value: T) { fn put_back(&self, value: T) {
let mut self = unsafe { transmute_mut(self) }; let self = unsafe { transmute_mut(self) };
if !self.is_empty() { if !self.is_empty() {
fail!(~"attempt to put a value back into a full cell"); fail!(~"attempt to put a value back into a full cell");
} }

View file

@ -16,7 +16,6 @@ Simple compression
use libc; use libc;
use libc::{c_void, size_t, c_int}; use libc::{c_void, size_t, c_int};
use ptr;
use vec; use vec;
#[cfg(test)] use rand; #[cfg(test)] use rand;
@ -29,13 +28,13 @@ pub mod rustrt {
pub extern { pub extern {
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void, unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t, src_buf_len: size_t,
pout_len: *size_t, pout_len: *mut size_t,
flags: c_int) flags: c_int)
-> *c_void; -> *c_void;
unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void, unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t, src_buf_len: size_t,
pout_len: *size_t, pout_len: *mut size_t,
flags: c_int) flags: c_int)
-> *c_void; -> *c_void;
} }
@ -53,7 +52,7 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
let res = let res =
rustrt::tdefl_compress_mem_to_heap(b as *c_void, rustrt::tdefl_compress_mem_to_heap(b as *c_void,
len as size_t, len as size_t,
&outsz, &mut outsz,
lz_norm); lz_norm);
assert!(res as int != 0); assert!(res as int != 0);
let out = vec::raw::from_buf_raw(res as *u8, let out = vec::raw::from_buf_raw(res as *u8,
@ -67,11 +66,11 @@ pub fn deflate_bytes(bytes: &const [u8]) -> ~[u8] {
pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] { pub fn inflate_bytes(bytes: &const [u8]) -> ~[u8] {
do vec::as_const_buf(bytes) |b, len| { do vec::as_const_buf(bytes) |b, len| {
unsafe { unsafe {
let outsz : size_t = 0; let mut outsz : size_t = 0;
let res = let res =
rustrt::tinfl_decompress_mem_to_heap(b as *c_void, rustrt::tinfl_decompress_mem_to_heap(b as *c_void,
len as size_t, len as size_t,
&outsz, &mut outsz,
0); 0);
assert!(res as int != 0); assert!(res as int != 0);
let out = vec::raw::from_buf_raw(res as *u8, let out = vec::raw::from_buf_raw(res as *u8,

View file

@ -253,8 +253,7 @@ pub mod types {
pub type ssize_t = i32; pub type ssize_t = i32;
} }
pub mod posix01 { pub mod posix01 {
use libc::types::os::arch::c95::{c_int, c_short, c_long, use libc::types::os::arch::c95::{c_short, c_long, time_t};
time_t};
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_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::{mode_t, off_t};
use libc::types::os::arch::posix88::{uid_t}; use libc::types::os::arch::posix88::{uid_t};

View file

@ -351,7 +351,7 @@ 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)] #[cfg(unix)]
pub fn pipe() -> Pipe { pub fn pipe() -> Pipe {
@ -373,8 +373,7 @@ pub fn pipe() -> Pipe {
// fully understand. Here we explicitly make the pipe non-inheritable, // fully understand. Here we explicitly make the pipe non-inheritable,
// which means to pass it to a subprocess they need to be duplicated // which means to pass it to a subprocess they need to be duplicated
// first, as in rust_run_program. // first, as in rust_run_program.
let mut fds = Pipe {in: 0 as c_int, let mut fds = Pipe {in: 0 as c_int, out: 0 as c_int};
out: 0 as c_int };
let res = libc::pipe(&mut fds.in, 1024 as ::libc::c_uint, let res = libc::pipe(&mut fds.in, 1024 as ::libc::c_uint,
(libc::O_BINARY | libc::O_NOINHERIT) as c_int); (libc::O_BINARY | libc::O_NOINHERIT) as c_int);
assert!((res == 0 as c_int)); assert!((res == 0 as c_int));
@ -959,10 +958,10 @@ pub fn last_os_error() -> ~str {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
#[cfg(target_os = "freebsd")] #[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] #[nolink]
extern { 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; buflen: size_t) -> c_int;
} }
unsafe { unsafe {
@ -974,10 +973,10 @@ pub fn last_os_error() -> ~str {
// and requires macros to instead use the POSIX compliant variant. // and requires macros to instead use the POSIX compliant variant.
// So we just use __xpg_strerror_r which is always POSIX compliant // So we just use __xpg_strerror_r which is always POSIX compliant
#[cfg(target_os = "linux")] #[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] #[nolink]
extern { 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; buflen: size_t) -> c_int;
} }
unsafe { unsafe {
@ -987,7 +986,7 @@ pub fn last_os_error() -> ~str {
let mut buf = [0 as c_char, ..TMPBUF_SZ]; let mut buf = [0 as c_char, ..TMPBUF_SZ];
unsafe { 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); TMPBUF_SZ as size_t);
if err < 0 { if err < 0 {
fail!(~"strerror_r failure"); fail!(~"strerror_r failure");

View file

@ -136,7 +136,6 @@ pub impl Scheduler {
/// Called by a running task to end execution, after which it will /// Called by a running task to end execution, after which it will
/// be recycled by the scheduler for reuse in a new task. /// be recycled by the scheduler for reuse in a new task.
fn terminate_current_task(~self) { fn terminate_current_task(~self) {
let mut self = self;
assert!(self.in_task_context()); assert!(self.in_task_context());
rtdebug!("ending running task"); rtdebug!("ending running task");
@ -152,7 +151,6 @@ pub impl Scheduler {
} }
fn schedule_new_task(~self, task: ~Task) { fn schedule_new_task(~self, task: ~Task) {
let mut self = self;
assert!(self.in_task_context()); assert!(self.in_task_context());
do self.switch_running_tasks_and_then(task) |last_task| { do self.switch_running_tasks_and_then(task) |last_task| {

View file

@ -501,7 +501,7 @@ pub mod rt {
pub fn conv_int(cv: Conv, i: int, buf: &mut ~str) { pub fn conv_int(cv: Conv, i: int, buf: &mut ~str) {
let radix = 10; let radix = 10;
let prec = get_int_precision(cv); 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 { let head = if i >= 0 {
if have_flag(cv.flags, flag_sign_always) { if have_flag(cv.flags, flag_sign_always) {
@ -516,7 +516,7 @@ pub mod rt {
} }
pub fn conv_uint(cv: Conv, u: uint, buf: &mut ~str) { pub fn conv_uint(cv: Conv, u: uint, buf: &mut ~str) {
let prec = get_int_precision(cv); let prec = get_int_precision(cv);
let mut rs = let rs =
match cv.ty { match cv.ty {
TyDefault => uint_to_str_prec(u, 10, prec), TyDefault => uint_to_str_prec(u, 10, prec),
TyHexLower => uint_to_str_prec(u, 16, prec), TyHexLower => uint_to_str_prec(u, 16, prec),
@ -559,7 +559,7 @@ pub mod rt {
CountIs(c) => (float::to_str_exact, c as uint), CountIs(c) => (float::to_str_exact, c as uint),
CountImplied => (float::to_str_digits, 6u) 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 { let head = if 0.0 <= f {
if have_flag(cv.flags, flag_sign_always) { if have_flag(cv.flags, flag_sign_always) {
Some('+') Some('+')

View file

@ -1826,13 +1826,10 @@ impl<'self,T:Copy> CopyableVector<T> for &'self [T] {
#[inline] #[inline]
fn to_owned(&self) -> ~[T] { fn to_owned(&self) -> ~[T] {
let mut result = ~[]; let mut result = ~[];
// FIXME: #4568
unsafe {
reserve(&mut result, self.len()); reserve(&mut result, self.len());
for self.each |e| { for self.each |e| {
result.push(copy *e); result.push(copy *e);
} }
}
result result
} }

View file

@ -28,7 +28,6 @@ use syntax::ast_util::local_def;
use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor}; use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor};
use syntax::visit::visit_crate; use syntax::visit::visit_crate;
use core::cast::transmute;
use core::hashmap::HashMap; use core::hashmap::HashMap;
pub enum LangItem { pub enum LangItem {
@ -370,7 +369,7 @@ pub impl LanguageItemCollector {
} }
fn collect_local_language_items(&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_crate(self.crate, (), mk_simple_visitor(@SimpleVisitor {
visit_item: |item| { visit_item: |item| {
for item.attrs.each |attribute| { for item.attrs.each |attribute| {
@ -380,11 +379,11 @@ pub impl LanguageItemCollector {
attribute.node.value attribute.node.value
); );
} }
}
}, },
.. *default_simple_visitor() .. *default_simple_visitor()
})); }));
} }
}
fn collect_external_language_items(&mut self) { fn collect_external_language_items(&mut self) {
let crate_store = self.session.cstore; let crate_store = self.session.cstore;

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> { pub fn moved_variable_node_id_from_def(def: def) -> Option<node_id> {
match def { match def {
def_binding(nid, _) | def_binding(nid, _) |
def_arg(nid, _, _) | def_arg(nid, _) |
def_local(nid, _) | def_local(nid, _) |
def_self(nid, _) => Some(nid), def_self(nid, _) => Some(nid),

View file

@ -13,7 +13,8 @@ use middle::ty::{ReSkolemized, ReVar};
use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid}; 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::{br_fresh, ctxt, field, method};
use middle::ty::{mt, t, param_bound, param_ty}; 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_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_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}; use middle::ty::{ty_nil, ty_opaque_box, ty_opaque_closure_ptr, ty_param};

View file

@ -617,7 +617,7 @@ pub mod writer {
priv impl Encoder { priv impl Encoder {
// used internally to emit things like the vector length and so on // used internally to emit things like the vector length and so on
fn _emit_tagged_uint(&self, t: EbmlEncoderTag, v: uint) { 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); self.wr_tagged_u32(t as uint, v as u32);
} }

View file

@ -23,7 +23,7 @@
use core::cast; use core::cast;
use core::cell::Cell; 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::pipes::recv;
use core::task; use core::task;

View file

@ -11,7 +11,6 @@
//! Sorting methods //! Sorting methods
use core::cmp::{Eq, Ord}; use core::cmp::{Eq, Ord};
use core::util;
use core::vec::len; use core::vec::len;
use core::vec; use core::vec;

View file

@ -17,7 +17,7 @@ use sort;
use core::cell::Cell; use core::cell::Cell;
use core::cmp; 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::either::{Either, Left, Right};
use core::hashmap::HashMap; use core::hashmap::HashMap;
use core::io; use core::io;

View file

@ -24,7 +24,7 @@ use parse::token::{ident_interner, mk_ident_interner};
use core::io; use core::io;
use core::option::{None, Option, Some}; use core::option::{None, Option, Some};
use core::path::Path; use core::path::Path;
use core::result::{Err, Ok, Result}; use core::result::{Err, Ok};
pub mod lexer; pub mod lexer;
pub mod parser; pub mod parser;

View file

@ -938,7 +938,7 @@ pub impl Parser {
match *self.token { match *self.token {
token::MOD_SEP => { token::MOD_SEP => {
match self.look_ahead(1u) { match self.look_ahead(1u) {
token::IDENT(id,_) => { token::IDENT(*) => {
self.bump(); self.bump();
ids.push(self.parse_ident()); ids.push(self.parse_ident());
} }
@ -3728,7 +3728,6 @@ pub impl Parser {
items: _, items: _,
foreign_items: foreign_items foreign_items: foreign_items
} = self.parse_foreign_items(first_item_attrs, true); } = self.parse_foreign_items(first_item_attrs, true);
let mut initial_attrs = attrs_remaining;
assert!(*self.token == token::RBRACE); assert!(*self.token == token::RBRACE);
ast::foreign_mod { ast::foreign_mod {
sort: sort, sort: sort,

View file

@ -1,7 +1,6 @@
// error-pattern:illegal borrow: borrowed value does not live long enough
fn main() { fn main() {
let v = ~"test"; let v = ~"test";
let sslice = str::slice(v, 0, v.len()); let sslice = str::slice(v, 0, v.len());
//~^ ERROR borrowed value does not live long enough
fail!(sslice); fail!(sslice);
} }