Refactor block_needs_anonymous_module
This commit is contained in:
parent
2ed210d5fe
commit
23bdbb13f4
1 changed files with 7 additions and 19 deletions
|
@ -142,29 +142,17 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
|||
}
|
||||
|
||||
fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
|
||||
// Check each statement.
|
||||
for statement in &block.stmts {
|
||||
match statement.node {
|
||||
StmtDecl(ref declaration, _) => {
|
||||
match declaration.node {
|
||||
DeclItem(_) => {
|
||||
fn is_item(statement: &hir::Stmt) -> bool {
|
||||
if let StmtDecl(ref declaration, _) = statement.node {
|
||||
if let DeclItem(_) = declaration.node {
|
||||
return true;
|
||||
}
|
||||
_ => {
|
||||
// Keep searching.
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// Keep searching.
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
// If we found no items, we don't need to create
|
||||
// an anonymous module.
|
||||
|
||||
return false;
|
||||
// If any statements are items, we need to create an anonymous module
|
||||
block.stmts.iter().any(is_item)
|
||||
}
|
||||
|
||||
/// Constructs the reduced graph for one item.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue