aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 785827a..73ae723 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -97,6 +97,7 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
assoc_type_conversions: HashMap::new(),
collections: method_attrs.collections,
type_conversions: method_attrs.type_conversions,
+ used_conversions: Default::default(),
};
for item in &original_trait.items {
@@ -127,7 +128,7 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
if let TraitItem::Method(method) = item {
let mut signature = method.sig.clone();
- match convert_trait_signature(&mut signature, &type_converter) {
+ match convert_trait_signature(&mut signature, &mut type_converter) {
Ok(parsed_method) => objectifiable_methods.push((signature, parsed_method)),
Err((span, err)) => match err {
MethodError::NonDispatchableMethod => continue,
@@ -181,6 +182,13 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
}
}
+ for ty in type_converter.type_conversions.keys() {
+ if !type_converter.used_conversions.contains(ty) {
+ // FUTURE: relax to warning once proc_macro::Diagnostic is stable
+ return abort!(ty.span(), "unused conversion");
+ }
+ }
+
let mut method_impls: Vec<ImplItemMethod> = Vec::new();
let mut dyn_trait = ItemTrait {