From b49a47abf3bcfb31c54ab26d72312b07f5022484 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 6 Aug 2019 22:14:27 +0200 Subject: [PATCH 1/4] Bump minimal supported rust version 1.36.0 for `mem::MaybeUninit` --- .travis.yml | 6 +++--- CHANGELOG.md | 3 ++- azure-pipelines.yml | 6 +++--- clippy.toml | 2 +- diesel_derives/src/sql_function.rs | 2 +- rust-toolchain | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc76eaac5e87..d2c9e55395d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ matrix: env: RUSTFLAGS="--cap-lints=warn" script: - (cd diesel_compile_tests && cargo +$TRAVIS_RUST_VERSION test) - - rust: 1.34.0 + - rust: 1.36.0 name: "Rustfmt && Clippy" script: - rustup component add rustfmt clippy @@ -60,8 +60,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.34.0 - name: "Minimal supported rust version == 1.34.0" + - rust: 1.36.0 + name: "Minimal supported rust version == 1.36.0" script: - cargo +$TRAVIS_RUST_VERSION check --all diff --git a/CHANGELOG.md b/CHANGELOG.md index 947053642e23..83e9583793dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,6 @@ 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 @@ -38,6 +37,8 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/ `Mysql::TypeMetadata`, you will need to take the new struct `MysqlTypeMetadata` instead. +* The minimal officially supported rustc version is now 1.36.0 + ### Fixed * Many types were incorrectly considered non-aggregate when they should not diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c9be8b763757..ea641b3c99e5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -197,7 +197,7 @@ jobs: - template: _build/install-rust.yml parameters: platform: Linux - rust_version: 1.34.0 + rust_version: 1.36.0 - bash: | sudo apt-get update && sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev @@ -241,11 +241,11 @@ jobs: - template: _build/install-rust.yml parameters: platform: Linux - rust_version: 1.34.0 + rust_version: 1.36.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.34.0 + displayName: Check building with rust 1.36.0 diff --git a/clippy.toml b/clippy.toml index 3684c0a47299..ab165574d129 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,4 +1,4 @@ -cyclomatic-complexity-threshold = 30 +cognitive-complexity-threshold = 30 doc-valid-idents = [ "MiB", "GiB", "TiB", "PiB", "EiB", "DirectX", "OpenGL", "TrueType", diff --git a/diesel_derives/src/sql_function.rs b/diesel_derives/src/sql_function.rs index 3c5a7ecae4fd..50c00eb9d286 100644 --- a/diesel_derives/src/sql_function.rs +++ b/diesel_derives/src/sql_function.rs @@ -7,7 +7,7 @@ use meta::*; use util::*; // Extremely curious why this triggers on a nearly branchless function -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] pub(crate) fn expand(input: SqlFunctionDecl) -> Result { let SqlFunctionDecl { mut attributes, diff --git a/rust-toolchain b/rust-toolchain index 2b17ffd5042f..39fc130ef857 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.34.0 +1.36.0 From 6cc5f0d5e73a9339b465d0a09707345b69ad40fe Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 6 Aug 2019 22:17:11 +0200 Subject: [PATCH 2/4] Replace usage of `mem::uninitialized` with `mem::MaybeUninit` --- diesel/src/mysql/types/date_and_time.rs | 7 +++---- diesel/src/serialize.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/diesel/src/mysql/types/date_and_time.rs b/diesel/src/mysql/types/date_and_time.rs index 143ecf332e8a..58f6fe5ec8d6 100644 --- a/diesel/src/mysql/types/date_and_time.rs +++ b/diesel/src/mysql/types/date_and_time.rs @@ -25,14 +25,13 @@ macro_rules! mysql_time_impls { } impl FromSql<$ty, Mysql> for ffi::MYSQL_TIME { - // ptr::copy_nonoverlapping does not require aligned pointers - #[allow(clippy::cast_ptr_alignment)] fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result { let bytes = not_none!(bytes); let bytes_ptr = bytes.as_ptr() as *const ffi::MYSQL_TIME; unsafe { - let mut result = mem::uninitialized(); - ptr::copy_nonoverlapping(bytes_ptr, &mut result, 1); + let mut result = mem::MaybeUninit::uninit(); + ptr::copy_nonoverlapping(bytes_ptr, result.as_mut_ptr(), 1); + let result = result.assume_init(); if result.neg == 0 { Ok(result) } else { diff --git a/diesel/src/serialize.rs b/diesel/src/serialize.rs index 6b71f79e120d..562b0b872a62 100644 --- a/diesel/src/serialize.rs +++ b/diesel/src/serialize.rs @@ -76,7 +76,7 @@ impl Output<'static, Vec, DB> { /// Unsafe to use for testing types which perform dynamic metadata lookup. pub fn test() -> Self { use std::mem; - #[allow(clippy::invalid_ref)] + #[allow(clippy::invalid_ref, deprecated)] Self::new(Vec::new(), unsafe { mem::uninitialized() }) } } From 65f7a333e15b36b5a8e8fd9e29228204844a03e7 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 6 Aug 2019 22:58:58 +0200 Subject: [PATCH 3/4] Add a comment to the `#[allow(deprecated)]` statement --- diesel/src/serialize.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/diesel/src/serialize.rs b/diesel/src/serialize.rs index 562b0b872a62..52e106baa99b 100644 --- a/diesel/src/serialize.rs +++ b/diesel/src/serialize.rs @@ -76,6 +76,9 @@ impl Output<'static, Vec, DB> { /// Unsafe to use for testing types which perform dynamic metadata lookup. pub fn test() -> Self { use std::mem; + // Allowing `deprecated` here because we are ok with using `mem::uninitialized` + // here. (Yes it's UB, but that won't be fixed by using `mem::MaybeUninit` + // but hey it's only for test code …) #[allow(clippy::invalid_ref, deprecated)] Self::new(Vec::new(), unsafe { mem::uninitialized() }) } From 9e9802d02592b98ccc304f104643eebbf0dfb583 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Wed, 7 Aug 2019 11:42:47 +0200 Subject: [PATCH 4/4] Fix a rustdoc issue with nightly --- diesel/src/expression/functions/date_and_time.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diesel/src/expression/functions/date_and_time.rs b/diesel/src/expression/functions/date_and_time.rs index d7906c977ec0..9c4eaf0d1043 100644 --- a/diesel/src/expression/functions/date_and_time.rs +++ b/diesel/src/expression/functions/date_and_time.rs @@ -35,7 +35,7 @@ sql_function! { /// ```ignore /// # #[macro_use] extern crate diesel; /// # extern crate chrono; - /// # include!(\"../../doctest_setup.rs\"); + /// # include!("../../doctest_setup.rs"); /// # use diesel::dsl::*; /// # /// # fn main() {