aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-22 10:50:14 +0100
committerMartin Fischer <martin@push-f.com>2021-11-22 10:51:24 +0100
commitad16a3e0ff064886a807c3c03610588f95943e2d (patch)
tree55606e868fa3c80350b2f1b0d56c30a7ca9ea49a
parentfa9d689238064784e5ad220ba9e0c95fad71fe66 (diff)
rename AssocTypeParseError to AssocTypeError
-rw-r--r--src/lib.rs8
-rw-r--r--src/parse_assoc_type.rs20
2 files changed, 14 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index caaf774..0b50546 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -37,7 +37,7 @@ use syn::Visibility;
use syn_utils::TypeOrPath;
use crate::parse_assoc_type::parse_assoc_type;
-use crate::parse_assoc_type::AssocTypeParseError;
+use crate::parse_assoc_type::AssocTypeError;
use crate::parse_trait_sig::parse_trait_signature;
use crate::parse_trait_sig::MethodParseError;
use crate::parse_trait_sig::SignatureChanges;
@@ -71,11 +71,11 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
for item in &original_trait.items {
if let TraitItem::Type(assoc_type) = item {
match parse_assoc_type(assoc_type) {
- Err((_, AssocTypeParseError::NoIntoBound)) => continue,
- Err((span, AssocTypeParseError::AssocTypeInBound)) => {
+ Err((_, AssocTypeError::NoIntoBound)) => continue,
+ Err((span, AssocTypeError::AssocTypeInBound)) => {
return abort!(span, "dynamize does not support associated types here")
}
- Err((span, AssocTypeParseError::GenericAssociatedType)) => {
+ Err((span, AssocTypeError::GenericAssociatedType)) => {
return abort!(
span,
"dynamize does not (yet?) support generic associated types"
diff --git a/src/parse_assoc_type.rs b/src/parse_assoc_type.rs
index 5bc86cb..df89a47 100644
--- a/src/parse_assoc_type.rs
+++ b/src/parse_assoc_type.rs
@@ -8,7 +8,7 @@ use crate::parse_trait_sig::TypeTransform;
use crate::syn_utils::{iter_type, lifetime_bounds, trait_bounds};
#[derive(Debug)]
-pub enum AssocTypeParseError {
+pub enum AssocTypeError {
AssocTypeInBound,
GenericAssociatedType,
NoIntoBound,
@@ -53,7 +53,7 @@ impl DestType<'_> {
pub fn parse_assoc_type(
assoc_type: &TraitItemType,
-) -> Result<(&Ident, DestType), (Span, AssocTypeParseError)> {
+) -> Result<(&Ident, DestType), (Span, AssocTypeError)> {
if let Some(bound) = trait_bounds(&assoc_type.bounds).next() {
if let PathSegment {
ident,
@@ -64,14 +64,14 @@ pub fn parse_assoc_type(
if let GenericArgument::Type(into_type) = &args.args[0] {
// provide a better error message for type A: Into<Self::B>
if iter_type(into_type).any(match_assoc_type) {
- return Err((into_type.span(), AssocTypeParseError::AssocTypeInBound));
+ return Err((into_type.span(), AssocTypeError::AssocTypeInBound));
}
// TODO: support lifetime GATs (see the currently failing tests/gats.rs)
if !assoc_type.generics.params.is_empty() {
return Err((
assoc_type.generics.params.span(),
- AssocTypeParseError::GenericAssociatedType,
+ AssocTypeError::GenericAssociatedType,
));
}
@@ -89,7 +89,7 @@ pub fn parse_assoc_type(
}),
));
}
- Err((assoc_type.span(), AssocTypeParseError::NoIntoBound))
+ Err((assoc_type.span(), AssocTypeError::NoIntoBound))
}
#[cfg(test)]
@@ -97,7 +97,7 @@ mod tests {
use quote::quote;
use syn::{TraitItemType, Type};
- use crate::parse_assoc_type::{parse_assoc_type, AssocTypeParseError, DestType};
+ use crate::parse_assoc_type::{parse_assoc_type, AssocTypeError, DestType};
#[test]
fn ok() {
@@ -122,7 +122,7 @@ mod tests {
assert!(matches!(
parse_assoc_type(&type1),
- Err((_, AssocTypeParseError::NoIntoBound))
+ Err((_, AssocTypeError::NoIntoBound))
));
}
@@ -135,7 +135,7 @@ mod tests {
assert!(matches!(
parse_assoc_type(&type1),
- Err((_, AssocTypeParseError::AssocTypeInBound))
+ Err((_, AssocTypeError::AssocTypeInBound))
));
}
@@ -148,7 +148,7 @@ mod tests {
assert!(matches!(
parse_assoc_type(&type1),
- Err((_, AssocTypeParseError::GenericAssociatedType))
+ Err((_, AssocTypeError::GenericAssociatedType))
));
}
@@ -161,7 +161,7 @@ mod tests {
assert!(matches!(
parse_assoc_type(&type1),
- Err((_, AssocTypeParseError::GenericAssociatedType))
+ Err((_, AssocTypeError::GenericAssociatedType))
));
}
}