diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2019-10-11 16:19:59 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2019-10-22 10:33:36 -0300 |
| commit | a19aed222622129dda8e7bf36935d72f82654e54 (patch) | |
| tree | 20289268b97d01e7f907dd6e5bd91999420955f0 | |
| parent | 190802cfca41df76fd7ef45d2915c89938a5904a (diff) | |
| download | rust-a19aed222622129dda8e7bf36935d72f82654e54.tar.gz rust-a19aed222622129dda8e7bf36935d72f82654e54.zip | |
Add intern table for `List<PlaceElem<'tcx>>`
| -rw-r--r-- | src/librustc/ty/context.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 665d4c2d069..da86335345c 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -21,7 +21,7 @@ use crate::middle::cstore::EncodedMetadata; use crate::middle::lang_items; use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use crate::middle::stability; -use crate::mir::{Body, interpret, ProjectionKind, Promoted}; +use crate::mir::{Body, interpret, PlaceElem, ProjectionKind, Promoted}; use crate::mir::interpret::{ConstValue, Allocation, Scalar}; use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef, Subst}; use crate::ty::ReprOptions; @@ -106,6 +106,7 @@ pub struct CtxtInterners<'tcx> { goal: InternedSet<'tcx, GoalKind<'tcx>>, goal_list: InternedSet<'tcx, List<Goal<'tcx>>>, projs: InternedSet<'tcx, List<ProjectionKind>>, + place_elems: InternedSet<'tcx, List<PlaceElem<'tcx>>>, const_: InternedSet<'tcx, Const<'tcx>>, } @@ -124,6 +125,7 @@ impl<'tcx> CtxtInterners<'tcx> { goal: Default::default(), goal_list: Default::default(), projs: Default::default(), + place_elems: Default::default(), const_: Default::default(), } } @@ -2145,6 +2147,13 @@ impl<'tcx> Borrow<[ProjectionKind]> } } +impl<'tcx> Borrow<[PlaceElem<'tcx>]> + for Interned<'tcx, List<PlaceElem<'tcx>>> { + fn borrow(&self) -> &[PlaceElem<'tcx>] { + &self.0[..] + } +} + impl<'tcx> Borrow<RegionKind> for Interned<'tcx, RegionKind> { fn borrow(&self) -> &RegionKind { &self.0 @@ -2245,7 +2254,8 @@ slice_interners!( predicates: _intern_predicates(Predicate<'tcx>), clauses: _intern_clauses(Clause<'tcx>), goal_list: _intern_goals(Goal<'tcx>), - projs: _intern_projs(ProjectionKind) + projs: _intern_projs(ProjectionKind), + place_elems: _intern_place_elems(PlaceElem<'tcx>) ); impl<'tcx> TyCtxt<'tcx> { @@ -2631,6 +2641,14 @@ impl<'tcx> TyCtxt<'tcx> { } } + pub fn intern_place_elems(self, ts: &[PlaceElem<'tcx>]) -> &'tcx List<PlaceElem<'tcx>> { + if ts.len() == 0 { + List::empty() + } else { + self._intern_place_elems(ts) + } + } + pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'tcx> { if ts.len() == 0 { List::empty() |
