1- use std:: { fmt:: { Display , Write } , mem} ;
1+ use std:: fmt:: { Display , Write } ;
2+ use std:: mem;
23
34use proc_macro2:: { Group , Ident , Span , TokenStream , TokenTree } ;
45use proc_macro_utils:: { Delimited , TokenStream2Ext , TokenStreamExt , TokenTree2Ext , TokenTreePunct } ;
@@ -82,7 +83,7 @@ impl Display for Param {
8283 }
8384}
8485
85- /// Attribute macro to remove boiler plate from proc macro entry points.
86+ /// Attribute macro to remove boilerplate from proc macro entry points.
8687///
8788/// See [the documentation at the crate root for more
8889/// details](https://docs.rs/manyhow#using-the-manyhow-macro).
@@ -193,7 +194,7 @@ pub fn manyhow(
193194 let flags_replace = |i : usize , replacement : Option < & str > | {
194195 let mut flags = flags. iter ( ) . map ( ToString :: to_string) . collect :: < Vec < _ > > ( ) ;
195196 if let Some ( replacement) = replacement {
196- flags[ i] = replacement . to_owned ( ) ;
197+ replacement . clone_into ( & mut flags[ i] ) ;
197198 } else {
198199 flags. remove ( i) ;
199200 }
@@ -292,7 +293,7 @@ pub fn manyhow(
292293 . last ( )
293294 . expect ( "use statement should contain at least on item" ) ;
294295
295- let Some ( fn_name) = fn_name. ident ( ) else {
296+ let Some ( mut fn_name) = fn_name. ident ( ) . cloned ( ) else {
296297 return with_helpful_error (
297298 item,
298299 fn_name. span ( ) ,
@@ -302,6 +303,8 @@ pub fn manyhow(
302303 ) ;
303304 } ;
304305
306+ fn_name. set_span ( Span :: call_site ( ) ) ;
307+
305308 quote ! ( fn #fn_name) . to_tokens ( & mut output) ;
306309 impl_fn_path = path. into_iter ( ) . collect ( ) ;
307310
0 commit comments