Skip to content

Commit 05f333e

Browse files
committed
---
yaml --- r: 150992 b: refs/heads/try2 c: 158d7a1 h: refs/heads/master v: v3
1 parent 216aee4 commit 05f333e

33 files changed

+227
-386
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6c82eb5d4de012ccf38620f81d8655308d37e318
8+
refs/heads/try2: 158d7a19b3f39bcdf3c8d7094fda8f0dd6e121b5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/driver/driver.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
328328
freevars, region_map, lang_items);
329329

330330
// passes are timed inside typeck
331-
let (method_map, vtable_map) = typeck::check_crate(&ty_cx, trait_map, krate);
331+
typeck::check_crate(&ty_cx, trait_map, krate);
332332

333333
time(time_passes, "check static items", (), |_|
334334
middle::check_static::check_crate(&ty_cx, krate));
@@ -338,56 +338,52 @@ pub fn phase_3_run_analysis_passes(sess: Session,
338338
middle::const_eval::process_crate(krate, &ty_cx));
339339

340340
time(time_passes, "const checking", (), |_|
341-
middle::check_const::check_crate(krate, def_map, method_map, &ty_cx));
341+
middle::check_const::check_crate(krate, &ty_cx));
342342

343343
let maps = (external_exports, last_private_map);
344344
let (exported_items, public_items) =
345345
time(time_passes, "privacy checking", maps, |(a, b)|
346-
middle::privacy::check_crate(&ty_cx, &method_map, &exp_map2,
347-
a, b, krate));
346+
middle::privacy::check_crate(&ty_cx, &exp_map2, a, b, krate));
348347

349348
time(time_passes, "effect checking", (), |_|
350-
middle::effect::check_crate(&ty_cx, method_map, krate));
349+
middle::effect::check_crate(&ty_cx, krate));
351350

352351
let middle::moves::MoveMaps {moves_map, moved_variables_set,
353352
capture_map} =
354353
time(time_passes, "compute moves", (), |_|
355-
middle::moves::compute_moves(&ty_cx, method_map, krate));
354+
middle::moves::compute_moves(&ty_cx, krate));
356355

357356
time(time_passes, "match checking", (), |_|
358-
middle::check_match::check_crate(&ty_cx, method_map,
359-
&moves_map, krate));
357+
middle::check_match::check_crate(&ty_cx, &moves_map, krate));
360358

361359
time(time_passes, "liveness checking", (), |_|
362-
middle::liveness::check_crate(&ty_cx, method_map,
363-
&capture_map, krate));
360+
middle::liveness::check_crate(&ty_cx, &capture_map, krate));
364361

365362
let root_map =
366363
time(time_passes, "borrow checking", (), |_|
367-
middle::borrowck::check_crate(&ty_cx, method_map,
368-
&moves_map, &moved_variables_set,
364+
middle::borrowck::check_crate(&ty_cx, &moves_map,
365+
&moved_variables_set,
369366
&capture_map, krate));
370367

371368
drop(moves_map);
372369
drop(moved_variables_set);
373370

374371
time(time_passes, "kind checking", (), |_|
375-
kind::check_crate(&ty_cx, method_map, krate));
372+
kind::check_crate(&ty_cx, krate));
376373

377374
let reachable_map =
378375
time(time_passes, "reachability checking", (), |_|
379-
reachable::find_reachable(&ty_cx, method_map, &exported_items));
376+
reachable::find_reachable(&ty_cx, &exported_items));
380377

381378
time(time_passes, "death checking", (), |_| {
382379
middle::dead::check_crate(&ty_cx,
383-
method_map,
384380
&exported_items,
385381
&reachable_map,
386382
krate)
387383
});
388384

389385
time(time_passes, "lint checking", (), |_|
390-
lint::check_crate(&ty_cx, method_map, &exported_items, krate));
386+
lint::check_crate(&ty_cx, &exported_items, krate));
391387

392388
CrateAnalysis {
393389
exp_map2: exp_map2,
@@ -396,8 +392,6 @@ pub fn phase_3_run_analysis_passes(sess: Session,
396392
public_items: public_items,
397393
maps: astencode::Maps {
398394
root_map: root_map,
399-
method_map: method_map,
400-
vtable_map: vtable_map,
401395
capture_map: RefCell::new(capture_map)
402396
},
403397
reachable: reachable_map

branches/try2/src/librustc/middle/astencode.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ use writer = serialize::ebml::writer;
5555
// Auxiliary maps of things to be encoded
5656
pub struct Maps {
5757
pub root_map: middle::borrowck::root_map,
58-
pub method_map: middle::typeck::MethodMap,
59-
pub vtable_map: middle::typeck::vtable_map,
6058
pub capture_map: RefCell<middle::moves::CaptureMap>,
6159
}
6260

@@ -1052,7 +1050,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10521050
}
10531051

10541052
let method_call = MethodCall::expr(id);
1055-
for &method in maps.method_map.borrow().find(&method_call).iter() {
1053+
for &method in tcx.method_map.borrow().find(&method_call).iter() {
10561054
ebml_w.tag(c::tag_table_method_map, |ebml_w| {
10571055
ebml_w.id(id);
10581056
ebml_w.tag(c::tag_table_val, |ebml_w| {
@@ -1061,7 +1059,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10611059
})
10621060
}
10631061

1064-
for &dr in maps.vtable_map.borrow().find(&method_call).iter() {
1062+
for &dr in tcx.vtable_map.borrow().find(&method_call).iter() {
10651063
ebml_w.tag(c::tag_table_vtable_map, |ebml_w| {
10661064
ebml_w.id(id);
10671065
ebml_w.tag(c::tag_table_val, |ebml_w| {
@@ -1075,7 +1073,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10751073
ty::AutoDerefRef(adj) => {
10761074
for autoderef in range(0, adj.autoderefs) {
10771075
let method_call = MethodCall::autoderef(id, autoderef as u32);
1078-
for &method in maps.method_map.borrow().find(&method_call).iter() {
1076+
for &method in tcx.method_map.borrow().find(&method_call).iter() {
10791077
ebml_w.tag(c::tag_table_method_map, |ebml_w| {
10801078
ebml_w.id(id);
10811079
ebml_w.tag(c::tag_table_val, |ebml_w| {
@@ -1084,7 +1082,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10841082
})
10851083
}
10861084

1087-
for &dr in maps.vtable_map.borrow().find(&method_call).iter() {
1085+
for &dr in tcx.vtable_map.borrow().find(&method_call).iter() {
10881086
ebml_w.tag(c::tag_table_vtable_map, |ebml_w| {
10891087
ebml_w.id(id);
10901088
ebml_w.tag(c::tag_table_val, |ebml_w| {
@@ -1398,7 +1396,7 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
13981396
expr_id: id,
13991397
autoderef: autoderef
14001398
};
1401-
dcx.maps.method_map.borrow_mut().insert(method_call, method);
1399+
dcx.tcx.method_map.borrow_mut().insert(method_call, method);
14021400
}
14031401
c::tag_table_vtable_map => {
14041402
let (autoderef, vtable_res) =
@@ -1408,7 +1406,7 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
14081406
expr_id: id,
14091407
autoderef: autoderef
14101408
};
1411-
dcx.maps.vtable_map.borrow_mut().insert(vtable_key, vtable_res);
1409+
dcx.tcx.vtable_map.borrow_mut().insert(vtable_key, vtable_res);
14121410
}
14131411
c::tag_table_adjustments => {
14141412
let adj: @ty::AutoAdjustment = @val_dsr.read_auto_adjustment(xcx);

branches/try2/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ fn check_loans_in_expr<'a>(this: &mut CheckLoanCtxt<'a>,
806806
this.check_for_conflicting_loans(expr.id);
807807
this.check_move_out_from_expr(expr);
808808

809-
let method_map = this.bccx.method_map.borrow();
809+
let method_map = this.bccx.tcx.method_map.borrow();
810810
match expr.node {
811811
ast::ExprPath(..) => {
812812
if !this.move_data.is_assignee(expr.id) {

branches/try2/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
188188
}
189189

190190
// Special checks for various kinds of expressions:
191-
let method_map = this.bccx.method_map.borrow();
191+
let method_map = this.bccx.tcx.method_map.borrow();
192192
match ex.node {
193193
ast::ExprAddrOf(mutbl, base) => {
194194
let base_cmt = this.bccx.cat_expr(base);
@@ -375,7 +375,7 @@ impl<'a> GatherLoanCtxt<'a> {
375375
pub fn guarantee_autoderefs(&mut self,
376376
expr: &ast::Expr,
377377
autoderefs: uint) {
378-
let method_map = self.bccx.method_map.borrow();
378+
let method_map = self.bccx.tcx.method_map.borrow();
379379
for i in range(0, autoderefs) {
380380
match method_map.find(&MethodCall::autoderef(expr.id, i as u32)) {
381381
Some(method) => {

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,13 @@ impl<'a> Visitor<()> for BorrowckCtxt<'a> {
7676
}
7777

7878
pub fn check_crate(tcx: &ty::ctxt,
79-
method_map: typeck::MethodMap,
8079
moves_map: &NodeSet,
8180
moved_variables_set: &NodeSet,
8281
capture_map: &moves::CaptureMap,
8382
krate: &ast::Crate)
8483
-> root_map {
8584
let mut bccx = BorrowckCtxt {
8685
tcx: tcx,
87-
method_map: method_map,
8886
moves_map: moves_map,
8987
moved_variables_set: moved_variables_set,
9088
capture_map: capture_map,
@@ -149,7 +147,6 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
149147
gather_loans::gather_loans_in_fn(this, decl, body);
150148
let mut loan_dfcx =
151149
DataFlowContext::new(this.tcx,
152-
this.method_map,
153150
LoanDataFlowOperator,
154151
id_range,
155152
all_loans.len());
@@ -161,7 +158,6 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
161158

162159
let flowed_moves = move_data::FlowedMoveData::new(move_data,
163160
this.tcx,
164-
this.method_map,
165161
id_range,
166162
body);
167163

@@ -176,7 +172,6 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
176172

177173
pub struct BorrowckCtxt<'a> {
178174
tcx: &'a ty::ctxt,
179-
method_map: typeck::MethodMap,
180175
moves_map: &'a NodeSet,
181176
moved_variables_set: &'a NodeSet,
182177
capture_map: &'a moves::CaptureMap,
@@ -437,12 +432,9 @@ impl<'a> BorrowckCtxt<'a> {
437432
self.moves_map.contains(&id)
438433
}
439434

440-
pub fn mc(&self) -> mc::MemCategorizationContext<TcxTyper<'a>> {
435+
pub fn mc(&self) -> mc::MemCategorizationContext<&'a ty::ctxt> {
441436
mc::MemCategorizationContext {
442-
typer: TcxTyper {
443-
tcx: self.tcx,
444-
method_map: self.method_map
445-
}
437+
typer: self.tcx,
446438
}
447439
}
448440

@@ -572,8 +564,7 @@ impl<'a> BorrowckCtxt<'a> {
572564
move_data::MoveExpr => {
573565
let (expr_ty, expr_span) = match self.tcx.map.find(move.id) {
574566
Some(ast_map::NodeExpr(expr)) => {
575-
(ty::expr_ty_adjusted(self.tcx, expr,
576-
&*self.method_map.borrow()), expr.span)
567+
(ty::expr_ty_adjusted(self.tcx, expr), expr.span)
577568
}
578569
r => self.tcx.sess.bug(format!("MoveExpr({:?}) maps to {:?}, not Expr",
579570
move.id, r))
@@ -599,8 +590,7 @@ impl<'a> BorrowckCtxt<'a> {
599590
move_data::Captured => {
600591
let (expr_ty, expr_span) = match self.tcx.map.find(move.id) {
601592
Some(ast_map::NodeExpr(expr)) => {
602-
(ty::expr_ty_adjusted(self.tcx, expr,
603-
&*self.method_map.borrow()), expr.span)
593+
(ty::expr_ty_adjusted(self.tcx, expr), expr.span)
604594
}
605595
r => self.tcx.sess.bug(format!("Captured({:?}) maps to {:?}, not Expr",
606596
move.id, r))
@@ -915,37 +905,32 @@ impl Repr for LoanPath {
915905

916906
///////////////////////////////////////////////////////////////////////////
917907

918-
pub struct TcxTyper<'a> {
919-
tcx: &'a ty::ctxt,
920-
method_map: typeck::MethodMap,
921-
}
922-
923-
impl<'a> mc::Typer for TcxTyper<'a> {
908+
impl<'a> mc::Typer for &'a ty::ctxt {
924909
fn tcx<'a>(&'a self) -> &'a ty::ctxt {
925-
self.tcx
910+
*self
926911
}
927912

928913
fn node_ty(&mut self, id: ast::NodeId) -> mc::McResult<ty::t> {
929-
Ok(ty::node_id_to_type(self.tcx, id))
914+
Ok(ty::node_id_to_type(*self, id))
930915
}
931916

932917
fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<ty::t> {
933918
self.method_map.borrow().find(&method_call).map(|method| method.ty)
934919
}
935920

936921
fn adjustment(&mut self, id: ast::NodeId) -> Option<@ty::AutoAdjustment> {
937-
self.tcx.adjustments.borrow().find_copy(&id)
922+
self.adjustments.borrow().find_copy(&id)
938923
}
939924

940925
fn is_method_call(&mut self, id: ast::NodeId) -> bool {
941926
self.method_map.borrow().contains_key(&typeck::MethodCall::expr(id))
942927
}
943928

944929
fn temporary_scope(&mut self, id: ast::NodeId) -> Option<ast::NodeId> {
945-
self.tcx.region_maps.temporary_scope(id)
930+
self.region_maps.temporary_scope(id)
946931
}
947932

948933
fn upvar_borrow(&mut self, id: ty::UpvarId) -> ty::UpvarBorrow {
949-
self.tcx.upvar_borrow_map.borrow().get_copy(&id)
934+
self.upvar_borrow_map.borrow().get_copy(&id)
950935
}
951936
}

branches/try2/src/librustc/middle/borrowck/move_data.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use middle::borrowck::*;
2222
use middle::dataflow::DataFlowContext;
2323
use middle::dataflow::DataFlowOperator;
2424
use middle::ty;
25-
use middle::typeck;
2625
use syntax::ast;
2726
use syntax::ast_util;
2827
use syntax::codemap::Span;
@@ -511,19 +510,16 @@ impl MoveData {
511510
impl<'a> FlowedMoveData<'a> {
512511
pub fn new(move_data: MoveData,
513512
tcx: &'a ty::ctxt,
514-
method_map: typeck::MethodMap,
515513
id_range: ast_util::IdRange,
516514
body: &ast::Block)
517515
-> FlowedMoveData<'a> {
518516
let mut dfcx_moves =
519517
DataFlowContext::new(tcx,
520-
method_map,
521518
MoveDataFlowOperator,
522519
id_range,
523520
move_data.moves.borrow().len());
524521
let mut dfcx_assign =
525522
DataFlowContext::new(tcx,
526-
method_map,
527523
AssignDataFlowOperator,
528524
id_range,
529525
move_data.var_assignments.borrow().len());

branches/try2/src/librustc/middle/check_const.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use syntax::visit::Visitor;
2121
use syntax::visit;
2222

2323
pub struct CheckCrateVisitor<'a> {
24-
def_map: resolve::DefMap,
25-
method_map: typeck::MethodMap,
2624
tcx: &'a ty::ctxt,
2725
}
2826

@@ -38,24 +36,16 @@ impl<'a> Visitor<bool> for CheckCrateVisitor<'a> {
3836
}
3937
}
4038

41-
pub fn check_crate(krate: &Crate,
42-
def_map: resolve::DefMap,
43-
method_map: typeck::MethodMap,
44-
tcx: &ty::ctxt) {
45-
let mut v = CheckCrateVisitor {
46-
def_map: def_map,
47-
method_map: method_map,
48-
tcx: tcx,
49-
};
50-
visit::walk_crate(&mut v, krate, false);
39+
pub fn check_crate(krate: &Crate, tcx: &ty::ctxt) {
40+
visit::walk_crate(&mut CheckCrateVisitor { tcx: tcx }, krate, false);
5141
tcx.sess.abort_if_errors();
5242
}
5343

5444
fn check_item(v: &mut CheckCrateVisitor, it: &Item, _is_const: bool) {
5545
match it.node {
5646
ItemStatic(_, _, ex) => {
5747
v.visit_expr(ex, true);
58-
check_item_recursion(&v.tcx.sess, &v.tcx.map, v.def_map, it);
48+
check_item_recursion(&v.tcx.sess, &v.tcx.map, v.tcx.def_map, it);
5949
}
6050
ItemEnum(ref enum_definition, _) => {
6151
for var in (*enum_definition).variants.iter() {
@@ -103,7 +93,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
10393
ExprLit(lit) if ast_util::lit_is_str(lit) => {}
10494
ExprBinary(..) | ExprUnary(..) => {
10595
let method_call = typeck::MethodCall::expr(e.id);
106-
if v.method_map.borrow().contains_key(&method_call) {
96+
if v.tcx.method_map.borrow().contains_key(&method_call) {
10797
v.tcx.sess.span_err(e.span, "user-defined operators are not \
10898
allowed in constant expressions");
10999
}
@@ -127,7 +117,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
127117
"paths in constants may only refer to \
128118
items without type parameters");
129119
}
130-
match v.def_map.borrow().find(&e.id) {
120+
match v.tcx.def_map.borrow().find(&e.id) {
131121
Some(&DefStatic(..)) |
132122
Some(&DefFn(_, _)) |
133123
Some(&DefVariant(_, _, _)) |
@@ -145,7 +135,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
145135
}
146136
}
147137
ExprCall(callee, _) => {
148-
match v.def_map.borrow().find(&callee.id) {
138+
match v.tcx.def_map.borrow().find(&callee.id) {
149139
Some(&DefStruct(..)) => {} // OK.
150140
Some(&DefVariant(..)) => {} // OK.
151141
_ => {

0 commit comments

Comments
 (0)