@@ -97,7 +97,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
9797 let mir = cx. tcx . optimized_mir ( def_id) ;
9898
9999 for ( bb, bbdata) in mir. basic_blocks ( ) . iter_enumerated ( ) {
100- let terminator = unwrap_or_continue ! ( & bbdata. terminator) ;
100+ let terminator = bbdata. terminator ( ) ;
101101
102102 // Give up on loops
103103 if terminator. successors ( ) . any ( |s| * s == bb) {
@@ -130,7 +130,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone {
130130 if ps. len ( ) != 1 {
131131 continue ;
132132 }
133- let pred_terminator = unwrap_or_continue ! ( & mir[ ps[ 0 ] ] . terminator) ;
133+ let pred_terminator = mir[ ps[ 0 ] ] . terminator ( ) ;
134134
135135 let pred_arg = if_chain ! {
136136 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 {
152152 } ;
153153
154154 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 ;
160158 }
161159
162160 let mut vis = LocalUseVisitor {
@@ -256,12 +254,7 @@ struct LocalUseVisitor {
256254
257255impl < ' tcx > mir:: visit:: Visitor < ' tcx > for LocalUseVisitor {
258256 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 ;
265258 for ( statement_index, statement) in statements. iter ( ) . enumerate ( ) {
266259 self . visit_statement ( block, statement, mir:: Location { block, statement_index } ) ;
267260
@@ -271,16 +264,14 @@ impl<'tcx> mir::visit::Visitor<'tcx> for LocalUseVisitor {
271264 }
272265 }
273266
274- if let Some ( terminator) = terminator {
275- self . visit_terminator (
267+ self . visit_terminator (
268+ block,
269+ data. terminator ( ) ,
270+ mir:: Location {
276271 block,
277- terminator,
278- mir:: Location {
279- block,
280- statement_index : statements. len ( ) ,
281- } ,
282- ) ;
283- }
272+ statement_index : statements. len ( ) ,
273+ } ,
274+ ) ;
284275 }
285276
286277 fn visit_local ( & mut self , local : & mir:: Local , ctx : PlaceContext < ' tcx > , _: mir:: Location ) {
0 commit comments