diff --git a/diesel/Cargo.toml b/diesel/Cargo.toml index 66f0e0c05c39..ab3125763a72 100644 --- a/diesel/Cargo.toml +++ b/diesel/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://diesel.rs" repository = "https://github.com/diesel-rs/diesel" keywords = ["orm", "database", "sql"] categories = ["database"] -edition = "2018" +edition = "2021" rust-version = "1.65.0" [dependencies] diff --git a/diesel/src/mysql/value.rs b/diesel/src/mysql/value.rs index 12c32c41f0b4..2769f28282cb 100644 --- a/diesel/src/mysql/value.rs +++ b/diesel/src/mysql/value.rs @@ -58,8 +58,6 @@ impl<'a> MysqlValue<'a> { /// Returns the numeric representation of this value, based on the type code. /// Returns an error if the type code is not numeric. pub(crate) fn numeric_value(&self) -> deserialize::Result> { - use std::convert::TryInto; - Ok(match self.tpe { MysqlType::UnsignedTiny | MysqlType::Tiny => { NumericRepresentation::Tiny(self.raw[0] as i8) diff --git a/diesel/src/result.rs b/diesel/src/result.rs index 1e5e159ea624..9dd778a6130f 100644 --- a/diesel/src/result.rs +++ b/diesel/src/result.rs @@ -388,7 +388,7 @@ impl PartialEq for Error { #[allow(warnings)] fn error_impls_send() { let err: Error = unimplemented!(); - let x: &Send = &err; + let x: &dyn Send = &err; } /// An unexpected `NULL` was encountered during deserialization diff --git a/diesel/src/sqlite/connection/raw.rs b/diesel/src/sqlite/connection/raw.rs index 40105bbe70a6..06517a9e0f47 100644 --- a/diesel/src/sqlite/connection/raw.rs +++ b/diesel/src/sqlite/connection/raw.rs @@ -306,6 +306,7 @@ extern "C" fn run_custom_function( let callback = std::panic::AssertUnwindSafe(&mut data_ptr.callback); let result = std::panic::catch_unwind(move || { + let _ = &callback; let args = unsafe { slice::from_raw_parts_mut(value_ptr, num_args as _) }; let res = (callback.0)(&*conn, args)?; let value = process_sql_function_result(&res)?; diff --git a/diesel_cli/Cargo.toml b/diesel_cli/Cargo.toml index 7f252456002d..36a67226d498 100644 --- a/diesel_cli/Cargo.toml +++ b/diesel_cli/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://diesel.rs" repository = "https://github.com/diesel-rs/diesel" keywords = ["diesel", "migrations", "cli"] autotests = false -edition = "2018" +edition = "2021" include = ["src/**/*", "LICENSE-*", "README.md"] rust-version = "1.65.0" diff --git a/diesel_derives/Cargo.toml b/diesel_derives/Cargo.toml index 01967419f887..9a5dcaafa82c 100644 --- a/diesel_derives/Cargo.toml +++ b/diesel_derives/Cargo.toml @@ -9,11 +9,7 @@ repository = "https://github.com/diesel-rs/diesel/tree/master/diesel_derives" autotests = false include = ["src/**/*", "LICENSE-*"] rust-version = "1.65.0" -# we cannot update to newer editions -# because we relay on a name resolution -# hack to get a `diesel` item inside of diesel -# as well as for using diesel-derives in external crates -edition = "2015" +edition = "2021" [dependencies] syn = { version = "2.0", features = ["derive", "fold", "full"] } diff --git a/diesel_derives/src/as_changeset.rs b/diesel_derives/src/as_changeset.rs index c71240847707..2b730dee2867 100644 --- a/diesel_derives/src/as_changeset.rs +++ b/diesel_derives/src/as_changeset.rs @@ -2,10 +2,10 @@ use proc_macro2::TokenStream; use quote::quote; use syn::{parse_quote, DeriveInput, Expr, Path, Result, Type}; -use attrs::AttributeSpanWrapper; -use field::Field; -use model::Model; -use util::{inner_of_option_ty, is_option_ty, wrap_in_dummy_mod}; +use crate::attrs::AttributeSpanWrapper; +use crate::field::Field; +use crate::model::Model; +use crate::util::{inner_of_option_ty, is_option_ty, wrap_in_dummy_mod}; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, false)?; diff --git a/diesel_derives/src/as_expression.rs b/diesel_derives/src/as_expression.rs index dd5cd26f3244..d6f820e3cfa1 100644 --- a/diesel_derives/src/as_expression.rs +++ b/diesel_derives/src/as_expression.rs @@ -3,8 +3,8 @@ use quote::quote; use syn::DeriveInput; use syn::Result; -use model::Model; -use util::{ty_for_foreign_derive, wrap_in_dummy_mod}; +use crate::model::Model; +use crate::util::{ty_for_foreign_derive, wrap_in_dummy_mod}; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, true, false)?; @@ -88,7 +88,7 @@ pub fn derive(item: DeriveInput) -> Result { quote!( #tokens - impl#impl_generics AsExpression<#sql_type> for #struct_ty { + impl #impl_generics AsExpression<#sql_type> for #struct_ty { type Expression = Bound<#sql_type, Self>; fn as_expression(self) -> Self::Expression { @@ -96,7 +96,7 @@ pub fn derive(item: DeriveInput) -> Result { } } - impl#impl_generics AsExpression> for #struct_ty { + impl #impl_generics AsExpression> for #struct_ty { type Expression = Bound, Self>; fn as_expression(self) -> Self::Expression { diff --git a/diesel_derives/src/associations.rs b/diesel_derives/src/associations.rs index 8a7a528419b5..6dd7d00b9f8a 100644 --- a/diesel_derives/src/associations.rs +++ b/diesel_derives/src/associations.rs @@ -4,9 +4,9 @@ use syn::fold::Fold; use syn::parse_quote; use syn::{DeriveInput, Ident, Lifetime, Result}; -use model::Model; -use parsers::BelongsTo; -use util::{camel_to_snake, wrap_in_dummy_mod}; +use crate::model::Model; +use crate::parsers::BelongsTo; +use crate::util::{camel_to_snake, wrap_in_dummy_mod}; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, false)?; diff --git a/diesel_derives/src/attrs.rs b/diesel_derives/src/attrs.rs index af928422ee49..14bdfcab1c8e 100644 --- a/diesel_derives/src/attrs.rs +++ b/diesel_derives/src/attrs.rs @@ -9,9 +9,9 @@ use syn::spanned::Spanned; use syn::token::Comma; use syn::{Attribute, Ident, LitBool, LitStr, Path, Type, TypePath}; -use deprecated::ParseDeprecated; -use parsers::{BelongsTo, MysqlType, PostgresType, SqliteType}; -use util::{ +use crate::deprecated::ParseDeprecated; +use crate::parsers::{BelongsTo, MysqlType, PostgresType, SqliteType}; +use crate::util::{ parse_eq, parse_paren, unknown_attribute, BELONGS_TO_NOTE, COLUMN_NAME_NOTE, DESERIALIZE_AS_NOTE, MYSQL_TYPE_NOTE, POSTGRES_TYPE_NOTE, SELECT_EXPRESSION_NOTE, SELECT_EXPRESSION_TYPE_NOTE, SERIALIZE_AS_NOTE, SQLITE_TYPE_NOTE, SQL_TYPE_NOTE, diff --git a/diesel_derives/src/deprecated/belongs_to.rs b/diesel_derives/src/deprecated/belongs_to.rs index 16b167c673b3..905577083f65 100644 --- a/diesel_derives/src/deprecated/belongs_to.rs +++ b/diesel_derives/src/deprecated/belongs_to.rs @@ -2,9 +2,9 @@ use syn::parse::{ParseStream, Result}; use syn::token::Comma; use syn::{parenthesized, Ident, LitStr}; -use deprecated::utils::parse_eq_and_lit_str; -use parsers::BelongsTo; -use util::BELONGS_TO_NOTE; +use crate::deprecated::utils::parse_eq_and_lit_str; +use crate::parsers::BelongsTo; +use crate::util::BELONGS_TO_NOTE; pub fn parse_belongs_to(name: Ident, input: ParseStream) -> Result { if input.is_empty() { diff --git a/diesel_derives/src/deprecated/changeset_options.rs b/diesel_derives/src/deprecated/changeset_options.rs index 23c8b2493d4e..70a72a326bcd 100644 --- a/diesel_derives/src/deprecated/changeset_options.rs +++ b/diesel_derives/src/deprecated/changeset_options.rs @@ -1,8 +1,8 @@ use syn::parse::{ParseStream, Result}; use syn::{parenthesized, Ident, LitBool}; -use deprecated::utils::parse_eq_and_lit_str; -use util::TREAT_NONE_AS_NULL_NOTE; +use crate::deprecated::utils::parse_eq_and_lit_str; +use crate::util::TREAT_NONE_AS_NULL_NOTE; pub fn parse_changeset_options(name: Ident, input: ParseStream) -> Result<(Ident, LitBool)> { if input.is_empty() { diff --git a/diesel_derives/src/deprecated/mod.rs b/diesel_derives/src/deprecated/mod.rs index df5d7613aa46..fa447d4c6b8f 100644 --- a/diesel_derives/src/deprecated/mod.rs +++ b/diesel_derives/src/deprecated/mod.rs @@ -18,7 +18,7 @@ pub trait ParseDeprecated: Sized { #[cfg(any(feature = "without-deprecated", not(feature = "with-deprecated")))] mod not_deprecated { use super::{ParseDeprecated, ParseStream, Result}; - use attrs::{FieldAttr, StructAttr}; + use crate::attrs::{FieldAttr, StructAttr}; impl ParseDeprecated for StructAttr { fn parse_deprecated(_input: ParseStream) -> Result> { @@ -36,18 +36,18 @@ mod not_deprecated { #[cfg(all(not(feature = "without-deprecated"), feature = "with-deprecated"))] mod impl_deprecated { use super::{ParseDeprecated, ParseStream, Result}; - use attrs::{FieldAttr, StructAttr}; - use deprecated::belongs_to::parse_belongs_to; - use deprecated::changeset_options::parse_changeset_options; - use deprecated::postgres_type::parse_postgres_type; - use deprecated::primary_key::parse_primary_key; - use deprecated::utils::parse_eq_and_lit_str; - use parsers::{MysqlType, PostgresType, SqliteType}; - use proc_macro2::Span; - use syn::Ident; - use util::{ + use crate::attrs::{FieldAttr, StructAttr}; + use crate::deprecated::belongs_to::parse_belongs_to; + use crate::deprecated::changeset_options::parse_changeset_options; + use crate::deprecated::postgres_type::parse_postgres_type; + use crate::deprecated::primary_key::parse_primary_key; + use crate::deprecated::utils::parse_eq_and_lit_str; + use crate::parsers::{MysqlType, PostgresType, SqliteType}; + use crate::util::{ COLUMN_NAME_NOTE, MYSQL_TYPE_NOTE, SQLITE_TYPE_NOTE, SQL_TYPE_NOTE, TABLE_NAME_NOTE, }; + use proc_macro2::Span; + use syn::Ident; macro_rules! warn { ($ident: expr, $help: expr) => { diff --git a/diesel_derives/src/deprecated/postgres_type.rs b/diesel_derives/src/deprecated/postgres_type.rs index ddefabd3e42b..5753f68de661 100644 --- a/diesel_derives/src/deprecated/postgres_type.rs +++ b/diesel_derives/src/deprecated/postgres_type.rs @@ -3,9 +3,9 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{parenthesized, Ident, LitInt, LitStr}; -use deprecated::utils::parse_eq_and_lit_str; -use parsers::PostgresType; -use util::{unknown_attribute, POSTGRES_TYPE_NOTE}; +use crate::deprecated::utils::parse_eq_and_lit_str; +use crate::parsers::PostgresType; +use crate::util::{unknown_attribute, POSTGRES_TYPE_NOTE}; enum Attr { Oid(Ident, LitInt), diff --git a/diesel_derives/src/diesel_numeric_ops.rs b/diesel_derives/src/diesel_numeric_ops.rs index 6e9d21e160b7..0777ca23a039 100644 --- a/diesel_derives/src/diesel_numeric_ops.rs +++ b/diesel_derives/src/diesel_numeric_ops.rs @@ -3,7 +3,7 @@ use quote::quote; use syn::parse_quote; use syn::DeriveInput; -use util::wrap_in_dummy_mod; +use crate::util::wrap_in_dummy_mod; pub fn derive(mut item: DeriveInput) -> TokenStream { let struct_name = &item.ident; diff --git a/diesel_derives/src/field.rs b/diesel_derives/src/field.rs index 48de67c3c2e4..eb0fad039f09 100644 --- a/diesel_derives/src/field.rs +++ b/diesel_derives/src/field.rs @@ -2,7 +2,7 @@ use proc_macro2::{Span, TokenStream}; use syn::spanned::Spanned; use syn::{Field as SynField, Ident, Index, Result, Type}; -use attrs::{parse_attributes, AttributeSpanWrapper, FieldAttr, SqlIdentifier}; +use crate::attrs::{parse_attributes, AttributeSpanWrapper, FieldAttr, SqlIdentifier}; pub struct Field { pub ty: Type, diff --git a/diesel_derives/src/from_sql_row.rs b/diesel_derives/src/from_sql_row.rs index 024463586d9e..d9cce837b650 100644 --- a/diesel_derives/src/from_sql_row.rs +++ b/diesel_derives/src/from_sql_row.rs @@ -4,8 +4,8 @@ use syn::parse_quote; use syn::DeriveInput; use syn::Result; -use model::Model; -use util::{ty_for_foreign_derive, wrap_in_dummy_mod}; +use crate::model::Model; +use crate::util::{ty_for_foreign_derive, wrap_in_dummy_mod}; pub fn derive(mut item: DeriveInput) -> Result { let model = Model::from_item(&item, true, false)?; diff --git a/diesel_derives/src/identifiable.rs b/diesel_derives/src/identifiable.rs index bbbca2016266..01245df86272 100644 --- a/diesel_derives/src/identifiable.rs +++ b/diesel_derives/src/identifiable.rs @@ -4,8 +4,8 @@ use syn::parse_quote; use syn::DeriveInput; use syn::Result; -use model::Model; -use util::wrap_in_dummy_mod; +use crate::model::Model; +use crate::util::wrap_in_dummy_mod; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, false)?; diff --git a/diesel_derives/src/insertable.rs b/diesel_derives/src/insertable.rs index eb5cdeee7ca0..684b50e568dd 100644 --- a/diesel_derives/src/insertable.rs +++ b/diesel_derives/src/insertable.rs @@ -1,12 +1,12 @@ -use attrs::AttributeSpanWrapper; -use field::Field; -use model::Model; +use crate::attrs::AttributeSpanWrapper; +use crate::field::Field; +use crate::model::Model; +use crate::util::{inner_of_option_ty, is_option_ty, wrap_in_dummy_mod}; use proc_macro2::TokenStream; use quote::quote; use quote::quote_spanned; use syn::parse_quote; use syn::{DeriveInput, Expr, Path, Result, Type}; -use util::{inner_of_option_ty, is_option_ty, wrap_in_dummy_mod}; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, true)?; diff --git a/diesel_derives/src/lib.rs b/diesel_derives/src/lib.rs index c9f8897e65fc..e9dbb3b0c153 100644 --- a/diesel_derives/src/lib.rs +++ b/diesel_derives/src/lib.rs @@ -1150,7 +1150,7 @@ pub fn derive_valid_grouping(input: TokenStream) -> TokenStream { /// sql_function!(fn add_mul(x: Integer, y: Integer, z: Double) -> Double); /// /// # #[cfg(feature = "sqlite")] -/// # fn run_test() -> Result<(), Box<::std::error::Error>> { +/// # fn run_test() -> Result<(), Box> { /// let connection = &mut SqliteConnection::establish(":memory:")?; /// /// add_mul::register_impl(connection, |x: i32, y: i32, z: f64| { diff --git a/diesel_derives/src/model.rs b/diesel_derives/src/model.rs index 8b4a870b6c35..d6f72520faef 100644 --- a/diesel_derives/src/model.rs +++ b/diesel_derives/src/model.rs @@ -8,10 +8,10 @@ use syn::{ LitBool, Path, Type, }; -use attrs::{parse_attributes, StructAttr}; -use field::Field; -use parsers::{BelongsTo, MysqlType, PostgresType, SqliteType}; -use util::camel_to_snake; +use crate::attrs::{parse_attributes, StructAttr}; +use crate::field::Field; +use crate::parsers::{BelongsTo, MysqlType, PostgresType, SqliteType}; +use crate::util::camel_to_snake; pub struct Model { name: Path, diff --git a/diesel_derives/src/parsers/belongs_to.rs b/diesel_derives/src/parsers/belongs_to.rs index 7ca79faf2159..50e00957c2d2 100644 --- a/diesel_derives/src/parsers/belongs_to.rs +++ b/diesel_derives/src/parsers/belongs_to.rs @@ -3,7 +3,7 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{Ident, TypePath}; -use util::{parse_eq, unknown_attribute, BELONGS_TO_NOTE}; +use crate::util::{parse_eq, unknown_attribute, BELONGS_TO_NOTE}; enum Attr { ForeignKey(Ident, Ident), diff --git a/diesel_derives/src/parsers/mysql_type.rs b/diesel_derives/src/parsers/mysql_type.rs index 6ee926d785e8..baa2dbe66e2f 100644 --- a/diesel_derives/src/parsers/mysql_type.rs +++ b/diesel_derives/src/parsers/mysql_type.rs @@ -3,7 +3,7 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{Ident, LitStr}; -use util::{parse_eq, unknown_attribute, MYSQL_TYPE_NOTE}; +use crate::util::{parse_eq, unknown_attribute, MYSQL_TYPE_NOTE}; enum Attr { Name(Ident, LitStr), diff --git a/diesel_derives/src/parsers/postgres_type.rs b/diesel_derives/src/parsers/postgres_type.rs index feb1d6855e65..5875a23d56ee 100644 --- a/diesel_derives/src/parsers/postgres_type.rs +++ b/diesel_derives/src/parsers/postgres_type.rs @@ -3,7 +3,7 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{Ident, LitInt, LitStr}; -use util::{parse_eq, unknown_attribute, POSTGRES_TYPE_NOTE, POSTGRES_TYPE_NOTE_ID}; +use crate::util::{parse_eq, unknown_attribute, POSTGRES_TYPE_NOTE, POSTGRES_TYPE_NOTE_ID}; enum Attr { Oid(Ident, LitInt), diff --git a/diesel_derives/src/parsers/sqlite_type.rs b/diesel_derives/src/parsers/sqlite_type.rs index f27bdafcef36..063ed65f4734 100644 --- a/diesel_derives/src/parsers/sqlite_type.rs +++ b/diesel_derives/src/parsers/sqlite_type.rs @@ -3,7 +3,7 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{Ident, LitStr}; -use util::{parse_eq, unknown_attribute, SQLITE_TYPE_NOTE}; +use crate::util::{parse_eq, unknown_attribute, SQLITE_TYPE_NOTE}; enum Attr { Name(Ident, LitStr), diff --git a/diesel_derives/src/query_id.rs b/diesel_derives/src/query_id.rs index bdfc958cb84b..123163c56a1e 100644 --- a/diesel_derives/src/query_id.rs +++ b/diesel_derives/src/query_id.rs @@ -3,7 +3,7 @@ use quote::quote; use syn::parse_quote; use syn::DeriveInput; -use util::wrap_in_dummy_mod; +use crate::util::wrap_in_dummy_mod; pub fn derive(mut item: DeriveInput) -> TokenStream { for ty_param in item.generics.type_params_mut() { diff --git a/diesel_derives/src/queryable.rs b/diesel_derives/src/queryable.rs index b6dc2247ad2a..c58b0464a31f 100644 --- a/diesel_derives/src/queryable.rs +++ b/diesel_derives/src/queryable.rs @@ -2,9 +2,9 @@ use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::{parse_quote, DeriveInput, Ident, Index, Result}; -use field::Field; -use model::Model; -use util::wrap_in_dummy_mod; +use crate::field::Field; +use crate::model::Model; +use crate::util::wrap_in_dummy_mod; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, false)?; diff --git a/diesel_derives/src/queryable_by_name.rs b/diesel_derives/src/queryable_by_name.rs index a8e50949faa7..eef8414c0017 100644 --- a/diesel_derives/src/queryable_by_name.rs +++ b/diesel_derives/src/queryable_by_name.rs @@ -2,10 +2,10 @@ use proc_macro2::TokenStream; use quote::quote; use syn::{parse_quote, DeriveInput, Ident, LitStr, Result, Type}; -use attrs::AttributeSpanWrapper; -use field::{Field, FieldName}; -use model::Model; -use util::wrap_in_dummy_mod; +use crate::attrs::AttributeSpanWrapper; +use crate::field::{Field, FieldName}; +use crate::model::Model; +use crate::util::wrap_in_dummy_mod; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, false)?; diff --git a/diesel_derives/src/selectable.rs b/diesel_derives/src/selectable.rs index eb20c5075f43..5edc93138c10 100644 --- a/diesel_derives/src/selectable.rs +++ b/diesel_derives/src/selectable.rs @@ -4,9 +4,9 @@ use syn::spanned::Spanned; use syn::DeriveInput; use syn::{parse_quote, Result}; -use field::Field; -use model::Model; -use util::wrap_in_dummy_mod; +use crate::field::Field; +use crate::model::Model; +use crate::util::wrap_in_dummy_mod; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, false, false)?; diff --git a/diesel_derives/src/sql_type.rs b/diesel_derives/src/sql_type.rs index 9e378d0a404e..2e6f00d65464 100644 --- a/diesel_derives/src/sql_type.rs +++ b/diesel_derives/src/sql_type.rs @@ -3,9 +3,9 @@ use quote::quote; use syn::Result; use syn::{DeriveInput, Ident}; -use model::Model; -use parsers::PostgresType; -use util::wrap_in_dummy_mod; +use crate::model::Model; +use crate::parsers::PostgresType; +use crate::util::wrap_in_dummy_mod; pub fn derive(item: DeriveInput) -> Result { let model = Model::from_item(&item, true, false)?; diff --git a/diesel_derives/src/util.rs b/diesel_derives/src/util.rs index fdaa16c8f58d..4f9930fcc113 100644 --- a/diesel_derives/src/util.rs +++ b/diesel_derives/src/util.rs @@ -4,7 +4,7 @@ use syn::parse::{Parse, ParseStream, Peek, Result}; use syn::token::Eq; use syn::{parenthesized, parse_quote, Data, DeriveInput, GenericArgument, Ident, Type}; -use model::Model; +use crate::model::Model; pub const COLUMN_NAME_NOTE: &str = "column_name = foo"; pub const SQL_TYPE_NOTE: &str = "sql_type = Foo"; diff --git a/diesel_derives/src/valid_grouping.rs b/diesel_derives/src/valid_grouping.rs index 750849eab8a8..676401fa76cf 100644 --- a/diesel_derives/src/valid_grouping.rs +++ b/diesel_derives/src/valid_grouping.rs @@ -4,8 +4,8 @@ use syn::parse_quote; use syn::DeriveInput; use syn::Result; -use model::Model; -use util::{ty_for_foreign_derive, wrap_in_dummy_mod}; +use crate::model::Model; +use crate::util::{ty_for_foreign_derive, wrap_in_dummy_mod}; pub fn derive(mut item: DeriveInput) -> Result { let model = Model::from_item(&item, true, false)?; diff --git a/diesel_derives/tests/as_changeset.rs b/diesel_derives/tests/as_changeset.rs index e366863a933e..fcae232f1c23 100644 --- a/diesel_derives/tests/as_changeset.rs +++ b/diesel_derives/tests/as_changeset.rs @@ -1,8 +1,8 @@ +use crate::helpers::*; +use crate::schema::*; use diesel::deserialize::FromSqlRow; use diesel::expression::AsExpression; use diesel::*; -use helpers::*; -use schema::*; #[test] fn named_ref_struct() { diff --git a/diesel_derives/tests/as_expression.rs b/diesel_derives/tests/as_expression.rs index 9e2f0c444181..cf8f739979cf 100644 --- a/diesel_derives/tests/as_expression.rs +++ b/diesel_derives/tests/as_expression.rs @@ -6,7 +6,7 @@ use diesel::sql_types::Text; use diesel::*; use std::convert::TryInto; -use helpers::connection; +use crate::helpers::connection; table! { my_structs (foo) { diff --git a/diesel_derives/tests/associations.rs b/diesel_derives/tests/associations.rs index b0f7e2583fff..86dc4c1467fe 100644 --- a/diesel_derives/tests/associations.rs +++ b/diesel_derives/tests/associations.rs @@ -1,5 +1,5 @@ +use crate::helpers::*; use diesel::*; -use helpers::*; type Backend = ::Backend; diff --git a/diesel_derives/tests/helpers.rs b/diesel_derives/tests/helpers.rs index 47f1ff0ca747..361f68d09ca8 100644 --- a/diesel_derives/tests/helpers.rs +++ b/diesel_derives/tests/helpers.rs @@ -86,10 +86,10 @@ cfg_if! { } pub fn connection_with_sean_and_tess_in_users_table() -> TestConnection { - use schema::users::dsl::*; + use crate::schema::users::dsl::*; let mut connection = connection(); - ::diesel::insert_into(users) + diesel::insert_into(users) .values(&vec![ (id.eq(1), name.eq("Sean"), hair_color.eq("black")), (id.eq(2), name.eq("Tess"), hair_color.eq("brown")), diff --git a/diesel_derives/tests/insertable.rs b/diesel_derives/tests/insertable.rs index dbc0d47fd208..d6eaeef83ac2 100644 --- a/diesel_derives/tests/insertable.rs +++ b/diesel_derives/tests/insertable.rs @@ -1,6 +1,6 @@ +use crate::helpers::*; +use crate::schema::*; use diesel::*; -use helpers::*; -use schema::*; #[test] fn simple_struct_definition() { diff --git a/diesel_derives/tests/queryable.rs b/diesel_derives/tests/queryable.rs index ef52da75b224..c76382f09ccd 100644 --- a/diesel_derives/tests/queryable.rs +++ b/diesel_derives/tests/queryable.rs @@ -2,7 +2,7 @@ use diesel::dsl::sql; use diesel::sql_types::Integer; use diesel::*; -use helpers::connection; +use crate::helpers::connection; #[test] fn named_struct_definition() { diff --git a/diesel_derives/tests/queryable_by_name.rs b/diesel_derives/tests/queryable_by_name.rs index 875f89a098b8..c64d77779f21 100644 --- a/diesel_derives/tests/queryable_by_name.rs +++ b/diesel_derives/tests/queryable_by_name.rs @@ -2,7 +2,7 @@ use diesel::sql_types::Integer; use diesel::*; -use helpers::connection; +use crate::helpers::connection; table! { my_structs (foo) { diff --git a/diesel_derives/tests/selectable.rs b/diesel_derives/tests/selectable.rs index d69c9950668f..a4aba7b49863 100644 --- a/diesel_derives/tests/selectable.rs +++ b/diesel_derives/tests/selectable.rs @@ -1,6 +1,6 @@ use diesel::*; -use helpers::connection; +use crate::helpers::connection; table! { my_structs (foo) { diff --git a/diesel_migrations/Cargo.toml b/diesel_migrations/Cargo.toml index 1ffe050c478c..2893a2789e49 100644 --- a/diesel_migrations/Cargo.toml +++ b/diesel_migrations/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0" description = "Migration management for diesel" documentation = "https://docs.rs/crate/diesel_migrations" homepage = "https://diesel.rs" -edition = "2018" +edition = "2021" rust-version = "1.65.0" [dependencies.migrations_internals] diff --git a/diesel_migrations/migrations_internals/Cargo.toml b/diesel_migrations/migrations_internals/Cargo.toml index 5f9847b7e23a..f36ff1aab1d6 100644 --- a/diesel_migrations/migrations_internals/Cargo.toml +++ b/diesel_migrations/migrations_internals/Cargo.toml @@ -5,6 +5,7 @@ license = "MIT OR Apache-2.0" description = "Internal implementation of diesels migration mechanism" homepage = "https://diesel.rs" rust-version = "1.65.0" +edition = "2021" [dependencies] serde = {version = "1", features = ["derive"]} diff --git a/diesel_migrations/migrations_macros/Cargo.toml b/diesel_migrations/migrations_macros/Cargo.toml index 25e4cec92119..7ff67f06d9fc 100644 --- a/diesel_migrations/migrations_macros/Cargo.toml +++ b/diesel_migrations/migrations_macros/Cargo.toml @@ -4,7 +4,7 @@ version = "2.0.0" license = "MIT OR Apache-2.0" description = "Codegeneration macros for diesels embedded migrations" homepage = "https://diesel.rs" -edition = "2018" +edition = "2021" rust-version = "1.65.0" [dependencies] diff --git a/diesel_tests/Cargo.toml b/diesel_tests/Cargo.toml index 4cd1ec98ee1d..d23d31d85898 100644 --- a/diesel_tests/Cargo.toml +++ b/diesel_tests/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Sage Griffin "] license = "MIT OR Apache-2.0" autotests = false autobenches = false -edition = "2018" +edition = "2021" publish = false [dependencies] diff --git a/diesel_tests/tests/deserialization.rs b/diesel_tests/tests/deserialization.rs index 54a5c867aab6..2fa208842462 100644 --- a/diesel_tests/tests/deserialization.rs +++ b/diesel_tests/tests/deserialization.rs @@ -23,7 +23,7 @@ fn generated_queryable_allows_lifetimes() { users.select((id, name)).first(connection) ); assert_eq!( - users.select((id, name)).first::(connection), + users.select((id, name)).first::>(connection), users.select(CowUser::as_select()).first(connection) ); } diff --git a/diesel_tests/tests/expressions/mod.rs b/diesel_tests/tests/expressions/mod.rs index 89769f5b42f7..58a96053bb7c 100644 --- a/diesel_tests/tests/expressions/mod.rs +++ b/diesel_tests/tests/expressions/mod.rs @@ -1,4 +1,4 @@ -extern crate bigdecimal; +use bigdecimal; mod date_and_time; mod ops; diff --git a/diesel_tests/tests/lib.rs b/diesel_tests/tests/lib.rs index 2b78ab621811..e4963a855de3 100644 --- a/diesel_tests/tests/lib.rs +++ b/diesel_tests/tests/lib.rs @@ -2,13 +2,9 @@ #[macro_use] extern crate assert_matches; -extern crate chrono; + #[macro_use] extern crate diesel; -#[cfg(feature = "sqlite")] -extern crate diesel_migrations; -extern crate dotenvy; -extern crate quickcheck; mod alias; #[cfg(not(feature = "sqlite"))] diff --git a/diesel_tests/tests/schema_dsl/functions.rs b/diesel_tests/tests/schema_dsl/functions.rs index aef69894b657..7edb4fd84dca 100644 --- a/diesel_tests/tests/schema_dsl/functions.rs +++ b/diesel_tests/tests/schema_dsl/functions.rs @@ -2,19 +2,19 @@ use diesel::sql_types; use super::structures::*; -pub fn create_table(name: &str, columns: Cols) -> CreateTable { +pub fn create_table(name: &str, columns: Cols) -> CreateTable<'_, Cols> { CreateTable::new(name, columns) } -pub fn integer(name: &str) -> Column { +pub fn integer(name: &str) -> Column<'_, sql_types::Integer> { Column::new(name, "INTEGER") } -pub fn string(name: &str) -> Column { +pub fn string(name: &str) -> Column<'_, sql_types::VarChar> { Column::new(name, "VARCHAR(255)") } -pub fn timestamp(name: &str) -> Column { +pub fn timestamp(name: &str) -> Column<'_, sql_types::VarChar> { Column::new(name, "TIMESTAMP") } @@ -23,10 +23,10 @@ pub fn timestamptz(name: &str) -> Column { Column::new(name, "TIMESTAMPTZ") } -pub fn time(name: &str) -> Column { +pub fn time(name: &str) -> Column<'_, sql_types::VarChar> { Column::new(name, "TIME") } -pub fn date(name: &str) -> Column { +pub fn date(name: &str) -> Column<'_, sql_types::VarChar> { Column::new(name, "DATE") } diff --git a/diesel_tests/tests/schema_dsl/structures.rs b/diesel_tests/tests/schema_dsl/structures.rs index 2a629508373a..6e631bc8ac11 100644 --- a/diesel_tests/tests/schema_dsl/structures.rs +++ b/diesel_tests/tests/schema_dsl/structures.rs @@ -33,7 +33,7 @@ impl<'a, T> Column<'a, T> { PrimaryKey(self) } - pub fn default(self, expr: &str) -> Default { + pub fn default(self, expr: &str) -> Default<'_, Self> { Default { column: self, value: expr, @@ -58,7 +58,7 @@ pub struct AutoIncrement(Col); pub struct NotNull(Col); impl<'a, T> NotNull> { - pub fn default(self, expr: &str) -> Default { + pub fn default(self, expr: &str) -> Default<'_, Self> { Default { column: self, value: expr, diff --git a/diesel_tests/tests/schema_inference.rs b/diesel_tests/tests/schema_inference.rs index 1809b39c0196..501ab81d46f4 100644 --- a/diesel_tests/tests/schema_inference.rs +++ b/diesel_tests/tests/schema_inference.rs @@ -1,9 +1,7 @@ -extern crate chrono; - #[cfg(feature = "sqlite")] mod sqlite { - use super::chrono::*; use crate::schema::*; + use chrono::*; use diesel::*; #[derive(Queryable, PartialEq, Debug, Insertable)] @@ -194,8 +192,8 @@ mod sqlite { #[cfg(feature = "postgres")] mod postgres { - use super::chrono::*; use crate::schema::*; + use chrono::*; use diesel::data_types::PgNumeric; use diesel::*; use std::collections::Bound;