mirror of https://github.com/rust-lang/rust.git
Encode coroutine_by_move_body_def_id in crate metadata
This commit is contained in:
parent
c52c23b6f4
commit
062ff4dfda
|
@ -290,6 +290,7 @@ provide! { tcx, def_id, other, cdata,
|
|||
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 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
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 @@ define_tables! {
|
|||
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 @@ extern crate foreign;
|
|||
|
||||
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