auto merge of #6431 : catamorphism/rust/warnings, r=catamorphism

Just cleaning up warnings.
This commit is contained in:
bors 2013-05-11 21:28:37 -07:00
commit 1f62b23411
29 changed files with 58 additions and 144 deletions

View File

@ -12,7 +12,6 @@
#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
#[allow(deprecated_mode)];
#[allow(deprecated_pattern)];
extern mod std(vers = "0.7-pre");

View File

@ -13,7 +13,6 @@ Message passing
*/
use cast::{transmute, transmute_mut};
use cast;
use either::{Either, Left, Right};
use kinds::Owned;
use option::{Option, Some, None};
@ -150,7 +149,7 @@ impl<T: Owned> GenericChan<T> for Chan<T> {
#[inline(always)]
fn send(&self, x: T) {
unsafe {
let mut self_endp = transmute_mut(&self.endp);
let self_endp = transmute_mut(&self.endp);
let endp = replace(self_endp, None);
*self_endp = Some(streamp::client::data(endp.unwrap(), x))
}
@ -161,7 +160,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> {
#[inline(always)]
fn try_send(&self, x: T) -> bool {
unsafe {
let mut self_endp = transmute_mut(&self.endp);
let self_endp = transmute_mut(&self.endp);
let endp = replace(self_endp, None);
match streamp::client::try_data(endp.unwrap(), x) {
Some(next) => {
@ -178,7 +177,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
#[inline(always)]
fn recv(&self) -> T {
unsafe {
let mut self_endp = transmute_mut(&self.endp);
let self_endp = transmute_mut(&self.endp);
let endp = replace(self_endp, None);
let streamp::data(x, endp) = recv(endp.unwrap());
*self_endp = Some(endp);
@ -189,7 +188,7 @@ impl<T: Owned> GenericPort<T> for Port<T> {
#[inline(always)]
fn try_recv(&self) -> Option<T> {
unsafe {
let mut self_endp = transmute_mut(&self.endp);
let self_endp = transmute_mut(&self.endp);
let endp = replace(self_endp, None);
match try_recv(endp.unwrap()) {
Some(streamp::data(x, endp)) => {
@ -206,7 +205,7 @@ impl<T: Owned> Peekable<T> for Port<T> {
#[inline(always)]
fn peek(&self) -> bool {
unsafe {
let mut self_endp = transmute_mut(&self.endp);
let self_endp = transmute_mut(&self.endp);
let mut endp = replace(self_endp, None);
let peek = match endp {
Some(ref mut endp) => peek(endp),
@ -220,12 +219,10 @@ impl<T: Owned> Peekable<T> for Port<T> {
impl<T: Owned> Selectable for Port<T> {
fn header(&mut self) -> *mut PacketHeader {
unsafe {
match self.endp {
Some(ref mut endp) => endp.header(),
None => fail!(~"peeking empty stream")
}
}
}
}
@ -259,7 +256,7 @@ pub impl<T: Owned> PortSet<T> {
impl<T:Owned> GenericPort<T> for PortSet<T> {
fn try_recv(&self) -> Option<T> {
unsafe {
let mut self_ports = transmute_mut(&self.ports);
let self_ports = transmute_mut(&self.ports);
let mut result = None;
// we have to swap the ports array so we aren't borrowing
// aliasable mutable memory.
@ -351,7 +348,7 @@ pub mod oneshot {
pub fn init<T: Owned>() -> (client::Oneshot<T>, server::Oneshot<T>) {
pub use core::pipes::HasBuffer;
let mut buffer = ~::core::pipes::Buffer {
let buffer = ~::core::pipes::Buffer {
header: ::core::pipes::BufferHeader(),
data: __Buffer {
Oneshot: ::core::pipes::mk_packet::<Oneshot<T>>()

View File

@ -11,7 +11,6 @@
/*! Condition handling */
use prelude::*;
use task;
use local_data::{local_data_pop, local_data_set};
// helper for transmutation, shown below.

View File

@ -61,7 +61,6 @@ they contained the following prologue:
#[no_core];
#[deny(non_camel_case_types)];
#[allow(deprecated_mutable_fields)];
// Make core testable by not duplicating lang items. See #2912
#[cfg(test)] extern mod realcore(name = "core", vers = "0.7-pre");

View File

@ -36,7 +36,6 @@ use option::{Some, None};
use prelude::*;
use ptr;
use str;
use task;
use uint;
use unstable::finally::Finally;
use vec;

View File

@ -348,7 +348,7 @@ pub fn send<T,Tbuffer>(mut p: SendPacketBuffered<T,Tbuffer>,
payload: T)
-> bool {
let header = p.header();
let mut p_ = p.unwrap();
let p_ = p.unwrap();
let p = unsafe { &mut *p_ };
assert!(ptr::to_unsafe_ptr(&(p.header)) == header);
assert!(p.payload.is_none());
@ -405,10 +405,8 @@ a message, or `Some(T)` if a message was received.
*/
pub fn try_recv<T:Owned,Tbuffer:Owned>(mut p: RecvPacketBuffered<T, Tbuffer>)
-> Option<T> {
let mut p_ = p.unwrap();
let mut p = unsafe {
&mut *p_
};
let p_ = p.unwrap();
let p = unsafe { &mut *p_ };
do (|| {
try_recv_(p)

View File

@ -43,7 +43,6 @@ fn main () {
use int;
use prelude::*;
use str;
use task;
use u32;
use uint;
use util;

View File

@ -409,7 +409,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
disr_val: int,
n_fields: uint,
name: &str) -> bool {
self.inner.push_ptr(); // NOTE remove after next snapshot
if ! self.inner.visit_enter_enum_variant(variant, disr_val,
n_fields, name) {
return false;
@ -433,7 +432,6 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
n_fields, name) {
return false;
}
self.inner.pop_ptr(); // NOTE remove after next snapshot
true
}

View File

@ -152,8 +152,7 @@ pub impl StreamWatcher {
extern fn close_cb(handle: *uvll::uv_stream_t) {
let mut stream_watcher: StreamWatcher = NativeHandle::from_native_handle(handle);
{
let mut data = get_watcher_data(&mut stream_watcher);
data.close_cb.swap_unwrap()();
get_watcher_data(&mut stream_watcher).close_cb.swap_unwrap()();
}
drop_watcher_data(&mut stream_watcher);
unsafe { free_handle(handle as *c_void) }
@ -214,8 +213,7 @@ pub impl TcpWatcher {
assert!(get_watcher_data(self).connect_cb.is_none());
get_watcher_data(self).connect_cb = Some(cb);
let mut connect_watcher = ConnectRequest::new();
let connect_handle = connect_watcher.native_handle();
let connect_handle = ConnectRequest::new().native_handle();
match address {
Ipv4(*) => {
do ip4_as_uv_ip4(address) |addr| {

View File

@ -46,8 +46,7 @@ impl Drop for UvEventLoop {
let self = unsafe {
transmute::<&UvEventLoop, &mut UvEventLoop>(self)
};
let mut uv_loop = self.uvio.uv_loop();
uv_loop.close();
self.uvio.uv_loop().close();
}
}
@ -189,9 +188,8 @@ impl TcpListener for UvTcpListener {
let maybe_stream = if status.is_none() {
let mut server_stream_watcher = server_stream_watcher;
let mut loop_ = loop_from_watcher(&server_stream_watcher);
let mut client_tcp_watcher = TcpWatcher::new(&mut loop_);
let client_tcp_watcher = client_tcp_watcher.as_stream();
// XXX: Need's to be surfaced in interface
let client_tcp_watcher = TcpWatcher::new(&mut loop_).as_stream();
// XXX: Needs to be surfaced in interface
server_stream_watcher.accept(client_tcp_watcher);
Some(~UvStream::new(client_tcp_watcher))
} else {

View File

@ -472,7 +472,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
/*##################################################################*
* Step 1. Get spawner's taskgroup info.
*##################################################################*/
let mut spawner_group: @@mut TCB =
let spawner_group: @@mut TCB =
match local_get(OldHandle(spawner), taskgroup_key!()) {
None => {
// Main task, doing first spawn ever. Lazily initialise

View File

@ -10,7 +10,6 @@
/*! See doc.rs for a thorough explanation of the borrow checker */
use core;
use core::prelude::*;
use mc = middle::mem_categorization;
@ -22,6 +21,8 @@ use middle::dataflow::DataFlowOperator;
use util::common::stmt_set;
use util::ppaux::{note_and_explain_region, Repr};
#[cfg(stage0)]
use core; // NOTE: this can be removed after the next snapshot
use core::hashmap::{HashSet, HashMap};
use core::io;
use core::result::{Result};

View File

@ -571,8 +571,6 @@ pub impl mem_categorization_ctxt {
}
}
/// The `field_id` parameter is the ID of the enclosing expression or
/// pattern. It is used to determine which variant of an enum is in use.
fn cat_field<N:ast_node>(&self,
node: N,
base_cmt: cmt,

View File

@ -60,7 +60,7 @@ use syntax::ast_util::{def_id_of_def, local_def};
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
use syntax::ast_util::{Privacy, Public, Private};
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
use syntax::attr::{attr_metas, contains_name, attrs_contains_name};
use syntax::attr::{attr_metas, contains_name};
use syntax::parse::token::ident_interner;
use syntax::parse::token::special_idents;
use syntax::print::pprust::path_to_str;

View File

@ -28,7 +28,8 @@ use util::ppaux::Repr;
use util::common::{indenter};
use util::enum_set::{EnumSet, CLike};
use core;
#[cfg(stage0)]
use core; // NOTE: this can be removed after the next snapshot
use core::ptr::to_unsafe_ptr;
use core::to_bytes;
use core::hashmap::{HashMap, HashSet};

View File

@ -544,12 +544,13 @@ use middle::typeck::infer::cres;
use util::common::indenter;
use util::ppaux::note_and_explain_region;
#[cfg(stage0)]
use core; // NOTE: this can be removed after next snapshot
use core::cell::{Cell, empty_cell};
use core::hashmap::{HashMap, HashSet};
use core::to_bytes;
use core::uint;
use core::vec;
use core;
use syntax::codemap::span;
use syntax::ast;

View File

@ -634,13 +634,6 @@ pub mod writer {
use core::vec;
// ebml writing
#[cfg(stage0)]
pub struct Encoder {
writer: @io::Writer,
priv mut size_positions: ~[uint],
}
#[cfg(not(stage0))]
pub struct Encoder {
writer: @io::Writer,
priv size_positions: ~[uint],

View File

@ -94,8 +94,6 @@ total line count).
}
*/
#[allow(deprecated_mutable_fields)];
use core::io::ReaderUtil;
/**
@ -212,8 +210,8 @@ impl FileInput {
pub fn next_file(&self) -> bool {
// No more files
// Compiler whines about "illegal borrow unless pure" for
// files.is_empty()
// unsafe block can be removed after the next snapshot
// (next one after 2013-05-03)
if unsafe { self.fi.files.is_empty() } {
self.fi.current_reader = None;
return false;
@ -337,7 +335,8 @@ impl io::Reader for FileInput {
fn eof(&self) -> bool {
// we've run out of files, and current_reader is either None or eof.
// compiler whines about illegal borrows for files.is_empty()
// unsafe block can be removed after the next snapshot
// (next one after 2013-05-03)
(unsafe { self.fi.files.is_empty() }) &&
match self.fi.current_reader { None => true, Some(r) => r.eof() }
@ -380,8 +379,7 @@ Fails when attempting to read from a file that can't be opened.
*/
#[cfg(stage0)]
pub fn input(f: &fn(&str) -> bool) {
let mut i = FileInput::from_args();
i.each_line(f);
FileInput::from_args().each_line(f);
}
/**
Iterate directly over the command line arguments (no arguments implies
@ -391,7 +389,7 @@ Fails when attempting to read from a file that can't be opened.
*/
#[cfg(not(stage0))]
pub fn input(f: &fn(&str) -> bool) -> bool {
let mut i = FileInput::from_args();
let i = FileInput::from_args();
i.each_line(f)
}
@ -404,8 +402,7 @@ Fails when attempting to read from a file that can't be opened.
*/
#[cfg(stage0)]
pub fn input_state(f: &fn(&str, FileInputState) -> bool) {
let mut i = FileInput::from_args();
i.each_line_state(f);
FileInput::from_args().each_line_state(f);
}
/**
Iterate directly over the command line arguments (no arguments
@ -416,7 +413,7 @@ Fails when attempting to read from a file that can't be opened.
*/
#[cfg(not(stage0))]
pub fn input_state(f: &fn(&str, FileInputState) -> bool) -> bool {
let mut i = FileInput::from_args();
let i = FileInput::from_args();
i.each_line_state(f)
}
@ -427,8 +424,7 @@ Fails when attempting to read from a file that can't be opened.
*/
#[cfg(stage0)]
pub fn input_vec(files: ~[Option<Path>], f: &fn(&str) -> bool) {
let mut i = FileInput::from_vec(files);
i.each_line(f);
FileInput::from_vec(files).each_line(f);
}
/**
Iterate over a vector of files (an empty vector implies just `stdin`).
@ -437,7 +433,7 @@ Fails when attempting to read from a file that can't be opened.
*/
#[cfg(not(stage0))]
pub fn input_vec(files: ~[Option<Path>], f: &fn(&str) -> bool) -> bool {
let mut i = FileInput::from_vec(files);
let i = FileInput::from_vec(files);
i.each_line(f)
}
@ -450,8 +446,7 @@ Fails when attempting to read from a file that can't be opened.
#[cfg(stage0)]
pub fn input_vec_state(files: ~[Option<Path>],
f: &fn(&str, FileInputState) -> bool) {
let mut i = FileInput::from_vec(files);
i.each_line_state(f);
FileInput::from_vec(files).each_line_state(f);
}
/**
Iterate over a vector of files (an empty vector implies just `stdin`)
@ -462,7 +457,7 @@ Fails when attempting to read from a file that can't be opened.
#[cfg(not(stage0))]
pub fn input_vec_state(files: ~[Option<Path>],
f: &fn(&str, FileInputState) -> bool) -> bool {
let mut i = FileInput::from_vec(files);
let i = FileInput::from_vec(files);
i.each_line_state(f)
}

View File

@ -29,17 +29,12 @@ use core::task;
use core::util::replace;
#[doc = "The future type"]
#[cfg(stage0)]
pub struct Future<A> {
priv mut state: FutureState<A>,
}
#[doc = "The future type"]
#[cfg(not(stage0))]
pub struct Future<A> {
priv state: FutureState<A>,
}
// n.b. It should be possible to get rid of this.
// Add a test, though -- tjc
// FIXME(#2829) -- futures should not be copyable, because they close
// over ~fn's that have pipes and so forth within!
#[unsafe_destructor]
@ -62,37 +57,6 @@ pub impl<A:Copy> Future<A> {
}
pub impl<A> Future<A> {
#[cfg(stage0)]
fn get_ref<'a>(&'a self) -> &'a A {
/*!
* Executes the future's closure and then returns a borrowed
* pointer to the result. The borrowed pointer lasts as long as
* the future.
*/
unsafe {
{
match self.state {
Forced(ref mut v) => { return cast::transmute(v); }
Evaluating => fail!(~"Recursive forcing of future!"),
Pending(_) => {}
}
}
{
let state = replace(&mut self.state, Evaluating);
match state {
Forced(_) | Evaluating => fail!(~"Logic error."),
Pending(f) => {
self.state = Forced(f());
cast::transmute(self.get_ref())
}
}
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
fn get_ref<'a>(&'a mut self) -> &'a A {
/*!
* Executes the future's closure and then returns a borrowed

View File

@ -220,13 +220,6 @@ impl serialize::Encoder for Encoder {
}
}
#[cfg(stage0)]
pub struct PrettyEncoder {
priv wr: @io::Writer,
priv mut indent: uint,
}
#[cfg(not(stage0))]
pub struct PrettyEncoder {
priv wr: @io::Writer,
priv indent: uint,
@ -845,12 +838,6 @@ pub fn from_str(s: &str) -> Result<Json, Error> {
}
}
#[cfg(stage0)]
pub struct Decoder {
priv mut stack: ~[Json],
}
#[cfg(not(stage0))]
pub struct Decoder {
priv stack: ~[Json],
}

View File

@ -972,19 +972,17 @@ impl io::Reader for TcpSocketBuf {
/// Implementation of `io::Reader` trait for a buffered `net::tcp::TcpSocket`
impl io::Writer for TcpSocketBuf {
pub fn write(&self, data: &[u8]) {
unsafe {
let socket_data_ptr: *TcpSocketData =
&(*((*(self.data)).sock).socket_data);
let w_result = write_common_impl(socket_data_ptr,
vec::slice(data,
0,
data.len()).to_vec());
if w_result.is_err() {
let err_data = w_result.get_err();
debug!(
"ERROR sock_buf as io::writer.writer err: %? %?",
err_data.err_name, err_data.err_msg);
}
let socket_data_ptr: *TcpSocketData =
&(*((*(self.data)).sock).socket_data);
let w_result = write_common_impl(socket_data_ptr,
vec::slice(data,
0,
data.len()).to_vec());
if w_result.is_err() {
let err_data = w_result.get_err();
debug!(
"ERROR sock_buf as io::writer.writer err: %? %?",
err_data.err_name, err_data.err_msg);
}
}
fn seek(&self, dist: int, seek: io::SeekStyle) {

View File

@ -16,8 +16,6 @@ A BigUint is represented as an array of BigDigits.
A BigInt is a combination of BigUint and Sign.
*/
#[deny(deprecated_mutable_fields)];
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix};

View File

@ -28,9 +28,6 @@ not required in or otherwise suitable for the core library.
#[deny(non_camel_case_types)];
// Allow mutable fields only in stage0.
#[warn(deprecated_mutable_fields)];
pub mod uv_ll;
// General io and system-services modules

View File

@ -410,9 +410,10 @@ type MonitorMsg = (TestDesc, TestResult);
fn run_tests(opts: &TestOpts,
tests: ~[TestDescAndFn],
callback: @fn(e: TestEvent)) {
let mut filtered_tests = filter_tests(opts, tests);
let filtered_tests = filter_tests(opts, tests);
let filtered_descs = filtered_tests.map(|t| copy t.desc);
callback(TeFiltered(filtered_descs));
let (filtered_tests, filtered_benchs) =

View File

@ -16,7 +16,6 @@ use opt_vec::OptVec;
use core::cast;
use core::option::{None, Option, Some};
use core::task;
use core::to_bytes;
use core::to_str::ToStr;
use std::serialize::{Encodable, Decodable, Encoder, Decoder};

View File

@ -27,7 +27,6 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
fld: @ast_fold,
orig: @fn(&expr_, span, @ast_fold) -> (expr_, span))
-> (expr_, span) {
let mut cx = cx;
match *e {
// expr_mac should really be expr_ext or something; it's the
// entry-point for all syntax extensions.
@ -113,7 +112,6 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
fld: @ast_fold,
orig: @fn(&ast::_mod, @ast_fold) -> ast::_mod)
-> ast::_mod {
let mut cx = cx;
// Fold the contents first:
let module_ = orig(module_, fld);

View File

@ -74,7 +74,7 @@ pub fn expand_proto(cx: @ext_ctxt, _sp: span, id: ast::ident,
let rdr = tt_rdr as @reader;
let rust_parser = Parser(sess, cfg, rdr.dup());
let mut proto = rust_parser.parse_proto(cx.str_of(id));
let proto = rust_parser.parse_proto(cx.str_of(id));
// check for errors
visit(proto, cx);

View File

@ -247,8 +247,8 @@ pub fn parse(
let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
/* we append new items to this while we go */
while cur_eis.len() > 0u { /* for each Earley Item */
let mut ei = cur_eis.pop();
while !cur_eis.is_empty() { /* for each Earley Item */
let ei = cur_eis.pop();
let idx = ei.idx;
let len = ei.elts.len();

View File

@ -202,15 +202,14 @@ fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
s: ~str, col: CharPos) {
let mut s1;
let len = str::len(s);
let len = s.len();
// FIXME #3961: Doing bytewise comparison and slicing with CharPos
let col = col.to_uint();
if all_whitespace(s, 0u, uint::min(len, col)) {
let s1 = if all_whitespace(s, 0, uint::min(len, col)) {
if col < len {
s1 = str::slice(s, col, len).to_owned();
} else { s1 = ~""; }
} else { s1 = s; }
str::slice(s, col, len).to_owned()
} else { ~"" }
} else { s };
debug!("pushing line: %s", s1);
lines.push(s1);
}