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 {
|
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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue