diff --git a/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block.rs b/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block.rs index a307d86e4d3..13d1b3ca6f8 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block.rs @@ -31,18 +31,6 @@ pub(crate) struct BasicBlock { terminator: Option, } -impl BasicBlock { - /// Gets a reference to basic block's terminator instruction. - /// - /// This accessor should not be used during basic block construction, at which time the - /// terminator may be as of yet unassigned. - pub(crate) fn terminator(&self) -> &TerminatorInstruction { - self.terminator - .as_ref() - .expect("ICE: Tried to get terminator before basic block construction had finished.") - } -} - /// An identifier for a Basic Block. pub(crate) type BasicBlockId = Id; diff --git a/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block_visitors.rs b/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block_visitors.rs index 9ccbfed7dec..e0d5dc1b3df 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block_visitors.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/ir/basic_block_visitors.rs @@ -7,7 +7,10 @@ use super::{ /// arguments are the branch instruction that is used to reach the successor, /// and the id of the successor block itself. pub(crate) fn visit_block_succs(basic_block: &BasicBlock, mut visit: F) { - match basic_block.terminator() { + match basic_block + .terminator() + .expect("ICE: No terminator indicates block is still under construction.") + { TerminatorInstruction::Jmp { destination, .. } => visit(*destination), TerminatorInstruction::JmpIf { then_destination, else_destination, .. } => { visit(*then_destination); diff --git a/crates/noirc_evaluator/src/ssa_refactor/ir/dfg.rs b/crates/noirc_evaluator/src/ssa_refactor/ir/dfg.rs index dbe25c14c3b..c21fc2c3f35 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/ir/dfg.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/ir/dfg.rs @@ -1,5 +1,3 @@ -use std::ops::{Index, IndexMut}; - use super::{ basic_block::{BasicBlock, BasicBlockId}, constant::{NumericConstant, NumericConstantId}, @@ -249,15 +247,7 @@ impl std::ops::Index for DataFlowGraph { } } -impl Index for DataFlowGraph { - type Output = BasicBlock; - /// Get a reference to a function's basic block for the given id. - fn index(&self, id: BasicBlockId) -> &BasicBlock { - &self.blocks[id] - } -} - -impl IndexMut for DataFlowGraph { +impl std::ops::IndexMut for DataFlowGraph { /// Get a mutable reference to a function's basic block for the given id. fn index_mut(&mut self, id: BasicBlockId) -> &mut BasicBlock { &mut self.blocks[id]