File tree 3 files changed +6
-13
lines changed
3 files changed +6
-13
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use std:: borrow:: Cow ;
6
6
use std:: fmt:: { self , Debug , Formatter } ;
7
+ use std:: iter;
7
8
use std:: ops:: { Index , IndexMut } ;
8
- use std:: { iter, mem} ;
9
9
10
10
pub use basic_blocks:: BasicBlocks ;
11
11
use either:: Either ;
Original file line number Diff line number Diff line change @@ -19,15 +19,6 @@ impl Statement<'_> {
19
19
pub fn make_nop ( & mut self ) {
20
20
self . kind = StatementKind :: Nop
21
21
}
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
- }
31
22
}
32
23
33
24
impl < ' tcx > StatementKind < ' tcx > {
Original file line number Diff line number Diff line change @@ -48,9 +48,11 @@ impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts {
48
48
49
49
// We're only changing an operand, not the terminator kinds or successors
50
50
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 {
54
56
bug ! ( "No longer an assign?" ) ;
55
57
} ;
56
58
let ( place, rvalue) = * place_and_rvalue;
You can’t perform that action at this time.
0 commit comments