about summary refs log tree commit diff
diff options
context:
space:
mode:
authorScott Olson <scott@solson.me>2015-12-30 06:55:51 -0600
committerScott Olson <scott@solson.me>2015-12-30 06:55:51 -0600
commitf8b61340e33bbb24709a862fd834ec10c871413c (patch)
tree152d319fd7f8c23701433c9e2f39f573454a397a
parentb65277496c8848cd6f08b55e8b413096c74b92af (diff)
downloadrust-f8b61340e33bbb24709a862fd834ec10c871413c.tar.gz
rust-f8b61340e33bbb24709a862fd834ec10c871413c.zip
Refactor MIR building for arguments.
-rw-r--r--src/librustc_mir/build/mod.rs32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 7ea9301664f..8347a03cda6 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -138,29 +138,25 @@ impl<'a,'tcx> Builder<'a,'tcx> {
                      -> BlockAnd<Vec<ArgDecl<'tcx>>>
     {
         self.in_scope(argument_extent, block, |this| {
-            let arg_decls = {
-                let num_implicit_args = implicit_arguments.len();
-                let implicit_arg_decls = implicit_arguments.into_iter()
-                                                           .map(|ty| ArgDecl { ty: ty });
-
-                // to start, translate the argument patterns and collect the
-                // argument types.
-                let explicit_arg_decls =
-                    explicit_arguments
-                    .into_iter()
-                    .enumerate()
-                    .map(|(index, (ty, pattern))| {
-                        let lvalue = Lvalue::Arg((num_implicit_args + index) as u32);
+            // to start, translate the argument patterns and collect the argument types.
+            let implicits = implicit_arguments.into_iter().map(|ty| (ty, None));
+            let explicits = explicit_arguments.into_iter().map(|(ty, pat)| (ty, Some(pat)));
+            let arg_decls =
+                implicits
+                .chain(explicits)
+                .enumerate()
+                .map(|(index, (ty, pattern))| {
+                    if let Some(pattern) = pattern {
+                        let lvalue = Lvalue::Arg(index as u32);
                         let pattern = this.hir.irrefutable_pat(pattern);
                         unpack!(block = this.lvalue_into_pattern(block,
                                                                  argument_extent,
                                                                  pattern,
                                                                  &lvalue));
-                        ArgDecl { ty: ty }
-                    });
-
-                implicit_arg_decls.chain(explicit_arg_decls).collect()
-            };
+                    }
+                    ArgDecl { ty: ty }
+                })
+                .collect();
 
             // start the first basic block and translate the body
             unpack!(block = this.ast_block(&Lvalue::ReturnPointer, block, ast_block));