@@ -97,7 +97,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
97
97
let mir = cx. tcx . optimized_mir ( def_id) ;
98
98
99
99
for ( bb, bbdata) in mir. basic_blocks ( ) . iter_enumerated ( ) {
100
- let terminator = unwrap_or_continue ! ( & bbdata. terminator) ;
100
+ let terminator = bbdata. terminator ( ) ;
101
101
102
102
// Give up on loops
103
103
if terminator. successors ( ) . any ( |s| * s == bb) {
@@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
130
130
if ps. len ( ) != 1 {
131
131
continue ;
132
132
}
133
- let pred_terminator = unwrap_or_continue ! ( & mir[ ps[ 0 ] ] . terminator) ;
133
+ let pred_terminator = mir[ ps[ 0 ] ] . terminator ( ) ;
134
134
135
135
let pred_arg = if_chain ! {
136
136
if let Some ( ( pred_fn_def_id, pred_arg, pred_arg_ty, Some ( res) ) ) =
@@ -152,11 +152,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
152
152
} ;
153
153
154
154
let used_later = traversal:: ReversePostorder :: new ( & mir, bb) . skip ( 1 ) . any ( |( tbb, tdata) | {
155
- if let Some ( term) = & tdata. terminator {
156
- // Give up on loops
157
- if term. successors ( ) . any ( |s| * s == bb) {
158
- return true ;
159
- }
155
+ // Give up on loops
156
+ if tdata. terminator ( ) . successors ( ) . any ( |s| * s == bb) {
157
+ return true ;
160
158
}
161
159
162
160
let mut vis = LocalUseVisitor {
@@ -256,12 +254,7 @@ struct LocalUseVisitor {
256
254
257
255
impl < ' tcx > mir:: visit:: Visitor < ' tcx > for LocalUseVisitor {
258
256
fn visit_basic_block_data ( & mut self , block : mir:: BasicBlock , data : & mir:: BasicBlockData < ' tcx > ) {
259
- let mir:: BasicBlockData {
260
- statements,
261
- terminator,
262
- is_cleanup : _,
263
- } = data;
264
-
257
+ let statements = & data. statements ;
265
258
for ( statement_index, statement) in statements. iter ( ) . enumerate ( ) {
266
259
self . visit_statement ( block, statement, mir:: Location { block, statement_index } ) ;
267
260
@@ -271,16 +264,14 @@ impl<'tcx> mir::visit::Visitor<'tcx> for LocalUseVisitor {
271
264
}
272
265
}
273
266
274
- if let Some ( terminator) = terminator {
275
- self . visit_terminator (
267
+ self . visit_terminator (
268
+ block,
269
+ data. terminator ( ) ,
270
+ mir:: Location {
276
271
block,
277
- terminator,
278
- mir:: Location {
279
- block,
280
- statement_index : statements. len ( ) ,
281
- } ,
282
- ) ;
283
- }
272
+ statement_index : statements. len ( ) ,
273
+ } ,
274
+ ) ;
284
275
}
285
276
286
277
fn visit_local ( & mut self , local : & mir:: Local , ctx : PlaceContext < ' tcx > , _: mir:: Location ) {
0 commit comments