From b816eda5325daf27162ad1614ddbfc2e609cdfce Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 25 Aug 2023 12:10:58 +0200 Subject: [PATCH] Fix a bunch of new warnings --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 1 + diesel/src/connection/mod.rs | 2 +- diesel/src/connection/statement_cache.rs | 4 ++-- diesel/src/connection/transaction_manager.rs | 4 ++-- diesel/src/lib.rs | 2 +- diesel/src/pg/connection/mod.rs | 4 ++-- diesel/src/query_builder/query_id.rs | 4 ++-- diesel/src/query_dsl/mod.rs | 3 +-- diesel/src/sql_types/mod.rs | 5 ++--- diesel/src/sqlite/connection/sqlite_value.rs | 2 +- 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 051f715a1e2e..ac76217e6eef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -221,11 +221,11 @@ jobs: - name: Test diesel-derives (nightly) if: matrix.rust == 'nightly' shell: bash - run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} diesel/unstable diesel/time time diesel/chrono chrono" + run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} diesel/unstable diesel/time time diesel/chrono chrono ${{ matrix.backend }}" - name: Test diesel-derives shell: bash - run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }}" + run: cargo +${{ matrix.rust }} test --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} ${{ matrix.backend }}" - name: Test diesel-cli shell: bash diff --git a/Cargo.toml b/Cargo.toml index bceec7ee1c6f..875009fd7818 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "diesel", "diesel_cli", diff --git a/diesel/src/connection/mod.rs b/diesel/src/connection/mod.rs index 79eaf28960f0..aa57744e8d39 100644 --- a/diesel/src/connection/mod.rs +++ b/diesel/src/connection/mod.rs @@ -232,7 +232,7 @@ where /// If the transaction fails to commit due to a `SerializationFailure` or a /// `ReadOnlyTransaction` a rollback will be attempted. /// If the rollback fails, the error will be returned in a - /// [`Error::RollbackErrorOnCommit`](crate::result::Error::RollbackErrorOnCommit), + /// [`Error::RollbackErrorOnCommit`], /// from which you will be able to extract both the original commit error and /// the rollback error. /// In addition, the connection will be considered broken diff --git a/diesel/src/connection/statement_cache.rs b/diesel/src/connection/statement_cache.rs index 4487bd6b086a..414e48359555 100644 --- a/diesel/src/connection/statement_cache.rs +++ b/diesel/src/connection/statement_cache.rs @@ -216,8 +216,8 @@ where /// Wraps a possibly cached prepared statement /// -/// Essentially a customized version of [`Cow`](std::borrow::Cow) -/// that does not depend on [`ToOwned`](std::borrow::ToOwned) +/// Essentially a customized version of [`Cow`] +/// that does not depend on [`ToOwned`] #[allow(missing_debug_implementations, unreachable_pub)] #[cfg_attr( doc_cfg, diff --git a/diesel/src/connection/transaction_manager.rs b/diesel/src/connection/transaction_manager.rs index 506ff5ad3b7c..b30646353e1f 100644 --- a/diesel/src/connection/transaction_manager.rs +++ b/diesel/src/connection/transaction_manager.rs @@ -873,7 +873,7 @@ mod test { .collect::>(); results.sort_by_key(|r| r.is_err()); - assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results); + assert!(results[0].is_ok(), "Got {:?} instead", results); // Note that contrary to Postgres, this is not a commit failure assert!( matches!(&results[1], Err(DatabaseError(SerializationFailure, _))), @@ -982,7 +982,7 @@ mod test { .collect::>(); results.sort_by_key(|r| r.is_err()); - assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results); + assert!(results[0].is_ok(), "Got {:?} instead", results); assert!( matches!(&results[1], Err(DatabaseError(SerializationFailure, _))), "Got {:?} instead", diff --git a/diesel/src/lib.rs b/diesel/src/lib.rs index dff8dfbba3cf..55c92ed749ea 100644 --- a/diesel/src/lib.rs +++ b/diesel/src/lib.rs @@ -186,7 +186,7 @@ //! `64-column-tables` feature. Enabling this feature will increase your compile times significantly. //! - `i-implement-a-third-party-backend-and-opt-into-breaking-changes`: This feature opens up some otherwise //! private API, that can be useful to implement a third party [`Backend`](crate::backend::Backend) -//! or write a custom [`Connection`](crate::connection::Connection) implementation. **Do not use this feature for +//! or write a custom [`Connection`] implementation. **Do not use this feature for //! any other usecase**. By enabling this feature you explicitly opt out diesel stability guarantees. We explicitly //! reserve us the right to break API's exported under this feature flag in any upcoming minor version release. //! If you publish a crate depending on this feature flag consider to restrict the supported diesel version to the diff --git a/diesel/src/pg/connection/mod.rs b/diesel/src/pg/connection/mod.rs index 5e0e766f0d34..bcf9b18f1cfe 100644 --- a/diesel/src/pg/connection/mod.rs +++ b/diesel/src/pg/connection/mod.rs @@ -850,7 +850,7 @@ mod tests { results.sort_by_key(|r| r.is_err()); - assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results); + assert!(results[0].is_ok(), "Got {:?} instead", results); assert!( matches!(&results[1], Err(DatabaseError(SerializationFailure, _))), "Got {:?} instead", @@ -966,7 +966,7 @@ mod tests { results.sort_by_key(|r| r.is_err()); - assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results); + assert!(results[0].is_ok(), "Got {:?} instead", results); assert!( matches!(&results[1], Err(DatabaseError(SerializationFailure, _))), "Got {:?} instead", diff --git a/diesel/src/query_builder/query_id.rs b/diesel/src/query_builder/query_id.rs index 064b41d132a6..846dba5f3d35 100644 --- a/diesel/src/query_builder/query_id.rs +++ b/diesel/src/query_builder/query_id.rs @@ -136,9 +136,9 @@ mod tests { } #[test] - #[cfg(features = "postgres")] + #[cfg(feature = "postgres")] fn boxed_queries_do_not_have_static_query_id() { - use pg::Pg; + use crate::pg::Pg; assert!(query_id(users::table.into_boxed::()).is_none()); } } diff --git a/diesel/src/query_dsl/mod.rs b/diesel/src/query_dsl/mod.rs index d8fc1e2772c5..b9701d14824e 100644 --- a/diesel/src/query_dsl/mod.rs +++ b/diesel/src/query_dsl/mod.rs @@ -1268,13 +1268,12 @@ pub trait QueryDsl: Sized { /// # } /// ``` /// - /// Diesel queries also have a similar problem to [`Iterator`][iterator], where + /// Diesel queries also have a similar problem to [`Iterator`], where /// returning them from a function requires exposing the implementation of that /// function. The [`helper_types`][helper_types] module exists to help with this, /// but you might want to hide the return type or have it conditionally change. /// Boxing can achieve both. /// - /// [iterator]: std::iter::Iterator /// [helper_types]: crate::helper_types /// /// ### Example diff --git a/diesel/src/sql_types/mod.rs b/diesel/src/sql_types/mod.rs index d74b4d0fb968..bfe55090fd61 100644 --- a/diesel/src/sql_types/mod.rs +++ b/diesel/src/sql_types/mod.rs @@ -196,14 +196,13 @@ pub type Decimal = Numeric; /// /// ### [`ToSql`](crate::serialize::ToSql) impls /// -/// - [`String`][String] +/// - [`String`] /// - [`&str`][str] /// /// ### [`FromSql`](crate::deserialize::FromSql) impls /// -/// - [`String`][String] +/// - [`String`] /// -/// [String]: std::string::String /// [str]: https://doc.rust-lang.org/nightly/std/primitive.str.html #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)] #[diesel(postgres_type(oid = 25, array_oid = 1009))] diff --git a/diesel/src/sqlite/connection/sqlite_value.rs b/diesel/src/sqlite/connection/sqlite_value.rs index ed2917c98b86..d8e4d5bdfe77 100644 --- a/diesel/src/sqlite/connection/sqlite_value.rs +++ b/diesel/src/sqlite/connection/sqlite_value.rs @@ -64,7 +64,7 @@ impl<'row, 'stmt, 'query> SqliteValue<'row, 'stmt, 'query> { let s = unsafe { let ptr = ffi::sqlite3_value_text(self.value.as_ptr()); let len = ffi::sqlite3_value_bytes(self.value.as_ptr()); - let bytes = slice::from_raw_parts(ptr as *const u8, len as usize); + let bytes = slice::from_raw_parts(ptr, len as usize); // The string is guaranteed to be utf8 according to // https://www.sqlite.org/c3ref/value_blob.html str::from_utf8_unchecked(bytes)