From dc7de37d995e5922ce3b016c5cc01f5fcd326570 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 11 Oct 2017 14:33:06 +0200 Subject: [PATCH] Explain the `_oibit_remover` field --- src/libcore/fmt/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 4b263596ac1bd..c2ebb419e9e3d 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -261,6 +261,13 @@ pub struct Formatter<'a> { struct Void { _priv: (), + /// Erases all oibits, because `Void` erases the type of the object that + /// will be used to produce formatted output. Since we do not know what + /// oibits the real types have (and they can have any or none), we need to + /// take the most conservative approach and forbid all oibits. + /// + /// It was added after #45197 showed that one could share a `!Sync` + /// object across threads by passing it into `format_args!`. _oibit_remover: PhantomData<*mut Fn()>, }