aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-22 11:35:39 +0100
committerMartin Fischer <martin@push-f.com>2021-11-22 11:35:39 +0100
commit5c6f0d3510517d867c27e9a658e5015fb9b3d5ef (patch)
tree84d4c35dfa2aa2c7352693e4006a846b4e9b5695 /src/transform.rs
parentf4419ca138a5307a705decf70683414296dcf116 (diff)
refactor: move Span out of TransformError enum
Diffstat (limited to 'src/transform.rs')
-rw-r--r--src/transform.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/transform.rs b/src/transform.rs
index 7fd3672..13cf519 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -20,8 +20,8 @@ pub struct TypeConverter<'a> {
}
pub enum TransformError {
- AssocTypeWithoutDestType(Span),
- UnsupportedType(Span),
+ AssocTypeWithoutDestType,
+ UnsupportedType,
}
impl TypeConverter<'_> {
@@ -44,7 +44,7 @@ impl TypeConverter<'_> {
ident == "HashMap" || ident == "BTreeMap"
}
- pub fn convert_type(&self, type_: &mut Type) -> Result<TypeTransform, TransformError> {
+ pub fn convert_type(&self, type_: &mut Type) -> Result<TypeTransform, (Span, TransformError)> {
if !iter_type(type_).any(match_assoc_type) {
return Ok(TypeTransform::NoOp);
}
@@ -101,7 +101,7 @@ impl TypeConverter<'_> {
let dest_type = self
.assoc_type_conversions
.get(ident)
- .ok_or_else(|| TransformError::AssocTypeWithoutDestType(ident.span()))?;
+ .ok_or_else(|| (ident.span(), TransformError::AssocTypeWithoutDestType))?;
*type_ = dest_type.get_dest();
return Ok(dest_type.type_transformation());
}
@@ -154,7 +154,7 @@ impl TypeConverter<'_> {
// the type contains an associated type but we
// don't know how to deal with it so we abort
- Err(TransformError::UnsupportedType(type_.span()))
+ Err((type_.span(), TransformError::UnsupportedType))
}
}
@@ -237,10 +237,10 @@ fn dynamize_trait_bound(
Ok(ret_type) => {
transforms.push(ret_type);
}
- Err(TransformError::AssocTypeWithoutDestType(span)) => {
+ Err((span, TransformError::AssocTypeWithoutDestType)) => {
return Err((span, MethodError::AssocTypeWithoutDestType));
}
- Err(TransformError::UnsupportedType(span)) => {
+ Err((span, TransformError::UnsupportedType)) => {
return Err((span, MethodError::UnsupportedType));
}
}