Skip to content

Commit

Permalink
Merge pull request diesel-rs#4130 from Ten0/remove_unused_NoCombinati…
Browse files Browse the repository at this point in the history
…onClause

Fix new Rust unused warnings
  • Loading branch information
weiznich committed Aug 23, 2024
1 parent 5c52a82 commit fcd602f
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 73 deletions.
10 changes: 5 additions & 5 deletions diesel/src/expression/array_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ impl_selectable_expression!(NotIn<T, U>);
/// Diesel provided several implementations here:
///
/// - An implementation for any [`Iterator`] over values
/// that implement [`AsExpression<ST>`] for the corresponding
/// sql type ST. The corresponding values clause will contain
/// bind statements for each individual value.
/// that implement [`AsExpression<ST>`] for the corresponding
/// sql type ST. The corresponding values clause will contain
/// bind statements for each individual value.
/// - An implementation for select statements, that returns
/// a single field. The corresponding values clause will contain
/// the sub query.
/// a single field. The corresponding values clause will contain
/// the sub query.
///
/// This trait is exposed for custom third party backends so
/// that they can restrict the [`QueryFragment`] implementations
Expand Down
78 changes: 39 additions & 39 deletions diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,64 +151,64 @@

//!
//! - `sqlite`: This feature enables the diesel sqlite backend. Enabling this feature requires per default
//! a compatible copy of `libsqlite3` for your target architecture. Alternatively, you can add `libsqlite3-sys`
//! with the `bundled` feature as a dependency to your crate so SQLite will be bundled:
//! ```toml
//! [dependencies]
//! libsqlite3-sys = { version = "0.29", features = ["bundled"] }
//! ```
//! a compatible copy of `libsqlite3` for your target architecture. Alternatively, you can add `libsqlite3-sys`
//! with the `bundled` feature as a dependency to your crate so SQLite will be bundled:
//! ```toml
//! [dependencies]
//! libsqlite3-sys = { version = "0.29", features = ["bundled"] }
//! ```
//! - `postgres`: This feature enables the diesel postgres backend. Enabling this feature requires a compatible
//! copy of `libpq` for your target architecture. This features implies `postgres_backend`
//! copy of `libpq` for your target architecture. This features implies `postgres_backend`
//! - `mysql`: This feature enables the idesel mysql backend. Enabling this feature requires a compatible copy
//! of `libmysqlclient` for your target architecture. This feature implies `mysql_backend`
//! of `libmysqlclient` for your target architecture. This feature implies `mysql_backend`
//! - `postgres_backend`: This feature enables those parts of diesels postgres backend, that are not dependent
//! on `libpq`. Diesel does not provide any connection implementation with only this feature enabled.
//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the
//! postgres backend outside of diesel itself, while reusing the existing query dsl extensions for the
//! postgres backend
//! on `libpq`. Diesel does not provide any connection implementation with only this feature enabled.
//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the
//! postgres backend outside of diesel itself, while reusing the existing query dsl extensions for the
//! postgres backend
//! - `mysql_backend`: This feature enables those parts of diesels mysql backend, that are not dependent
//! on `libmysqlclient`. Diesel does not provide any connection implementation with only this feature enabled.
//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the
//! mysql backend outside of diesel itself, while reusing the existing query dsl extensions for the
//! mysql backend
//! on `libmysqlclient`. Diesel does not provide any connection implementation with only this feature enabled.
//! This feature can be used to implement a custom implementation of diesels `Connection` trait for the
//! mysql backend outside of diesel itself, while reusing the existing query dsl extensions for the
//! mysql backend
//! - `returning_clauses_for_sqlite_3_35`: This feature enables support for `RETURNING` clauses in the sqlite backend.
//! Enabling this feature requires sqlite 3.35.0 or newer.
//! Enabling this feature requires sqlite 3.35.0 or newer.
//! - `32-column-tables`: This feature enables support for tables with up to 32 columns.
//! This feature is enabled by default. Consider disabling this feature if you write a library crate
//! providing general extensions for diesel or if you do not need to support tables with more than 16 columns
//! and you want to minimize your compile times.
//! This feature is enabled by default. Consider disabling this feature if you write a library crate
//! providing general extensions for diesel or if you do not need to support tables with more than 16 columns
//! and you want to minimize your compile times.
//! - `64-column-tables`: This feature enables support for tables with up to 64 columns. It implies the
//! `32-column-tables` feature. Enabling this feature will increase your compile times.
//! `32-column-tables` feature. Enabling this feature will increase your compile times.
//! - `128-column-tables`: This feature enables support for tables with up to 128 columns. It implies the
//! `64-column-tables` feature. Enabling this feature will increase your compile times significantly.
//! `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`] 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
//! currently released minor version.
//! private API, that can be useful to implement a third party [`Backend`](crate::backend::Backend)
//! 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
//! currently released minor version.
//! - `serde_json`: This feature flag enables support for (de)serializing json values from the database using
//! types provided by `serde_json`.
//! types provided by `serde_json`.
//! - `chrono`: This feature flags enables support for (de)serializing date/time values from the database using
//! types provided by `chrono`
//! types provided by `chrono`
//! - `uuid`: This feature flag enables support for (de)serializing uuid values from the database using types
//! provided by `uuid`
//! provided by `uuid`
//! - `network-address`: This feature flag enables support for (de)serializing
//! IP values from the database using types provided by `ipnetwork`.
//! IP values from the database using types provided by `ipnetwork`.
//! - `ipnet-address`: This feature flag enables support for (de)serializing IP
//! values from the database using types provided by `ipnet`.
//! values from the database using types provided by `ipnet`.
//! - `numeric`: This feature flag enables support for (de)serializing numeric values from the database using types
//! provided by `bigdecimal`
//! provided by `bigdecimal`
//! - `r2d2`: This feature flag enables support for the `r2d2` connection pool implementation.
//! - `extras`: This feature enables the feature flagged support for any third party crate. This implies the
//! following feature flags: `serde_json`, `chrono`, `uuid`, `network-address`, `numeric`, `r2d2`
//! following feature flags: `serde_json`, `chrono`, `uuid`, `network-address`, `numeric`, `r2d2`
//! - `with-deprecated`: This feature enables items marked as `#[deprecated]`. It is enabled by default.
//! disabling this feature explicitly opts out diesels stability guarantee.
//! disabling this feature explicitly opts out diesels stability guarantee.
//! - `without-deprecated`: This feature disables any item marked as `#[deprecated]`. Enabling this feature
//! explicitly opts out the stability guarantee given by diesel. This feature overrides the `with-deprecated`.
//! Note that this may also remove items that are not shown as `#[deprecated]` in our documentation, due to
//! various bugs in rustdoc. It can be used to check if you depend on any such hidden `#[deprecated]` item.
//! explicitly opts out the stability guarantee given by diesel. This feature overrides the `with-deprecated`.
//! Note that this may also remove items that are not shown as `#[deprecated]` in our documentation, due to
//! various bugs in rustdoc. It can be used to check if you depend on any such hidden `#[deprecated]` item.
//!
//! By default the following features are enabled:
//!
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/mysql/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::RunQueryDsl;
/// * `ssl_cert` accepts a path to the client's certificate file
/// * `ssl_key` accepts a path to the client's private key file
/// * `ssl_mode` expects a value defined for MySQL client command option `--ssl-mode`
/// See <https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode>
/// See <https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode>
///
/// # Supported loading model implementations
///
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Connection for MysqlConnection {
/// * `ssl_cert` accepts a path to the client's certificate file
/// * `ssl_key` accepts a path to the client's private key file
/// * `ssl_mode` expects a value defined for MySQL client command option `--ssl-mode`
/// See <https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode>
/// See <https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode>
fn establish(database_url: &str) -> ConnectionResult<Self> {
let mut instrumentation = crate::connection::instrumentation::get_default_instrumentation();
instrumentation.on_connection_event(InstrumentationEvent::StartEstablishConnection {
Expand Down
12 changes: 0 additions & 12 deletions diesel/src/query_builder/combination_clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ use crate::query_builder::insert_statement::InsertFromSelect;
use crate::query_builder::{AsQuery, AstPass, Query, QueryFragment, QueryId, SelectQuery};
use crate::{CombineDsl, Insertable, QueryResult, RunQueryDsl, Table};

#[derive(Debug, Clone, Copy, QueryId)]
pub(crate) struct NoCombinationClause;

impl<DB> QueryFragment<DB> for NoCombinationClause
where
DB: Backend + DieselReserveSpecialization,
{
fn walk_ast<'b>(&'b self, _: AstPass<'_, 'b, DB>) -> QueryResult<()> {
Ok(())
}
}

#[derive(Debug, Copy, Clone, QueryId)]
#[must_use = "Queries are only executed when calling `load`, `get_result` or similar."]
/// Combine queries using a combinator like `UNION`, `INTERSECT` or `EXPECT`
Expand Down
3 changes: 3 additions & 0 deletions diesel_cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ impl PrintSchema {
self.import_types.as_deref()
}

// it's a false positive
// https://github.com/rust-lang/rust-clippy/issues/12856
#[allow(clippy::needless_borrows_for_generic_args)]
fn set_relative_path_base(&mut self, base: &Path) {
if let Some(ref mut file) = self.file {
if file.is_relative() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
error[E0599]: no method named `with_format` found for struct `CopyFromQuery<users::table, pg::query_builder::copy::copy_from::InsertableWrapper<Vec<NewUser>>>` in the current scope
--> tests/fail/copy_can_only_use_options_with_raw_variant.rs:49:10
|
47 | diesel::copy_from(users::table)
| -------------------------------
| |
| _____method `with_format` is available on `CopyFromQuery<users::table, pg::query_builder::copy::copy_from::NotSet>`
| |
47 | / diesel::copy_from(users::table)
48 | | .from_insertable(vec![NewUser { name: "John" }])
49 | | .with_format(CopyFormat::Csv)
| | -^^^^^^^^^^^ method not found in `CopyFromQuery<table, InsertableWrapper<Vec<NewUser>>>`
Expand Down
9 changes: 9 additions & 0 deletions diesel_compile_tests/tests/fail/derive/selectable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ error[E0425]: cannot find value `non_existing` in module `users`
|
33 | select_expression = (users::id, users::non_existing),
| ^^^^^^^^^^^^ not found in `users`

error[E0308]: mismatched types
--> tests/fail/derive/selectable.rs:38:29
|
38 | select_expression = (users::id + 45),
| ^^^^^^^^^^^^^^^^ expected `id`, found `Add<id, Bound<Integer, i32>>`
|
= note: expected struct `columns::id`
found struct `diesel::expression::ops::numeric::Add<columns::id, diesel::expression::bound::Bound<diesel::sql_types::Integer, i32>>`
2 changes: 1 addition & 1 deletion diesel_compile_tests/tests/fail/only_only_on_table.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ note: the trait `Table` must be implemented
= note: the following trait defines an item `only`, perhaps you need to implement it:
candidate #1: `diesel::dsl::OnlyDsl`

error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: diesel::pg::Pg '?2
error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: diesel::pg::Pg '?2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: diesel::pg::Pg '?2
error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: diesel::pg::Pg '?2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: diesel::pg::Pg '?2
error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:364:21: relating different kinds: diesel::pg::Pg '?2
6 changes: 3 additions & 3 deletions diesel_derives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ pub fn derive_query_id(input: TokenStream) -> TokenStream {
/// your struct__ matches __all fields in the query__, including the order and
/// count. This means that field order is significant if you're using
/// `#[derive(Queryable)]`. __Field name has no effect__. If you see errors while
/// loading data into a struct that derives `Queryable`: Consider using [`#[derive(Selectable)]`]
/// + `#[diesel(check_for_backend(YourBackendType))]` to check for mismatching fields at
/// compile-time.
/// loading data into a struct that derives `Queryable`: Consider using
/// [`#[derive(Selectable)]`] + `#[diesel(check_for_backend(YourBackendType))]`
/// to check for mismatching fields at compile-time.
///
/// To provide custom deserialization behavior for a field, you can use
/// `#[diesel(deserialize_as = SomeType)]`. If this attribute is present, Diesel
Expand Down
2 changes: 1 addition & 1 deletion examples/mysql/all_about_inserts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct UserForm<'a> {
}

#[derive(Queryable, PartialEq, Debug)]
struct User {
pub struct User {
id: i32,
name: String,
hair_color: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion examples/postgres/all_about_inserts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct UserForm<'a> {
}

#[derive(Queryable, PartialEq, Debug)]
struct User {
pub struct User {
id: i32,
name: String,
hair_color: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion examples/sqlite/all_about_inserts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct UserForm<'a> {
}

#[derive(Queryable, PartialEq, Debug)]
struct User {
pub struct User {
id: i32,
name: String,
hair_color: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.79.0
1.80.0

0 comments on commit fcd602f

Please sign in to comment.