Encode coroutine_by_move_body_def_id in crate metadata
This commit is contained in:
parent
c52c23b6f4
commit
062ff4dfda
@ -290,6 +290,7 @@ fn into_args(self) -> (DefId, SimplifiedType) {
|
||||
fn_arg_names => { table }
|
||||
coroutine_kind => { table_direct }
|
||||
coroutine_for_closure => { table }
|
||||
coroutine_by_move_body_def_id => { table }
|
||||
eval_static_initializer => {
|
||||
Ok(cdata
|
||||
.root
|
||||
|
@ -1488,9 +1488,18 @@ fn encode_def_ids(&mut self) {
|
||||
if def_kind == DefKind::Closure
|
||||
&& tcx.type_of(def_id).skip_binder().is_coroutine_closure()
|
||||
{
|
||||
let coroutine_for_closure = self.tcx.coroutine_for_closure(def_id);
|
||||
self.tables
|
||||
.coroutine_for_closure
|
||||
.set_some(def_id.index, self.tcx.coroutine_for_closure(def_id).into());
|
||||
.set_some(def_id.index, coroutine_for_closure.into());
|
||||
|
||||
// If this async closure has a by-move body, record it too.
|
||||
if tcx.needs_coroutine_by_move_body_def_id(coroutine_for_closure) {
|
||||
self.tables.coroutine_by_move_body_def_id.set_some(
|
||||
coroutine_for_closure.index,
|
||||
self.tcx.coroutine_by_move_body_def_id(coroutine_for_closure).into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
if let DefKind::Static { .. } = def_kind {
|
||||
if !self.tcx.is_foreign_item(def_id) {
|
||||
|
@ -446,6 +446,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
|
||||
fn_arg_names: Table<DefIndex, LazyArray<Ident>>,
|
||||
coroutine_kind: Table<DefIndex, hir::CoroutineKind>,
|
||||
coroutine_for_closure: Table<DefIndex, RawDefId>,
|
||||
coroutine_by_move_body_def_id: Table<DefIndex, RawDefId>,
|
||||
eval_static_initializer: Table<DefIndex, LazyValue<mir::interpret::ConstAllocation<'static>>>,
|
||||
trait_def: Table<DefIndex, LazyValue<ty::TraitDef>>,
|
||||
trait_item_def_id: Table<DefIndex, RawDefId>,
|
||||
|
@ -12,8 +12,13 @@
|
||||
|
||||
struct NoCopy;
|
||||
|
||||
async fn call_once(f: impl async FnOnce()) {
|
||||
f().await;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
block_on::block_on(async {
|
||||
foreign::closure()().await;
|
||||
call_once(foreign::closure()).await;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user