@@ -58,104 +58,6 @@ pub enum DefIdSource {
58
58
ClosureSource
59
59
}
60
60
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
-
159
61
pub type DefIdConvert < ' a > = & ' a mut FnMut ( DefIdSource , ast:: DefId ) -> ast:: DefId ;
160
62
161
63
pub struct TyDecoder < ' a , ' tcx : ' a > {
@@ -292,7 +194,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
292
194
}
293
195
}
294
196
295
- fn parse_region ( & mut self ) -> ty:: Region {
197
+ pub fn parse_region ( & mut self ) -> ty:: Region {
296
198
match self . next ( ) {
297
199
'b' => {
298
200
assert_eq ! ( self . next( ) , '[' ) ;
@@ -629,7 +531,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
629
531
}
630
532
}
631
533
632
- fn parse_bare_fn_ty ( & mut self ) -> ty:: BareFnTy < ' tcx > {
534
+ pub fn parse_bare_fn_ty ( & mut self ) -> ty:: BareFnTy < ' tcx > {
633
535
let unsafety = parse_unsafety ( self . next ( ) ) ;
634
536
let abi = self . parse_abi_set ( ) ;
635
537
let sig = self . parse_sig ( ) ;
@@ -777,21 +679,6 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
777
679
}
778
680
}
779
681
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
-
795
682
// Rust metadata parsing
796
683
fn parse_defid ( buf : & [ u8 ] ) -> ast:: DefId {
797
684
let mut colon_idx = 0 ;
0 commit comments