about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-01-27 10:51:22 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-02-03 23:39:13 +0000
commit23bdbb13f4087751d7310ae896ccd3e1ae690abb (patch)
tree396e4b7762ce65f86ec1dd9ea9b16e799c3dc31d /src
parent2ed210d5fe6cfc9deec6d0242c96c4d64cf2248d (diff)
downloadrust-23bdbb13f4087751d7310ae896ccd3e1ae690abb.tar.gz
rust-23bdbb13f4087751d7310ae896ccd3e1ae690abb.zip
Refactor block_needs_anonymous_module
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 8f4913f0420..e84525ca296 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -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(_) => {
-                            return true;
-                        }
-                        _ => {
-                            // Keep searching.
-                        }
-                    }
-                }
-                _ => {
-                    // Keep searching.
+        fn is_item(statement: &hir::Stmt) -> bool {
+            if let StmtDecl(ref declaration, _) = statement.node {
+                if let DeclItem(_) = declaration.node {
+                    return true;
                 }
             }
+            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.