aboutsummaryrefslogtreecommitdiff
path: root/src/transform.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-22 11:31:48 +0100
committerMartin Fischer <martin@push-f.com>2021-11-22 11:31:48 +0100
commitf4419ca138a5307a705decf70683414296dcf116 (patch)
treef4bb6cd5f66894d3507333402fa1b8f8e24a7870 /src/transform.rs
parent6b01f08fa1de6d67ab47ad19493ea683a75fc2ed (diff)
simplify MethodError variants
Diffstat (limited to 'src/transform.rs')
-rw-r--r--src/transform.rs28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/transform.rs b/src/transform.rs
index cf18456..7fd3672 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -20,8 +20,8 @@ pub struct TypeConverter<'a> {
}
pub enum TransformError {
- UnconvertibleAssocType(Span),
- AssocTypeInUnsupportedType(Span),
+ AssocTypeWithoutDestType(Span),
+ UnsupportedType(Span),
}
impl TypeConverter<'_> {
@@ -101,7 +101,7 @@ impl TypeConverter<'_> {
let dest_type = self
.assoc_type_conversions
.get(ident)
- .ok_or_else(|| TransformError::UnconvertibleAssocType(ident.span()))?;
+ .ok_or_else(|| TransformError::AssocTypeWithoutDestType(ident.span()))?;
*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::AssocTypeInUnsupportedType(type_.span()))
+ Err(TransformError::UnsupportedType(type_.span()))
}
}
@@ -200,10 +200,7 @@ pub fn dynamize_function_bounds(
if let Some(assoc_type) =
iter_type(&predicate_type.bounded_ty).find_map(filter_map_assoc_paths)
{
- return Err((
- assoc_type.span(),
- MethodError::UnconvertibleAssocTypeInWhereClause,
- ));
+ return Err((assoc_type.span(), MethodError::UnconvertedAssocType));
}
// just to provide better error messages
@@ -212,10 +209,7 @@ pub fn dynamize_function_bounds(
if let Some(assoc_type) =
iter_path(&bound.path).find_map(filter_map_assoc_paths)
{
- return Err((
- assoc_type.span(),
- MethodError::UnconvertibleAssocTypeInWhereClause,
- ));
+ return Err((assoc_type.span(), MethodError::UnconvertedAssocType));
}
}
}
@@ -243,11 +237,11 @@ fn dynamize_trait_bound(
Ok(ret_type) => {
transforms.push(ret_type);
}
- Err(TransformError::UnconvertibleAssocType(span)) => {
- return Err((span, MethodError::UnconvertibleAssocType));
+ Err(TransformError::AssocTypeWithoutDestType(span)) => {
+ return Err((span, MethodError::AssocTypeWithoutDestType));
}
- Err(TransformError::AssocTypeInUnsupportedType(span)) => {
- return Err((span, MethodError::UnconvertibleAssocTypeInFnInput));
+ Err(TransformError::UnsupportedType(span)) => {
+ return Err((span, MethodError::UnsupportedType));
}
}
}
@@ -261,7 +255,7 @@ fn dynamize_trait_bound(
.filter_map(filter_map_assoc_paths)
.next()
{
- return Err((path.span(), MethodError::UnconvertibleAssocTypeInTraitBound));
+ return Err((path.span(), MethodError::UnconvertedAssocType));
}
Ok(())
}