From 7bcb8fb35886eb61bd7e6f30fd1f28a22635b274 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Thu, 26 Mar 2015 09:18:49 -0700 Subject: [PATCH] Fix most warnings Blocked on rust-lang/rust#23734 on the last --- src/error.rs | 10 +++++----- src/url.rs | 2 +- tests/test.rs | 29 ++++++++++++++--------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/error.rs b/src/error.rs index fc989582..44148570 100644 --- a/src/error.rs +++ b/src/error.rs @@ -65,9 +65,9 @@ impl error::Error for ConnectError { fn cause(&self) -> Option<&error::Error> { match *self { - ConnectError::DbError(ref err) => Some(err as &error::Error), - ConnectError::SslError(ref err) => Some(err as &error::Error), - ConnectError::IoError(ref err) => Some(err as &error::Error), + ConnectError::DbError(ref err) => Some(err), + ConnectError::SslError(ref err) => Some(err), + ConnectError::IoError(ref err) => Some(err), _ => None } } @@ -159,8 +159,8 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { match *self { - Error::DbError(ref err) => Some(err as &error::Error), - Error::IoError(ref err) => Some(err as &error::Error), + Error::DbError(ref err) => Some(err), + Error::IoError(ref err) => Some(err), _ => None } } diff --git a/src/url.rs b/src/url.rs index 51bd2c8e..9526d99e 100644 --- a/src/url.rs +++ b/src/url.rs @@ -120,7 +120,7 @@ fn decode_inner(c: &str, full_url: bool) -> DecodeResult { Some(b) => match b as char { '%' => { let bytes = match (iter.next(), iter.next()) { - (Some(one), Some(two)) => [one as u8, two as u8], + (Some(one), Some(two)) => [one, two], _ => return Err(format!("Malformed input: found '%' \ without two trailing bytes")), }; diff --git a/tests/test.rs b/tests/test.rs index 5d2a8904..fdae55fe 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -17,7 +17,6 @@ use postgres::{HandleNotice, SslMode, Type, Kind, - ToSql, Error, ConnectError, DbError, @@ -761,8 +760,8 @@ fn test_copy_in() { let stmt = or_panic!(conn.prepare_copy_in("foo", &["id", "name"])); let data = (0i32..2).map(|i| { - VecStreamIterator::new(vec![Box::new(i) as Box, - Box::new(format!("{}", i)) as Box]) + VecStreamIterator::new(vec![Box::new(i), + Box::new(format!("{}", i))]) }); assert_eq!(Ok(2), stmt.execute(data)); @@ -779,9 +778,9 @@ fn test_copy_in_bad_column_count() { let stmt = or_panic!(conn.prepare_copy_in("foo", &["id", "name"])); let data = vec![ - VecStreamIterator::new(vec![Box::new(1i32) as Box, - Box::new("Steven".to_string()) as Box]), - VecStreamIterator::new(vec![Box::new(2i32) as Box]), + VecStreamIterator::new(vec![Box::new(1i32), + Box::new("Steven".to_string())]), + VecStreamIterator::new(vec![Box::new(2i32)]), ].into_iter(); let res = stmt.execute(data); @@ -792,11 +791,11 @@ fn test_copy_in_bad_column_count() { } let data = vec![ - VecStreamIterator::new(vec![Box::new(1i32) as Box, - Box::new("Steven".to_string()) as Box]), - VecStreamIterator::new(vec![Box::new(2i32) as Box, - Box::new("Steven".to_string()) as Box, - Box::new(3i64) as Box]), + VecStreamIterator::new(vec![Box::new(1i32), + Box::new("Steven".to_string())]), + VecStreamIterator::new(vec![Box::new(2i32), + Box::new("Steven".to_string()), + Box::new(3i64)]), ].into_iter(); let res = stmt.execute(data); @@ -817,10 +816,10 @@ fn test_copy_in_bad_type() { let stmt = or_panic!(conn.prepare_copy_in("foo", &["id", "name"])); let data = vec![ - VecStreamIterator::new(vec![Box::new(1i32) as Box, - Box::new("Steven".to_string()) as Box]), - VecStreamIterator::new(vec![Box::new(2i32) as Box, - Box::new(1i32) as Box]), + VecStreamIterator::new(vec![Box::new(1i32), + Box::new("Steven".to_string())]), + VecStreamIterator::new(vec![Box::new(2i32), + Box::new(1i32)]), ].into_iter(); let res = stmt.execute(data);