about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-29 06:34:43 +0200
committerGitHub <noreply@github.com>2022-08-29 06:34:43 +0200
commit663b8949b79fd28ed0e96e485ef2ca682bf5802a (patch)
tree731c603a172873eabe56c47615e7dc09fec8a548
parentf48af912ea9a9726ff851a3e4a809e1d2daeb0ba (diff)
parent1071c4c10bb24f12b65bfface2859c1fd8898575 (diff)
downloadrust-663b8949b79fd28ed0e96e485ef2ca682bf5802a.tar.gz
rust-663b8949b79fd28ed0e96e485ef2ca682bf5802a.zip
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.
-rw-r--r--src/analyze.rs2
-rw-r--r--src/base.rs4
-rw-r--r--src/constant.rs2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/analyze.rs b/src/analyze.rs
index 35b89358b19..0cbb9f3ec2d 100644
--- a/src/analyze.rs
+++ b/src/analyze.rs
@@ -26,7 +26,7 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec<Local, SsaKind> {
         })
         .collect::<IndexVec<Local, SsaKind>>();
 
-    for bb in fx.mir.basic_blocks().iter() {
+    for bb in fx.mir.basic_blocks.iter() {
         for stmt in bb.statements.iter() {
             match &stmt.kind {
                 Assign(place_and_rval) => match &place_and_rval.1 {
diff --git a/src/base.rs b/src/base.rs
index 44c34d6c8cb..3011813c703 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -73,7 +73,7 @@ pub(crate) fn codegen_fn<'tcx>(
     // Predefine blocks
     let start_block = bcx.create_block();
     let block_map: IndexVec<BasicBlock, Block> =
-        (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect();
+        (0..mir.basic_blocks.len()).map(|_| bcx.create_block()).collect();
 
     // Make FunctionCx
     let target_config = module.target_config();
@@ -271,7 +271,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
     }
     fx.tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(fx, start_block));
 
-    for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() {
+    for (bb, bb_data) in fx.mir.basic_blocks.iter_enumerated() {
         let block = fx.get_block(bb);
         fx.bcx.switch_to_block(block);
 
diff --git a/src/constant.rs b/src/constant.rs
index 7f7fd0e9c57..e2b68f24a21 100644
--- a/src/constant.rs
+++ b/src/constant.rs
@@ -505,7 +505,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
                 return None;
             }
             let mut computed_const_val = None;
-            for bb_data in fx.mir.basic_blocks() {
+            for bb_data in fx.mir.basic_blocks.iter() {
                 for stmt in &bb_data.statements {
                     match &stmt.kind {
                         StatementKind::Assign(local_and_rvalue) if &local_and_rvalue.0 == place => {