aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-22 10:53:43 +0100
committerMartin Fischer <martin@push-f.com>2021-11-22 10:53:43 +0100
commit8178b4671b03a9c7d4dbe6c4ce66b9cb737c4e2d (patch)
tree7ffa56d4b74acacc35f6de6b9eea141643e51ce8 /src
parentad16a3e0ff064886a807c3c03610588f95943e2d (diff)
rename AssocTypeError variants
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs4
-rw-r--r--src/parse_assoc_type.rs15
2 files changed, 11 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0b50546..fbd32ec 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -71,8 +71,8 @@ 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((_, AssocTypeError::NoIntoBound)) => continue,
- Err((span, AssocTypeError::AssocTypeInBound)) => {
+ Err((_, AssocTypeError::NoTraitBound)) => continue,
+ Err((span, AssocTypeError::TraitBoundContainsAssocType)) => {
return abort!(span, "dynamize does not support associated types here")
}
Err((span, AssocTypeError::GenericAssociatedType)) => {
diff --git a/src/parse_assoc_type.rs b/src/parse_assoc_type.rs
index df89a47..a02e06c 100644
--- a/src/parse_assoc_type.rs
+++ b/src/parse_assoc_type.rs
@@ -9,9 +9,9 @@ use crate::syn_utils::{iter_type, lifetime_bounds, trait_bounds};
#[derive(Debug)]
pub enum AssocTypeError {
- AssocTypeInBound,
+ NoTraitBound,
+ TraitBoundContainsAssocType,
GenericAssociatedType,
- NoIntoBound,
}
#[derive(Debug, Clone)]
@@ -64,7 +64,10 @@ 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(), AssocTypeError::AssocTypeInBound));
+ return Err((
+ into_type.span(),
+ AssocTypeError::TraitBoundContainsAssocType,
+ ));
}
// TODO: support lifetime GATs (see the currently failing tests/gats.rs)
@@ -89,7 +92,7 @@ pub fn parse_assoc_type(
}),
));
}
- Err((assoc_type.span(), AssocTypeError::NoIntoBound))
+ Err((assoc_type.span(), AssocTypeError::NoTraitBound))
}
#[cfg(test)]
@@ -122,7 +125,7 @@ mod tests {
assert!(matches!(
parse_assoc_type(&type1),
- Err((_, AssocTypeError::NoIntoBound))
+ Err((_, AssocTypeError::NoTraitBound))
));
}
@@ -135,7 +138,7 @@ mod tests {
assert!(matches!(
parse_assoc_type(&type1),
- Err((_, AssocTypeError::AssocTypeInBound))
+ Err((_, AssocTypeError::TraitBoundContainsAssocType))
));
}