mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 09:33:26 +00:00
Arena-allocate Crate during lowering.
This commit is contained in:
parent
e05cd155fe
commit
c520cf2253
@ -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 {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user