diff --git a/build.rs b/build.rs index 5f1e97d..9c85c2e 100644 --- a/build.rs +++ b/build.rs @@ -40,11 +40,9 @@ fn main() { )); // Integer is a dummy placeholder. Compiling fails when passing (). - diesel::expression::sql_literal::sql::<(diesel::sql_types::Integer)>( - "PRAGMA foreign_keys = ON", - ) - .execute(&connection) - .expect("Should be able to enable foreign keys"); + diesel::expression::sql_literal::sql::("PRAGMA foreign_keys = ON") + .execute(&connection) + .expect("Should be able to enable foreign keys"); sqlfunc::markdown_to_fts::register_impl(&connection, |_: String| -> String { unreachable!() }) .unwrap(); diff --git a/src/db.rs b/src/db.rs index e756b9d..f81d2e3 100644 --- a/src/db.rs +++ b/src/db.rs @@ -21,7 +21,7 @@ pub mod sqlfunc { impl CustomizeConnection for SqliteInitializer { fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), r2d2_diesel::Error> { - sql::<(Integer)>("PRAGMA foreign_keys = ON") + sql::("PRAGMA foreign_keys = ON") .execute(conn) .map_err(|x| r2d2_diesel::Error::QueryError(x))?; diff --git a/src/resources/changes_resource.rs b/src/resources/changes_resource.rs index 6da7626..cc7dd94 100644 --- a/src/resources/changes_resource.rs +++ b/src/resources/changes_resource.rs @@ -352,8 +352,6 @@ impl Resource for ChangesResource { let head = self.head(); Box::new(data.join(head).and_then(move |(mut data, head)| { - use std::iter::Iterator; - let extra_element = if data.len() > self.limit as usize { data.pop() } else { diff --git a/src/resources/pagination.rs b/src/resources/pagination.rs index 361e0a2..26235ca 100644 --- a/src/resources/pagination.rs +++ b/src/resources/pagination.rs @@ -8,15 +8,11 @@ pub struct Error; impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "{}", (self as &dyn error::Error).description()) + write!(f, "`after` and `before` are mutually exclusive") } } -impl error::Error for Error { - fn description(&self) -> &str { - "`after` and `before` are mutually exclusive" - } -} +impl error::Error for Error {} #[derive(Deserialize)] struct PaginationStruct { diff --git a/src/state.rs b/src/state.rs index 99f0a44..9608890 100644 --- a/src/state.rs +++ b/src/state.rs @@ -92,8 +92,6 @@ fn decide_slug( &base_slug }; - use crate::schema::article_revisions; - let mut slug = base_slug.to_owned(); let mut disambiguator = 1; @@ -125,8 +123,6 @@ impl<'a> SyncState<'a> { } pub fn get_article_slug(&self, article_id: i32) -> Result, Error> { - use crate::schema::article_revisions; - Ok(article_revisions::table .filter(article_revisions::article_id.eq(article_id)) .filter(article_revisions::latest.eq(true)) @@ -140,8 +136,6 @@ impl<'a> SyncState<'a> { article_id: i32, revision: i32, ) -> Result, Error> { - use crate::schema::article_revisions; - Ok(article_revisions::table .filter(article_revisions::article_id.eq(article_id)) .filter(article_revisions::revision.eq(revision)) @@ -181,8 +175,6 @@ impl<'a> SyncState<'a> { article_id: i32, revision: i32, ) -> Result, Error> { - use crate::schema::article_revisions; - Ok(self .query_article_revision_stubs(move |query| { query @@ -202,8 +194,6 @@ impl<'a> SyncState<'a> { } self.db_connection.transaction(|| { - use crate::schema::article_revisions; - Ok( match article_revisions::table .filter(article_revisions::slug.eq(slug)) @@ -327,8 +317,6 @@ impl<'a> SyncState<'a> { } self.db_connection.transaction(|| { - use crate::schema::article_revisions; - let (latest_revision, prev_title, prev_slug, prev_theme) = article_revisions::table .filter(article_revisions::article_id.eq(article_id)) .order(article_revisions::revision.desc()) @@ -424,9 +412,9 @@ impl<'a> SyncState<'a> { let article_id = { use diesel::expression::sql_literal::sql; // Diesel and SQLite are a bit in disagreement for how this should look: - sql::<(diesel::sql_types::Integer)>("INSERT INTO articles VALUES (null)") + sql::("INSERT INTO articles VALUES (null)") .execute(self.db_connection)?; - sql::<(diesel::sql_types::Integer)>("SELECT LAST_INSERT_ROWID()") + sql::("SELECT LAST_INSERT_ROWID()") .load::(self.db_connection)? .pop() .expect("Statement must evaluate to an integer")