Skip to content

File tree

23 files changed

+107
-89
lines changed

23 files changed

+107
-89
lines changed
 

‎src/librustc/arena.rs

+42
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,48 @@ macro_rules! arena_types {
1616
)>,
1717
[few] mir_keys: rustc::util::nodemap::DefIdSet,
1818
[decode] specialization_graph: rustc::traits::specialization_graph::Graph,
19+
[] region_scope_tree: rustc::middle::region::ScopeTree,
20+
[] item_local_set: rustc::util::nodemap::ItemLocalSet,
21+
[decode] mir_const_qualif: rustc_data_structures::bit_set::BitSet<rustc::mir::Local>,
22+
[] trait_impls_of: rustc::ty::trait_def::TraitImpls,
23+
[] dropck_outlives:
24+
rustc::infer::canonical::Canonical<'tcx,
25+
rustc::infer::canonical::QueryResponse<'tcx,
26+
rustc::traits::query::dropck_outlives::DropckOutlivesResult<'tcx>
27+
>
28+
>,
29+
[] normalize_projection_ty:
30+
rustc::infer::canonical::Canonical<'tcx,
31+
rustc::infer::canonical::QueryResponse<'tcx,
32+
rustc::traits::query::normalize::NormalizationResult<'tcx>
33+
>
34+
>,
35+
[] implied_outlives_bounds:
36+
rustc::infer::canonical::Canonical<'tcx,
37+
rustc::infer::canonical::QueryResponse<'tcx,
38+
Vec<rustc::traits::query::outlives_bounds::OutlivesBound<'tcx>>
39+
>
40+
>,
41+
[] type_op_subtype:
42+
rustc::infer::canonical::Canonical<'tcx,
43+
rustc::infer::canonical::QueryResponse<'tcx, ()>
44+
>,
45+
[] type_op_normalize_poly_fn_sig:
46+
rustc::infer::canonical::Canonical<'tcx,
47+
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::PolyFnSig<'tcx>>
48+
>,
49+
[] type_op_normalize_fn_sig:
50+
rustc::infer::canonical::Canonical<'tcx,
51+
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::FnSig<'tcx>>
52+
>,
53+
[] type_op_normalize_predicate:
54+
rustc::infer::canonical::Canonical<'tcx,
55+
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Predicate<'tcx>>
56+
>,
57+
[] type_op_normalize_ty:
58+
rustc::infer::canonical::Canonical<'tcx,
59+
rustc::infer::canonical::QueryResponse<'tcx, rustc::ty::Ty<'tcx>>
60+
>,
1961
], $tcx);
2062
)
2163
}

‎src/librustc/infer/canonical/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
2424
use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin};
2525
use rustc_data_structures::indexed_vec::IndexVec;
26-
use rustc_data_structures::sync::Lrc;
2726
use rustc_macros::HashStable;
2827
use serialize::UseSpecializedDecodable;
2928
use smallvec::SmallVec;
@@ -186,7 +185,7 @@ pub struct QueryResponse<'tcx, R> {
186185
pub type Canonicalized<'gcx, V> = Canonical<'gcx, <V as Lift<'gcx>>::Lifted>;
187186

188187
pub type CanonicalizedQueryResponse<'gcx, T> =
189-
Lrc<Canonical<'gcx, QueryResponse<'gcx, <T as Lift<'gcx>>::Lifted>>>;
188+
&'gcx Canonical<'gcx, QueryResponse<'gcx, <T as Lift<'gcx>>::Lifted>>;
190189

191190
/// Indicates whether or not we were able to prove the query to be
192191
/// true.

‎src/librustc/infer/canonical/query_response.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//!
88
//! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html
99
10+
use crate::arena::ArenaAllocatable;
1011
use crate::infer::canonical::substitute::substitute_value;
1112
use crate::infer::canonical::{
1213
Canonical, CanonicalVarValues, CanonicalizedQueryResponse, Certainty,
@@ -17,7 +18,6 @@ use crate::infer::InferCtxtBuilder;
1718
use crate::infer::{InferCtxt, InferOk, InferResult};
1819
use rustc_data_structures::indexed_vec::Idx;
1920
use rustc_data_structures::indexed_vec::IndexVec;
20-
use rustc_data_structures::sync::Lrc;
2121
use std::fmt::Debug;
2222
use syntax_pos::DUMMY_SP;
2323
use crate::traits::query::{Fallible, NoSolution};
@@ -54,6 +54,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> {
5454
where
5555
K: TypeFoldable<'tcx>,
5656
R: Debug + Lift<'gcx> + TypeFoldable<'tcx>,
57+
Canonical<'gcx, <QueryResponse<'gcx, R> as Lift<'gcx>>::Lifted>: ArenaAllocatable,
5758
{
5859
self.enter_with_canonical(
5960
DUMMY_SP,
@@ -99,6 +100,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
99100
) -> Fallible<CanonicalizedQueryResponse<'gcx, T>>
100101
where
101102
T: Debug + Lift<'gcx> + TypeFoldable<'tcx>,
103+
Canonical<'gcx, <QueryResponse<'gcx, T> as Lift<'gcx>>::Lifted>: ArenaAllocatable,
102104
{
103105
let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?;
104106
let canonical_result = self.canonicalize_response(&query_response);
@@ -108,7 +110,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
108110
canonical_result
109111
);
110112

111-
Ok(Lrc::new(canonical_result))
113+
Ok(self.tcx.arena.alloc(canonical_result))
112114
}
113115

114116
/// A version of `make_canonicalized_query_response` that does

‎src/librustc/middle/expr_use_visitor.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use crate::middle::region;
1717
use crate::ty::{self, DefIdTree, TyCtxt, adjustment};
1818

1919
use crate::hir::{self, PatKind};
20-
use rustc_data_structures::sync::Lrc;
2120
use std::rc::Rc;
2221
use syntax::ptr::P;
2322
use syntax_pos::Span;
@@ -272,7 +271,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
272271
param_env: ty::ParamEnv<'tcx>,
273272
region_scope_tree: &'a region::ScopeTree,
274273
tables: &'a ty::TypeckTables<'tcx>,
275-
rvalue_promotable_map: Option<Lrc<ItemLocalSet>>)
274+
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
276275
-> Self
277276
{
278277
ExprUseVisitor {

‎src/librustc/middle/mem_categorization.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ use syntax_pos::Span;
7777
use std::borrow::Cow;
7878
use std::fmt;
7979
use std::hash::{Hash, Hasher};
80-
use rustc_data_structures::sync::Lrc;
8180
use rustc_data_structures::indexed_vec::Idx;
8281
use std::rc::Rc;
8382
use crate::util::nodemap::ItemLocalSet;
@@ -290,7 +289,7 @@ pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
290289
pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
291290
pub region_scope_tree: &'a region::ScopeTree,
292291
pub tables: &'a ty::TypeckTables<'tcx>,
293-
rvalue_promotable_map: Option<Lrc<ItemLocalSet>>,
292+
rvalue_promotable_map: Option<&'tcx ItemLocalSet>,
294293
infcx: Option<&'a InferCtxt<'a, 'gcx, 'tcx>>,
295294
}
296295

@@ -400,7 +399,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx, 'tcx> {
400399
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
401400
region_scope_tree: &'a region::ScopeTree,
402401
tables: &'a ty::TypeckTables<'tcx>,
403-
rvalue_promotable_map: Option<Lrc<ItemLocalSet>>)
402+
rvalue_promotable_map: Option<&'tcx ItemLocalSet>)
404403
-> MemCategorizationContext<'a, 'tcx, 'tcx> {
405404
MemCategorizationContext {
406405
tcx,

‎src/librustc/middle/region.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::ty;
1212

1313
use std::mem;
1414
use std::fmt;
15-
use rustc_data_structures::sync::Lrc;
1615
use rustc_macros::HashStable;
1716
use syntax::source_map;
1817
use syntax::ast;
@@ -1329,7 +1328,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
13291328
}
13301329

13311330
fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
1332-
-> Lrc<ScopeTree>
1331+
-> &'tcx ScopeTree
13331332
{
13341333
let closure_base_def_id = tcx.closure_base_def_id(def_id);
13351334
if closure_base_def_id != def_id {
@@ -1371,7 +1370,7 @@ fn region_scope_tree<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
13711370
ScopeTree::default()
13721371
};
13731372

1374-
Lrc::new(scope_tree)
1373+
tcx.arena.alloc(scope_tree)
13751374
}
13761375

13771376
pub fn provide(providers: &mut Providers<'_>) {

‎src/librustc/query/mod.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ rustc_queries! {
9191
/// Maps DefId's that have an associated Mir to the result
9292
/// of the MIR qualify_consts pass. The actual meaning of
9393
/// the value isn't known except to the pass itself.
94-
query mir_const_qualif(key: DefId) -> (u8, Lrc<BitSet<mir::Local>>) {
94+
query mir_const_qualif(key: DefId) -> (u8, &'tcx BitSet<mir::Local>) {
9595
cache { key.is_local() }
9696
}
9797

@@ -174,7 +174,7 @@ rustc_queries! {
174174

175175
/// Returns the inferred outlives predicates (e.g., for `struct
176176
/// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
177-
query inferred_outlives_of(_: DefId) -> Lrc<Vec<ty::Predicate<'tcx>>> {}
177+
query inferred_outlives_of(_: DefId) -> &'tcx [ty::Predicate<'tcx>] {}
178178

179179
/// Maps from the `DefId` of a trait to the list of
180180
/// super-predicates. This is a subset of the full list of
@@ -456,7 +456,7 @@ rustc_queries! {
456456

457457
/// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
458458
/// in the case of closures, this will be redirected to the enclosing function.
459-
query region_scope_tree(_: DefId) -> Lrc<region::ScopeTree> {}
459+
query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {}
460460

461461
query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx> {
462462
no_force
@@ -504,7 +504,7 @@ rustc_queries! {
504504
}
505505
cache { true }
506506
}
507-
query rvalue_promotable_map(key: DefId) -> Lrc<ItemLocalSet> {
507+
query rvalue_promotable_map(key: DefId) -> &'tcx ItemLocalSet {
508508
desc { |tcx|
509509
"checking which parts of `{}` are promotable to static",
510510
tcx.def_path_str(key)
@@ -540,7 +540,7 @@ rustc_queries! {
540540
}
541541

542542
TypeChecking {
543-
query trait_impls_of(key: DefId) -> Lrc<ty::trait_def::TraitImpls> {
543+
query trait_impls_of(key: DefId) -> &'tcx ty::trait_def::TraitImpls {
544544
desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
545545
}
546546
query specialization_graph_of(_: DefId) -> &'tcx specialization_graph::Graph {}
@@ -892,7 +892,7 @@ rustc_queries! {
892892
query normalize_projection_ty(
893893
goal: CanonicalProjectionGoal<'tcx>
894894
) -> Result<
895-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>>,
895+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
896896
NoSolution,
897897
> {
898898
no_force
@@ -910,7 +910,7 @@ rustc_queries! {
910910
query implied_outlives_bounds(
911911
goal: CanonicalTyGoal<'tcx>
912912
) -> Result<
913-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>>,
913+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
914914
NoSolution,
915915
> {
916916
no_force
@@ -921,7 +921,7 @@ rustc_queries! {
921921
query dropck_outlives(
922922
goal: CanonicalTyGoal<'tcx>
923923
) -> Result<
924-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>>,
924+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
925925
NoSolution,
926926
> {
927927
no_force
@@ -940,7 +940,7 @@ rustc_queries! {
940940
query evaluate_goal(
941941
goal: traits::ChalkCanonicalGoal<'tcx>
942942
) -> Result<
943-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
943+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
944944
NoSolution
945945
> {
946946
no_force
@@ -951,7 +951,7 @@ rustc_queries! {
951951
query type_op_ascribe_user_type(
952952
goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
953953
) -> Result<
954-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
954+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
955955
NoSolution,
956956
> {
957957
no_force
@@ -962,7 +962,7 @@ rustc_queries! {
962962
query type_op_eq(
963963
goal: CanonicalTypeOpEqGoal<'tcx>
964964
) -> Result<
965-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
965+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
966966
NoSolution,
967967
> {
968968
no_force
@@ -973,7 +973,7 @@ rustc_queries! {
973973
query type_op_subtype(
974974
goal: CanonicalTypeOpSubtypeGoal<'tcx>
975975
) -> Result<
976-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
976+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
977977
NoSolution,
978978
> {
979979
no_force
@@ -984,7 +984,7 @@ rustc_queries! {
984984
query type_op_prove_predicate(
985985
goal: CanonicalTypeOpProvePredicateGoal<'tcx>
986986
) -> Result<
987-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>>,
987+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
988988
NoSolution,
989989
> {
990990
no_force
@@ -995,7 +995,7 @@ rustc_queries! {
995995
query type_op_normalize_ty(
996996
goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
997997
) -> Result<
998-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>>,
998+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
999999
NoSolution,
10001000
> {
10011001
no_force
@@ -1006,7 +1006,7 @@ rustc_queries! {
10061006
query type_op_normalize_predicate(
10071007
goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
10081008
) -> Result<
1009-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>>,
1009+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
10101010
NoSolution,
10111011
> {
10121012
no_force
@@ -1017,7 +1017,7 @@ rustc_queries! {
10171017
query type_op_normalize_poly_fn_sig(
10181018
goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
10191019
) -> Result<
1020-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>>,
1020+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
10211021
NoSolution,
10221022
> {
10231023
no_force
@@ -1028,7 +1028,7 @@ rustc_queries! {
10281028
query type_op_normalize_fn_sig(
10291029
goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
10301030
) -> Result<
1031-
Lrc<Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>>,
1031+
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
10321032
NoSolution,
10331033
> {
10341034
no_force

‎src/librustc/ty/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1120,11 +1120,7 @@ pub struct CratePredicatesMap<'tcx> {
11201120
/// For each struct with outlive bounds, maps to a vector of the
11211121
/// predicate of its outlive bounds. If an item has no outlives
11221122
/// bounds, it will have no entry.
1123-
pub predicates: FxHashMap<DefId, Lrc<Vec<ty::Predicate<'tcx>>>>,
1124-
1125-
/// An empty vector, useful for cloning.
1126-
#[stable_hasher(ignore)]
1127-
pub empty_predicate: Lrc<Vec<ty::Predicate<'tcx>>>,
1123+
pub predicates: FxHashMap<DefId, &'tcx [ty::Predicate<'tcx>]>,
11281124
}
11291125

11301126
impl<'tcx> AsRef<Predicate<'tcx>> for Predicate<'tcx> {

‎src/librustc/ty/trait_def.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::ty::{Ty, TyCtxt};
1010
use rustc_data_structures::fx::FxHashMap;
1111
use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
1212
StableHasherResult};
13-
use rustc_data_structures::sync::Lrc;
1413
use rustc_macros::HashStable;
1514

1615
/// A trait's definition with type information.
@@ -151,7 +150,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
151150
// Query provider for `trait_impls_of`.
152151
pub(super) fn trait_impls_of_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
153152
trait_id: DefId)
154-
-> Lrc<TraitImpls> {
153+
-> &'tcx TraitImpls {
155154
let mut impls = TraitImpls::default();
156155

157156
{
@@ -188,7 +187,7 @@ pub(super) fn trait_impls_of_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
188187
}
189188
}
190189

191-
Lrc::new(impls)
190+
tcx.arena.alloc(impls)
192191
}
193192

194193
impl<'a> HashStable<StableHashingContext<'a>> for TraitImpls {

‎src/librustc_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> {
228228
// Some in `borrowck_fn` and cleared later
229229
tables: &'a ty::TypeckTables<'tcx>,
230230

231-
region_scope_tree: Lrc<region::ScopeTree>,
231+
region_scope_tree: &'tcx region::ScopeTree,
232232

233233
owner_def_id: DefId,
234234

‎src/librustc_metadata/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
131131
mir
132132
}
133133
mir_const_qualif => {
134-
(cdata.mir_const_qualif(def_id.index), Lrc::new(BitSet::new_empty(0)))
134+
(cdata.mir_const_qualif(def_id.index), tcx.arena.alloc(BitSet::new_empty(0)))
135135
}
136136
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
137137
inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }

0 commit comments

Comments
 (0)
Please sign in to comment.