Replace Body::basic_blocks() with field access

This commit is contained in:
Tomasz Miąsko 2022-07-05 00:00:00 +00:00
parent 2cdc54d265
commit e4eddc611a
2 changed files with 4 additions and 4 deletions

View File

@ -105,7 +105,7 @@ fn check_fn(
vis.into_map(cx, maybe_storage_live_result) vis.into_map(cx, maybe_storage_live_result)
}; };
for (bb, bbdata) in mir.basic_blocks().iter_enumerated() { for (bb, bbdata) in mir.basic_blocks.iter_enumerated() {
let terminator = bbdata.terminator(); let terminator = bbdata.terminator();
if terminator.source_info.span.from_expansion() { if terminator.source_info.span.from_expansion() {
@ -186,7 +186,7 @@ fn check_fn(
unwrap_or_continue!(find_stmt_assigns_to(cx, mir, pred_arg, true, ps[0])); unwrap_or_continue!(find_stmt_assigns_to(cx, mir, pred_arg, true, ps[0]));
let loc = mir::Location { let loc = mir::Location {
block: bb, block: bb,
statement_index: mir.basic_blocks()[bb].statements.len(), statement_index: mir.basic_blocks[bb].statements.len(),
}; };
// This can be turned into `res = move local` if `arg` and `cloned` are not borrowed // This can be turned into `res = move local` if `arg` and `cloned` are not borrowed
@ -310,7 +310,7 @@ fn find_stmt_assigns_to<'tcx>(
by_ref: bool, by_ref: bool,
bb: mir::BasicBlock, bb: mir::BasicBlock,
) -> Option<(mir::Local, CannotMoveOut)> { ) -> Option<(mir::Local, CannotMoveOut)> {
let rvalue = mir.basic_blocks()[bb].statements.iter().rev().find_map(|stmt| { let rvalue = mir.basic_blocks[bb].statements.iter().rev().find_map(|stmt| {
if let mir::StatementKind::Assign(box (mir::Place { local, .. }, v)) = &stmt.kind { if let mir::StatementKind::Assign(box (mir::Place { local, .. }, v)) = &stmt.kind {
return if *local == to_local { Some(v) } else { None }; return if *local == to_local { Some(v) } else { None };
} }

View File

@ -55,7 +55,7 @@ pub fn is_min_const_fn<'a, 'tcx>(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv:
body.local_decls.iter().next().unwrap().source_info.span, body.local_decls.iter().next().unwrap().source_info.span,
)?; )?;
for bb in body.basic_blocks() { for bb in body.basic_blocks.iter() {
check_terminator(tcx, body, bb.terminator(), msrv)?; check_terminator(tcx, body, bb.terminator(), msrv)?;
for stmt in &bb.statements { for stmt in &bb.statements {
check_statement(tcx, body, def_id, stmt)?; check_statement(tcx, body, def_id, stmt)?;