Skip to content

Commit b4f54f9

Browse files
committed
Minor fixes
1 parent 9115b31 commit b4f54f9

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/librustc/middle/cfg/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ impl CFG {
5151
}
5252

5353
pub fn node_is_reachable(&self, id: ast::NodeId) -> bool {
54-
for node in self.graph.depth_traverse(self.entry) {
55-
if node.id == id { return true }
56-
}
57-
return false;
54+
self.graph.depth_traverse(self.entry).any(|node| node.id == id)
5855
}
5956
}

src/librustc/middle/graph.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,10 @@ pub struct DepthFirstTraversal<'g, N:'g, E:'g> {
313313

314314
impl<'g, N, E> Iterator<&'g N> for DepthFirstTraversal<'g, N, E> {
315315
fn next(&mut self) -> Option<&'g N> {
316-
while self.stack.len() > 0 {
317-
let idx = self.stack.pop().unwrap();
318-
if self.visited.contains(&idx.node_id()) {
316+
while let Some(idx) = self.stack.pop() {
317+
if self.visited.insert(idx.node_id()) {
319318
continue;
320319
}
321-
self.visited.insert(idx.node_id());
322320
self.graph.each_outgoing_edge(idx, |_, e| -> bool {
323321
if !self.visited.contains(&e.target().node_id()) {
324322
self.stack.push(e.target());

src/librustc_trans/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
14681468
let debug_context = debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl);
14691469
let (blk_id, cfg) = build_cfg(ccx.tcx(), id);
14701470
let nested_returns = if let Some(ref cfg) = cfg {
1471-
has_nested_returns(ccx.tcx(), cfg, blk_id)
1471+
has_nested_returns(ccx.tcx(), cfg, blk_id)
14721472
} else {
14731473
false
14741474
};

0 commit comments

Comments
 (0)