Skip to content

Commit 24d3f5b

Browse files
committed
Implement visit_basic_block_data
1 parent 105ae71 commit 24d3f5b

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

clippy_lints/src/redundant_clone.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,31 @@ struct LocalUseVisitor {
261261
}
262262

263263
impl<'tcx> mir::visit::Visitor<'tcx> for LocalUseVisitor {
264-
fn visit_statement(&mut self, block: mir::BasicBlock, statement: &mir::Statement<'tcx>, location: mir::Location) {
265-
// Once flagged, skip remaining statements
266-
if !self.used_other_than_drop {
267-
self.super_statement(block, statement, location);
264+
fn visit_basic_block_data(&mut self, block: mir::BasicBlock, data: &mir::BasicBlockData<'tcx>) {
265+
let mir::BasicBlockData {
266+
statements,
267+
terminator,
268+
is_cleanup: _,
269+
} = data;
270+
271+
for (statement_index, statement) in statements.iter().enumerate() {
272+
self.visit_statement(block, statement, mir::Location { block, statement_index });
273+
274+
// Once flagged, skip remaining statements
275+
if self.used_other_than_drop {
276+
return;
277+
}
278+
}
279+
280+
if let Some(terminator) = terminator {
281+
self.visit_terminator(
282+
block,
283+
terminator,
284+
mir::Location {
285+
block,
286+
statement_index: statements.len(),
287+
},
288+
);
268289
}
269290
}
270291

0 commit comments

Comments
 (0)