diff options
| author | Jon Gjengset <jon@thesquareplanet.com> | 2019-09-27 17:15:17 -0400 |
|---|---|---|
| committer | Jon Gjengset <jon@thesquareplanet.com> | 2019-09-27 17:36:45 -0400 |
| commit | 06e4ff4d61f44d7e239e02256829ecf1e5598657 (patch) | |
| tree | d6e8a9c4fb57b4b43bbe3b85808d6b2b54b030e1 /src/liballoc | |
| parent | a37fe2de697bb1a9d304e4e811836e125f944cd5 (diff) | |
| download | rust-06e4ff4d61f44d7e239e02256829ecf1e5598657.tar.gz rust-06e4ff4d61f44d7e239e02256829ecf1e5598657.zip | |
Scope format! temporaries
This places the temporaries that `format!` generates to refer to its arguments (through `&dyn Trait`) in a short-lived scope surrounding just the invocation of `format!`. This enables `format!` to be used in generators without the temporaries preventing the generator from being `Send` (due to `dyn Trait` not being `Sync`). See rust-lang/rust#64477 for details.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/macros.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index 2f2cdc39c63..422d3486f92 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -98,5 +98,8 @@ macro_rules! vec { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! format { - ($($arg:tt)*) => ($crate::fmt::format($crate::__export::format_args!($($arg)*))) + ($($arg:tt)*) => {{ + let res = $crate::fmt::format($crate::__export::format_args!($($arg)*)); + res + }} } |
