@@ -190,15 +190,13 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
190
190
}
191
191
192
192
if let Some ( impl_) = impl_parent {
193
- let node_to_be_removed;
194
-
195
193
// Remove complete impl block if it has only one child (as such it will be empty
196
194
// after deleting that child)
197
- if impl_child_count == 1 {
198
- node_to_be_removed = impl_. syntax ( ) ;
195
+ let node_to_be_removed = if impl_child_count == 1 {
196
+ impl_. syntax ( )
199
197
} else {
200
198
//Remove selected node
201
- node_to_be_removed = & node;
199
+ & node
202
200
} ;
203
201
204
202
builder. delete ( node_to_be_removed. text_range ( ) ) ;
@@ -715,14 +713,12 @@ fn does_source_exists_outside_sel_in_same_mod(
715
713
}
716
714
Definition :: Function ( x) => {
717
715
if let Some ( source) = x. source ( ctx. db ( ) ) {
718
- let have_same_parent;
719
- if let Some ( ast_module) = & curr_parent_module {
720
- have_same_parent =
721
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
716
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
717
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
722
718
} else {
723
719
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
724
- have_same_parent = source_file_id == curr_file_id;
725
- }
720
+ source_file_id == curr_file_id
721
+ } ;
726
722
727
723
if have_same_parent {
728
724
source_exists_outside_sel_in_same_mod =
@@ -732,14 +728,12 @@ fn does_source_exists_outside_sel_in_same_mod(
732
728
}
733
729
Definition :: Adt ( x) => {
734
730
if let Some ( source) = x. source ( ctx. db ( ) ) {
735
- let have_same_parent;
736
- if let Some ( ast_module) = & curr_parent_module {
737
- have_same_parent =
738
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
731
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
732
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
739
733
} else {
740
734
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
741
- have_same_parent = source_file_id == curr_file_id;
742
- }
735
+ source_file_id == curr_file_id
736
+ } ;
743
737
744
738
if have_same_parent {
745
739
source_exists_outside_sel_in_same_mod =
@@ -749,14 +743,12 @@ fn does_source_exists_outside_sel_in_same_mod(
749
743
}
750
744
Definition :: Variant ( x) => {
751
745
if let Some ( source) = x. source ( ctx. db ( ) ) {
752
- let have_same_parent;
753
- if let Some ( ast_module) = & curr_parent_module {
754
- have_same_parent =
755
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
746
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
747
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
756
748
} else {
757
749
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
758
- have_same_parent = source_file_id == curr_file_id;
759
- }
750
+ source_file_id == curr_file_id
751
+ } ;
760
752
761
753
if have_same_parent {
762
754
source_exists_outside_sel_in_same_mod =
@@ -766,14 +758,12 @@ fn does_source_exists_outside_sel_in_same_mod(
766
758
}
767
759
Definition :: Const ( x) => {
768
760
if let Some ( source) = x. source ( ctx. db ( ) ) {
769
- let have_same_parent;
770
- if let Some ( ast_module) = & curr_parent_module {
771
- have_same_parent =
772
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
761
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
762
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
773
763
} else {
774
764
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
775
- have_same_parent = source_file_id == curr_file_id;
776
- }
765
+ source_file_id == curr_file_id
766
+ } ;
777
767
778
768
if have_same_parent {
779
769
source_exists_outside_sel_in_same_mod =
@@ -783,14 +773,12 @@ fn does_source_exists_outside_sel_in_same_mod(
783
773
}
784
774
Definition :: Static ( x) => {
785
775
if let Some ( source) = x. source ( ctx. db ( ) ) {
786
- let have_same_parent;
787
- if let Some ( ast_module) = & curr_parent_module {
788
- have_same_parent =
789
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
776
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
777
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
790
778
} else {
791
779
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
792
- have_same_parent = source_file_id == curr_file_id;
793
- }
780
+ source_file_id == curr_file_id
781
+ } ;
794
782
795
783
if have_same_parent {
796
784
source_exists_outside_sel_in_same_mod =
@@ -800,14 +788,12 @@ fn does_source_exists_outside_sel_in_same_mod(
800
788
}
801
789
Definition :: Trait ( x) => {
802
790
if let Some ( source) = x. source ( ctx. db ( ) ) {
803
- let have_same_parent;
804
- if let Some ( ast_module) = & curr_parent_module {
805
- have_same_parent =
806
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
791
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
792
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
807
793
} else {
808
794
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
809
- have_same_parent = source_file_id == curr_file_id;
810
- }
795
+ source_file_id == curr_file_id
796
+ } ;
811
797
812
798
if have_same_parent {
813
799
source_exists_outside_sel_in_same_mod =
@@ -817,14 +803,12 @@ fn does_source_exists_outside_sel_in_same_mod(
817
803
}
818
804
Definition :: TypeAlias ( x) => {
819
805
if let Some ( source) = x. source ( ctx. db ( ) ) {
820
- let have_same_parent;
821
- if let Some ( ast_module) = & curr_parent_module {
822
- have_same_parent =
823
- compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( ) ;
806
+ let have_same_parent = if let Some ( ast_module) = & curr_parent_module {
807
+ compare_hir_and_ast_module ( ast_module, x. module ( ctx. db ( ) ) , ctx) . is_some ( )
824
808
} else {
825
809
let source_file_id = source. file_id . original_file ( ctx. db ( ) ) ;
826
- have_same_parent = source_file_id == curr_file_id;
827
- }
810
+ source_file_id == curr_file_id
811
+ } ;
828
812
829
813
if have_same_parent {
830
814
source_exists_outside_sel_in_same_mod =
0 commit comments