Skip to content

Commit a19aed2

Browse files
committed
Add intern table for List<PlaceElem<'tcx>>
1 parent 190802c commit a19aed2

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/librustc/ty/context.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::middle::cstore::EncodedMetadata;
2121
use crate::middle::lang_items;
2222
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
2323
use crate::middle::stability;
24-
use crate::mir::{Body, interpret, ProjectionKind, Promoted};
24+
use crate::mir::{Body, interpret, PlaceElem, ProjectionKind, Promoted};
2525
use crate::mir::interpret::{ConstValue, Allocation, Scalar};
2626
use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef, Subst};
2727
use crate::ty::ReprOptions;
@@ -106,6 +106,7 @@ pub struct CtxtInterners<'tcx> {
106106
goal: InternedSet<'tcx, GoalKind<'tcx>>,
107107
goal_list: InternedSet<'tcx, List<Goal<'tcx>>>,
108108
projs: InternedSet<'tcx, List<ProjectionKind>>,
109+
place_elems: InternedSet<'tcx, List<PlaceElem<'tcx>>>,
109110
const_: InternedSet<'tcx, Const<'tcx>>,
110111
}
111112

@@ -124,6 +125,7 @@ impl<'tcx> CtxtInterners<'tcx> {
124125
goal: Default::default(),
125126
goal_list: Default::default(),
126127
projs: Default::default(),
128+
place_elems: Default::default(),
127129
const_: Default::default(),
128130
}
129131
}
@@ -2145,6 +2147,13 @@ impl<'tcx> Borrow<[ProjectionKind]>
21452147
}
21462148
}
21472149

2150+
impl<'tcx> Borrow<[PlaceElem<'tcx>]>
2151+
for Interned<'tcx, List<PlaceElem<'tcx>>> {
2152+
fn borrow(&self) -> &[PlaceElem<'tcx>] {
2153+
&self.0[..]
2154+
}
2155+
}
2156+
21482157
impl<'tcx> Borrow<RegionKind> for Interned<'tcx, RegionKind> {
21492158
fn borrow(&self) -> &RegionKind {
21502159
&self.0
@@ -2245,7 +2254,8 @@ slice_interners!(
22452254
predicates: _intern_predicates(Predicate<'tcx>),
22462255
clauses: _intern_clauses(Clause<'tcx>),
22472256
goal_list: _intern_goals(Goal<'tcx>),
2248-
projs: _intern_projs(ProjectionKind)
2257+
projs: _intern_projs(ProjectionKind),
2258+
place_elems: _intern_place_elems(PlaceElem<'tcx>)
22492259
);
22502260

22512261
impl<'tcx> TyCtxt<'tcx> {
@@ -2631,6 +2641,14 @@ impl<'tcx> TyCtxt<'tcx> {
26312641
}
26322642
}
26332643

2644+
pub fn intern_place_elems(self, ts: &[PlaceElem<'tcx>]) -> &'tcx List<PlaceElem<'tcx>> {
2645+
if ts.len() == 0 {
2646+
List::empty()
2647+
} else {
2648+
self._intern_place_elems(ts)
2649+
}
2650+
}
2651+
26342652
pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'tcx> {
26352653
if ts.len() == 0 {
26362654
List::empty()

0 commit comments

Comments
 (0)