Skip to content

Commit 2129866

Browse files
committed
Directly encode IsAsync in metadata.
1 parent 42820da commit 2129866

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12071207
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body))
12081208
}
12091209
};
1210-
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
1210+
self.tables.asyncness.set(def_id.index, m_sig.header.asyncness);
12111211
self.tables.impl_constness.set(def_id.index, hir::Constness::NotConst);
12121212
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
12131213
container,
@@ -1265,7 +1265,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12651265
}
12661266
ty::AssocKind::Fn => {
12671267
let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind else { bug!() };
1268-
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
1268+
self.tables.asyncness.set(def_id.index, sig.header.asyncness);
12691269
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
12701270
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
12711271
let constness = if self.tcx.is_const_fn_raw(def_id) {
@@ -1394,7 +1394,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13941394
EntryKind::Const
13951395
}
13961396
hir::ItemKind::Fn(ref sig, .., body) => {
1397-
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
1397+
self.tables.asyncness.set(def_id.index, sig.header.asyncness);
13981398
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
13991399
self.tables.impl_constness.set(def_id.index, sig.header.constness);
14001400
EntryKind::Fn
@@ -1886,7 +1886,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18861886

18871887
match nitem.kind {
18881888
hir::ForeignItemKind::Fn(_, ref names, _) => {
1889-
record!(self.tables.asyncness[def_id] <- hir::IsAsync::NotAsync);
1889+
self.tables.asyncness.set(def_id.index, hir::IsAsync::NotAsync);
18901890
record!(self.tables.fn_arg_names[def_id] <- *names);
18911891
let constness = if self.tcx.is_const_fn_raw(def_id) {
18921892
hir::Constness::Const

compiler/rustc_metadata/src/rmeta/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ define_tables! {
317317
coerce_unsized_info: Table<DefIndex, Lazy!(ty::adjustment::CoerceUnsizedInfo)>,
318318
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
319319
rendered_const: Table<DefIndex, Lazy!(String)>,
320-
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
320+
asyncness: Table<DefIndex, hir::IsAsync>,
321321
fn_arg_names: Table<DefIndex, Lazy!([Ident])>,
322322
generator_kind: Table<DefIndex, Lazy!(hir::GeneratorKind)>,
323323
trait_def: Table<DefIndex, Lazy!(ty::TraitDef)>,

compiler/rustc_metadata/src/rmeta/table.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ fixed_size_enum! {
128128
}
129129
}
130130

131+
fixed_size_enum! {
132+
hir::IsAsync {
133+
( NotAsync )
134+
( Async )
135+
}
136+
}
137+
131138
// NOTE(eddyb) there could be an impl for `usize`, which would enable a more
132139
// generic `Lazy<T>` impl, but in the general case we might not need / want to
133140
// fit every `usize` in `u32`.

0 commit comments

Comments
 (0)