fix failing tests

This commit is contained in:
Max Känner 2024-08-16 18:44:04 +02:00
parent aa1b8d9272
commit 10d0750678

View File

@ -102,7 +102,7 @@ impl ConfigField {
impl #ident { impl #ident {
pub fn new(value: #ty) -> Option<Self> { pub fn new(value: #ty) -> Option<Self> {
if (#min..=#max).contains(&value) { if (#min..=#max).contains(&value) {
Self(value) Some(Self(value))
} else { } else {
None None
} }
@ -165,7 +165,7 @@ impl ConfigField {
let conversion = if self.has_custom_limits() { let conversion = if self.has_custom_limits() {
quote! { quote! {
Self::new(value).ok_or_else(|| { Self::new(value).ok_or_else(|| {
<D:Error as ::serde::de::Error>::custom("checking value bounds") <D::Error as ::serde::de::Error>::custom("checking value bounds")
}) })
} }
} else { } else {
@ -213,8 +213,8 @@ impl ConfigField {
(stringify!($field), (stringify!($field),
value.clone().explicit().map(|val| { value.clone().explicit().map(|val| {
parse_quote!({ parse_quote!({
let val: #ty = #val; fn type_ascribe(val: #ty) -> #ty {val}
val type_ascribe(#val)
}) })
}).unwrap_or_else(|| { }).unwrap_or_else(|| {
parse_quote!(#ty::$default) parse_quote!(#ty::$default)
@ -290,7 +290,7 @@ impl ConfigField {
.enumerate() .enumerate()
.map(|(i, (_, expr))| { .map(|(i, (_, expr))| {
quote! { quote! {
#i => #expr.serialize(ser).map_err(|err| ::miniconf::Error::Inner(0, err)), #i => ::serde::Serialize::serialize(&#expr, ser).map_err(|err| ::miniconf::Error::Inner(0, err)),
} }
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -307,7 +307,7 @@ impl ConfigField {
S: ::serde::Serializer, S: ::serde::Serializer,
{ {
let ::core::result::Result::Ok(key) = keys.next::<Self>() else { let ::core::result::Result::Ok(key) = keys.next::<Self>() else {
return self.serialize(ser).map_err(|err| ::miniconf::Error::Inner(1, err)).map(|_| 1); return ::serde::Serialize::serialize(&self, ser).map_err(|err| ::miniconf::Error::Inner(1, err)).map(|_| 1);
}; };
let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?; let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?;
if !keys.finalize() { if !keys.finalize() {
@ -338,7 +338,7 @@ impl ConfigField {
D: ::serde::Deserializer<'de>, D: ::serde::Deserializer<'de>,
{ {
let ::core::result::Result::Ok(key) = keys.next::<Self>() else { let ::core::result::Result::Ok(key) = keys.next::<Self>() else {
*self = Self::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?; *self = <Self as ::serde::Deserialize>::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?;
return ::core::result::Result::Ok(0); return ::core::result::Result::Ok(0);
}; };
let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?; let index = ::miniconf::Key::find::<Self>(&key).ok_or(::miniconf::Traversal::NotFound(1))?;
@ -347,7 +347,7 @@ impl ConfigField {
} }
match index { match index {
0 => { 0 => {
*self = Self::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?; *self = <Self as ::serde::Deserialize>::deserialize(de).map_err(|err| ::miniconf::Error::Inner(0, err))?;
Ok(0) Ok(0)
} }
, ,