Skip to content

Commit 5722410

Browse files
committed
Fix logic error and add unreachable after returns
1 parent b4f54f9 commit 5722410

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/librustc/middle/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ pub struct DepthFirstTraversal<'g, N:'g, E:'g> {
314314
impl<'g, N, E> Iterator<&'g N> for DepthFirstTraversal<'g, N, E> {
315315
fn next(&mut self) -> Option<&'g N> {
316316
while let Some(idx) = self.stack.pop() {
317-
if self.visited.insert(idx.node_id()) {
317+
if !self.visited.insert(idx.node_id()) {
318318
continue;
319319
}
320320
self.graph.each_outgoing_edge(idx, |_, e| -> bool {

src/librustc_trans/trans/expr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,10 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
945945
if let &Some(ref x) = ex {
946946
bcx = trans_into(bcx, &**x, Ignore);
947947
}
948+
// Mark the end of the block as unreachable. Once we get to
949+
// a return expression, there's no more we should be doing
950+
// after this.
951+
Unreachable(bcx);
948952
bcx
949953
}
950954
}

0 commit comments

Comments
 (0)