Merge pull request #181 from gwenn/clippy

Fix clippy warnings
This commit is contained in:
John Gallagher 2016-12-31 01:23:40 -05:00 committed by GitHub
commit 4c8b0ab6dd
8 changed files with 17 additions and 19 deletions

View File

@ -42,7 +42,7 @@ fn main() {
&[&me.name, &me.time_created, &me.data]).unwrap();
let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
let mut person_iter = stmt.query_map(&[], |row| {
let person_iter = stmt.query_map(&[], |row| {
Person {
id: row.get(0),
name: row.get(1),

View File

@ -18,7 +18,7 @@
//! # use std::path::Path;
//! # use std::time;
//!
//! fn backupDb<P: AsRef<Path>>(src: &Connection, dst: P, progress: fn(backup::Progress))
//! fn backup_db<P: AsRef<Path>>(src: &Connection, dst: P, progress: fn(backup::Progress))
//! -> Result<()> {
//! let mut dst = try!(Connection::open(dst));
//! let backup = try!(backup::Backup::new(src, &mut dst));

View File

@ -12,6 +12,7 @@ pub type SqliteError = Error;
/// Enum listing possible errors from rusqlite.
#[derive(Debug)]
#[allow(enum_variant_names)]
pub enum Error {
/// An error from an underlying SQLite call.
SqliteFailure(ffi::Error, Option<String>),
@ -152,7 +153,6 @@ impl error::Error for Error {
}
}
#[cfg_attr(feature="clippy", allow(match_same_arms))]
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::SqliteFailure(ref err, _) => Some(err),

View File

@ -274,10 +274,9 @@ impl Connection {
///
/// ```rust
/// # use rusqlite::{Connection, Result};
/// # type c_double = f64;
/// fn scalar_function_example(db: Connection) -> Result<()> {
/// try!(db.create_scalar_function("halve", 1, true, |ctx| {
/// let value = try!(ctx.get::<c_double>(0));
/// let value = try!(ctx.get::<f64>(0));
/// Ok(value / 2f64)
/// }));
///

View File

@ -36,7 +36,7 @@
//! &[&me.name, &me.time_created, &me.data]).unwrap();
//!
//! let mut stmt = conn.prepare("SELECT id, name, time_created, data FROM person").unwrap();
//! let mut person_iter = stmt.query_map(&[], |row| {
//! let person_iter = stmt.query_map(&[], |row| {
//! Person {
//! id: row.get(0),
//! name: row.get(1),
@ -50,6 +50,7 @@
//! }
//! }
//! ```
#![allow(unknown_lints)]
extern crate libc;
extern crate libsqlite3_sys as ffi;
@ -1019,6 +1020,7 @@ pub struct Rows<'stmt> {
stmt: Option<&'stmt Statement<'stmt>>,
}
#[allow(should_implement_trait)]
impl<'stmt> Rows<'stmt> {
fn new(stmt: &'stmt Statement<'stmt>) -> Rows<'stmt> {
Rows { stmt: Some(stmt) }

View File

@ -94,7 +94,7 @@ impl<'conn> Statement<'conn> {
/// ## Example
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result, Rows};
/// # use rusqlite::{Connection, Result};
/// fn query(conn: &Connection) -> Result<()> {
/// let mut stmt = try!(conn.prepare("SELECT * FROM test where name = :name"));
/// let mut rows = try!(stmt.query_named(&[(":name", &"one")]));

View File

@ -44,8 +44,8 @@ pub type SqliteTransaction<'conn> = Transaction<'conn>;
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result};
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
/// let tx = try!(conn.transaction());
///
@ -73,8 +73,8 @@ pub struct Transaction<'conn> {
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result};
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
/// let sp = try!(conn.savepoint());
///
@ -120,7 +120,7 @@ impl<'conn> Transaction<'conn> {
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result};
/// # fn perform_queries_part_1_succeeds(conn: &Connection) -> bool { true }
/// # fn perform_queries_part_1_succeeds(_conn: &Connection) -> bool { true }
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
/// let mut tx = try!(conn.transaction());
///
@ -328,8 +328,8 @@ impl Connection {
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result};
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
/// let tx = try!(conn.transaction());
///
@ -369,8 +369,8 @@ impl Connection {
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result};
/// # fn do_queries_part_1(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_1(_conn: &Connection) -> Result<()> { Ok(()) }
/// # fn do_queries_part_2(_conn: &Connection) -> Result<()> { Ok(()) }
/// fn perform_queries(conn: &mut Connection) -> Result<()> {
/// let sp = try!(conn.savepoint());
///
@ -401,7 +401,6 @@ impl Connection {
}
#[cfg(test)]
#[cfg_attr(feature="clippy", allow(similar_names))]
mod test {
use Connection;
use super::DropBehavior;

View File

@ -108,7 +108,6 @@ impl fmt::Display for Type {
}
#[cfg(test)]
#[cfg_attr(feature="clippy", allow(similar_names))]
mod test {
extern crate time;
@ -209,7 +208,6 @@ mod test {
}
#[test]
#[cfg_attr(feature="clippy", allow(cyclomatic_complexity))]
fn test_mismatched_types() {
fn is_invalid_column_type(err: Error) -> bool {
match err {