Skip to content

Commit 7cf87a5

Browse files
authored
Merge pull request #131 from blackbeam/fix-derive-result
derive: fix unqualified `Result` in generated code
2 parents 9a37f10 + 463a99e commit 7cf87a5

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

derive/src/from_row/structs/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,10 @@ impl ToTokens for GenericStruct<'_> {
216216
let ty = &f.ty;
217217
if attrs.json {
218218
quote::quote!(#ident: #ident.commit().0)
219+
} else if attrs.with.is_some() {
220+
quote::quote!( #ident )
219221
} else {
220-
if attrs.with.is_some() {
221-
quote::quote!( #ident )
222-
} else {
223-
quote::quote!(#ident: <<#ty as FromValue>::Intermediate as std::convert::Into<#ty>>::into(#ident))
224-
}
222+
quote::quote!(#ident: <<#ty as FromValue>::Intermediate as std::convert::Into<#ty>>::into(#ident))
225223
}
226224
})
227225
.collect::<Vec<_>>();

derive/src/from_value/enums/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl ToTokens for Enum {
333333
impl std::convert::TryFrom<#crat::Value> for #ir_name {
334334
type Error = #crat::FromValueError;
335335

336-
fn try_from(v: #crat::Value) -> Result<Self, Self::Error> {
336+
fn try_from(v: #crat::Value) -> std::result::Result<Self, Self::Error> {
337337
match v {
338338
#( #branches )*
339339
v => Err(#crat::FromValueError(v)),

derive/src/from_value/structs/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl ToTokens for NewTypeNoGenerics<'_> {
128128
impl std::convert::TryFrom<#crat::Value> for #ir_name {
129129
type Error = #crat::FromValueError;
130130

131-
fn try_from(v: #crat::Value) -> Result<Self, Self::Error> {
131+
fn try_from(v: #crat::Value) -> std::result::Result<Self, Self::Error> {
132132
#path(v).map(Self)
133133
}
134134
}
@@ -162,7 +162,7 @@ impl ToTokens for NewTypeNoGenerics<'_> {
162162
impl TryFrom<Value> for #ir_name<#field_type> {
163163
type Error = <<#field_type as FromValue>::Intermediate as TryFrom<Value>>::Error;
164164

165-
fn try_from(value: Value) -> Result<Self, Self::Error> {
165+
fn try_from(value: Value) -> std::result::Result<Self, Self::Error> {
166166
<#field_type as FromValue>::Intermediate::try_from(value).map(Self)
167167
}
168168
}
@@ -279,7 +279,7 @@ impl ToTokens for NewType<'_> {
279279
where #additional_bounds {
280280
type Error = #crat::FromValueError;
281281

282-
fn try_from(v: #crat::Value) -> Result<Self, Self::Error> {
282+
fn try_from(v: #crat::Value) -> std::result::Result<Self, Self::Error> {
283283
#path(v)
284284
}
285285
}
@@ -305,7 +305,7 @@ impl ToTokens for NewType<'_> {
305305
{
306306
type Error = <<#field_type as #crat::prelude::FromValue>::Intermediate as std::convert::TryFrom<#crat::Value>>::Error;
307307

308-
fn try_from(value: #crat::Value) -> Result<Self, Self::Error> {
308+
fn try_from(value: #crat::Value) -> std::result::Result<Self, Self::Error> {
309309
<#field_type as #crat::prelude::FromValue>::Intermediate::try_from(value).map(Self)
310310
}
311311
}

0 commit comments

Comments
 (0)