@@ -15,6 +15,7 @@ use metadata::common::*;
15
15
use metadata:: cstore;
16
16
use metadata:: decoder;
17
17
use metadata:: inline:: InlinedItem ;
18
+ use middle:: def_id:: DefId ;
18
19
use middle:: lang_items;
19
20
use middle:: ty;
20
21
@@ -30,11 +31,11 @@ use std::collections::hash_map::HashMap;
30
31
#[ derive( Copy , Clone ) ]
31
32
pub struct MethodInfo {
32
33
pub name : ast:: Name ,
33
- pub def_id : ast :: DefId ,
34
+ pub def_id : DefId ,
34
35
pub vis : ast:: Visibility ,
35
36
}
36
37
37
- pub fn get_symbol ( cstore : & cstore:: CStore , def : ast :: DefId ) -> String {
38
+ pub fn get_symbol ( cstore : & cstore:: CStore , def : DefId ) -> String {
38
39
let cdata = cstore. get_crate_data ( def. krate ) ;
39
40
decoder:: get_symbol ( cdata. data ( ) , def. node )
40
41
}
@@ -52,7 +53,7 @@ pub fn each_lang_item<F>(cstore: &cstore::CStore,
52
53
53
54
/// Iterates over each child of the given item.
54
55
pub fn each_child_of_item < F > ( cstore : & cstore:: CStore ,
55
- def_id : ast :: DefId ,
56
+ def_id : DefId ,
56
57
callback : F ) where
57
58
F : FnMut ( decoder:: DefLike , ast:: Name , ast:: Visibility ) ,
58
59
{
@@ -83,7 +84,7 @@ pub fn each_top_level_item_of_crate<F>(cstore: &cstore::CStore,
83
84
callback)
84
85
}
85
86
86
- pub fn get_item_path ( tcx : & ty:: ctxt , def : ast :: DefId ) -> Vec < ast_map:: PathElem > {
87
+ pub fn get_item_path ( tcx : & ty:: ctxt , def : DefId ) -> Vec < ast_map:: PathElem > {
87
88
let cstore = & tcx. sess . cstore ;
88
89
let cdata = cstore. get_crate_data ( def. krate ) ;
89
90
let path = decoder:: get_item_path ( & * cdata, def. node ) ;
@@ -96,22 +97,22 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>
96
97
} )
97
98
}
98
99
99
- pub fn get_item_name ( tcx : & ty:: ctxt , def : ast :: DefId ) -> ast:: Name {
100
+ pub fn get_item_name ( tcx : & ty:: ctxt , def : DefId ) -> ast:: Name {
100
101
let cstore = & tcx. sess . cstore ;
101
102
let cdata = cstore. get_crate_data ( def. krate ) ;
102
103
decoder:: get_item_name ( & cstore. intr , & cdata, def. node )
103
104
}
104
105
105
106
pub enum FoundAst < ' ast > {
106
107
Found ( & ' ast InlinedItem ) ,
107
- FoundParent ( ast :: DefId , & ' ast InlinedItem ) ,
108
+ FoundParent ( DefId , & ' ast InlinedItem ) ,
108
109
NotFound ,
109
110
}
110
111
111
112
// Finds the AST for this item in the crate metadata, if any. If the item was
112
113
// not marked for inlining, then the AST will not be present and hence none
113
114
// will be returned.
114
- pub fn maybe_get_item_ast < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId ,
115
+ pub fn maybe_get_item_ast < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId ,
115
116
decode_inlined_item : decoder:: DecodeInlinedItem )
116
117
-> FoundAst < ' tcx > {
117
118
let cstore = & tcx. sess . cstore ;
@@ -120,13 +121,13 @@ pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId,
120
121
}
121
122
122
123
/// Returns information about the given implementation.
123
- pub fn get_impl_items ( cstore : & cstore:: CStore , impl_def_id : ast :: DefId )
124
+ pub fn get_impl_items ( cstore : & cstore:: CStore , impl_def_id : DefId )
124
125
-> Vec < ty:: ImplOrTraitItemId > {
125
126
let cdata = cstore. get_crate_data ( impl_def_id. krate ) ;
126
127
decoder:: get_impl_items ( & * cdata, impl_def_id. node )
127
128
}
128
129
129
- pub fn get_impl_or_trait_item < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
130
+ pub fn get_impl_or_trait_item < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
130
131
-> ty:: ImplOrTraitItem < ' tcx > {
131
132
let cdata = tcx. sess . cstore . get_crate_data ( def. krate ) ;
132
133
decoder:: get_impl_or_trait_item ( tcx. sess . cstore . intr . clone ( ) ,
@@ -135,114 +136,114 @@ pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
135
136
tcx)
136
137
}
137
138
138
- pub fn get_trait_name ( cstore : & cstore:: CStore , def : ast :: DefId ) -> ast:: Name {
139
+ pub fn get_trait_name ( cstore : & cstore:: CStore , def : DefId ) -> ast:: Name {
139
140
let cdata = cstore. get_crate_data ( def. krate ) ;
140
141
decoder:: get_trait_name ( cstore. intr . clone ( ) ,
141
142
& * cdata,
142
143
def. node )
143
144
}
144
145
145
- pub fn is_static_method ( cstore : & cstore:: CStore , def : ast :: DefId ) -> bool {
146
+ pub fn is_static_method ( cstore : & cstore:: CStore , def : DefId ) -> bool {
146
147
let cdata = cstore. get_crate_data ( def. krate ) ;
147
148
decoder:: is_static_method ( & * cdata, def. node )
148
149
}
149
150
150
- pub fn get_trait_item_def_ids ( cstore : & cstore:: CStore , def : ast :: DefId )
151
+ pub fn get_trait_item_def_ids ( cstore : & cstore:: CStore , def : DefId )
151
152
-> Vec < ty:: ImplOrTraitItemId > {
152
153
let cdata = cstore. get_crate_data ( def. krate ) ;
153
154
decoder:: get_trait_item_def_ids ( & * cdata, def. node )
154
155
}
155
156
156
157
pub fn get_item_variances ( cstore : & cstore:: CStore ,
157
- def : ast :: DefId ) -> ty:: ItemVariances {
158
+ def : DefId ) -> ty:: ItemVariances {
158
159
let cdata = cstore. get_crate_data ( def. krate ) ;
159
160
decoder:: get_item_variances ( & * cdata, def. node )
160
161
}
161
162
162
163
pub fn get_provided_trait_methods < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
163
- def : ast :: DefId )
164
+ def : DefId )
164
165
-> Vec < Rc < ty:: Method < ' tcx > > > {
165
166
let cstore = & tcx. sess . cstore ;
166
167
let cdata = cstore. get_crate_data ( def. krate ) ;
167
168
decoder:: get_provided_trait_methods ( cstore. intr . clone ( ) , & * cdata, def. node , tcx)
168
169
}
169
170
170
- pub fn get_associated_consts < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
171
+ pub fn get_associated_consts < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
171
172
-> Vec < Rc < ty:: AssociatedConst < ' tcx > > > {
172
173
let cstore = & tcx. sess . cstore ;
173
174
let cdata = cstore. get_crate_data ( def. krate ) ;
174
175
decoder:: get_associated_consts ( cstore. intr . clone ( ) , & * cdata, def. node , tcx)
175
176
}
176
177
177
- pub fn get_type_name_if_impl ( cstore : & cstore:: CStore , def : ast :: DefId )
178
+ pub fn get_type_name_if_impl ( cstore : & cstore:: CStore , def : DefId )
178
179
-> Option < ast:: Name > {
179
180
let cdata = cstore. get_crate_data ( def. krate ) ;
180
181
decoder:: get_type_name_if_impl ( & * cdata, def. node )
181
182
}
182
183
183
184
pub fn get_methods_if_impl ( cstore : & cstore:: CStore ,
184
- def : ast :: DefId )
185
+ def : DefId )
185
186
-> Option < Vec < MethodInfo > > {
186
187
let cdata = cstore. get_crate_data ( def. krate ) ;
187
188
decoder:: get_methods_if_impl ( cstore. intr . clone ( ) , & * cdata, def. node )
188
189
}
189
190
190
191
pub fn get_item_attrs ( cstore : & cstore:: CStore ,
191
- def_id : ast :: DefId )
192
+ def_id : DefId )
192
193
-> Vec < ast:: Attribute > {
193
194
let cdata = cstore. get_crate_data ( def_id. krate ) ;
194
195
decoder:: get_item_attrs ( & * cdata, def_id. node )
195
196
}
196
197
197
- pub fn get_struct_field_names ( cstore : & cstore:: CStore , def : ast :: DefId ) -> Vec < ast:: Name > {
198
+ pub fn get_struct_field_names ( cstore : & cstore:: CStore , def : DefId ) -> Vec < ast:: Name > {
198
199
let cdata = cstore. get_crate_data ( def. krate ) ;
199
200
decoder:: get_struct_field_names ( & cstore. intr , & * cdata, def. node )
200
201
}
201
202
202
- pub fn get_struct_field_attrs ( cstore : & cstore:: CStore , def : ast :: DefId ) -> HashMap < ast:: NodeId ,
203
+ pub fn get_struct_field_attrs ( cstore : & cstore:: CStore , def : DefId ) -> HashMap < ast:: NodeId ,
203
204
Vec < ast:: Attribute > > {
204
205
let cdata = cstore. get_crate_data ( def. krate ) ;
205
206
decoder:: get_struct_field_attrs ( & * cdata)
206
207
}
207
208
208
209
pub fn get_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
209
- def : ast :: DefId )
210
+ def : DefId )
210
211
-> ty:: TypeScheme < ' tcx > {
211
212
let cstore = & tcx. sess . cstore ;
212
213
let cdata = cstore. get_crate_data ( def. krate ) ;
213
214
decoder:: get_type ( & * cdata, def. node , tcx)
214
215
}
215
216
216
- pub fn get_trait_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId ) -> ty:: TraitDef < ' tcx > {
217
+ pub fn get_trait_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId ) -> ty:: TraitDef < ' tcx > {
217
218
let cstore = & tcx. sess . cstore ;
218
219
let cdata = cstore. get_crate_data ( def. krate ) ;
219
220
decoder:: get_trait_def ( & * cdata, def. node , tcx)
220
221
}
221
222
222
- pub fn get_adt_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId ) -> ty:: AdtDefMaster < ' tcx > {
223
+ pub fn get_adt_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId ) -> ty:: AdtDefMaster < ' tcx > {
223
224
let cstore = & tcx. sess . cstore ;
224
225
let cdata = cstore. get_crate_data ( def. krate ) ;
225
226
decoder:: get_adt_def ( & cstore. intr , & * cdata, def. node , tcx)
226
227
}
227
228
228
- pub fn get_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
229
+ pub fn get_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
229
230
-> ty:: GenericPredicates < ' tcx >
230
231
{
231
232
let cstore = & tcx. sess . cstore ;
232
233
let cdata = cstore. get_crate_data ( def. krate ) ;
233
234
decoder:: get_predicates ( & * cdata, def. node , tcx)
234
235
}
235
236
236
- pub fn get_super_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
237
+ pub fn get_super_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
237
238
-> ty:: GenericPredicates < ' tcx >
238
239
{
239
240
let cstore = & tcx. sess . cstore ;
240
241
let cdata = cstore. get_crate_data ( def. krate ) ;
241
242
decoder:: get_super_predicates ( & * cdata, def. node , tcx)
242
243
}
243
244
244
- pub fn get_field_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , class_id : ast :: DefId ,
245
- def : ast :: DefId ) -> ty:: TypeScheme < ' tcx > {
245
+ pub fn get_field_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , class_id : DefId ,
246
+ def : DefId ) -> ty:: TypeScheme < ' tcx > {
246
247
let cstore = & tcx. sess . cstore ;
247
248
let cdata = cstore. get_crate_data ( class_id. krate ) ;
248
249
let all_items = reader:: get_doc ( rbml:: Doc :: new ( cdata. data ( ) ) , tag_items) ;
@@ -267,7 +268,7 @@ pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
267
268
}
268
269
269
270
pub fn get_impl_polarity < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
270
- def : ast :: DefId )
271
+ def : DefId )
271
272
-> Option < ast:: ImplPolarity >
272
273
{
273
274
let cstore = & tcx. sess . cstore ;
@@ -276,7 +277,7 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
276
277
}
277
278
278
279
pub fn get_custom_coerce_unsized_kind < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
279
- def : ast :: DefId )
280
+ def : DefId )
280
281
-> Option < ty:: CustomCoerceUnsized > {
281
282
let cstore = & tcx. sess . cstore ;
282
283
let cdata = cstore. get_crate_data ( def. krate ) ;
@@ -286,7 +287,7 @@ pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
286
287
// Given a def_id for an impl, return the trait it implements,
287
288
// if there is one.
288
289
pub fn get_impl_trait < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
289
- def : ast :: DefId )
290
+ def : DefId )
290
291
-> Option < ty:: TraitRef < ' tcx > > {
291
292
let cstore = & tcx. sess . cstore ;
292
293
let cdata = cstore. get_crate_data ( def. krate ) ;
@@ -300,18 +301,18 @@ pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
300
301
}
301
302
302
303
pub fn each_inherent_implementation_for_type < F > ( cstore : & cstore:: CStore ,
303
- def_id : ast :: DefId ,
304
+ def_id : DefId ,
304
305
callback : F ) where
305
- F : FnMut ( ast :: DefId ) ,
306
+ F : FnMut ( DefId ) ,
306
307
{
307
308
let cdata = cstore. get_crate_data ( def_id. krate ) ;
308
309
decoder:: each_inherent_implementation_for_type ( & * cdata, def_id. node , callback)
309
310
}
310
311
311
312
pub fn each_implementation_for_trait < F > ( cstore : & cstore:: CStore ,
312
- def_id : ast :: DefId ,
313
+ def_id : DefId ,
313
314
mut callback : F ) where
314
- F : FnMut ( ast :: DefId ) ,
315
+ F : FnMut ( DefId ) ,
315
316
{
316
317
cstore. iter_crate_data ( |_, cdata| {
317
318
decoder:: each_implementation_for_trait ( cdata, def_id, & mut callback)
@@ -322,16 +323,16 @@ pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
322
323
/// default method or an implementation of a trait method), returns the ID of
323
324
/// the trait that the method belongs to. Otherwise, returns `None`.
324
325
pub fn get_trait_of_item ( cstore : & cstore:: CStore ,
325
- def_id : ast :: DefId ,
326
+ def_id : DefId ,
326
327
tcx : & ty:: ctxt )
327
- -> Option < ast :: DefId > {
328
+ -> Option < DefId > {
328
329
let cdata = cstore. get_crate_data ( def_id. krate ) ;
329
330
decoder:: get_trait_of_item ( & * cdata, def_id. node , tcx)
330
331
}
331
332
332
333
pub fn get_tuple_struct_definition_if_ctor ( cstore : & cstore:: CStore ,
333
- def_id : ast :: DefId )
334
- -> Option < ast :: DefId >
334
+ def_id : DefId )
335
+ -> Option < DefId >
335
336
{
336
337
let cdata = cstore. get_crate_data ( def_id. krate ) ;
337
338
decoder:: get_tuple_struct_definition_if_ctor ( & * cdata, def_id. node )
@@ -352,37 +353,37 @@ pub fn get_missing_lang_items(cstore: &cstore::CStore, cnum: ast::CrateNum)
352
353
decoder:: get_missing_lang_items ( & * cdata)
353
354
}
354
355
355
- pub fn get_method_arg_names ( cstore : & cstore:: CStore , did : ast :: DefId )
356
+ pub fn get_method_arg_names ( cstore : & cstore:: CStore , did : DefId )
356
357
-> Vec < String >
357
358
{
358
359
let cdata = cstore. get_crate_data ( did. krate ) ;
359
360
decoder:: get_method_arg_names ( & * cdata, did. node )
360
361
}
361
362
362
363
pub fn get_reachable_ids ( cstore : & cstore:: CStore , cnum : ast:: CrateNum )
363
- -> Vec < ast :: DefId >
364
+ -> Vec < DefId >
364
365
{
365
366
let cdata = cstore. get_crate_data ( cnum) ;
366
367
decoder:: get_reachable_ids ( & * cdata)
367
368
}
368
369
369
- pub fn is_typedef ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
370
+ pub fn is_typedef ( cstore : & cstore:: CStore , did : DefId ) -> bool {
370
371
let cdata = cstore. get_crate_data ( did. krate ) ;
371
372
decoder:: is_typedef ( & * cdata, did. node )
372
373
}
373
374
374
- pub fn is_const_fn ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
375
+ pub fn is_const_fn ( cstore : & cstore:: CStore , did : DefId ) -> bool {
375
376
let cdata = cstore. get_crate_data ( did. krate ) ;
376
377
decoder:: is_const_fn ( & * cdata, did. node )
377
378
}
378
379
379
- pub fn is_impl ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
380
+ pub fn is_impl ( cstore : & cstore:: CStore , did : DefId ) -> bool {
380
381
let cdata = cstore. get_crate_data ( did. krate ) ;
381
382
decoder:: is_impl ( & * cdata, did. node )
382
383
}
383
384
384
385
pub fn get_stability ( cstore : & cstore:: CStore ,
385
- def : ast :: DefId )
386
+ def : DefId )
386
387
-> Option < attr:: Stability > {
387
388
let cdata = cstore. get_crate_data ( def. krate ) ;
388
389
decoder:: get_stability ( & * cdata, def. node )
@@ -392,23 +393,23 @@ pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
392
393
cstore. get_crate_data ( krate) . staged_api
393
394
}
394
395
395
- pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : ast :: DefId )
396
+ pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : DefId )
396
397
-> Vec < attr:: ReprAttr > {
397
398
let cdata = cstore. get_crate_data ( def. krate ) ;
398
399
decoder:: get_repr_attrs ( & * cdata, def. node )
399
400
}
400
401
401
- pub fn is_defaulted_trait ( cstore : & cstore:: CStore , trait_def_id : ast :: DefId ) -> bool {
402
+ pub fn is_defaulted_trait ( cstore : & cstore:: CStore , trait_def_id : DefId ) -> bool {
402
403
let cdata = cstore. get_crate_data ( trait_def_id. krate ) ;
403
404
decoder:: is_defaulted_trait ( & * cdata, trait_def_id. node )
404
405
}
405
406
406
- pub fn is_default_impl ( cstore : & cstore:: CStore , impl_did : ast :: DefId ) -> bool {
407
+ pub fn is_default_impl ( cstore : & cstore:: CStore , impl_did : DefId ) -> bool {
407
408
let cdata = cstore. get_crate_data ( impl_did. krate ) ;
408
409
decoder:: is_default_impl ( & * cdata, impl_did. node )
409
410
}
410
411
411
- pub fn is_extern_fn ( cstore : & cstore:: CStore , did : ast :: DefId ,
412
+ pub fn is_extern_fn ( cstore : & cstore:: CStore , did : DefId ,
412
413
tcx : & ty:: ctxt ) -> bool {
413
414
let cdata = cstore. get_crate_data ( did. krate ) ;
414
415
decoder:: is_extern_fn ( & * cdata, did. node , tcx)
0 commit comments