@@ -151,7 +151,7 @@ fn extract_target(node: &SyntaxNode, selection_range: TextRange) -> Option<Modul
151
151
let mut body_items: Vec < ast:: Item > = node
152
152
. children ( )
153
153
. filter_map ( |child| {
154
- if let Some ( item) = ast:: Item :: cast ( child. clone ( ) ) {
154
+ if let Some ( item) = ast:: Item :: cast ( child) {
155
155
if selection_range. contains_range ( item. syntax ( ) . text_range ( ) ) {
156
156
return Some ( item) ;
157
157
}
@@ -312,20 +312,20 @@ impl Module {
312
312
get_replacements_for_visibilty_change ( self . body_items . clone ( ) , false ) ;
313
313
314
314
let impl_items = impls. into_iter ( ) . fold ( Vec :: new ( ) , |mut impl_items, x| {
315
- let this_impl_items =
315
+ let mut this_impl_items =
316
316
x. syntax ( ) . descendants ( ) . fold ( Vec :: new ( ) , |mut this_impl_items, x| {
317
- if let Some ( item) = ast:: Item :: cast ( x. clone ( ) ) {
317
+ if let Some ( item) = ast:: Item :: cast ( x) {
318
318
this_impl_items. push ( item) ;
319
319
}
320
320
return this_impl_items;
321
321
} ) ;
322
322
323
- impl_items. append ( & mut this_impl_items. clone ( ) ) ;
323
+ impl_items. append ( & mut this_impl_items) ;
324
324
return impl_items;
325
325
} ) ;
326
326
327
327
let ( _, mut impl_item_replacements, _, _) =
328
- get_replacements_for_visibilty_change ( impl_items. clone ( ) , true ) ;
328
+ get_replacements_for_visibilty_change ( impl_items, true ) ;
329
329
330
330
replacements. append ( & mut impl_item_replacements) ;
331
331
@@ -337,7 +337,7 @@ impl Module {
337
337
. find ( |x| x. to_string ( ) == desc. to_string ( ) )
338
338
. is_some ( ) ;
339
339
if is_record_field_present {
340
- replacements. push ( ( desc. visibility ( ) . clone ( ) , desc. syntax ( ) . clone ( ) ) ) ;
340
+ replacements. push ( ( desc. visibility ( ) , desc. syntax ( ) . clone ( ) ) ) ;
341
341
}
342
342
} ) ;
343
343
} ) ;
@@ -472,7 +472,7 @@ impl Module {
472
472
( & x. 1 ) . into_iter ( ) . for_each ( |x| {
473
473
let node_opt: Option < ast:: Use > = find_node_at_range ( file. syntax ( ) , x. range ) ;
474
474
if let Some ( node) = node_opt {
475
- use_opt = Some ( node. clone ( ) ) ;
475
+ use_opt = Some ( node) ;
476
476
}
477
477
} ) ;
478
478
}
@@ -529,7 +529,7 @@ impl Module {
529
529
}
530
530
531
531
if let Some ( use_tree_str) = use_tree_str_opt {
532
- let mut use_tree_str = use_tree_str. clone ( ) ;
532
+ let mut use_tree_str = use_tree_str;
533
533
use_tree_str. reverse ( ) ;
534
534
if use_tree_str[ 0 ] . to_string ( ) . contains ( "super" ) {
535
535
let super_path = make:: ext:: ident_path ( "super" ) ;
@@ -776,42 +776,24 @@ fn get_replacements_for_visibilty_change(
776
776
body_items. push ( item. clone ( ) ) ;
777
777
//Use stmts are ignored
778
778
match item {
779
- ast:: Item :: Const ( it) => {
780
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
781
- }
782
- ast:: Item :: Enum ( it) => {
783
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
784
- }
785
- ast:: Item :: ExternCrate ( it) => {
786
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
787
- }
788
- ast:: Item :: Fn ( it) => replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) ) ,
779
+ ast:: Item :: Const ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
780
+ ast:: Item :: Enum ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
781
+ ast:: Item :: ExternCrate ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
782
+ ast:: Item :: Fn ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
789
783
ast:: Item :: Impl ( it) => impls. push ( it) ,
790
- ast:: Item :: MacroRules ( it) => {
791
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
792
- }
793
- ast:: Item :: MacroDef ( it) => {
794
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
795
- }
796
- ast:: Item :: Module ( it) => {
797
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
798
- }
799
- ast:: Item :: Static ( it) => {
800
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
801
- }
784
+ ast:: Item :: MacroRules ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
785
+ ast:: Item :: MacroDef ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
786
+ ast:: Item :: Module ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
787
+ ast:: Item :: Static ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
802
788
ast:: Item :: Struct ( it) => {
803
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) ) ;
804
- record_field_parents. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) ) ;
805
- }
806
- ast:: Item :: Trait ( it) => {
807
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
808
- }
809
- ast:: Item :: TypeAlias ( it) => {
810
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) )
789
+ replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ;
790
+ record_field_parents. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ;
811
791
}
792
+ ast:: Item :: Trait ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
793
+ ast:: Item :: TypeAlias ( it) => replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ,
812
794
ast:: Item :: Union ( it) => {
813
- replacements. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) ) ;
814
- record_field_parents. push ( ( it. visibility ( ) . clone ( ) , it. syntax ( ) . clone ( ) ) ) ;
795
+ replacements. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ;
796
+ record_field_parents. push ( ( it. visibility ( ) , it. syntax ( ) . clone ( ) ) ) ;
815
797
}
816
798
_ => ( ) ,
817
799
}
@@ -825,7 +807,7 @@ fn get_use_tree_paths_from_path(
825
807
use_tree_str : & mut Vec < ast:: Path > ,
826
808
) -> Option < & mut Vec < ast:: Path > > {
827
809
path. syntax ( ) . ancestors ( ) . filter ( |x| x. to_string ( ) != path. to_string ( ) ) . find_map ( |x| {
828
- if let Some ( use_tree) = ast:: UseTree :: cast ( x. clone ( ) ) {
810
+ if let Some ( use_tree) = ast:: UseTree :: cast ( x) {
829
811
if let Some ( upper_tree_path) = use_tree. path ( ) {
830
812
if upper_tree_path. to_string ( ) != path. to_string ( ) {
831
813
use_tree_str. push ( upper_tree_path. clone ( ) ) ;
0 commit comments