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

Update all the crates to the 2021 edition #3568

Merged
merged 1 commit into from
Mar 26, 2023
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
2 changes: 1 addition & 1 deletion diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 0 additions & 2 deletions diesel/src/mysql/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<NumericRepresentation<'_>> {
use std::convert::TryInto;

Ok(match self.tpe {
MysqlType::UnsignedTiny | MysqlType::Tiny => {
NumericRepresentation::Tiny(self.raw[0] as i8)
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions diesel/src/sqlite/connection/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ extern "C" fn run_custom_function<F, Ret, RetSqlType>(
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)?;
Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 1 addition & 5 deletions diesel_derives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this 2015, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed it before #3564
I tried that migration already yesterday and noticed that dependencies. I did not think much about that and went on trying to minimize one of the rust-analyzer type issues with diesel, so that the rust-analyzer team had at least a minimal example without depending on diesel. While doing that someone from that team said that they cannot explain how name resolution even worked for code generated by diesel proc-macro. Because I hit that by accident a bit earlier I was able to explain that and they suggested the extern crate self as diesel; fix. That in turn remove the need to use the 2015 edition there, so after all that's all somehow related.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, I remember trying this exact trick when I was refactoring the derives. But, it didn't work back then, so I thought maybe the issue was something else and ended up keeping the old hack.


[dependencies]
syn = { version = "2.0", features = ["derive", "fold", "full"] }
Expand Down
8 changes: 4 additions & 4 deletions diesel_derives/src/as_changeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, false, false)?;
Expand Down
8 changes: 4 additions & 4 deletions diesel_derives/src/as_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, true, false)?;
Expand Down Expand Up @@ -88,15 +88,15 @@ pub fn derive(item: DeriveInput) -> Result<TokenStream> {
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 {
Bound::new(self)
}
}

impl#impl_generics AsExpression<Nullable<#sql_type>> for #struct_ty {
impl #impl_generics AsExpression<Nullable<#sql_type>> for #struct_ty {
type Expression = Bound<Nullable<#sql_type>, Self>;

fn as_expression(self) -> Self::Expression {
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/associations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, false, false)?;
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/deprecated/belongs_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BelongsTo> {
if input.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions diesel_derives/src/deprecated/changeset_options.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
22 changes: 11 additions & 11 deletions diesel_derives/src/deprecated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<Self>> {
Expand All @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/deprecated/postgres_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/diesel_numeric_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions diesel_derives/src/from_sql_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, true, false)?;
Expand Down
4 changes: 2 additions & 2 deletions diesel_derives/src/identifiable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, false, false)?;
Expand Down
8 changes: 4 additions & 4 deletions diesel_derives/src/insertable.rs
Original file line number Diff line number Diff line change
@@ -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<TokenStream> {
let model = Model::from_item(&item, false, true)?;
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>> {
/// let connection = &mut SqliteConnection::establish(":memory:")?;
///
/// add_mul::register_impl(connection, |x: i32, y: i32, z: f64| {
Expand Down
8 changes: 4 additions & 4 deletions diesel_derives/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/parsers/belongs_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/parsers/mysql_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/parsers/postgres_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/parsers/sqlite_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/query_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, false, false)?;
Expand Down
8 changes: 4 additions & 4 deletions diesel_derives/src/queryable_by_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, false, false)?;
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/selectable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, false, false)?;
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/sql_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TokenStream> {
let model = Model::from_item(&item, true, false)?;
Expand Down
2 changes: 1 addition & 1 deletion diesel_derives/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading