@@ -65,7 +65,7 @@ pub fn script_bind(args: TokenStream, input: TokenStream) -> TokenStream {
6565 if meta_list. iter ( ) . any ( |meta| match meta {
6666 Meta :: Path ( path) => {
6767 path. segments . len ( ) == 1 &&
68- path. segments . first ( ) . unwrap ( ) . ident . to_string ( ) == UNIV_ARG_IGNORE
68+ path. segments . first ( ) . unwrap ( ) . ident == UNIV_ARG_IGNORE
6969 }
7070 _ => false ,
7171 } ) {
@@ -287,6 +287,7 @@ fn handle_struct(item: &ItemStruct, args: Vec<&Meta>) -> Result<TokenStream2, Co
287287 name: #field_name,
288288 type_serial: #field_type_serial,
289289 size: size_of:: <#field_type>( ) ,
290+ #[ allow( clippy:: clone_on_copy, clippy:: needless_borrow) ]
290291 accessor: #field_accessor_tokens,
291292 #[ allow( clippy:: clone_on_copy, clippy:: needless_borrow) ]
292293 mutator: #field_mutator_tokens,
@@ -301,7 +302,6 @@ fn handle_struct(item: &ItemStruct, args: Vec<&Meta>) -> Result<TokenStream2, Co
301302 Ok ( quote ! {
302303 #item
303304 const _: ( ) = {
304- use :: argus_scripting_bind:: Wrappable ;
305305 #ctor_dtor_proxies_tokens
306306 #script_bound_impl_tokens
307307 #wrappable_impl_tokens
@@ -313,7 +313,6 @@ fn handle_struct(item: &ItemStruct, args: Vec<&Meta>) -> Result<TokenStream2, Co
313313 Ok ( quote ! {
314314 #item
315315 const _: ( ) = {
316- use :: argus_scripting_bind:: Wrappable ;
317316 #script_bound_impl_tokens
318317 #register_struct_tokens
319318 #( #field_regs) *
@@ -483,7 +482,6 @@ fn handle_enum(item: &ItemEnum, args: Vec<&Meta>) -> Result<TokenStream2, Compil
483482 Ok ( quote ! {
484483 #item
485484 const _: ( ) = {
486- use :: argus_scripting_bind:: Wrappable ;
487485 #script_bound_impl_tokens
488486 #wrappable_impl_tokens
489487 const _: ( ) = {
@@ -632,9 +630,9 @@ fn gen_fn_binding_code(
632630 Type :: Path ( assoc_type. expect ( "Associated type was missing" ) . clone ( ) ) ;
633631 match & self_type. reference {
634632 Some ( ( and_token, lifetime) ) => Ok ( Type :: Reference ( TypeReference {
635- and_token : and_token. clone ( ) ,
633+ and_token : * and_token,
636634 lifetime : lifetime. clone ( ) ,
637- mutability : self_type. mutability . clone ( ) ,
635+ mutability : self_type. mutability ,
638636 elem : Box :: new ( assoc_type_path) ,
639637 } ) ) ,
640638 None => Ok ( assoc_type_path) ,
@@ -649,7 +647,7 @@ fn gen_fn_binding_code(
649647 Vec < ( ObjectType , Vec < Type > ) > =
650648 param_types. iter ( )
651649 . map ( |ty| {
652- parse_type ( & ty, ValueFlowDirection :: FromScript )
650+ parse_type ( ty, ValueFlowDirection :: FromScript )
653651 } )
654652 . collect :: < Result < _ , _ > > ( ) ?;
655653
@@ -684,7 +682,7 @@ fn gen_fn_binding_code(
684682 for i in 0 ..param_obj_types. len ( ) {
685683 let syn_type = & param_types[ i] ;
686684 let param_type_tokens: TokenStream2 ;
687- let boxed_trait_obj_opt = try_as_boxed_trait_object ( & syn_type) ;
685+ let boxed_trait_obj_opt = try_as_boxed_trait_object ( syn_type) ;
688686 if let Some ( trait_obj) = boxed_trait_obj_opt {
689687 //TODO: only allow 1 bound (?)
690688 let Some ( paren_args) = trait_obj. bounds . iter ( ) . find_map ( |bound| match bound {
@@ -1052,9 +1050,9 @@ fn handle_impl(impl_block: &ItemImpl, _args: Vec<&Meta>) -> Result<TokenStream2,
10521050 if let Some ( pos) = f. attrs . iter ( ) . position ( |attr| {
10531051 if attr. path ( ) . segments . len ( ) != 1 { return false ; }
10541052 let seg = attr. path ( ) . segments . first ( ) . expect ( "First path segment was missing" ) ;
1055- seg. ident . to_string ( ) == ATTR_SCRIPT_BIND
1053+ seg. ident == ATTR_SCRIPT_BIND
10561054 } ) {
1057- fns_to_bind. push ( ( & f, f. attrs [ pos] . meta . clone ( ) ) ) ;
1055+ fns_to_bind. push ( ( f, f. attrs [ pos] . meta . clone ( ) ) ) ;
10581056 let mut f_clone = f. clone ( ) ;
10591057 // remove script_bind attribute since it's being handled as
10601058 // part of the impl block
@@ -1117,7 +1115,7 @@ fn handle_impl(impl_block: &ItemImpl, _args: Vec<&Meta>) -> Result<TokenStream2,
11171115}
11181116
11191117fn handle_impl_fn ( ty : & TypePath , f : & ImplItemFn , args : Meta ) -> Result < TokenStream2 , CompileError > {
1120- let fn_attr_span = args. span ( ) . clone ( ) ;
1118+ let fn_attr_span = args. span ( ) ;
11211119 let meta_list = match args {
11221120 Meta :: List ( meta_list) => {
11231121 let args_tokens = TokenStream :: from ( meta_list. tokens ) ;
@@ -1185,6 +1183,7 @@ enum ValueFlowDirection {
11851183}
11861184
11871185#[ derive( Clone , Copy , PartialEq , PartialOrd ) ]
1186+ #[ allow( unused) ]
11881187enum OuterTypeType {
11891188 None ,
11901189 Reference ,
@@ -1223,7 +1222,7 @@ fn parse_type_internal(
12231222 let ty = if let Type :: Group ( group) = ty {
12241223 group. elem . as_ref ( )
12251224 } else {
1226- & base_ty
1225+ base_ty
12271226 } ;
12281227
12291228 if let Some ( trait_obj) = try_as_boxed_trait_object ( ty) {
@@ -1258,7 +1257,7 @@ fn parse_type_internal(
12581257 } ;
12591258 let ( out_type, out_syn_types) = match & paren_args. output {
12601259 ReturnType :: Type ( _, ty) => {
1261- parse_type_internal ( & ty, flow_direction, OuterTypeType :: None ) ?
1260+ parse_type_internal ( ty, flow_direction, OuterTypeType :: None ) ?
12621261 } ,
12631262 ReturnType :: Default => ( ObjectType :: empty ( ) , vec ! [ ] ) ,
12641263 } ;
@@ -1294,32 +1293,32 @@ fn parse_type_internal(
12941293 all_syn_types,
12951294 ) )
12961295 } else if let Type :: Path ( path) = ty {
1297- if path. path . segments . len ( ) == 0 {
1296+ if path. path . segments . is_empty ( ) {
12981297 return Err ( CompileError :: new ( path. span ( ) , "Type path does not contain any segments" ) ) ;
12991298 }
13001299
13011300 let parsed_opt = first_some ! (
1302- resolve_i8( & path) ,
1303- resolve_i16( & path) ,
1304- resolve_i32( & path) ,
1305- resolve_i64( & path) ,
1306- resolve_i128( & path) ,
1307- resolve_u8( & path) ,
1308- resolve_u16( & path) ,
1309- resolve_u32( & path) ,
1310- resolve_u64( & path) ,
1311- resolve_u128( & path) ,
1312- resolve_f32( & path) ,
1313- resolve_f64( & path) ,
1314- resolve_bool( & path) ,
1315- resolve_string( & path) ,
1301+ resolve_i8( path) ,
1302+ resolve_i16( path) ,
1303+ resolve_i32( path) ,
1304+ resolve_i64( path) ,
1305+ resolve_i128( path) ,
1306+ resolve_u8( path) ,
1307+ resolve_u16( path) ,
1308+ resolve_u32( path) ,
1309+ resolve_u64( path) ,
1310+ resolve_u128( path) ,
1311+ resolve_f32( path) ,
1312+ resolve_f64( path) ,
1313+ resolve_bool( path) ,
1314+ resolve_string( path) ,
13161315 ) ;
13171316
13181317 if let Some ( res) = parsed_opt {
13191318 return Ok ( ( res, vec ! [ ] ) ) ;
13201319 }
13211320
1322- if let Some ( res) = resolve_vec ( & path, flow_direction) ? {
1321+ if let Some ( res) = resolve_vec ( path, flow_direction) ? {
13231322 if outer_type != OuterTypeType :: None &&
13241323 outer_type != OuterTypeType :: Reference {
13251324 return Err ( CompileError :: new ( path. span ( ) , "Vec may not be used as an inner type" ) ) ;
@@ -1329,22 +1328,22 @@ fn parse_type_internal(
13291328 return Ok ( ( res. 0 , resolved_inner_type) ) ;
13301329 }
13311330
1332- if let Some ( res) = resolve_result ( & path, flow_direction) ? {
1331+ if let Some ( res) = resolve_result ( path, flow_direction) ? {
13331332 if outer_type != OuterTypeType :: None {
1334- if outer_type == OuterTypeType :: Reference {
1335- return Err ( CompileError :: new (
1333+ return if outer_type == OuterTypeType :: Reference {
1334+ Err ( CompileError :: new (
13361335 path. span ( ) ,
13371336 "Result may not be passed as references in bound symbol"
1338- ) ) ;
1337+ ) )
13391338 } else {
1340- return Err ( CompileError :: new (
1339+ Err ( CompileError :: new (
13411340 path. span ( ) , "Result may not be used as an inner type"
1342- ) ) ;
1341+ ) )
13431342 }
13441343 }
13451344
13461345 let resolved_inner_types = [ res. 1 , res. 2 ] . into_iter ( )
1347- . filter_map ( |opt| opt )
1346+ . flatten ( )
13481347 . collect ( ) ;
13491348 return Ok ( ( res. 0 , resolved_inner_types) ) ;
13501349 }
@@ -1426,7 +1425,7 @@ fn parse_type_internal(
14261425 } else if let Type :: Ptr ( _) = ty {
14271426 Err ( CompileError :: new ( ty. span ( ) , "Pointer is not allowed in bound symbol" ) )
14281427 } else if let Type :: Tuple ( tuple) = ty {
1429- if tuple. elems . len ( ) == 0 {
1428+ if tuple. elems . is_empty ( ) {
14301429 Ok ( (
14311430 ObjectType :: empty ( ) ,
14321431 vec ! [ ] ,
@@ -1449,8 +1448,8 @@ fn match_path(subject: &Path, needle: Vec<&'static str>) -> bool {
14491448 needle[ needle. len ( ) - subject. segments . len ( ) ..]
14501449 . iter ( )
14511450 . enumerate ( )
1452- . map ( |( i, seg) | subject. segments [ i] . ident . to_string ( ) == * seg)
1453- . fold ( true , |a , b| a && b)
1451+ . map ( |( i, seg) | subject. segments [ i] . ident == seg)
1452+ . all ( |b| b)
14541453 }
14551454}
14561455
@@ -1528,7 +1527,7 @@ fn resolve_vec(ty: &TypePath, flow_direction: ValueFlowDirection)
15281527 else { return Err ( CompileError :: new ( ty. span ( ) , "Invalid Vec argument syntax" ) ) ; } ;
15291528
15301529 let ( inner_obj_type, resolved_inner_types) =
1531- parse_type_internal ( & inner_type, flow_direction, OuterTypeType :: Vec ) ?;
1530+ parse_type_internal ( inner_type, flow_direction, OuterTypeType :: Vec ) ?;
15321531 assert ! ( resolved_inner_types. len( ) <= 1 ,
15331532 "Parsing Vec type returned too many resolved types for inner type" ) ;
15341533
0 commit comments