aboutsummaryrefslogtreecommitdiff
path: root/src/trait_sig.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-26 10:27:50 +0100
committerMartin Fischer <martin@push-f.com>2021-11-26 11:45:53 +0100
commitd37cf6a72e633afb10ec78bdbeec6631d601adfe (patch)
tree1db3a4b735382c65c0feed07a3328cdd059c4bd5 /src/trait_sig.rs
parent7489a3c2246e7ea2483446dd2ed3fdbfaf462c1a (diff)
return error for unused #[convert]s
Diffstat (limited to 'src/trait_sig.rs')
-rw-r--r--src/trait_sig.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/trait_sig.rs b/src/trait_sig.rs
index a1be44f..ce6f318 100644
--- a/src/trait_sig.rs
+++ b/src/trait_sig.rs
@@ -57,7 +57,7 @@ pub struct SignatureChanges {
pub fn convert_trait_signature(
signature: &mut Signature,
- type_converter: &TypeConverter,
+ type_converter: &mut TypeConverter,
) -> Result<SignatureChanges, (Span, MethodError)> {
if is_non_dispatchable(signature) {
return Err((signature.span(), MethodError::NonDispatchableMethod));
@@ -144,7 +144,7 @@ fn bounds_self_and_has_bound_sized(predicate: &WherePredicate) -> bool {
#[cfg(test)]
mod tests {
- use std::collections::HashMap;
+ use std::collections::{HashMap, HashSet};
use quote::{format_ident, quote};
use syn::{TraitItemMethod, Type};
@@ -161,6 +161,7 @@ mod tests {
collections: HashMap::new(),
trait_ident: format_ident!("test"),
type_conversions: HashMap::new(),
+ used_conversions: HashSet::new(),
}
}
@@ -172,7 +173,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Ok(SignatureChanges {
return_type: TypeTransform::NoOp,
..
@@ -194,7 +195,7 @@ mod tests {
type_converter.assoc_type_conversions.insert(ident, dest);
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &type_converter),
+ convert_trait_signature(&mut type1.sig, &mut type_converter),
Ok(SignatureChanges {
return_type: TypeTransform::Into,
..
@@ -210,7 +211,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((
_,
MethodError::Transform(TransformError::AssocTypeWithoutDestType)
@@ -226,7 +227,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -239,7 +240,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -252,7 +253,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -265,7 +266,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::NonDispatchableMethod))
));
}
@@ -278,7 +279,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -291,7 +292,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -304,7 +305,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -317,7 +318,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}
@@ -330,7 +331,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::AssocTypeInInputs))
));
}
@@ -343,7 +344,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::AssocTypeInInputs))
));
}
@@ -356,7 +357,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::ImplTraitInInputs))
));
}
@@ -369,7 +370,7 @@ mod tests {
.unwrap();
assert!(matches!(
- convert_trait_signature(&mut type1.sig, &test_converter()),
+ convert_trait_signature(&mut type1.sig, &mut test_converter()),
Err((_, MethodError::Transform(TransformError::UnsupportedType)))
));
}