Minor fixes

This commit is contained in:
James Miller 2014-12-17 13:24:35 +13:00
parent 9115b319c3
commit b4f54f96df
3 changed files with 4 additions and 9 deletions

View file

@ -51,9 +51,6 @@ impl CFG {
}
pub fn node_is_reachable(&self, id: ast::NodeId) -> bool {
for node in self.graph.depth_traverse(self.entry) {
if node.id == id { return true }
}
return false;
self.graph.depth_traverse(self.entry).any(|node| node.id == id)
}
}

View file

@ -313,12 +313,10 @@ pub struct DepthFirstTraversal<'g, N:'g, E:'g> {
impl<'g, N, E> Iterator<&'g N> for DepthFirstTraversal<'g, N, E> {
fn next(&mut self) -> Option<&'g N> {
while self.stack.len() > 0 {
let idx = self.stack.pop().unwrap();
if self.visited.contains(&idx.node_id()) {
while let Some(idx) = self.stack.pop() {
if self.visited.insert(idx.node_id()) {
continue;
}
self.visited.insert(idx.node_id());
self.graph.each_outgoing_edge(idx, |_, e| -> bool {
if !self.visited.contains(&e.target().node_id()) {
self.stack.push(e.target());

View file

@ -1468,7 +1468,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
let debug_context = debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl);
let (blk_id, cfg) = build_cfg(ccx.tcx(), id);
let nested_returns = if let Some(ref cfg) = cfg {
has_nested_returns(ccx.tcx(), cfg, blk_id)
has_nested_returns(ccx.tcx(), cfg, blk_id)
} else {
false
};