Skip to content

Commit 6742b23

Browse files
committed
rustc_metadata: remove all unnecessary tables from astencode.
1 parent d2ea3da commit 6742b23

File tree

1 file changed

+2
-80
lines changed

1 file changed

+2
-80
lines changed

src/librustc_metadata/astencode.rs

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use decoder::DecodeContext;
1919
use encoder::EncodeContext;
2020

2121
use middle::cstore::{InlinedItem, InlinedItemRef};
22-
use rustc::ty::adjustment;
2322
use rustc::hir::def;
2423
use rustc::hir::def_id::DefId;
25-
use rustc::ty::{self, TyCtxt};
24+
use rustc::ty::TyCtxt;
2625

2726
use syntax::ast;
2827

@@ -128,12 +127,8 @@ enum Table {
128127
Def,
129128
NodeType,
130129
ItemSubsts,
131-
Freevars,
132-
MethodMap,
133130
Adjustment,
134-
UpvarCaptureMap,
135-
ConstQualif,
136-
CastKind
131+
ConstQualif
137132
}
138133

139134
fn encode_side_tables_for_id(ecx: &mut EncodeContext, id: ast::NodeId) {
@@ -156,60 +151,11 @@ fn encode_side_tables_for_id(ecx: &mut EncodeContext, id: ast::NodeId) {
156151
item_substs.substs.encode(ecx).unwrap();
157152
}
158153

159-
if let Some(fv) = tcx.freevars.borrow().get(&id) {
160-
ecx.entry(Table::Freevars, id);
161-
fv.encode(ecx).unwrap();
162-
163-
for freevar in fv {
164-
ecx.entry(Table::UpvarCaptureMap, id);
165-
let def_id = freevar.def.def_id();
166-
let var_id = tcx.map.as_local_node_id(def_id).unwrap();
167-
let upvar_id = ty::UpvarId {
168-
var_id: var_id,
169-
closure_expr_id: id
170-
};
171-
let upvar_capture = tcx.tables
172-
.borrow()
173-
.upvar_capture_map
174-
.get(&upvar_id)
175-
.unwrap()
176-
.clone();
177-
var_id.encode(ecx).unwrap();
178-
upvar_capture.encode(ecx).unwrap();
179-
}
180-
}
181-
182-
let method_call = ty::MethodCall::expr(id);
183-
if let Some(method) = tcx.tables.borrow().method_map.get(&method_call) {
184-
ecx.entry(Table::MethodMap, id);
185-
method_call.autoderef.encode(ecx).unwrap();
186-
method.encode(ecx).unwrap();
187-
}
188-
189154
if let Some(adjustment) = tcx.tables.borrow().adjustments.get(&id) {
190-
match *adjustment {
191-
adjustment::AdjustDerefRef(ref adj) => {
192-
for autoderef in 0..adj.autoderefs {
193-
let method_call = ty::MethodCall::autoderef(id, autoderef as u32);
194-
if let Some(method) = tcx.tables.borrow().method_map.get(&method_call) {
195-
ecx.entry(Table::MethodMap, id);
196-
method_call.autoderef.encode(ecx).unwrap();
197-
method.encode(ecx).unwrap();
198-
}
199-
}
200-
}
201-
_ => {}
202-
}
203-
204155
ecx.entry(Table::Adjustment, id);
205156
adjustment.encode(ecx).unwrap();
206157
}
207158

208-
if let Some(cast_kind) = tcx.cast_kinds.borrow().get(&id) {
209-
ecx.entry(Table::CastKind, id);
210-
cast_kind.encode(ecx).unwrap();
211-
}
212-
213159
if let Some(qualif) = tcx.const_qualif_map.borrow().get(&id) {
214160
ecx.entry(Table::ConstQualif, id);
215161
qualif.encode(ecx).unwrap();
@@ -234,34 +180,10 @@ fn decode_side_tables(dcx: &mut DecodeContext, ast_doc: rbml::Doc) {
234180
let item_substs = Decodable::decode(dcx).unwrap();
235181
dcx.tcx().tables.borrow_mut().item_substs.insert(id, item_substs);
236182
}
237-
Table::Freevars => {
238-
let fv_info = Decodable::decode(dcx).unwrap();
239-
dcx.tcx().freevars.borrow_mut().insert(id, fv_info);
240-
}
241-
Table::UpvarCaptureMap => {
242-
let upvar_id = ty::UpvarId {
243-
var_id: Decodable::decode(dcx).unwrap(),
244-
closure_expr_id: id
245-
};
246-
let ub = Decodable::decode(dcx).unwrap();
247-
dcx.tcx().tables.borrow_mut().upvar_capture_map.insert(upvar_id, ub);
248-
}
249-
Table::MethodMap => {
250-
let method_call = ty::MethodCall {
251-
expr_id: id,
252-
autoderef: Decodable::decode(dcx).unwrap()
253-
};
254-
let method = Decodable::decode(dcx).unwrap();
255-
dcx.tcx().tables.borrow_mut().method_map.insert(method_call, method);
256-
}
257183
Table::Adjustment => {
258184
let adj = Decodable::decode(dcx).unwrap();
259185
dcx.tcx().tables.borrow_mut().adjustments.insert(id, adj);
260186
}
261-
Table::CastKind => {
262-
let cast_kind = Decodable::decode(dcx).unwrap();
263-
dcx.tcx().cast_kinds.borrow_mut().insert(id, cast_kind);
264-
}
265187
Table::ConstQualif => {
266188
let qualif = Decodable::decode(dcx).unwrap();
267189
dcx.tcx().const_qualif_map.borrow_mut().insert(id, qualif);

0 commit comments

Comments
 (0)