1
Fork 0

Refactor block_needs_anonymous_module

This commit is contained in:
Jeffrey Seyfried 2016-01-27 10:51:22 +00:00
parent 2ed210d5fe
commit 23bdbb13f4

View file

@ -142,29 +142,17 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
} }
fn block_needs_anonymous_module(&mut self, block: &Block) -> bool { fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
// Check each statement. fn is_item(statement: &hir::Stmt) -> bool {
for statement in &block.stmts { if let StmtDecl(ref declaration, _) = statement.node {
match statement.node { if let DeclItem(_) = declaration.node {
StmtDecl(ref declaration, _) => { return true;
match declaration.node {
DeclItem(_) => {
return true;
}
_ => {
// Keep searching.
}
}
}
_ => {
// Keep searching.
} }
} }
false
} }
// If we found no items, we don't need to create // If any statements are items, we need to create an anonymous module
// an anonymous module. block.stmts.iter().any(is_item)
return false;
} }
/// Constructs the reduced graph for one item. /// Constructs the reduced graph for one item.