Fix build
This commit is contained in:
parent
1e1f90786d
commit
e9b5a04a4f
@ -3,10 +3,10 @@ use quote::{format_ident, quote};
|
||||
use std::iter;
|
||||
use syn::{
|
||||
punctuated::Punctuated, token, AngleBracketedGenericArguments, Data, DataStruct, DeriveInput,
|
||||
Error, Fields, GenericArgument, GenericParam, Generics, Ident, Lifetime, LifetimeDef,
|
||||
PathArguments, PathSegment,
|
||||
Error, Fields, GenericArgument, GenericParam, Generics, Ident, Lifetime, PathArguments,
|
||||
PathSegment,
|
||||
};
|
||||
use syn::{TraitBound, TraitBoundModifier, TypeParamBound};
|
||||
use syn::{LifetimeParam, TraitBound, TraitBoundModifier, TypeParamBound};
|
||||
|
||||
use crate::accepts;
|
||||
use crate::composites::Field;
|
||||
@ -96,9 +96,9 @@ pub fn expand_derive_fromsql(input: DeriveInput) -> Result<TokenStream, Error> {
|
||||
let (impl_generics, _, _) = generics.split_for_impl();
|
||||
let (_, ty_generics, where_clause) = input.generics.split_for_impl();
|
||||
let out = quote! {
|
||||
impl#impl_generics postgres_types::FromSql<#lifetime> for #ident#ty_generics #where_clause {
|
||||
impl #impl_generics postgres_types::FromSql<#lifetime> for #ident #ty_generics #where_clause {
|
||||
fn from_sql(_type: &postgres_types::Type, buf: &#lifetime [u8])
|
||||
-> std::result::Result<#ident#ty_generics,
|
||||
-> std::result::Result<#ident #ty_generics,
|
||||
std::boxed::Box<dyn std::error::Error +
|
||||
std::marker::Sync +
|
||||
std::marker::Send>> {
|
||||
@ -217,7 +217,7 @@ fn build_generics(source: &Generics) -> (Generics, Lifetime) {
|
||||
let mut out = append_generic_bound(source.to_owned(), &new_fromsql_bound(&lifetime));
|
||||
out.params.insert(
|
||||
0,
|
||||
GenericParam::Lifetime(LifetimeDef::new(lifetime.to_owned())),
|
||||
GenericParam::Lifetime(LifetimeParam::new(lifetime.to_owned())),
|
||||
);
|
||||
|
||||
(out, lifetime)
|
||||
|
@ -1,4 +1,5 @@
|
||||
use syn::{Attribute, Error, Lit, Meta, NestedMeta};
|
||||
use syn::punctuated::Punctuated;
|
||||
use syn::{Attribute, Error, Expr, ExprLit, Lit, Meta, Token};
|
||||
|
||||
pub struct Overrides {
|
||||
pub name: Option<String>,
|
||||
@ -13,26 +14,28 @@ impl Overrides {
|
||||
};
|
||||
|
||||
for attr in attrs {
|
||||
let attr = attr.parse_meta()?;
|
||||
|
||||
if !attr.path().is_ident("postgres") {
|
||||
continue;
|
||||
}
|
||||
|
||||
let list = match attr {
|
||||
let list = match &attr.meta {
|
||||
Meta::List(ref list) => list,
|
||||
bad => return Err(Error::new_spanned(bad, "expected a #[postgres(...)]")),
|
||||
};
|
||||
|
||||
for item in &list.nested {
|
||||
let nested = list.parse_args_with(Punctuated::<Meta, Token![,]>::parse_terminated)?;
|
||||
|
||||
for item in nested {
|
||||
match item {
|
||||
NestedMeta::Meta(Meta::NameValue(meta)) => {
|
||||
Meta::NameValue(meta) => {
|
||||
if !meta.path.is_ident("name") {
|
||||
return Err(Error::new_spanned(&meta.path, "unknown override"));
|
||||
}
|
||||
|
||||
let value = match &meta.lit {
|
||||
Lit::Str(s) => s.value(),
|
||||
let value = match &meta.value {
|
||||
Expr::Lit(ExprLit {
|
||||
lit: Lit::Str(lit), ..
|
||||
}) => lit.value(),
|
||||
bad => {
|
||||
return Err(Error::new_spanned(bad, "expected a string literal"))
|
||||
}
|
||||
@ -40,7 +43,7 @@ impl Overrides {
|
||||
|
||||
overrides.name = Some(value);
|
||||
}
|
||||
NestedMeta::Meta(Meta::Path(ref path)) => {
|
||||
Meta::Path(path) => {
|
||||
if !path.is_ident("transparent") {
|
||||
return Err(Error::new_spanned(path, "unknown override"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user