pub fn report_dead_code(&mut self, node: Option<Index>) {
        let root = match node {
            Some(node) => node,
            None => return,
        };

        let flow = crate::flow::analyze(self);
        let reachable = self.analyze_reachability(&flow, root);

        let mut errors = Vec::new();
        for (node_index, node) in self.iter().filter(|(i, _)| reachable.contains(i)) {
            // The boundary of dead code is: when an *impassable* node has a continuation which
            // itself is *unreachable*.
            if let Some(cont_index) = node.next {
                if !flow.is_passable(node_index)
                    && !self[cont_index].allow_unreachable
                    && !reachable.contains(&cont_index)
                {
                    // Emit an error for the node which causes the unreachability, and the node
                    // which is made to be unreachable.
                    errors.push((node_index, CompileError::FollowingCodeUnreachable));
                    errors.push((cont_index, CompileError::UnreachableStatement));
                }
            }
        }

        // Insert all the discovered errors at once
        for (index, error) in errors {
            self.insert_error_at(index, error);
        }
    }
/// Attach errors to all dead code and code that leads to dead code, based on an internal call
/// to the flow analysis and reachability analysis on the graph.
Attach errors to all dead code and code that leads to dead code, based on an internal call
to the flow analysis and reachability analysis on the graph.
Attach errors to all dead code and code that leads to dead code based on an internal call to the flow analysis and reachability analysis on the graph .
pub fn report_dead_code(&mut self, node: Option<Index>) {
        let root = match node {
            Some(node) => node,
            None => return,
        };
        let flow = crate::flow::analyze(self);
        let reachable = self.analyze_reachability(&flow, root);
        let mut errors = Vec::new();
        for (node_index, node) in self.iter().filter(|(i, _)| reachable.contains(i)) {
            // The boundary of dead code is: when an *impassable* node has a continuation which
            // itself is *unreachable*.
            if let Some(cont_index) = node.next {
                if !flow.is_passable(node_index)
                    && !self[cont_index].allow_unreachable
                    && !reachable.contains(&cont_index)
                {
                    // Emit an error for the node which causes the unreachability, and the node
                    // which is made to be unreachable.
                    errors.push((node_index, CompileError::FollowingCodeUnreachable));
                    errors.push((cont_index, CompileError::UnreachableStatement));
                }
            }
        }
        // Insert all the discovered errors at once
        for (index, error) in errors {
            self.insert_error_at(index, error);
        }
    }
pub fn report_dead_code ( & mut self , node : Option < Index > ) { let root = match node { Some ( node ) => node , None => return , } ; let flow = crate :: flow :: analyze ( self ) ; let reachable = self . analyze_reachability ( & flow , root ) ; let mut errors = Vec :: new ( ) ; for ( node_index , node ) in self . iter ( ) . filter ( | ( i , _ ) | reachable . contains ( i ) ) { // The boundary of dead code is: when an *impassable* node has a continuation which // itself is *unreachable*. if let Some ( cont_index ) = node . next { if ! flow . is_passable ( node_index ) && ! self [ cont_index ] . allow_unreachable && ! reachable . contains ( & cont_index ) { // Emit an error for the node which causes the unreachability, and the node // which is made to be unreachable. errors . push ( ( node_index , CompileError :: FollowingCodeUnreachable ) ) ; errors . push ( ( cont_index , CompileError :: UnreachableStatement ) ) ; } } } // Insert all the discovered errors at once for ( index , error ) in errors { self . insert_error_at ( index , error ) ; } }
Attach errors to all dead code and code that leads to dead code, based on an internal call
to the flow analysis and reachability analysis on the graph.
Attach errors to all dead code and code that leads to dead code based on an internal call to the flow analysis and reachability analysis on the graph .
&mut self
node
Option<Index>