aboutsummaryrefslogtreecommitdiff
path: root/src/trait_sig.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-25 13:48:26 +0100
committerMartin Fischer <martin@push-f.com>2021-11-25 13:48:46 +0100
commit8046190e8f537407210fb87acbfe96d4084d58da (patch)
tree34c093627f5fd75db82cb8fb48402b82ace7d803 /src/trait_sig.rs
parent74a29b912aaa14dbeb7e5c51ae11c61e733ef645 (diff)
support Self qualified as same trait
Diffstat (limited to 'src/trait_sig.rs')
-rw-r--r--src/trait_sig.rs40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/trait_sig.rs b/src/trait_sig.rs
index 3fb439f..5d8eddf 100644
--- a/src/trait_sig.rs
+++ b/src/trait_sig.rs
@@ -140,6 +140,8 @@ fn bounds_self_and_has_bound_sized(predicate: &WherePredicate) -> bool {
#[cfg(test)]
mod tests {
+ use std::collections::HashMap;
+
use quote::{format_ident, quote};
use syn::{TraitItemMethod, Type};
@@ -149,6 +151,14 @@ mod tests {
transform::{TransformError, TypeConverter},
};
+ fn test_converter() -> TypeConverter<'static> {
+ TypeConverter {
+ assoc_type_conversions: HashMap::new(),
+ collections: HashMap::new(),
+ trait_ident: format_ident!("test"),
+ }
+ }
+
#[test]
fn ok_void() {
let mut type1: TraitItemMethod = syn::parse2(quote! {
@@ -157,7 +167,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Ok(SignatureChanges {
return_type: TypeTransform::NoOp,
..
@@ -172,7 +182,7 @@ mod tests {
})
.unwrap();
- let mut type_converter = TypeConverter::default();
+ let mut type_converter = test_converter();
let ident = format_ident!("A");
let dest_inner = Type::Verbatim(quote! {Example});
let dest = DestType::Into(&dest_inner);
@@ -195,7 +205,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((
_,
MethodError::Transform(TransformError::AssocTypeWithoutDestType)
@@ -211,7 +221,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -224,7 +234,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -237,7 +247,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -250,7 +260,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -263,7 +273,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -276,7 +286,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -289,7 +299,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -302,7 +312,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -315,7 +325,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::AssocTypeInInputs))
));
}
@@ -328,7 +338,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::AssocTypeInInputs))
));
}
@@ -341,7 +351,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::ImplTraitInInputs))
));
}
@@ -354,7 +364,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &Default::default()),
+ convert_trait_signature(&mut type1.sig, &test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}