Skip to content

Commit 7a3a1be

Browse files
committed
remove the last remnants of old interface
1 parent b09cf12 commit 7a3a1be

File tree

3 files changed

+29
-138
lines changed

3 files changed

+29
-138
lines changed

src/librustc/metadata/decoder.rs

+24-18
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ use metadata::csearch;
2424
use metadata::cstore;
2525
use metadata::encoder::def_to_u64;
2626
use metadata::inline::InlinedItem;
27-
use metadata::tydecode::{parse_ty_data, parse_region_data,
28-
parse_type_param_def_data, parse_bare_fn_ty_data,
29-
parse_trait_ref_data, parse_predicate_data};
27+
use metadata::tydecode::TyDecoder;
3028
use middle::def;
3129
use middle::lang_items;
3230
use middle::subst;
@@ -235,22 +233,25 @@ fn variant_disr_val(d: rbml::Doc) -> Option<ty::Disr> {
235233

236234
fn doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
237235
let tp = reader::get_doc(doc, tag_items_data_item_type);
238-
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
239-
|_, did| translate_def_id(cdata, did))
236+
TyDecoder::with_doc(tcx, cdata.cnum, tp,
237+
&mut |_, did| translate_def_id(cdata, did))
238+
.parse_ty()
240239
}
241240

242241
fn maybe_doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Option<Ty<'tcx>> {
243242
reader::maybe_get_doc(doc, tag_items_data_item_type).map(|tp| {
244-
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
245-
|_, did| translate_def_id(cdata, did))
243+
TyDecoder::with_doc(tcx, cdata.cnum, tp,
244+
&mut |_, did| translate_def_id(cdata, did))
245+
.parse_ty()
246246
})
247247
}
248248

249249
fn doc_method_fty<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>,
250250
cdata: Cmd) -> ty::BareFnTy<'tcx> {
251251
let tp = reader::get_doc(doc, tag_item_method_fty);
252-
parse_bare_fn_ty_data(tp.data, cdata.cnum, tp.start, tcx,
253-
|_, did| translate_def_id(cdata, did))
252+
TyDecoder::with_doc(tcx, cdata.cnum, tp,
253+
&mut |_, did| translate_def_id(cdata, did))
254+
.parse_bare_fn_ty()
254255
}
255256

256257
pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
@@ -260,8 +261,9 @@ pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
260261

261262
fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
262263
-> ty::TraitRef<'tcx> {
263-
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
264-
|_, did| translate_def_id(cdata, did))
264+
TyDecoder::with_doc(tcx, cdata.cnum, doc,
265+
&mut |_, did| translate_def_id(cdata, did))
266+
.parse_trait_ref()
265267
}
266268

267269
fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
@@ -1465,9 +1467,10 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
14651467

14661468
let mut types = subst::VecPerParamSpace::empty();
14671469
for p in reader::tagged_docs(doc, tag_type_param_def) {
1468-
let bd = parse_type_param_def_data(
1469-
p.data, p.start, cdata.cnum, tcx,
1470-
|_, did| translate_def_id(cdata, did));
1470+
let bd =
1471+
TyDecoder::with_doc(tcx, cdata.cnum, p,
1472+
&mut |_, did| translate_def_id(cdata, did))
1473+
.parse_type_param_def();
14711474
types.push(bd.space, bd);
14721475
}
14731476

@@ -1487,8 +1490,9 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
14871490
let index = reader::doc_as_u64(doc) as u32;
14881491

14891492
let bounds = reader::tagged_docs(rp_doc, tag_items_data_region).map(|p| {
1490-
parse_region_data(p.data, cdata.cnum, p.start, tcx,
1491-
|_, did| translate_def_id(cdata, did))
1493+
TyDecoder::with_doc(tcx, cdata.cnum, p,
1494+
&mut |_, did| translate_def_id(cdata, did))
1495+
.parse_region()
14921496
}).collect();
14931497

14941498
regions.push(space, ty::RegionParameterDef { name: name,
@@ -1515,8 +1519,10 @@ fn doc_predicates<'tcx>(base_doc: rbml::Doc,
15151519
let space = subst::ParamSpace::from_uint(reader::doc_as_u8(space_doc) as usize);
15161520

15171521
let data_doc = reader::get_doc(predicate_doc, tag_predicate_data);
1518-
let data = parse_predicate_data(data_doc.data, data_doc.start, cdata.cnum, tcx,
1519-
|_, did| translate_def_id(cdata, did));
1522+
let data =
1523+
TyDecoder::with_doc(tcx, cdata.cnum, data_doc,
1524+
&mut |_, did| translate_def_id(cdata, did))
1525+
.parse_predicate();
15201526

15211527
predicates.push(space, data);
15221528
}

src/librustc/metadata/tydecode.rs

+2-115
Original file line numberDiff line numberDiff line change
@@ -58,104 +58,6 @@ pub enum DefIdSource {
5858
ClosureSource
5959
}
6060

61-
pub fn parse_ty_closure_data<'tcx, F>(data: &[u8],
62-
crate_num: ast::CrateNum,
63-
pos: usize,
64-
tcx: &ty::ctxt<'tcx>,
65-
mut conv: F)
66-
-> ty::ClosureTy<'tcx> where
67-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
68-
{
69-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
70-
st.parse_closure_ty()
71-
}
72-
73-
pub fn parse_ty_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
74-
tcx: &ty::ctxt<'tcx>, mut conv: F) -> Ty<'tcx> where
75-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
76-
{
77-
debug!("parse_ty_data {}", data_log_string(data, pos));
78-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
79-
st.parse_ty()
80-
}
81-
82-
pub fn parse_region_data<F>(data: &[u8], crate_num: ast::CrateNum, pos: usize, tcx: &ty::ctxt,
83-
mut conv: F) -> ty::Region where
84-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
85-
{
86-
debug!("parse_region_data {}", data_log_string(data, pos));
87-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
88-
st.parse_region()
89-
}
90-
91-
pub fn parse_bare_fn_ty_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
92-
tcx: &ty::ctxt<'tcx>, mut conv: F)
93-
-> ty::BareFnTy<'tcx> where
94-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
95-
{
96-
debug!("parse_bare_fn_ty_data {}", data_log_string(data, pos));
97-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
98-
st.parse_bare_fn_ty()
99-
}
100-
101-
pub fn parse_trait_ref_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
102-
tcx: &ty::ctxt<'tcx>, mut conv: F)
103-
-> ty::TraitRef<'tcx> where
104-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
105-
{
106-
debug!("parse_trait_ref_data {}", data_log_string(data, pos));
107-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
108-
st.parse_trait_ref()
109-
}
110-
111-
pub fn parse_substs_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum, pos: usize,
112-
tcx: &ty::ctxt<'tcx>, mut conv: F) -> subst::Substs<'tcx> where
113-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
114-
{
115-
debug!("parse_substs_data{}", data_log_string(data, pos));
116-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
117-
st.parse_substs()
118-
}
119-
120-
pub fn parse_existential_bounds_data<'tcx, F>(data: &[u8], crate_num: ast::CrateNum,
121-
pos: usize, tcx: &ty::ctxt<'tcx>, mut conv: F)
122-
-> ty::ExistentialBounds<'tcx> where
123-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
124-
{
125-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
126-
st.parse_existential_bounds()
127-
}
128-
129-
pub fn parse_builtin_bounds_data<F>(data: &[u8], crate_num: ast::CrateNum,
130-
pos: usize, tcx: &ty::ctxt, mut conv: F)
131-
-> ty::BuiltinBounds where
132-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
133-
{
134-
let mut st = TyDecoder::new(data, crate_num, pos, tcx, &mut conv);
135-
st.parse_builtin_bounds()
136-
}
137-
138-
pub fn parse_type_param_def_data<'tcx, F>(data: &[u8], start: usize,
139-
crate_num: ast::CrateNum, tcx: &ty::ctxt<'tcx>,
140-
mut conv: F) -> ty::TypeParameterDef<'tcx> where
141-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
142-
{
143-
let mut st = TyDecoder::new(data, crate_num, start, tcx, &mut conv);
144-
st.parse_type_param_def()
145-
}
146-
147-
pub fn parse_predicate_data<'tcx, F>(data: &[u8],
148-
start: usize,
149-
crate_num: ast::CrateNum,
150-
tcx: &ty::ctxt<'tcx>,
151-
mut conv: F)
152-
-> ty::Predicate<'tcx> where
153-
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
154-
{
155-
let mut st = TyDecoder::new(data, crate_num, start, tcx, &mut conv);
156-
st.parse_predicate()
157-
}
158-
15961
pub type DefIdConvert<'a> = &'a mut FnMut(DefIdSource, ast::DefId) -> ast::DefId;
16062

16163
pub struct TyDecoder<'a, 'tcx: 'a> {
@@ -292,7 +194,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
292194
}
293195
}
294196

295-
fn parse_region(&mut self) -> ty::Region {
197+
pub fn parse_region(&mut self) -> ty::Region {
296198
match self.next() {
297199
'b' => {
298200
assert_eq!(self.next(), '[');
@@ -629,7 +531,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
629531
}
630532
}
631533

632-
fn parse_bare_fn_ty(&mut self) -> ty::BareFnTy<'tcx> {
534+
pub fn parse_bare_fn_ty(&mut self) -> ty::BareFnTy<'tcx> {
633535
let unsafety = parse_unsafety(self.next());
634536
let abi = self.parse_abi_set();
635537
let sig = self.parse_sig();
@@ -777,21 +679,6 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
777679
}
778680
}
779681

780-
fn data_log_string(data: &[u8], pos: usize) -> String {
781-
let mut buf = String::new();
782-
buf.push_str("<<");
783-
for i in pos..data.len() {
784-
let c = data[i];
785-
if c > 0x20 && c <= 0x7F {
786-
buf.push(c as char);
787-
} else {
788-
buf.push('.');
789-
}
790-
}
791-
buf.push_str(">>");
792-
buf
793-
}
794-
795682
// Rust metadata parsing
796683
fn parse_defid(buf: &[u8]) -> ast::DefId {
797684
let mut colon_idx = 0;

src/librustc/middle/astencode.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1252,11 +1252,9 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12521252
fn read_substs<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
12531253
-> subst::Substs<'tcx> {
12541254
self.read_opaque(|this, doc| {
1255-
Ok(tydecode::parse_substs_data(doc.data,
1256-
dcx.cdata.cnum,
1257-
doc.start,
1258-
dcx.tcx,
1259-
|s, a| this.convert_def_id(dcx, s, a)))
1255+
Ok(tydecode::TyDecoder::with_doc(dcx.tcx, dcx.cdata.cnum, doc,
1256+
&mut |s, a| this.convert_def_id(dcx, s, a))
1257+
.parse_substs())
12601258
}).unwrap()
12611259
}
12621260

0 commit comments

Comments
 (0)