Add fn_arg_names table.
This commit is contained in:
parent
6cc96a45ac
commit
381d32e7d6
4 changed files with 14 additions and 29 deletions
|
@ -1395,15 +1395,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
||||||
tcx.arena.alloc_from_iter(self.root.lang_items_missing.decode(self))
|
tcx.arena.alloc_from_iter(self.root.lang_items_missing.decode(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_fn_param_names(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [Ident] {
|
|
||||||
let param_names = match self.kind(id) {
|
|
||||||
EntryKind::Fn(data) | EntryKind::ForeignFn(data) => data.decode(self).param_names,
|
|
||||||
EntryKind::AssocFn(data) => data.decode(self).fn_data.param_names,
|
|
||||||
_ => Lazy::empty(),
|
|
||||||
};
|
|
||||||
LazyQueryDecodable::decode_query(Some(param_names), self, tcx, || unreachable!())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn exported_symbols(
|
fn exported_symbols(
|
||||||
self,
|
self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
|
|
@ -139,6 +139,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
mir_const_qualif => { table }
|
mir_const_qualif => { table }
|
||||||
rendered_const => { table }
|
rendered_const => { table }
|
||||||
asyncness => { table }
|
asyncness => { table }
|
||||||
|
fn_arg_names => { table }
|
||||||
|
|
||||||
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
|
trait_def => { cdata.get_trait_def(def_id.index, tcx.sess) }
|
||||||
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
|
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
|
||||||
|
@ -154,7 +155,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
static_mutability => { cdata.static_mutability(def_id.index) }
|
static_mutability => { cdata.static_mutability(def_id.index) }
|
||||||
generator_kind => { cdata.generator_kind(def_id.index) }
|
generator_kind => { cdata.generator_kind(def_id.index) }
|
||||||
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
|
item_attrs => { tcx.arena.alloc_from_iter(cdata.get_item_attrs(def_id.index, tcx.sess)) }
|
||||||
fn_arg_names => { cdata.get_fn_param_names(tcx, def_id.index) }
|
|
||||||
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
|
trait_of_item => { cdata.get_trait_of_item(def_id.index) }
|
||||||
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
|
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
|
||||||
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
|
is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) }
|
||||||
|
|
|
@ -1195,12 +1195,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
ty::AssocKind::Fn => {
|
ty::AssocKind::Fn => {
|
||||||
let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind {
|
let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind {
|
||||||
let param_names = match *m {
|
match *m {
|
||||||
hir::TraitFn::Required(ref names) => self.encode_fn_param_names(names),
|
hir::TraitFn::Required(ref names) => {
|
||||||
hir::TraitFn::Provided(body) => self.encode_fn_param_names_for_body(body),
|
record!(self.tables.fn_arg_names[def_id] <- *names)
|
||||||
|
}
|
||||||
|
hir::TraitFn::Provided(body) => {
|
||||||
|
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
|
record!(self.tables.asyncness[def_id] <- m_sig.header.asyncness);
|
||||||
FnData { constness: hir::Constness::NotConst, param_names }
|
FnData { constness: hir::Constness::NotConst }
|
||||||
} else {
|
} else {
|
||||||
bug!()
|
bug!()
|
||||||
};
|
};
|
||||||
|
@ -1262,6 +1266,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
ty::AssocKind::Fn => {
|
ty::AssocKind::Fn => {
|
||||||
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
|
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
|
||||||
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||||
|
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
|
||||||
FnData {
|
FnData {
|
||||||
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
|
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
|
||||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||||
|
@ -1269,7 +1274,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
hir::Constness::NotConst
|
hir::Constness::NotConst
|
||||||
},
|
},
|
||||||
param_names: self.encode_fn_param_names_for_body(body),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bug!()
|
bug!()
|
||||||
|
@ -1294,14 +1298,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Ident]> {
|
|
||||||
self.lazy(self.tcx.hir().body_param_names(body_id))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn encode_fn_param_names(&mut self, param_names: &[Ident]) -> Lazy<[Ident]> {
|
|
||||||
self.lazy(param_names.iter())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn encode_mir(&mut self) {
|
fn encode_mir(&mut self) {
|
||||||
if self.is_proc_macro {
|
if self.is_proc_macro {
|
||||||
return;
|
return;
|
||||||
|
@ -1405,10 +1401,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
hir::ItemKind::Fn(ref sig, .., body) => {
|
hir::ItemKind::Fn(ref sig, .., body) => {
|
||||||
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
record!(self.tables.asyncness[def_id] <- sig.header.asyncness);
|
||||||
let data = FnData {
|
record!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
|
||||||
constness: sig.header.constness,
|
let data = FnData { constness: sig.header.constness };
|
||||||
param_names: self.encode_fn_param_names_for_body(body),
|
|
||||||
};
|
|
||||||
|
|
||||||
EntryKind::Fn(self.lazy(data))
|
EntryKind::Fn(self.lazy(data))
|
||||||
}
|
}
|
||||||
|
@ -1874,13 +1868,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
match nitem.kind {
|
match nitem.kind {
|
||||||
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
hir::ForeignItemKind::Fn(_, ref names, _) => {
|
||||||
record!(self.tables.asyncness[def_id] <- hir::IsAsync::NotAsync);
|
record!(self.tables.asyncness[def_id] <- hir::IsAsync::NotAsync);
|
||||||
|
record!(self.tables.fn_arg_names[def_id] <- *names);
|
||||||
let data = FnData {
|
let data = FnData {
|
||||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||||
hir::Constness::Const
|
hir::Constness::Const
|
||||||
} else {
|
} else {
|
||||||
hir::Constness::NotConst
|
hir::Constness::NotConst
|
||||||
},
|
},
|
||||||
param_names: self.encode_fn_param_names(names),
|
|
||||||
};
|
};
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::ForeignFn(self.lazy(data)));
|
record!(self.tables.kind[def_id] <- EntryKind::ForeignFn(self.lazy(data)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,6 +311,7 @@ define_tables! {
|
||||||
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
|
mir_const_qualif: Table<DefIndex, Lazy!(mir::ConstQualifs)>,
|
||||||
rendered_const: Table<DefIndex, Lazy!(String)>,
|
rendered_const: Table<DefIndex, Lazy!(String)>,
|
||||||
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
|
asyncness: Table<DefIndex, Lazy!(hir::IsAsync)>,
|
||||||
|
fn_arg_names: Table<DefIndex, Lazy!([Ident])>,
|
||||||
|
|
||||||
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
trait_item_def_id: Table<DefIndex, Lazy<DefId>>,
|
||||||
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
inherent_impls: Table<DefIndex, Lazy<[DefIndex]>>,
|
||||||
|
@ -363,7 +364,6 @@ enum EntryKind {
|
||||||
#[derive(MetadataEncodable, MetadataDecodable)]
|
#[derive(MetadataEncodable, MetadataDecodable)]
|
||||||
struct FnData {
|
struct FnData {
|
||||||
constness: hir::Constness,
|
constness: hir::Constness,
|
||||||
param_names: Lazy<[Ident]>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(TyEncodable, TyDecodable)]
|
#[derive(TyEncodable, TyDecodable)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue