diff --git a/.travis.yml b/.travis.yml index 4d789ea93337..4df7fe0105ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,11 +43,11 @@ matrix: allow_failures: - rust: nightly include: - - rust: nightly-2018-11-27 + - rust: nightly-2019-02-26 name: "Compile tests" script: - (cd diesel_compile_tests && cargo +$TRAVIS_RUST_VERSION test) - - rust: 1.31.1 + - rust: 1.34.0 name: "Rustfmt && Clippy" script: - rustup component add rustfmt clippy @@ -59,8 +59,8 @@ matrix: - SQLITE_DATABASE_URL=/tmp/test.db script: - (cd diesel_cli && cargo +$TRAVIS_RUST_VERSION test --no-default-features --features "sqlite-bundled") - - rust: 1.31.1 - name: "Minimal supported rust version == 1.31.1" + - rust: 1.34.0 + name: "Minimal supported rust version == 1.34.0" script: - cargo +$TRAVIS_RUST_VERSION check --all diff --git a/CHANGELOG.md b/CHANGELOG.md index 5500efd26629..447fb11f0f8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/ `&DB::RawValue` or `&::RawValue>`) should use [`backend::RawValue`][raw-value-2-0-0] instead. Implementors of `Backend` should check the relevant section of [the migration guide][2-0-migration]. +* The minimal officially supported rustc version is now 1.34.0 [backend-2-0-0]: http://docs.diesel.rs/diesel/backend/trait.Backend.html [raw-value-2-0-0]: http://docs.diesel.rs/diesel/backend/type.RawValue.html diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f0580654d395..5cc8d21449d6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -178,7 +178,7 @@ jobs: - template: _build/install-rust.yml parameters: platform: Linux - rust_version: nightly-2018-11-27 + rust_version: nightly-2019-02-26 - bash: | sudo apt-get update && sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev @@ -195,7 +195,7 @@ jobs: - template: _build/install-rust.yml parameters: platform: Linux - rust_version: 1.31.1 + rust_version: 1.34.0 - bash: | sudo apt-get update && sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev @@ -239,11 +239,11 @@ jobs: - template: _build/install-rust.yml parameters: platform: Linux - rust_version: 1.31.1 + rust_version: 1.34.0 - bash: | sudo apt-get update && sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev displayName: Install build dependencies - bash: | cargo check --all - displayName: Check building with rust 1.31.1 + displayName: Check building with rust 1.34.0 diff --git a/diesel/src/connection/statement_cache.rs b/diesel/src/connection/statement_cache.rs index 6c6a9472161c..75cff91b158c 100644 --- a/diesel/src/connection/statement_cache.rs +++ b/diesel/src/connection/statement_cache.rs @@ -108,7 +108,7 @@ pub struct StatementCache { pub cache: RefCell, Statement>>, } -#[allow(clippy::len_without_is_empty, clippy::new_without_default_derive)] +#[allow(clippy::len_without_is_empty, clippy::new_without_default)] impl StatementCache where DB: Backend, diff --git a/diesel/src/lib.rs b/diesel/src/lib.rs index b2b4135882e5..fd98d592aa70 100644 --- a/diesel/src/lib.rs +++ b/diesel/src/lib.rs @@ -93,7 +93,7 @@ //! You can come ask for help at //! [gitter.im/diesel-rs/diesel](https://gitter.im/diesel-rs/diesel) -#![cfg_attr(feature = "unstable", feature(specialization, try_from))] +#![cfg_attr(feature = "unstable", feature(specialization))] // Built-in Lints #![deny( warnings, diff --git a/diesel/src/mysql/connection/url.rs b/diesel/src/mysql/connection/url.rs index 2eae2a6ac076..41fc54499422 100644 --- a/diesel/src/mysql/connection/url.rs +++ b/diesel/src/mysql/connection/url.rs @@ -25,7 +25,7 @@ impl ConnectionOptions { return Err(connection_url_error()); } - if url.path_segments().map(|x| x.count()).unwrap_or(0) > 1 { + if url.path_segments().map(Iterator::count).unwrap_or(0) > 1 { return Err(connection_url_error()); } diff --git a/diesel/src/mysql/types/numeric.rs b/diesel/src/mysql/types/numeric.rs index dd7d7d7be43a..ed8208ca9258 100644 --- a/diesel/src/mysql/types/numeric.rs +++ b/diesel/src/mysql/types/numeric.rs @@ -15,7 +15,7 @@ pub mod bigdecimal { fn to_sql(&self, out: &mut Output) -> serialize::Result { write!(out, "{}", *self) .map(|_| IsNull::No) - .map_err(|e| e.into()) + .map_err(Into::into) } } diff --git a/diesel/src/pg/connection/cursor.rs b/diesel/src/pg/connection/cursor.rs index 0e951beda814..be7b354e9481 100644 --- a/diesel/src/pg/connection/cursor.rs +++ b/diesel/src/pg/connection/cursor.rs @@ -59,8 +59,6 @@ impl NamedCursor { where T: QueryableByName, { - use result::Error::DeserializationError; - (0..self.db_result.num_rows()) .map(|i| { let row = PgNamedRow::new(&self, i); diff --git a/diesel/src/pg/types/integers.rs b/diesel/src/pg/types/integers.rs index 6414443cd5a7..b93c92b7a5a6 100644 --- a/diesel/src/pg/types/integers.rs +++ b/diesel/src/pg/types/integers.rs @@ -9,7 +9,7 @@ use sql_types; impl FromSql for u32 { fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result { let mut bytes = not_none!(bytes); - bytes.read_u32::().map_err(|e| e.into()) + bytes.read_u32::().map_err(Into::into) } } @@ -17,7 +17,7 @@ impl ToSql for u32 { fn to_sql(&self, out: &mut Output) -> serialize::Result { out.write_u32::(*self) .map(|_| IsNull::No) - .map_err(|e| e.into()) + .map_err(Into::into) } } diff --git a/diesel/src/pg/types/numeric.rs b/diesel/src/pg/types/numeric.rs index 3d260e025170..b80a761f20d1 100644 --- a/diesel/src/pg/types/numeric.rs +++ b/diesel/src/pg/types/numeric.rs @@ -17,9 +17,7 @@ mod bigdecimal { use serialize::{self, Output, ToSql}; use sql_types::Numeric; - #[cfg(feature = "unstable")] use std::convert::{TryFrom, TryInto}; - #[cfg(feature = "unstable")] use std::error::Error; /// Iterator over the digits of a big uint in base 10k. @@ -40,44 +38,40 @@ mod bigdecimal { } } - fn pg_decimal_to_bigdecimal(numeric: &PgNumeric) -> deserialize::Result { - let (sign, weight, scale, digits) = match *numeric { - PgNumeric::Positive { - weight, - scale, - ref digits, - } => (Sign::Plus, weight, scale, digits), - PgNumeric::Negative { - weight, - scale, - ref digits, - } => (Sign::Minus, weight, scale, digits), - PgNumeric::NaN => return Err(Box::from("NaN is not (yet) supported in BigDecimal")), - }; - - let mut result = BigUint::default(); - let count = digits.len() as i64; - for digit in digits { - result *= BigUint::from(10_000u64); - result += BigUint::from(*digit as u64); - } - // First digit got factor 10_000^(digits.len() - 1), but should get 10_000^weight - let correction_exp = 4 * (i64::from(weight) - count + 1); - let result = BigDecimal::new(BigInt::from_biguint(sign, result), -correction_exp) - .with_scale(i64::from(scale)); - Ok(result) - } - - #[cfg(feature = "unstable")] impl<'a> TryFrom<&'a PgNumeric> for BigDecimal { type Error = Box; fn try_from(numeric: &'a PgNumeric) -> deserialize::Result { - pg_decimal_to_bigdecimal(numeric) + let (sign, weight, scale, digits) = match *numeric { + PgNumeric::Positive { + weight, + scale, + ref digits, + } => (Sign::Plus, weight, scale, digits), + PgNumeric::Negative { + weight, + scale, + ref digits, + } => (Sign::Minus, weight, scale, digits), + PgNumeric::NaN => { + return Err(Box::from("NaN is not (yet) supported in BigDecimal")) + } + }; + + let mut result = BigUint::default(); + let count = digits.len() as i64; + for digit in digits { + result *= BigUint::from(10_000u64); + result += BigUint::from(*digit as u64); + } + // First digit got factor 10_000^(digits.len() - 1), but should get 10_000^weight + let correction_exp = 4 * (i64::from(weight) - count + 1); + let result = BigDecimal::new(BigInt::from_biguint(sign, result), -correction_exp) + .with_scale(i64::from(scale)); + Ok(result) } } - #[cfg(feature = "unstable")] impl TryFrom for BigDecimal { type Error = Box; @@ -88,7 +82,11 @@ mod bigdecimal { impl<'a> From<&'a BigDecimal> for PgNumeric { // NOTE(clippy): No `std::ops::MulAssign` impl for `BigInt` - #[allow(clippy::assign_op_pattern)] + // NOTE(clippy): Clippy suggests to replace the `.take_while(|i| i.is_zero())` + // with `.take_while(Zero::is_zero)`, but that's a false positive. + // The closure gets an `&&i16` due to autoderef `::is_zero(&self) -> bool` + // is called. There is no impl for `&i16` that would work with this closure. + #[allow(clippy::assign_op_pattern, clippy::redundant_closure)] fn from(decimal: &'a BigDecimal) -> Self { let (mut integer, scale) = decimal.as_bigint_and_exponent(); let scale = scale as u16; @@ -156,9 +154,7 @@ mod bigdecimal { impl FromSql for BigDecimal { fn from_sql(numeric: Option<&[u8]>) -> deserialize::Result { - // FIXME: Use the TryFrom impl when try_from is stable - let numeric = PgNumeric::from_sql(numeric)?; - pg_decimal_to_bigdecimal(&numeric) + PgNumeric::from_sql(numeric)?.try_into() } } diff --git a/diesel/src/pg/types/uuid.rs b/diesel/src/pg/types/uuid.rs index cc6fa22ea6d8..0cd25768b185 100644 --- a/diesel/src/pg/types/uuid.rs +++ b/diesel/src/pg/types/uuid.rs @@ -16,7 +16,7 @@ struct UuidProxy(uuid::Uuid); impl FromSql for uuid::Uuid { fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result { let bytes = not_none!(bytes); - uuid::Uuid::from_bytes(bytes).map_err(|e| e.into()) + uuid::Uuid::from_bytes(bytes).map_err(Into::into) } } diff --git a/diesel/src/pg/types/uuid_v0_7.rs b/diesel/src/pg/types/uuid_v0_7.rs index 03ad3ae9a85f..4a1fbdc9c27f 100644 --- a/diesel/src/pg/types/uuid_v0_7.rs +++ b/diesel/src/pg/types/uuid_v0_7.rs @@ -16,7 +16,7 @@ struct UuidProxy(uuid::Uuid); impl FromSql for uuid::Uuid { fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result { let bytes = not_none!(bytes); - uuid::Uuid::from_slice(bytes).map_err(|e| e.into()) + uuid::Uuid::from_slice(bytes).map_err(Into::into) } } diff --git a/diesel/src/query_builder/bind_collector.rs b/diesel/src/query_builder/bind_collector.rs index 0d2d633775ff..da032e00835e 100644 --- a/diesel/src/query_builder/bind_collector.rs +++ b/diesel/src/query_builder/bind_collector.rs @@ -42,7 +42,7 @@ pub struct RawBytesBindCollector { pub binds: Vec>>, } -#[allow(clippy::new_without_default_derive)] +#[allow(clippy::new_without_default)] impl RawBytesBindCollector { /// Construct an empty `RawBytesBindCollector` pub fn new() -> Self { diff --git a/diesel/src/query_builder/update_statement/changeset.rs b/diesel/src/query_builder/update_statement/changeset.rs index a1621f7fa146..1838f45554eb 100644 --- a/diesel/src/query_builder/update_statement/changeset.rs +++ b/diesel/src/query_builder/update_statement/changeset.rs @@ -36,7 +36,7 @@ impl AsChangeset for Option { type Changeset = Option; fn as_changeset(self) -> Self::Changeset { - self.map(|v| v.as_changeset()) + self.map(AsChangeset::as_changeset) } } diff --git a/diesel/src/query_builder/where_clause.rs b/diesel/src/query_builder/where_clause.rs index 493070fc73b1..f44fca5974b8 100644 --- a/diesel/src/query_builder/where_clause.rs +++ b/diesel/src/query_builder/where_clause.rs @@ -159,7 +159,6 @@ where fn and(self, predicate: Predicate) -> Self::Output { use self::BoxedWhereClause::Where; - use expression::operators::And; match self { Where(where_clause) => Where(Box::new(And::new(where_clause, predicate))), diff --git a/diesel_cli/src/database.rs b/diesel_cli/src/database.rs index 5686db65ae70..02bba790b54f 100644 --- a/diesel_cli/src/database.rs +++ b/diesel_cli/src/database.rs @@ -234,12 +234,9 @@ fn drop_database(database_url: &str) -> DatabaseResult<()> { } #[cfg(feature = "sqlite")] Backend::Sqlite => { - use std::fs; - use std::path::Path; - if Path::new(database_url).exists() { println!("Dropping database: {}", database_url); - fs::remove_file(&database_url)?; + std::fs::remove_file(&database_url)?; } } #[cfg(feature = "mysql")] diff --git a/diesel_cli/src/database_error.rs b/diesel_cli/src/database_error.rs index 90bd8fcbe5ca..6e3f9246a03b 100644 --- a/diesel_cli/src/database_error.rs +++ b/diesel_cli/src/database_error.rs @@ -46,15 +46,15 @@ impl Error for DatabaseError { } IoError(ref error) => error .source() - .map(|e| e.description()) + .map(Error::description) .unwrap_or_else(|| error.description()), QueryError(ref error) => error .source() - .map(|e| e.description()) + .map(Error::description) .unwrap_or_else(|| error.description()), ConnectionError(ref error) => error .source() - .map(|e| e.description()) + .map(Error::description) .unwrap_or_else(|| error.description()), } } diff --git a/diesel_cli/src/infer_schema_internals/foreign_keys.rs b/diesel_cli/src/infer_schema_internals/foreign_keys.rs index 9442cac19e35..e2727709c25e 100644 --- a/diesel_cli/src/infer_schema_internals/foreign_keys.rs +++ b/diesel_cli/src/infer_schema_internals/foreign_keys.rs @@ -15,7 +15,7 @@ pub fn remove_unsafe_foreign_keys_for_codegen( let duplicates = foreign_keys .iter() - .map(|fk| fk.ordered_tables()) + .map(ForeignKeyConstraint::ordered_tables) .filter(|tables| { let dup_count = foreign_keys .iter() diff --git a/diesel_cli/tests/support/project_builder.rs b/diesel_cli/tests/support/project_builder.rs index 34a745f003f7..a494d1377dc5 100644 --- a/diesel_cli/tests/support/project_builder.rs +++ b/diesel_cli/tests/support/project_builder.rs @@ -161,7 +161,6 @@ impl Project { } pub fn create_migration_in_directory(&self, directory: &str, name: &str, up: &str, down: &str) { - use std::io::Write; let migration_path = self.directory.path().join(directory).join(name); fs::create_dir(&migration_path) .expect("Migrations folder must exist to create a migration"); diff --git a/diesel_compile_tests/rust-toolchain b/diesel_compile_tests/rust-toolchain index db2b74720bf0..907057cce5ed 100644 --- a/diesel_compile_tests/rust-toolchain +++ b/diesel_compile_tests/rust-toolchain @@ -1 +1 @@ -nightly-2018-11-27 +nightly-2019-02-26 diff --git a/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_correct_type.rs b/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_correct_type.rs index 39184e5c5440..1eb8505a6b22 100644 --- a/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_correct_type.rs +++ b/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_correct_type.rs @@ -16,5 +16,6 @@ fn main() { //~| ERROR E0277 //~| ERROR E0277 //~| ERROR E0277 + //~| ERROR E0277 select(array((1f64, 3f64))).get_result::>(&connection); } diff --git a/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_same_type.rs b/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_same_type.rs index f531864a3014..e5db544f1684 100644 --- a/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_same_type.rs +++ b/diesel_compile_tests/tests/compile-fail/array_expressions_must_be_same_type.rs @@ -17,6 +17,7 @@ fn main() { //~| ERROR E0277 //~| ERROR E0277 //~| ERROR E0277 + //~| ERROR E0277 select(array((1, 3f64))).get_result::>(&connection).unwrap(); //~^ ERROR E0277 @@ -26,4 +27,5 @@ fn main() { //~| ERROR E0277 //~| ERROR E0277 //~| ERROR E0277 + //~| ERROR E0277 } diff --git a/diesel_compile_tests/tests/compile_tests.rs b/diesel_compile_tests/tests/compile_tests.rs index 04cb95a10bc0..c92d899e45d6 100644 --- a/diesel_compile_tests/tests/compile_tests.rs +++ b/diesel_compile_tests/tests/compile_tests.rs @@ -1,8 +1,8 @@ #![cfg(not(windows))] extern crate compiletest_rs as compiletest; -use std::path::PathBuf; use std::env::var; +use std::path::PathBuf; fn run_mode(mode: &'static str) { let mut config = compiletest::Config::default(); @@ -10,7 +10,7 @@ fn run_mode(mode: &'static str) { let cfg_mode = mode.parse().expect("Invalid mode"); if let Ok(name) = var::<&str>("TESTNAME") { - let s : String = name.to_owned(); + let s: String = name.to_owned(); config.filter = Some(s) } config.mode = cfg_mode; diff --git a/diesel_compile_tests/tests/ui/as_changeset_bad_column_name_syntax.stderr b/diesel_compile_tests/tests/ui/as_changeset_bad_column_name_syntax.stderr index a9d853734fbe..16f2abbc6ff5 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_bad_column_name_syntax.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_bad_column_name_syntax.stderr @@ -4,5 +4,23 @@ error: `column_name` must be in the form `column_name = "value"` 14 | #[column_name] | ^^^^^^^^^^^ -error: aborting due to previous error +error[E0412]: cannot find type `column_name` in module `users` + --> $DIR/as_changeset_bad_column_name_syntax.rs:14:7 + | +14 | #[column_name] + | ^^^^^^^^^^^ not found in `users` + +error[E0425]: cannot find value `column_name` in module `users` + --> $DIR/as_changeset_bad_column_name_syntax.rs:14:7 + | +14 | #[column_name] + | ^^^^^^^^^^^ not found in `users` + +error[E0601]: `main` function not found in crate `as_changeset_bad_column_name_syntax` + | + = note: consider adding a `main` function to `$DIR/as_changeset_bad_column_name_syntax.rs` + +error: aborting due to 4 previous errors +Some errors occurred: E0412, E0425, E0601. +For more information about an error, try `rustc --explain E0412`. diff --git a/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr b/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr index ace74baa0630..1d8b36c3225c 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_bad_primary_key_syntax.stderr @@ -10,5 +10,12 @@ error: Expected `qux` found `qux ( id )` 12 | #[primary_key(id, bar = "baz", qux(id))] | ^^^ -error: aborting due to 2 previous errors +error[E0433]: failed to resolve: use of undeclared type or module `user_forms` + --> $DIR/as_changeset_bad_primary_key_syntax.rs:13:8 + | +13 | struct UserForm { + | ^^^^^^^^ use of undeclared type or module `user_forms` + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0433`. diff --git a/diesel_compile_tests/tests/ui/as_changeset_missing_column_name_tuple_struct.stderr b/diesel_compile_tests/tests/ui/as_changeset_missing_column_name_tuple_struct.stderr index 6aee5bfbd920..7c325a664894 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_missing_column_name_tuple_struct.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_missing_column_name_tuple_struct.stderr @@ -10,5 +10,35 @@ error: All fields of tuple structs must be annotated with `#[column_name]` 14 | struct User(i32, #[column_name = "name"] String, String); | ^^^^^^ -error: aborting due to 2 previous errors +error[E0412]: cannot find type `unknown_column` in module `users` + --> $DIR/as_changeset_missing_column_name_tuple_struct.rs:14:13 + | +14 | struct User(i32, #[column_name = "name"] String, String); + | ^^^ not found in `users` + +error[E0412]: cannot find type `unknown_column` in module `users` + --> $DIR/as_changeset_missing_column_name_tuple_struct.rs:14:50 + | +14 | struct User(i32, #[column_name = "name"] String, String); + | ^^^^^^ not found in `users` + +error[E0425]: cannot find value `unknown_column` in module `users` + --> $DIR/as_changeset_missing_column_name_tuple_struct.rs:14:13 + | +14 | struct User(i32, #[column_name = "name"] String, String); + | ^^^ not found in `users` + +error[E0425]: cannot find value `unknown_column` in module `users` + --> $DIR/as_changeset_missing_column_name_tuple_struct.rs:14:50 + | +14 | struct User(i32, #[column_name = "name"] String, String); + | ^^^^^^ not found in `users` + +error[E0601]: `main` function not found in crate `as_changeset_missing_column_name_tuple_struct` + | + = note: consider adding a `main` function to `$DIR/as_changeset_missing_column_name_tuple_struct.rs` + +error: aborting due to 7 previous errors +Some errors occurred: E0412, E0425, E0601. +For more information about an error, try `rustc --explain E0412`. diff --git a/diesel_compile_tests/tests/ui/as_changeset_on_non_struct.stderr b/diesel_compile_tests/tests/ui/as_changeset_on_non_struct.stderr index 698a3e839eef..41020246372c 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_on_non_struct.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_on_non_struct.stderr @@ -4,5 +4,10 @@ error: This derive can only be used on structs 12 | #[derive(AsChangeset)] | ^^^^^^^^^^^ -error: aborting due to previous error +error[E0601]: `main` function not found in crate `as_changeset_on_non_struct` + | + = note: consider adding a `main` function to `$DIR/as_changeset_on_non_struct.rs` +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0601`. diff --git a/diesel_compile_tests/tests/ui/as_changeset_struct_with_only_primary_key.stderr b/diesel_compile_tests/tests/ui/as_changeset_struct_with_only_primary_key.stderr index b0b88148bac3..bbf69795b7f3 100644 --- a/diesel_compile_tests/tests/ui/as_changeset_struct_with_only_primary_key.stderr +++ b/diesel_compile_tests/tests/ui/as_changeset_struct_with_only_primary_key.stderr @@ -7,5 +7,17 @@ error: Deriving `AsChangeset` on a structure that only contains the primary key = help: If you want to change the primary key of a row, you should do so with `.set(table::id.eq(new_id))`. = note: `#[derive(AsChangeset)]` never changes the primary key of a row. -error: aborting due to previous error +error[E0601]: `main` function not found in crate `as_changeset_struct_with_only_primary_key` + | + = note: consider adding a `main` function to `$DIR/as_changeset_struct_with_only_primary_key.rs` +error[E0277]: the trait bound `(): diesel::query_builder::AsChangeset` is not satisfied + --> $DIR/as_changeset_struct_with_only_primary_key.rs:17:10 + | +17 | #[derive(AsChangeset)] + | ^^^^^^^^^^^ the trait `diesel::query_builder::AsChangeset` is not implemented for `()` + +error: aborting due to 3 previous errors + +Some errors occurred: E0277, E0601. +For more information about an error, try `rustc --explain E0277`. diff --git a/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr b/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr index 4de25629101c..ff0fb00a7cda 100644 --- a/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr +++ b/diesel_compile_tests/tests/ui/belongs_to_invalid_option_syntax.stderr @@ -44,5 +44,12 @@ warning: Unrecognized option random_option 29 | #[belongs_to(Baz, foreign_key = "bar_id", random_option)] | ^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +error[E0433]: failed to resolve: use of undeclared type or module `foos` + --> $DIR/belongs_to_invalid_option_syntax.rs:30:8 + | +30 | struct Foo { + | ^^^ use of undeclared type or module `foos` + +error: aborting due to 6 previous errors +For more information about this error, try `rustc --explain E0433`. diff --git a/diesel_derives/src/meta.rs b/diesel_derives/src/meta.rs index 6d324f797032..891a8627418b 100644 --- a/diesel_derives/src/meta.rs +++ b/diesel_derives/src/meta.rs @@ -49,7 +49,7 @@ impl MetaItem { } pub fn expect_bool_value(&self) -> bool { - match self.str_value().as_ref().map(|s| s.as_str()) { + match self.str_value().as_ref().map(String::as_str) { Ok("true") => true, Ok("false") => false, _ => { @@ -229,7 +229,6 @@ impl MetaItem { } } -#[cfg_attr(rustfmt, rustfmt_skip)] // https://github.com/rust-lang-nursery/rustfmt/issues/2392 pub struct Nested<'a>(syn::punctuated::Iter<'a, syn::NestedMeta>); impl<'a> Iterator for Nested<'a> { diff --git a/diesel_derives/src/queryable.rs b/diesel_derives/src/queryable.rs index debca8564b34..2dd9d49d7faa 100644 --- a/diesel_derives/src/queryable.rs +++ b/diesel_derives/src/queryable.rs @@ -1,6 +1,7 @@ use proc_macro2; use syn; +use field::Field; use model::*; use util::*; @@ -11,7 +12,7 @@ pub fn derive(item: syn::DeriveInput) -> Result, _>>()?; let field_ty = &field_ty; let build_expr = model.fields().iter().enumerate().map(|(i, f)| { diff --git a/diesel_derives/src/sql_type.rs b/diesel_derives/src/sql_type.rs index 158d1a9895f7..bf3ce6bd6b5b 100644 --- a/diesel_derives/src/sql_type.rs +++ b/diesel_derives/src/sql_type.rs @@ -98,7 +98,7 @@ fn pg_tokens(item: &syn::DeriveInput) -> Option { .help("Valid options are `type_name` or `oid` and `array_oid`")) } }) - .and_then(|res| res.map_err(|e| e.emit()).ok()) + .and_then(|res| res.map_err(Diagnostic::emit).ok()) .and_then(|ty| { if cfg!(not(feature = "postgres")) { return None; diff --git a/diesel_migrations/migrations_internals/src/lib.rs b/diesel_migrations/migrations_internals/src/lib.rs index 933e21a8ba83..f5a46df1e049 100644 --- a/diesel_migrations/migrations_internals/src/lib.rs +++ b/diesel_migrations/migrations_internals/src/lib.rs @@ -225,7 +225,7 @@ pub fn revert_migration_with_version( output: &mut Write, ) -> Result<(), RunMigrationsError> { migration_with_version(migrations_dir, ver) - .map_err(|e| e.into()) + .map_err(Into::into) .and_then(|m| revert_migration(conn, &m, output)) } @@ -240,7 +240,7 @@ where Conn: MigrationConnection, { migration_with_version(migrations_dir, ver) - .map_err(|e| e.into()) + .map_err(Into::into) .and_then(|m| run_migration(conn, &*m, output)) } @@ -288,8 +288,6 @@ pub fn migration_paths_in_directory(path: &Path) -> Result, Migrat } fn migrations_in_directory(path: &Path) -> Result>, MigrationError> { - use self::migration::migration_from; - migration_paths_in_directory(path)? .iter() .map(|e| migration_from(e.path())) diff --git a/diesel_migrations/migrations_internals/src/migration.rs b/diesel_migrations/migrations_internals/src/migration.rs index 1bdb73ae1bff..b6ae8b3458d5 100644 --- a/diesel_migrations/migrations_internals/src/migration.rs +++ b/diesel_migrations/migrations_internals/src/migration.rs @@ -19,8 +19,7 @@ impl<'a> fmt::Display for MigrationName<'a> { let file_name = self .migration .file_path() - .and_then(|file_path| file_path.file_name()) - .and_then(|file| file.to_str()); + .and_then(|file_path| file_path.file_name()?.to_str()); if let Some(name) = file_name { f.write_str(name)?; } else { diff --git a/diesel_migrations/migrations_macros/src/embed_migrations.rs b/diesel_migrations/migrations_macros/src/embed_migrations.rs index 4dc2a7f9cfe1..34171174f2c1 100644 --- a/diesel_migrations/migrations_macros/src/embed_migrations.rs +++ b/diesel_migrations/migrations_macros/src/embed_migrations.rs @@ -4,6 +4,7 @@ use syn; use migrations::migration_directory_from_given_path; use migrations_internals::{migration_paths_in_directory, version_from_path}; use std::error::Error; +use std::fs::DirEntry; use std::path::Path; use util::{get_option, get_options_from_input}; @@ -83,7 +84,7 @@ pub fn derive_embed_migrations(input: &syn::DeriveInput) -> proc_macro2::TokenSt fn migration_literals_from_path(path: &Path) -> Result, Box> { let mut migrations = migration_paths_in_directory(path)?; - migrations.sort_by_key(|a| a.path()); + migrations.sort_by_key(DirEntry::path); migrations .into_iter() diff --git a/diesel_migrations/migrations_macros/src/util.rs b/diesel_migrations/migrations_macros/src/util.rs index 4d8330f45a57..b057f511702e 100644 --- a/diesel_migrations/migrations_macros/src/util.rs +++ b/diesel_migrations/migrations_macros/src/util.rs @@ -21,7 +21,7 @@ pub fn get_options_from_input( let options = attrs .iter() .find(|a| &a.path == name) - .map(|a| a.parse_meta()); + .map(Attribute::parse_meta); match options { Some(Ok(Meta::List(MetaList { ref nested, .. }))) => Some( nested diff --git a/rust-toolchain b/rust-toolchain index 6bae540243f6..2b17ffd5042f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.31.1 +1.34.0