aboutsummaryrefslogtreecommitdiff
path: root/src/parse_trait_sig.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-22 11:05:13 +0100
committerMartin Fischer <martin@push-f.com>2021-11-22 11:05:13 +0100
commit6b01f08fa1de6d67ab47ad19493ea683a75fc2ed (patch)
tree2edcd1e6cae887e7394dd95ea94666fbf62c0005 /src/parse_trait_sig.rs
parent8178b4671b03a9c7d4dbe6c4ce66b9cb737c4e2d (diff)
rename MethodParseError to MethodError
Diffstat (limited to 'src/parse_trait_sig.rs')
-rw-r--r--src/parse_trait_sig.rs44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/parse_trait_sig.rs b/src/parse_trait_sig.rs
index 29b3205..9542a69 100644
--- a/src/parse_trait_sig.rs
+++ b/src/parse_trait_sig.rs
@@ -23,7 +23,7 @@ pub enum TypeTransform {
}
#[derive(Debug)]
-pub enum MethodParseError {
+pub enum MethodError {
NonDispatchableMethod,
AssocTypeInInputs,
ImplTraitInInputs,
@@ -49,19 +49,19 @@ pub struct SignatureChanges {
pub fn parse_trait_signature(
signature: &mut Signature,
type_converter: &TypeConverter,
-) -> Result<SignatureChanges, (Span, MethodParseError)> {
+) -> Result<SignatureChanges, (Span, MethodError)> {
if is_non_dispatchable(signature) {
- return Err((signature.span(), MethodParseError::NonDispatchableMethod));
+ return Err((signature.span(), MethodError::NonDispatchableMethod));
}
// provide better error messages for associated types in params
for input in &signature.inputs {
if let FnArg::Typed(pattype) = input {
if iter_type(&pattype.ty).any(match_assoc_type) {
- return Err((pattype.ty.span(), MethodParseError::AssocTypeInInputs));
+ return Err((pattype.ty.span(), MethodError::AssocTypeInInputs));
}
if let Some(impl_trait) = iter_type(&pattype.ty).find_map(filter_map_impl_trait) {
- return Err((impl_trait.span(), MethodParseError::ImplTraitInInputs));
+ return Err((impl_trait.span(), MethodError::ImplTraitInInputs));
}
}
}
@@ -72,10 +72,10 @@ pub fn parse_trait_signature(
ReturnType::Type(_, og_type) => match type_converter.convert_type(og_type) {
Ok(ret_type) => ret_type,
Err(TransformError::UnconvertibleAssocType(span)) => {
- return Err((span, MethodParseError::UnconvertibleAssocType));
+ return Err((span, MethodError::UnconvertibleAssocType));
}
Err(TransformError::AssocTypeInUnsupportedType(span)) => {
- return Err((span, MethodParseError::AssocTypeInUnsupportedReturnType));
+ return Err((span, MethodError::AssocTypeInUnsupportedReturnType));
}
},
ReturnType::Default => TypeTransform::NoOp,
@@ -142,9 +142,7 @@ mod tests {
use crate::{
parse_assoc_type::DestType,
- parse_trait_sig::{
- parse_trait_signature, MethodParseError, SignatureChanges, TypeTransform,
- },
+ parse_trait_sig::{parse_trait_signature, MethodError, SignatureChanges, TypeTransform},
transform::TypeConverter,
};
@@ -195,7 +193,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::UnconvertibleAssocType))
+ Err((_, MethodError::UnconvertibleAssocType))
));
}
@@ -208,7 +206,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::NonDispatchableMethod))
+ Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -221,7 +219,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::NonDispatchableMethod))
+ Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -234,7 +232,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::NonDispatchableMethod))
+ Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -247,7 +245,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::NonDispatchableMethod))
+ Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -260,7 +258,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::AssocTypeInUnsupportedReturnType))
+ Err((_, MethodError::AssocTypeInUnsupportedReturnType))
));
}
@@ -273,7 +271,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::AssocTypeInUnsupportedReturnType))
+ Err((_, MethodError::AssocTypeInUnsupportedReturnType))
));
}
@@ -286,7 +284,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::AssocTypeInUnsupportedReturnType))
+ Err((_, MethodError::AssocTypeInUnsupportedReturnType))
));
}
@@ -299,7 +297,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::AssocTypeInUnsupportedReturnType))
+ Err((_, MethodError::AssocTypeInUnsupportedReturnType))
));
}
@@ -312,7 +310,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::AssocTypeInInputs))
+ Err((_, MethodError::AssocTypeInInputs))
));
}
@@ -325,7 +323,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::AssocTypeInInputs))
+ Err((_, MethodError::AssocTypeInInputs))
));
}
@@ -338,7 +336,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::ImplTraitInInputs))
+ Err((_, MethodError::ImplTraitInInputs))
));
}
@@ -351,7 +349,7 @@ mod tests {
assert!(matches!(
parse_trait_signature(&mut type1.sig, &Default::default()),
- Err((_, MethodParseError::UnconvertibleAssocTypeInFnInput))
+ Err((_, MethodError::UnconvertibleAssocTypeInFnInput))
));
}
}