Skip to content

Commit

Permalink
Fix new clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Jan 24, 2022
1 parent cbc7ef3 commit 99ecace
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 23 deletions.
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ doc-valid-idents = [
"JavaScript", "NaN", "OAuth",
"SQLite", "PostgreSQL", "MySQL"
]
avoid-breaking-exported-api = false
1 change: 0 additions & 1 deletion diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
#![warn(
clippy::unwrap_used,
clippy::print_stdout,
clippy::wrong_pub_self_convention,
clippy::mut_mut,
clippy::non_ascii_literal,
clippy::similar_names,
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl CommitErrorProcessor for MysqlConnection {
}
TransactionManagerStatus::Valid(ref v) => v,
};
default_process_commit_error(&state, error)
default_process_commit_error(state, error)
}
}

Expand Down
10 changes: 5 additions & 5 deletions diesel/src/pg/expression/expression_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait PgExpressionMethods: Expression + Sized {
/// assert_eq!(Ok(1), not_distinct.first(connection));
/// # }
/// ```
#[allow(clippy::clippy::wrong_self_convention)] // This is named after the sql operator
#[allow(clippy::wrong_self_convention)] // This is named after the sql operator
fn is_not_distinct_from<T>(self, other: T) -> dsl::IsNotDistinctFrom<Self, T>
where
Self::SqlType: SqlType,
Expand Down Expand Up @@ -55,7 +55,7 @@ pub trait PgExpressionMethods: Expression + Sized {
/// assert_eq!(Ok(1), not_distinct.first(connection));
/// # }
/// ```
#[allow(clippy::clippy::wrong_self_convention)] // This is named after the sql operator
#[allow(clippy::wrong_self_convention)] // This is named after the sql operator
fn is_distinct_from<T>(self, other: T) -> dsl::IsDistinctFrom<Self, T>
where
Self::SqlType: SqlType,
Expand Down Expand Up @@ -292,7 +292,7 @@ pub trait PgArrayExpressionMethods: Expression + Sized {
/// # Ok(())
/// # }
/// ```
#[allow(clippy::clippy::wrong_self_convention)] // This is named after the sql operator
#[allow(clippy::wrong_self_convention)] // This is named after the sql operator
fn is_contained_by<T>(self, other: T) -> dsl::IsContainedBy<Self, T>
where
Self::SqlType: SqlType,
Expand Down Expand Up @@ -870,7 +870,7 @@ pub trait PgNetExpressionMethods: Expression + Sized {
/// # Ok(())
/// # }
/// ```
#[allow(clippy::clippy::wrong_self_convention)] // This is named after the sql operator
#[allow(clippy::wrong_self_convention)] // This is named after the sql operator
fn is_contained_by<T>(self, other: T) -> dsl::IsContainedByNet<Self, T>
where
T: AsExpression<Inet>,
Expand Down Expand Up @@ -928,7 +928,7 @@ pub trait PgNetExpressionMethods: Expression + Sized {
/// # Ok(())
/// # }
/// ```
#[allow(clippy::clippy::wrong_self_convention)] // This is named after the sql operator
#[allow(clippy::wrong_self_convention)] // This is named after the sql operator
fn is_contained_by_or_eq<T>(self, other: T) -> dsl::IsContainedByNetLoose<Self, T>
where
T: AsExpression<Inet>,
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/pg/metadata_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
}
}

let r = lookup_type(&&cache_key, self);
let r = lookup_type(&cache_key, self);

match r {
Ok(type_metadata) => {
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/sqlite/connection/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl SqliteCallbackError {
s = e.to_string();
&s
}
SqliteCallbackError::Panic(_, msg) => &msg,
SqliteCallbackError::Panic(_, msg) => msg,
};
unsafe {
context_error_str(ctx, msg);
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/sqlite/expression/expression_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub trait SqliteExpressionMethods: Expression + Sized {
/// # Ok(())
/// # }
/// ```
#[allow(clippy::clippy::wrong_self_convention)] // This is named after the sql operator
#[allow(clippy::wrong_self_convention)] // This is named after the sql operator
fn is_not<T>(self, other: T) -> dsl::IsNot<Self, T>
where
Self::SqlType: SqlType,
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/util/once_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<T> OnceCell<T> {
// `assert`, while keeping `set/get` would be sound, but it seems
// better to panic, rather than to silently use an old value.
assert!(self.set(val).is_ok(), "reentrant init");
self.get().unwrap()
self.get().expect("We set the value in the line above")
}

pub(crate) fn get(&self) -> Option<&T> {
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/src/infer_schema_internals/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub fn load_table_data(
let primary_key = get_primary_keys(&mut connection, &name)?;
let primary_key = primary_key
.iter()
.map(|k| rust_name_for_sql_name(&k))
.map(|k| rust_name_for_sql_name(k))
.collect();

let column_data = get_column_information(&mut connection, &name, column_sorting)?
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/src/infer_schema_internals/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl SqliteVersion {

fn get_sqlite_version(conn: &mut SqliteConnection) -> SqliteVersion {
let query = "SELECT sqlite_version()";
let result = sql::<sql_types::Text>(&query).load::<String>(conn).unwrap();
let result = sql::<sql_types::Text>(query).load::<String>(conn).unwrap();
let parts = result[0]
.split('.')
.map(|part| part.parse().unwrap())
Expand Down
3 changes: 1 addition & 2 deletions diesel_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
clippy::non_ascii_literal,
clippy::similar_names,
clippy::unicode_not_nfc,
clippy::used_underscore_binding,
clippy::wrong_pub_self_convention
clippy::used_underscore_binding
)]
#![cfg_attr(test, allow(clippy::result_unwrap_used))]

Expand Down
4 changes: 2 additions & 2 deletions diesel_derives/src/insertable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn field_ty_serialize_as(
let column_name = field.column_name();

if treat_none_as_default_value {
let inner_ty = inner_of_option_ty(&ty);
let inner_ty = inner_of_option_ty(ty);

quote!(
std::option::Option<diesel::dsl::Eq<
Expand Down Expand Up @@ -180,7 +180,7 @@ fn field_expr_serialize_as(
let column = quote!(#table_name::#column_name);

if treat_none_as_default_value {
if is_option_ty(&ty) {
if is_option_ty(ty) {
quote!(self.#field_name.map(|x| #column.eq(::std::convert::Into::<#ty>::into(x))))
} else {
quote!(std::option::Option::Some(#column.eq(::std::convert::Into::<#ty>::into(self.#field_name))))
Expand Down
1 change: 0 additions & 1 deletion diesel_derives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
clippy::map_unwrap_or
)]
#![warn(
clippy::wrong_pub_self_convention,
clippy::mut_mut,
clippy::non_ascii_literal,
clippy::similar_names,
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/sql_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ fn is_sqlite_type(ty: &Type) -> bool {
if ident == "Nullable" {
if let PathArguments::AngleBracketed(ref ab) = last_segment.arguments {
if let Some(GenericArgument::Type(ty)) = ab.args.first() {
return is_sqlite_type(&ty);
return is_sqlite_type(ty);
}
}
return false;
Expand Down
1 change: 0 additions & 1 deletion diesel_migrations/migrations_internals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![warn(
clippy::unwrap_used,
clippy::print_stdout,
clippy::wrong_pub_self_convention,
clippy::mut_mut,
clippy::non_ascii_literal,
clippy::similar_names,
Expand Down
1 change: 0 additions & 1 deletion diesel_migrations/migrations_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#![warn(
clippy::unwrap_used,
clippy::print_stdout,
clippy::wrong_pub_self_convention,
clippy::mut_mut,
clippy::non_ascii_literal,
clippy::similar_names,
Expand Down
2 changes: 1 addition & 1 deletion diesel_migrations/src/file_based_migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl DieselMigrationName {
}

pub(crate) fn from_name(name: &str) -> Result<Self, MigrationError> {
let version = migrations_internals::version_from_string(&name)
let version = migrations_internals::version_from_string(name)
.ok_or_else(|| MigrationError::UnknownMigrationFormat(PathBuf::from(name)))?;
Ok(Self {
name: name.to_owned(),
Expand Down
1 change: 0 additions & 1 deletion diesel_migrations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#![allow(clippy::needless_pass_by_value, clippy::map_unwrap_or)]
#![warn(
missing_docs,
clippy::wrong_pub_self_convention,
clippy::mut_mut,
clippy::non_ascii_literal,
clippy::similar_names,
Expand Down

0 comments on commit 99ecace

Please sign in to comment.