Skip to content

Commit ea1c6df

Browse files
committed
rustc: stop interning CodeExtent, it's small enough.
1 parent da8b6e2 commit ea1c6df

File tree

35 files changed

+239
-320
lines changed

35 files changed

+239
-320
lines changed

src/librustc/cfg/construct.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use rustc_data_structures::graph;
1212
use cfg::*;
13+
use middle::region::CodeExtent;
1314
use ty::{self, TyCtxt};
1415
use syntax::ast;
1516
use syntax::ptr::P;
@@ -586,8 +587,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
586587
scope_id: ast::NodeId,
587588
to_index: CFGIndex) {
588589
let mut data = CFGEdgeData { exiting_scopes: vec![] };
589-
let mut scope = self.tcx.node_extent(from_expr.id);
590-
let target_scope = self.tcx.node_extent(scope_id);
590+
let mut scope = CodeExtent::Misc(from_expr.id);
591+
let target_scope = CodeExtent::Misc(scope_id);
591592
let region_maps = self.tcx.region_maps(self.owner_def_id);
592593
while scope != target_scope {
593594
data.exiting_scopes.push(scope.node_id());

src/librustc/ich/impls_ty.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::subst::Kind<'t
3939
}
4040
}
4141

42-
impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::RegionKind<'tcx> {
42+
impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ty::RegionKind {
4343
fn hash_stable<W: StableHasherResult>(&self,
4444
hcx: &mut StableHashingContext<'a, 'tcx>,
4545
hasher: &mut StableHasher<W>) {
@@ -428,24 +428,24 @@ impl_stable_hash_for!(enum ty::cast::CastKind {
428428
FnPtrAddrCast
429429
});
430430

431-
impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::CodeExtentData
431+
impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::CodeExtent
432432
{
433433
fn hash_stable<W: StableHasherResult>(&self,
434434
hcx: &mut StableHashingContext<'a, 'tcx>,
435435
hasher: &mut StableHasher<W>) {
436-
use middle::region::CodeExtentData;
436+
use middle::region::CodeExtent;
437437

438438
mem::discriminant(self).hash_stable(hcx, hasher);
439439
match *self {
440-
CodeExtentData::Misc(node_id) |
441-
CodeExtentData::DestructionScope(node_id) => {
440+
CodeExtent::Misc(node_id) |
441+
CodeExtent::DestructionScope(node_id) => {
442442
node_id.hash_stable(hcx, hasher);
443443
}
444-
CodeExtentData::CallSiteScope(body_id) |
445-
CodeExtentData::ParameterScope(body_id) => {
444+
CodeExtent::CallSiteScope(body_id) |
445+
CodeExtent::ParameterScope(body_id) => {
446446
body_id.hash_stable(hcx, hasher);
447447
}
448-
CodeExtentData::Remainder(block_remainder) => {
448+
CodeExtent::Remainder(block_remainder) => {
449449
block_remainder.hash_stable(hcx, hasher);
450450
}
451451
}

src/librustc/infer/error_reporting/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
151151
return;
152152
}
153153
};
154-
let scope_decorated_tag = match *scope {
155-
region::CodeExtentData::Misc(_) => tag,
156-
region::CodeExtentData::CallSiteScope(_) => {
154+
let scope_decorated_tag = match scope {
155+
region::CodeExtent::Misc(_) => tag,
156+
region::CodeExtent::CallSiteScope(_) => {
157157
"scope of call-site for function"
158158
}
159-
region::CodeExtentData::ParameterScope(_) => {
159+
region::CodeExtent::ParameterScope(_) => {
160160
"scope of function body"
161161
}
162-
region::CodeExtentData::DestructionScope(_) => {
162+
region::CodeExtent::DestructionScope(_) => {
163163
new_string = format!("destruction scope surrounding {}", tag);
164164
&new_string[..]
165165
}
166-
region::CodeExtentData::Remainder(r) => {
166+
region::CodeExtent::Remainder(r) => {
167167
new_string = format!("block suffix following statement {}",
168168
r.first_statement_index);
169169
&new_string[..]

src/librustc/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13241324

13251325
pub fn resolve_regions_and_report_errors(&self,
13261326
region_context: DefId,
1327-
region_map: &RegionMaps<'tcx>,
1327+
region_map: &RegionMaps,
13281328
free_regions: &FreeRegionMap<'tcx>) {
13291329
let region_rels = RegionRelations::new(self.tcx,
13301330
region_context,

src/librustc/infer/region_inference/graphviz.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,20 @@ struct ConstraintGraph<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
124124
graph_name: String,
125125
region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>,
126126
map: &'a FxHashMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
127-
node_ids: FxHashMap<Node<'tcx>, usize>,
127+
node_ids: FxHashMap<Node, usize>,
128128
}
129129

130130
#[derive(Clone, Hash, PartialEq, Eq, Debug, Copy)]
131-
enum Node<'tcx> {
131+
enum Node {
132132
RegionVid(ty::RegionVid),
133-
Region(ty::RegionKind<'tcx>),
133+
Region(ty::RegionKind),
134134
}
135135

136136
// type Edge = Constraint;
137137
#[derive(Clone, PartialEq, Eq, Debug, Copy)]
138138
enum Edge<'tcx> {
139139
Constraint(Constraint<'tcx>),
140-
EnclScope(CodeExtent<'tcx>, CodeExtent<'tcx>),
140+
EnclScope(CodeExtent, CodeExtent),
141141
}
142142

143143
impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> {
@@ -176,7 +176,7 @@ impl<'a, 'gcx, 'tcx> ConstraintGraph<'a, 'gcx, 'tcx> {
176176
}
177177

178178
impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
179-
type Node = Node<'tcx>;
179+
type Node = Node;
180180
type Edge = Edge<'tcx>;
181181
fn graph_id(&self) -> dot::Id {
182182
dot::Id::new(&*self.graph_name).unwrap()
@@ -209,7 +209,7 @@ impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
209209
}
210210
}
211211

212-
fn constraint_to_nodes<'tcx>(c: &Constraint<'tcx>) -> (Node<'tcx>, Node<'tcx>) {
212+
fn constraint_to_nodes(c: &Constraint) -> (Node, Node) {
213213
match *c {
214214
Constraint::ConstrainVarSubVar(rv_1, rv_2) =>
215215
(Node::RegionVid(rv_1), Node::RegionVid(rv_2)),
@@ -222,7 +222,7 @@ fn constraint_to_nodes<'tcx>(c: &Constraint<'tcx>) -> (Node<'tcx>, Node<'tcx>) {
222222
}
223223
}
224224

225-
fn edge_to_nodes<'tcx>(e: &Edge<'tcx>) -> (Node<'tcx>, Node<'tcx>) {
225+
fn edge_to_nodes(e: &Edge) -> (Node, Node) {
226226
match *e {
227227
Edge::Constraint(ref c) => constraint_to_nodes(c),
228228
Edge::EnclScope(sub, sup) => {
@@ -233,9 +233,9 @@ fn edge_to_nodes<'tcx>(e: &Edge<'tcx>) -> (Node<'tcx>, Node<'tcx>) {
233233
}
234234

235235
impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
236-
type Node = Node<'tcx>;
236+
type Node = Node;
237237
type Edge = Edge<'tcx>;
238-
fn nodes(&self) -> dot::Nodes<Node<'tcx>> {
238+
fn nodes(&self) -> dot::Nodes<Node> {
239239
let mut set = FxHashSet();
240240
for node in self.node_ids.keys() {
241241
set.insert(*node);
@@ -250,12 +250,12 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
250250
debug!("region graph has {} edges", v.len());
251251
Cow::Owned(v)
252252
}
253-
fn source(&self, edge: &Edge<'tcx>) -> Node<'tcx> {
253+
fn source(&self, edge: &Edge<'tcx>) -> Node {
254254
let (n1, _) = edge_to_nodes(edge);
255255
debug!("edge {:?} has source {:?}", edge, n1);
256256
n1
257257
}
258-
fn target(&self, edge: &Edge<'tcx>) -> Node<'tcx> {
258+
fn target(&self, edge: &Edge<'tcx>) -> Node {
259259
let (_, n2) = edge_to_nodes(edge);
260260
debug!("edge {:?} has target {:?}", edge, n2);
261261
n2

src/librustc/middle/expr_use_visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ enum PassArgs {
271271

272272
impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
273273
pub fn new(delegate: &'a mut (Delegate<'tcx>+'a),
274-
region_maps: &'a RegionMaps<'tcx>,
274+
region_maps: &'a RegionMaps,
275275
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>)
276276
-> Self
277277
{
@@ -283,7 +283,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
283283

284284
pub fn with_options(delegate: &'a mut (Delegate<'tcx>+'a),
285285
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
286-
region_maps: &'a RegionMaps<'tcx>,
286+
region_maps: &'a RegionMaps,
287287
options: mc::MemCategorizationOptions)
288288
-> Self
289289
{

src/librustc/middle/free_region.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct RegionRelations<'a, 'gcx: 'tcx, 'tcx: 'a> {
3535
pub context: DefId,
3636

3737
/// region maps for the given context
38-
pub region_maps: &'a RegionMaps<'tcx>,
38+
pub region_maps: &'a RegionMaps,
3939

4040
/// free-region relationships
4141
pub free_regions: &'a FreeRegionMap<'tcx>,
@@ -45,7 +45,7 @@ impl<'a, 'gcx, 'tcx> RegionRelations<'a, 'gcx, 'tcx> {
4545
pub fn new(
4646
tcx: TyCtxt<'a, 'gcx, 'tcx>,
4747
context: DefId,
48-
region_maps: &'a RegionMaps<'tcx>,
48+
region_maps: &'a RegionMaps,
4949
free_regions: &'a FreeRegionMap<'tcx>,
5050
) -> Self {
5151
Self {

src/librustc/middle/mem_categorization.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl ast_node for hir::Pat {
290290
#[derive(Clone)]
291291
pub struct MemCategorizationContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
292292
pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
293-
pub region_maps: &'a RegionMaps<'tcx>,
293+
pub region_maps: &'a RegionMaps,
294294
options: MemCategorizationOptions,
295295
}
296296

@@ -406,15 +406,15 @@ impl MutabilityCategory {
406406
impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
407407
/// Context should be the `DefId` we use to fetch region-maps.
408408
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
409-
region_maps: &'a RegionMaps<'tcx>)
409+
region_maps: &'a RegionMaps)
410410
-> MemCategorizationContext<'a, 'gcx, 'tcx> {
411411
MemCategorizationContext::with_options(infcx,
412412
region_maps,
413413
MemCategorizationOptions::default())
414414
}
415415

416416
pub fn with_options(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
417-
region_maps: &'a RegionMaps<'tcx>,
417+
region_maps: &'a RegionMaps,
418418
options: MemCategorizationOptions)
419419
-> MemCategorizationContext<'a, 'gcx, 'tcx> {
420420
MemCategorizationContext {
@@ -839,7 +839,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
839839
pub fn temporary_scope(&self, id: ast::NodeId) -> (ty::Region<'tcx>, ty::Region<'tcx>)
840840
{
841841
let (scope, old_scope) =
842-
self.region_maps.old_and_new_temporary_scope(self.tcx(), id);
842+
self.region_maps.old_and_new_temporary_scope(id);
843843
(self.tcx().mk_region(match scope {
844844
Some(scope) => ty::ReScope(scope),
845845
None => ty::ReStatic

0 commit comments

Comments
 (0)