If an .await occurs inside a formatting macro, the resulting generator is no longer Send.
Context
This has already tripped up some people which seem to get quite confused with this error message, so I'd rather we not regress here:
Code
I tried this code:
async fn foo() {
println!("{} {:?}", "", async {}.await);
}
const _ASSERT_SEND: fn() = || {
let _: &dyn Send = &foo();
};
I expected to see this happen: Code compiles fine: the type of foo() is Send.
Instead, this happened: The type of foo() is not send, since the backing state-machine generator produced for it now captures part of the fmt internals involving a & reference to the extern { type Opaque; }, which is not Sync.
Version it worked on
It most recently worked on: beta
Version with regression
rustc --version --verbose:
nightly-2022-01-23 84322efad553c7a79c80
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
Context
This has already tripped up some people which seem to get quite confused with this error message, so I'd rather we not regress here:
Code
I tried this code:
I expected to see this happen: Code compiles fine: the type of
foo()isSend.Instead, this happened: The type of
foo()is not send, since the backing state-machine generator produced for it now captures part of thefmtinternals involving a&reference to theextern { type Opaque; }, which is notSync.Version it worked on
It most recently worked on: beta
Version with regression
rustc --version --verbose:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged