Skip to content

Commit d1afee2

Browse files
committed
Auto merge of #59540 - Zoxc:the-arena-2, r=<try>
[WIP] Use arenas to avoid Lrc in queries #1 Based on #59536.
2 parents 33fe113 + f8f8bf7 commit d1afee2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/librustc/arena.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ macro_rules! arena_types {
1616
)>,
1717
[few] mir_keys: rustc::util::nodemap::DefIdSet,
1818
[decode] specialization_graph: rustc::traits::specialization_graph::Graph,
19+
[decode] borrowck: rustc::middle::borrowck::BorrowCheckResult,
1920
], $tcx);
2021
)
2122
}

src/librustc/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ rustc_queries! {
368368
}
369369

370370
BorrowChecking {
371-
query borrowck(_: DefId) -> Lrc<BorrowCheckResult> {}
371+
query borrowck(_: DefId) -> &'tcx BorrowCheckResult {}
372372

373373
/// Borrow checks the function body. If this is a closure, returns
374374
/// additional requirements that the closure's creator must verify.

src/librustc_borrowck/borrowck/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
7777
}
7878

7979
fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
80-
-> Lrc<BorrowCheckResult>
80+
-> &'tcx BorrowCheckResult
8181
{
8282
assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck());
8383

@@ -91,7 +91,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
9191
// those things (notably the synthesized constructors from
9292
// tuple structs/variants) do not have an associated body
9393
// and do not need borrowchecking.
94-
return Lrc::new(BorrowCheckResult {
94+
return tcx.arena.alloc(BorrowCheckResult {
9595
used_mut_nodes: Default::default(),
9696
signalled_any_error: SignalledError::NoErrorsSeen,
9797
})
@@ -142,7 +142,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
142142
unused::check(&mut bccx, body);
143143
}
144144

145-
Lrc::new(BorrowCheckResult {
145+
tcx.arena.alloc(BorrowCheckResult {
146146
used_mut_nodes: bccx.used_mut_nodes.into_inner(),
147147
signalled_any_error: bccx.signalled_any_error.into_inner(),
148148
})

0 commit comments

Comments
 (0)