22#[ path = "impls_tests.rs" ]
33mod impls_tests;
44
5- use syn:: { Attribute , ImplItem , ImplItemFn , ReturnType , Visibility , parse_quote} ;
5+ use syn:: {
6+ Attribute , Error , ImplItem , ImplItemFn , ItemImpl , Result , ReturnType , Visibility , parse_quote,
7+ } ;
68
79use crate :: {
810 DataSpec , Spec ,
@@ -11,11 +13,7 @@ use crate::{
1113
1214impl Mode {
1315 /// Expand impl items.
14- pub fn instrument_impl (
15- & self ,
16- spec : DataSpec ,
17- mut the_impl : syn:: ItemImpl ,
18- ) -> syn:: Result < syn:: ItemImpl > {
16+ pub fn instrument_impl ( & self , spec : DataSpec , mut the_impl : ItemImpl ) -> Result < ItemImpl > {
1917 if the_impl. trait_ . is_some ( ) {
2018 return Err ( make_item_error ( & the_impl, "trait impl" ) ) ;
2119 } ;
@@ -33,7 +31,7 @@ impl Mode {
3331 item_fn. attrs = func_attrs;
3432
3533 if item_fn. sig . ident . to_string ( ) . starts_with ( "__anodized_" ) {
36- return Err ( syn :: Error :: new_spanned (
34+ return Err ( Error :: new_spanned (
3735 item_fn. sig . ident ,
3836 r#"An item with the `__anodized_` prefix is internal. Do not implement it directly.
3937Instead, ensure that both the impl block and the fn have a `#[spec]` annotation."# ,
@@ -102,7 +100,7 @@ Instead, ensure that both the impl block and the fn have a `#[spec]` annotation.
102100 // Build a wrapper that forwards to the "split" function.
103101 let mut wrapper_fn = item_fn. clone ( ) ;
104102 let mangled_ident =
105- Self :: build_split_fn ( false , & mut wrapper_fn. sig , & mut wrapper_fn. block ) ;
103+ Self :: build_split_fn ( true , & mut wrapper_fn. sig , & mut wrapper_fn. block ) ;
106104 new_items. push ( ImplItem :: Fn ( wrapper_fn) ) ;
107105
108106 // "Split" the original function by mangling its return type.
@@ -122,23 +120,23 @@ Instead, ensure that both the impl block and the fn have a `#[spec]` annotation.
122120 ImplItem :: Const ( mut const_item) => {
123121 let ( spec, attrs) = find_spec_attr ( const_item. attrs ) ?;
124122 if let Some ( ref spec_attr) = spec {
125- return Err ( make_item_error ( & spec_attr, "trait impl const" ) ) ;
123+ return Err ( make_item_error ( & spec_attr, "impl const" ) ) ;
126124 }
127125 const_item. attrs = attrs;
128126 new_items. push ( ImplItem :: Const ( const_item) ) ;
129127 }
130128 ImplItem :: Type ( mut type_item) => {
131129 let ( spec, attrs) = find_spec_attr ( type_item. attrs ) ?;
132130 if let Some ( ref spec_attr) = spec {
133- return Err ( make_item_error ( & spec_attr, "trait impl type" ) ) ;
131+ return Err ( make_item_error ( & spec_attr, "impl type" ) ) ;
134132 }
135133 type_item. attrs = attrs;
136134 new_items. push ( ImplItem :: Type ( type_item) ) ;
137135 }
138136 ImplItem :: Macro ( mut macro_item) => {
139137 let ( spec, attrs) = find_spec_attr ( macro_item. attrs ) ?;
140138 if let Some ( ref spec_attr) = spec {
141- return Err ( make_item_error ( & spec_attr, "trait impl macro" ) ) ;
139+ return Err ( make_item_error ( & spec_attr, "impl macro" ) ) ;
142140 }
143141 macro_item. attrs = attrs;
144142 new_items. push ( ImplItem :: Macro ( macro_item) ) ;
0 commit comments