This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Original file line number Diff line number Diff line change 44
55use std:: borrow:: Cow ;
66use std:: fmt:: { self , Debug , Formatter } ;
7+ use std:: iter;
78use std:: ops:: { Index , IndexMut } ;
8- use std:: { iter, mem} ;
99
1010pub use basic_blocks:: BasicBlocks ;
1111use either:: Either ;
Original file line number Diff line number Diff line change @@ -19,15 +19,6 @@ impl Statement<'_> {
1919 pub fn make_nop ( & mut self ) {
2020 self . kind = StatementKind :: Nop
2121 }
22-
23- /// Changes a statement to a nop and returns the original statement.
24- #[ must_use = "If you don't need the statement, use `make_nop` instead" ]
25- pub fn replace_nop ( & mut self ) -> Self {
26- Statement {
27- source_info : self . source_info ,
28- kind : mem:: replace ( & mut self . kind , StatementKind :: Nop ) ,
29- }
30- }
3122}
3223
3324impl < ' tcx > StatementKind < ' tcx > {
Original file line number Diff line number Diff line change @@ -48,9 +48,11 @@ impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts {
4848
4949 // We're only changing an operand, not the terminator kinds or successors
5050 let basic_blocks = body. basic_blocks . as_mut_preserves_cfg ( ) ;
51- let init_statement =
52- basic_blocks[ init_loc. block ] . statements [ init_loc. statement_index ] . replace_nop ( ) ;
53- let StatementKind :: Assign ( place_and_rvalue) = init_statement. kind else {
51+ let init_statement_kind = std:: mem:: replace (
52+ & mut basic_blocks[ init_loc. block ] . statements [ init_loc. statement_index ] . kind ,
53+ StatementKind :: Nop ,
54+ ) ;
55+ let StatementKind :: Assign ( place_and_rvalue) = init_statement_kind else {
5456 bug ! ( "No longer an assign?" ) ;
5557 } ;
5658 let ( place, rvalue) = * place_and_rvalue;
You can’t perform that action at this time.
0 commit comments