From 06e4ff4d61f44d7e239e02256829ecf1e5598657 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Fri, 27 Sep 2019 17:15:17 -0400 Subject: 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. --- src/liballoc/macros.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/liballoc') 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 + }} } -- cgit 1.4.1-3-g733a5