@@ -133,7 +133,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
133
133
}
134
134
_ => { /* mark as unpromotable below */ }
135
135
}
136
- } else if let TempState :: Defined { ref mut uses, .. } = * temp {
136
+ } else if let TempState :: Defined { uses, .. } = temp {
137
137
// We always allow borrows, even mutable ones, as we need
138
138
// to promote mutable borrows of some ZSTs e.g., `&mut []`.
139
139
let allowed_use = match context {
@@ -748,7 +748,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
748
748
if loc. statement_index < num_stmts {
749
749
let ( mut rvalue, source_info) = {
750
750
let statement = & mut self . source [ loc. block ] . statements [ loc. statement_index ] ;
751
- let StatementKind :: Assign ( box ( _, ref mut rhs) ) = statement. kind else {
751
+ let StatementKind :: Assign ( box ( _, rhs) ) = & mut statement. kind else {
752
752
span_bug ! (
753
753
statement. source_info. span,
754
754
"{:?} is not an assignment" ,
@@ -778,9 +778,9 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
778
778
self . source [ loc. block ] . terminator ( ) . clone ( )
779
779
} else {
780
780
let terminator = self . source [ loc. block ] . terminator_mut ( ) ;
781
- let target = match terminator. kind {
782
- TerminatorKind :: Call { target : Some ( target) , .. } => target,
783
- ref kind => {
781
+ let target = match & terminator. kind {
782
+ TerminatorKind :: Call { target : Some ( target) , .. } => * target,
783
+ kind => {
784
784
span_bug ! ( terminator. source_info. span, "{:?} not promotable" , kind) ;
785
785
}
786
786
} ;
@@ -814,7 +814,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
814
814
..terminator
815
815
} ;
816
816
}
817
- ref kind => {
817
+ kind => {
818
818
span_bug ! ( terminator. source_info. span, "{:?} not promotable" , kind) ;
819
819
}
820
820
} ;
@@ -847,54 +847,50 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
847
847
let local_decls = & mut self . source . local_decls ;
848
848
let loc = candidate. location ;
849
849
let statement = & mut blocks[ loc. block ] . statements [ loc. statement_index ] ;
850
- match statement. kind {
851
- StatementKind :: Assign ( box (
852
- _,
853
- Rvalue :: Ref ( ref mut region, borrow_kind, ref mut place) ,
854
- ) ) => {
855
- // Use the underlying local for this (necessarily interior) borrow.
856
- let ty = local_decls[ place. local ] . ty ;
857
- let span = statement. source_info . span ;
858
-
859
- let ref_ty = tcx. mk_ref (
860
- tcx. lifetimes . re_erased ,
861
- ty:: TypeAndMut { ty, mutbl : borrow_kind. to_mutbl_lossy ( ) } ,
862
- ) ;
850
+ let StatementKind :: Assign ( box ( _, Rvalue :: Ref ( region, borrow_kind, place) ) ) = & mut statement. kind else {
851
+ bug ! ( )
852
+ } ;
863
853
864
- * region = tcx. lifetimes . re_erased ;
865
-
866
- let mut projection = vec ! [ PlaceElem :: Deref ] ;
867
- projection. extend ( place. projection ) ;
868
- place. projection = tcx. intern_place_elems ( & projection) ;
869
-
870
- // Create a temp to hold the promoted reference.
871
- // This is because `*r` requires `r` to be a local,
872
- // otherwise we would use the `promoted` directly.
873
- let mut promoted_ref = LocalDecl :: new ( ref_ty, span) ;
874
- promoted_ref. source_info = statement. source_info ;
875
- let promoted_ref = local_decls. push ( promoted_ref) ;
876
- assert_eq ! ( self . temps. push( TempState :: Unpromotable ) , promoted_ref) ;
877
-
878
- let promoted_ref_statement = Statement {
879
- source_info : statement. source_info ,
880
- kind : StatementKind :: Assign ( Box :: new ( (
881
- Place :: from ( promoted_ref) ,
882
- Rvalue :: Use ( promoted_operand ( ref_ty, span) ) ,
883
- ) ) ) ,
884
- } ;
885
- self . extra_statements . push ( ( loc, promoted_ref_statement) ) ;
886
-
887
- Rvalue :: Ref (
888
- tcx. lifetimes . re_erased ,
889
- borrow_kind,
890
- Place {
891
- local : mem:: replace ( & mut place. local , promoted_ref) ,
892
- projection : List :: empty ( ) ,
893
- } ,
894
- )
895
- }
896
- _ => bug ! ( ) ,
897
- }
854
+ // Use the underlying local for this (necessarily interior) borrow.
855
+ let ty = local_decls[ place. local ] . ty ;
856
+ let span = statement. source_info . span ;
857
+
858
+ let ref_ty = tcx. mk_ref (
859
+ tcx. lifetimes . re_erased ,
860
+ ty:: TypeAndMut { ty, mutbl : borrow_kind. to_mutbl_lossy ( ) } ,
861
+ ) ;
862
+
863
+ * region = tcx. lifetimes . re_erased ;
864
+
865
+ let mut projection = vec ! [ PlaceElem :: Deref ] ;
866
+ projection. extend ( place. projection ) ;
867
+ place. projection = tcx. intern_place_elems ( & projection) ;
868
+
869
+ // Create a temp to hold the promoted reference.
870
+ // This is because `*r` requires `r` to be a local,
871
+ // otherwise we would use the `promoted` directly.
872
+ let mut promoted_ref = LocalDecl :: new ( ref_ty, span) ;
873
+ promoted_ref. source_info = statement. source_info ;
874
+ let promoted_ref = local_decls. push ( promoted_ref) ;
875
+ assert_eq ! ( self . temps. push( TempState :: Unpromotable ) , promoted_ref) ;
876
+
877
+ let promoted_ref_statement = Statement {
878
+ source_info : statement. source_info ,
879
+ kind : StatementKind :: Assign ( Box :: new ( (
880
+ Place :: from ( promoted_ref) ,
881
+ Rvalue :: Use ( promoted_operand ( ref_ty, span) ) ,
882
+ ) ) ) ,
883
+ } ;
884
+ self . extra_statements . push ( ( loc, promoted_ref_statement) ) ;
885
+
886
+ Rvalue :: Ref (
887
+ tcx. lifetimes . re_erased ,
888
+ * borrow_kind,
889
+ Place {
890
+ local : mem:: replace ( & mut place. local , promoted_ref) ,
891
+ projection : List :: empty ( ) ,
892
+ } ,
893
+ )
898
894
} ;
899
895
900
896
assert_eq ! ( self . new_block( ) , START_BLOCK ) ;
0 commit comments