Fix build
This commit is contained in:
parent
1e1f90786d
commit
e9b5a04a4f
@ -3,10 +3,10 @@ use quote::{format_ident, quote};
|
|||||||
use std::iter;
|
use std::iter;
|
||||||
use syn::{
|
use syn::{
|
||||||
punctuated::Punctuated, token, AngleBracketedGenericArguments, Data, DataStruct, DeriveInput,
|
punctuated::Punctuated, token, AngleBracketedGenericArguments, Data, DataStruct, DeriveInput,
|
||||||
Error, Fields, GenericArgument, GenericParam, Generics, Ident, Lifetime, LifetimeDef,
|
Error, Fields, GenericArgument, GenericParam, Generics, Ident, Lifetime, PathArguments,
|
||||||
PathArguments, PathSegment,
|
PathSegment,
|
||||||
};
|
};
|
||||||
use syn::{TraitBound, TraitBoundModifier, TypeParamBound};
|
use syn::{LifetimeParam, TraitBound, TraitBoundModifier, TypeParamBound};
|
||||||
|
|
||||||
use crate::accepts;
|
use crate::accepts;
|
||||||
use crate::composites::Field;
|
use crate::composites::Field;
|
||||||
@ -217,7 +217,7 @@ fn build_generics(source: &Generics) -> (Generics, Lifetime) {
|
|||||||
let mut out = append_generic_bound(source.to_owned(), &new_fromsql_bound(&lifetime));
|
let mut out = append_generic_bound(source.to_owned(), &new_fromsql_bound(&lifetime));
|
||||||
out.params.insert(
|
out.params.insert(
|
||||||
0,
|
0,
|
||||||
GenericParam::Lifetime(LifetimeDef::new(lifetime.to_owned())),
|
GenericParam::Lifetime(LifetimeParam::new(lifetime.to_owned())),
|
||||||
);
|
);
|
||||||
|
|
||||||
(out, lifetime)
|
(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 struct Overrides {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
@ -13,26 +14,28 @@ impl Overrides {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
let attr = attr.parse_meta()?;
|
|
||||||
|
|
||||||
if !attr.path().is_ident("postgres") {
|
if !attr.path().is_ident("postgres") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let list = match attr {
|
let list = match &attr.meta {
|
||||||
Meta::List(ref list) => list,
|
Meta::List(ref list) => list,
|
||||||
bad => return Err(Error::new_spanned(bad, "expected a #[postgres(...)]")),
|
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 {
|
match item {
|
||||||
NestedMeta::Meta(Meta::NameValue(meta)) => {
|
Meta::NameValue(meta) => {
|
||||||
if !meta.path.is_ident("name") {
|
if !meta.path.is_ident("name") {
|
||||||
return Err(Error::new_spanned(&meta.path, "unknown override"));
|
return Err(Error::new_spanned(&meta.path, "unknown override"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = match &meta.lit {
|
let value = match &meta.value {
|
||||||
Lit::Str(s) => s.value(),
|
Expr::Lit(ExprLit {
|
||||||
|
lit: Lit::Str(lit), ..
|
||||||
|
}) => lit.value(),
|
||||||
bad => {
|
bad => {
|
||||||
return Err(Error::new_spanned(bad, "expected a string literal"))
|
return Err(Error::new_spanned(bad, "expected a string literal"))
|
||||||
}
|
}
|
||||||
@ -40,7 +43,7 @@ impl Overrides {
|
|||||||
|
|
||||||
overrides.name = Some(value);
|
overrides.name = Some(value);
|
||||||
}
|
}
|
||||||
NestedMeta::Meta(Meta::Path(ref path)) => {
|
Meta::Path(path) => {
|
||||||
if !path.is_ident("transparent") {
|
if !path.is_ident("transparent") {
|
||||||
return Err(Error::new_spanned(path, "unknown override"));
|
return Err(Error::new_spanned(path, "unknown override"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user