Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust toolchain update #3396

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions diesel/src/connection/statement_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<'a, T> Deref for MaybeCached<'a, T> {
fn deref(&self) -> &Self::Target {
match *self {
MaybeCached::CannotCache(ref x) => x,
MaybeCached::Cached(ref x) => &**x,
MaybeCached::Cached(ref x) => x,
}
}
}
Expand All @@ -246,7 +246,7 @@ impl<'a, T> DerefMut for MaybeCached<'a, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match *self {
MaybeCached::CannotCache(ref mut x) => x,
MaybeCached::Cached(ref mut x) => &mut **x,
MaybeCached::Cached(ref mut x) => x,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions diesel/src/connection/transaction_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ where
Cow::from(format!("SAVEPOINT diesel_savepoint_{}", transaction_depth))
}
};
conn.batch_execute(&*start_transaction_sql)?;
conn.batch_execute(&start_transaction_sql)?;
Self::get_transaction_state(conn)?
.change_transaction_depth(TransactionDepthChange::IncreaseDepth)?;

Expand Down Expand Up @@ -362,7 +362,7 @@ where
None => return Err(Error::NotInTransaction),
};

match conn.batch_execute(&*rollback_sql) {
match conn.batch_execute(&rollback_sql) {
Ok(()) => {
Self::get_transaction_state(conn)?
.change_transaction_depth(TransactionDepthChange::DecreaseDepth)?;
Expand Down Expand Up @@ -410,7 +410,7 @@ where
transaction_depth.get() - 1
)),
};
match conn.batch_execute(&*commit_sql) {
match conn.batch_execute(&commit_sql) {
Ok(()) => {
Self::get_transaction_state(conn)?
.change_transaction_depth(TransactionDepthChange::DecreaseDepth)?;
Expand Down
28 changes: 7 additions & 21 deletions diesel/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,28 +569,14 @@ pub mod is_aggregate {
}
}

// Note that these docs are similar to but slightly different than the stable
// docs below. Make sure if you change these that you also change the docs
// below.
/// Trait alias to represent an expression that isn't aggregate by default.
///
/// This alias represents a type which is not aggregate if there is no group by
/// clause. More specifically, it represents for types which implement
/// [`ValidGrouping<()>`] where `IsAggregate` is [`is_aggregate::No`] or
/// [`is_aggregate::Yes`].
///
/// While this trait is a useful stand-in for common cases, `T: NonAggregate`
/// cannot always be used when `T: ValidGrouping<(), IsAggregate = No>` or
/// `T: ValidGrouping<(), IsAggregate = Never>` could be. For that reason,
/// unless you need to abstract over both columns and literals, you should
/// prefer to use [`ValidGrouping<()>`] in your bounds instead.
///
/// [`ValidGrouping<()>`]: ValidGrouping
#[cfg(feature = "unstable")]
pub trait NonAggregate = ValidGrouping<()>
where
<Self as ValidGrouping<()>>::IsAggregate:
MixedAggregates<is_aggregate::No, Output = is_aggregate::No>;
// this needs to be a seperate module for the reasons given in
// https://github.com/rust-lang/rust/issues/65860
mod unstable;

#[cfg(feature = "unstable")]
#[doc(inline)]
pub use self::unstable::NonAggregate;

// Note that these docs are similar to but slightly different than the unstable
// docs above. Make sure if you change these that you also change the docs
Expand Down
23 changes: 23 additions & 0 deletions diesel/src/expression/unstable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use crate::expression::{is_aggregate, MixedAggregates, ValidGrouping};

// Note that these docs are similar to but slightly different than the stable
// docs below. Make sure if you change these that you also change the docs
// below.
/// Trait alias to represent an expression that isn't aggregate by default.
///
/// This alias represents a type which is not aggregate if there is no group by
/// clause. More specifically, it represents for types which implement
/// [`ValidGrouping<()>`] where `IsAggregate` is [`is_aggregate::No`] or
/// [`is_aggregate::Yes`].
///
/// While this trait is a useful stand-in for common cases, `T: NonAggregate`
/// cannot always be used when `T: ValidGrouping<(), IsAggregate = No>` or
/// `T: ValidGrouping<(), IsAggregate = Never>` could be. For that reason,
/// unless you need to abstract over both columns and literals, you should
/// prefer to use [`ValidGrouping<()>`] in your bounds instead.
///
/// [`ValidGrouping<()>`]: ValidGrouping
pub trait NonAggregate = ValidGrouping<()>
where
<Self as ValidGrouping<()>>::IsAggregate:
MixedAggregates<is_aggregate::No, Output = is_aggregate::No>;
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl Drop for BindData {
impl BindData {
fn for_input((tpe, data): (MysqlType, Option<Vec<u8>>)) -> Self {
let (tpe, flags) = tpe.into();
let is_null = if data.is_none() { 1 } else { 0 };
let is_null = i8::from(data.is_none());
let mut bytes = data.unwrap_or_default();
let ptr = NonNull::new(bytes.as_mut_ptr());
let len = bytes.len() as libc::c_ulong;
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl ConnectionOptions {

let host = match url.host() {
Some(Host::Ipv6(host)) => Some(CString::new(host.to_string())?),
Some(host) if host.to_string() == "localhost" && unix_socket != None => None,
Some(host) if host.to_string() == "localhost" && unix_socket.is_some() => None,
Some(host) => Some(CString::new(host.to_string())?),
None => None,
};
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl FromSql<Unsigned<BigInt>, Mysql> for u64 {
#[cfg(feature = "mysql_backend")]
impl ToSql<Bool, Mysql> for bool {
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> serialize::Result {
let int_value = if *self { 1 } else { 0 };
let int_value = i32::from(*self);
<i32 as ToSql<Integer, Mysql>>::to_sql(&int_value, &mut out.reborrow())
}
}
Expand Down
13 changes: 7 additions & 6 deletions diesel/src/query_builder/ast_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,24 @@ where
/// done implicitly for references. For structs with lifetimes it must be
/// done explicitly. This method matches the semantics of what Rust would do
/// implicitly if you were passing a mutable reference
#[allow(clippy::explicit_auto_deref)] // clippy is wrong here
pub fn reborrow(&'_ mut self) -> AstPass<'_, 'b, DB> {
let internals = match self.internals {
AstPassInternals::ToSql(ref mut builder, ref mut options) => {
AstPassInternals::ToSql(&mut **builder, &mut **options)
AstPassInternals::ToSql(*builder, options)
}
AstPassInternals::CollectBinds {
ref mut collector,
ref mut metadata_lookup,
} => AstPassInternals::CollectBinds {
collector: &mut **collector,
metadata_lookup: &mut **metadata_lookup,
collector: *collector,
metadata_lookup: *metadata_lookup,
},
AstPassInternals::IsSafeToCachePrepared(ref mut result) => {
AstPassInternals::IsSafeToCachePrepared(&mut **result)
AstPassInternals::IsSafeToCachePrepared(result)
}
AstPassInternals::DebugBinds(ref mut f) => AstPassInternals::DebugBinds(&mut **f),
AstPassInternals::IsNoop(ref mut result) => AstPassInternals::IsNoop(&mut **result),
AstPassInternals::DebugBinds(ref mut f) => AstPassInternals::DebugBinds(f),
AstPassInternals::IsNoop(ref mut result) => AstPassInternals::IsNoop(result),
};
AstPass {
internals,
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, 'b, DB: Backend> Output<'a, 'b, DB> {
/// Returns the backend's mechanism for dynamically looking up type
/// metadata at runtime, if relevant for the given backend.
pub fn metadata_lookup(&mut self) -> &mut DB::MetadataLookup {
*self.metadata_lookup.as_mut().expect("Lookup is there")
self.metadata_lookup.as_mut().expect("Lookup is there")
}

/// Set the inner buffer to a specific value
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ fn drop_database(database_url: &str) -> DatabaseResult<()> {
Backend::Sqlite => {
if Path::new(database_url).exists() {
println!("Dropping database: {}", database_url);
std::fs::remove_file(&database_url)?;
std::fs::remove_file(database_url)?;
}
}
#[cfg(feature = "mysql")]
Expand Down
4 changes: 2 additions & 2 deletions diesel_cli/tests/migration_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ fn migrations_can_be_run_with_no_cargo_toml() {
let db = database(&p.database_url());

let cargo_toml_path = Path::new("Cargo.toml");
p.delete_single_file(&cargo_toml_path);
p.delete_single_file(cargo_toml_path);

p.command("database").arg("setup").run();

Expand Down Expand Up @@ -476,7 +476,7 @@ fn migrations_can_be_run_with_no_down() {
let db = database(&p.database_url());

let cargo_toml_path = Path::new("Cargo.toml");
p.delete_single_file(&cargo_toml_path);
p.delete_single_file(cargo_toml_path);

p.command("database").arg("setup").run();

Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/tests/support/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl TestCommand {
let mut command = Command::new(path_to_diesel_cli());
command.args(&self.args).current_dir(&self.cwd);
for &(ref k, ref v) in self.env_vars.iter() {
command.env(&k, &v);
command.env(k, v);
}
command
}
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/tests/queryable_by_name.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::blacklisted_name)]
#![allow(clippy::disallowed_names)]
use diesel::sql_types::Integer;
use diesel::*;

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.64.0
1.65.0