diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-01-15 14:39:08 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-01-15 18:34:38 -0500 |
| commit | 419ac4a1b899ba88fb360b4c71c08f3610564cd4 (patch) | |
| tree | a67114bd33e84818930d054f29ac81b726a88198 /src/libsyntax/ext | |
| parent | 149fc76698318f8f7cdfaa37a818e347721764e7 (diff) | |
| download | rust-419ac4a1b899ba88fb360b4c71c08f3610564cd4.tar.gz rust-419ac4a1b899ba88fb360b4c71c08f3610564cd4.zip | |
Issue #3511 - Rationalize temporary lifetimes.
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/format.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index a4b8dd78403..3ad5857395d 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -634,17 +634,24 @@ impl<'a> Context<'a> { self.ecx.expr_ident(e.span, lname))); } + // Now create a vector containing all the arguments + let slicename = self.ecx.ident_of("__args_vec"); + { + let args = names.move_iter().map(|a| a.unwrap()); + let mut args = locals.move_iter().chain(args); + let args = self.ecx.expr_vec_slice(self.fmtsp, args.collect()); + lets.push(self.ecx.stmt_let(self.fmtsp, false, slicename, args)); + } + // Now create the fmt::Arguments struct with all our locals we created. - let args = names.move_iter().map(|a| a.unwrap()); - let mut args = locals.move_iter().chain(args); let fmt = self.ecx.expr_ident(self.fmtsp, static_name); - let args = self.ecx.expr_vec_slice(self.fmtsp, args.collect()); + let args_slice = self.ecx.expr_ident(self.fmtsp, slicename); let result = self.ecx.expr_call_global(self.fmtsp, ~[ self.ecx.ident_of("std"), self.ecx.ident_of("fmt"), self.ecx.ident_of("Arguments"), self.ecx.ident_of("new"), - ], ~[fmt, args]); + ], ~[fmt, args_slice]); // We did all the work of making sure that the arguments // structure is safe, so we can safely have an unsafe block. |
