diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-22 10:53:43 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-22 10:53:43 +0100 |
commit | 8178b4671b03a9c7d4dbe6c4ce66b9cb737c4e2d (patch) | |
tree | 7ffa56d4b74acacc35f6de6b9eea141643e51ce8 | |
parent | ad16a3e0ff064886a807c3c03610588f95943e2d (diff) |
rename AssocTypeError variants
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | src/parse_assoc_type.rs | 15 |
2 files changed, 11 insertions, 8 deletions
@@ -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)) )); } |