Arena-allocate Crate during lowering.

This commit is contained in:
Camille GILLOT 2021-06-11 18:55:14 +02:00
parent e05cd155fe
commit c520cf2253
2 changed files with 6 additions and 6 deletions

View File

@ -296,7 +296,7 @@ pub fn lower_crate<'a, 'hir>(
resolver: &'a mut dyn ResolverAstLowering,
nt_to_tokenstream: NtToTokenstream,
arena: &'hir Arena<'hir>,
) -> hir::Crate<'hir> {
) -> &'hir hir::Crate<'hir> {
let _prof_timer = sess.prof.verbose_generic_activity("hir_lowering");
LoweringContext {
@ -403,7 +403,7 @@ enum AnonymousLifetimeMode {
}
impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn lower_crate(mut self, c: &Crate) -> hir::Crate<'hir> {
fn lower_crate(mut self, c: &Crate) -> &'hir hir::Crate<'hir> {
/// Full-crate AST visitor that inserts into a fresh
/// `LoweringContext` any information that may be
/// needed from arbitrary locations in the crate,
@ -530,7 +530,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
hir::Crate {
let krate = hir::Crate {
item: module,
exported_macros: self.arena.alloc_from_iter(self.exported_macros),
non_exported_macro_attrs: self.arena.alloc_from_iter(self.non_exported_macro_attrs),
@ -545,7 +545,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
proc_macros,
trait_map,
attrs: self.attrs,
}
};
self.arena.alloc(krate)
}
fn insert_item(&mut self, item: hir::Item<'hir>) -> hir::ItemId {

View File

@ -460,7 +460,7 @@ pub fn lower_to_hir<'res, 'tcx>(
resolver: &'res mut Resolver<'_>,
krate: &'res ast::Crate,
arena: &'tcx rustc_ast_lowering::Arena<'tcx>,
) -> Crate<'tcx> {
) -> &'tcx Crate<'tcx> {
// Lower AST to HIR.
let hir_crate = rustc_ast_lowering::lower_crate(
sess,
@ -796,7 +796,6 @@ pub fn create_global_ctxt<'tcx>(
let krate = resolver
.borrow_mut()
.access(|resolver| lower_to_hir(sess, &lint_store, resolver, krate, hir_arena));
let krate = &*hir_arena.alloc(krate);
let resolver_outputs = BoxedResolver::to_resolver_outputs(resolver);
let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess);