@@ -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 ) ;
@@ -98,14 +99,14 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>
98
99
99
100
pub enum FoundAst < ' ast > {
100
101
Found ( & ' ast InlinedItem ) ,
101
- FoundParent ( ast :: DefId , & ' ast InlinedItem ) ,
102
+ FoundParent ( DefId , & ' ast InlinedItem ) ,
102
103
NotFound ,
103
104
}
104
105
105
106
// Finds the AST for this item in the crate metadata, if any. If the item was
106
107
// not marked for inlining, then the AST will not be present and hence none
107
108
// will be returned.
108
- pub fn maybe_get_item_ast < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId ,
109
+ pub fn maybe_get_item_ast < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId ,
109
110
decode_inlined_item : decoder:: DecodeInlinedItem )
110
111
-> FoundAst < ' tcx > {
111
112
let cstore = & tcx. sess . cstore ;
@@ -114,13 +115,13 @@ pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId,
114
115
}
115
116
116
117
/// Returns information about the given implementation.
117
- pub fn get_impl_items ( cstore : & cstore:: CStore , impl_def_id : ast :: DefId )
118
+ pub fn get_impl_items ( cstore : & cstore:: CStore , impl_def_id : DefId )
118
119
-> Vec < ty:: ImplOrTraitItemId > {
119
120
let cdata = cstore. get_crate_data ( impl_def_id. krate ) ;
120
121
decoder:: get_impl_items ( & * cdata, impl_def_id. node )
121
122
}
122
123
123
- pub fn get_impl_or_trait_item < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
124
+ pub fn get_impl_or_trait_item < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
124
125
-> ty:: ImplOrTraitItem < ' tcx > {
125
126
let cdata = tcx. sess . cstore . get_crate_data ( def. krate ) ;
126
127
decoder:: get_impl_or_trait_item ( tcx. sess . cstore . intr . clone ( ) ,
@@ -129,114 +130,114 @@ pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
129
130
tcx)
130
131
}
131
132
132
- pub fn get_trait_name ( cstore : & cstore:: CStore , def : ast :: DefId ) -> ast:: Name {
133
+ pub fn get_trait_name ( cstore : & cstore:: CStore , def : DefId ) -> ast:: Name {
133
134
let cdata = cstore. get_crate_data ( def. krate ) ;
134
135
decoder:: get_trait_name ( cstore. intr . clone ( ) ,
135
136
& * cdata,
136
137
def. node )
137
138
}
138
139
139
- pub fn is_static_method ( cstore : & cstore:: CStore , def : ast :: DefId ) -> bool {
140
+ pub fn is_static_method ( cstore : & cstore:: CStore , def : DefId ) -> bool {
140
141
let cdata = cstore. get_crate_data ( def. krate ) ;
141
142
decoder:: is_static_method ( & * cdata, def. node )
142
143
}
143
144
144
- pub fn get_trait_item_def_ids ( cstore : & cstore:: CStore , def : ast :: DefId )
145
+ pub fn get_trait_item_def_ids ( cstore : & cstore:: CStore , def : DefId )
145
146
-> Vec < ty:: ImplOrTraitItemId > {
146
147
let cdata = cstore. get_crate_data ( def. krate ) ;
147
148
decoder:: get_trait_item_def_ids ( & * cdata, def. node )
148
149
}
149
150
150
151
pub fn get_item_variances ( cstore : & cstore:: CStore ,
151
- def : ast :: DefId ) -> ty:: ItemVariances {
152
+ def : DefId ) -> ty:: ItemVariances {
152
153
let cdata = cstore. get_crate_data ( def. krate ) ;
153
154
decoder:: get_item_variances ( & * cdata, def. node )
154
155
}
155
156
156
157
pub fn get_provided_trait_methods < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
157
- def : ast :: DefId )
158
+ def : DefId )
158
159
-> Vec < Rc < ty:: Method < ' tcx > > > {
159
160
let cstore = & tcx. sess . cstore ;
160
161
let cdata = cstore. get_crate_data ( def. krate ) ;
161
162
decoder:: get_provided_trait_methods ( cstore. intr . clone ( ) , & * cdata, def. node , tcx)
162
163
}
163
164
164
- pub fn get_associated_consts < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
165
+ pub fn get_associated_consts < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
165
166
-> Vec < Rc < ty:: AssociatedConst < ' tcx > > > {
166
167
let cstore = & tcx. sess . cstore ;
167
168
let cdata = cstore. get_crate_data ( def. krate ) ;
168
169
decoder:: get_associated_consts ( cstore. intr . clone ( ) , & * cdata, def. node , tcx)
169
170
}
170
171
171
- pub fn get_type_name_if_impl ( cstore : & cstore:: CStore , def : ast :: DefId )
172
+ pub fn get_type_name_if_impl ( cstore : & cstore:: CStore , def : DefId )
172
173
-> Option < ast:: Name > {
173
174
let cdata = cstore. get_crate_data ( def. krate ) ;
174
175
decoder:: get_type_name_if_impl ( & * cdata, def. node )
175
176
}
176
177
177
178
pub fn get_methods_if_impl ( cstore : & cstore:: CStore ,
178
- def : ast :: DefId )
179
+ def : DefId )
179
180
-> Option < Vec < MethodInfo > > {
180
181
let cdata = cstore. get_crate_data ( def. krate ) ;
181
182
decoder:: get_methods_if_impl ( cstore. intr . clone ( ) , & * cdata, def. node )
182
183
}
183
184
184
185
pub fn get_item_attrs ( cstore : & cstore:: CStore ,
185
- def_id : ast :: DefId )
186
+ def_id : DefId )
186
187
-> Vec < ast:: Attribute > {
187
188
let cdata = cstore. get_crate_data ( def_id. krate ) ;
188
189
decoder:: get_item_attrs ( & * cdata, def_id. node )
189
190
}
190
191
191
- pub fn get_struct_field_names ( cstore : & cstore:: CStore , def : ast :: DefId ) -> Vec < ast:: Name > {
192
+ pub fn get_struct_field_names ( cstore : & cstore:: CStore , def : DefId ) -> Vec < ast:: Name > {
192
193
let cdata = cstore. get_crate_data ( def. krate ) ;
193
194
decoder:: get_struct_field_names ( & cstore. intr , & * cdata, def. node )
194
195
}
195
196
196
- pub fn get_struct_field_attrs ( cstore : & cstore:: CStore , def : ast :: DefId ) -> HashMap < ast:: NodeId ,
197
+ pub fn get_struct_field_attrs ( cstore : & cstore:: CStore , def : DefId ) -> HashMap < ast:: NodeId ,
197
198
Vec < ast:: Attribute > > {
198
199
let cdata = cstore. get_crate_data ( def. krate ) ;
199
200
decoder:: get_struct_field_attrs ( & * cdata)
200
201
}
201
202
202
203
pub fn get_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
203
- def : ast :: DefId )
204
+ def : DefId )
204
205
-> ty:: TypeScheme < ' tcx > {
205
206
let cstore = & tcx. sess . cstore ;
206
207
let cdata = cstore. get_crate_data ( def. krate ) ;
207
208
decoder:: get_type ( & * cdata, def. node , tcx)
208
209
}
209
210
210
- pub fn get_trait_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId ) -> ty:: TraitDef < ' tcx > {
211
+ pub fn get_trait_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId ) -> ty:: TraitDef < ' tcx > {
211
212
let cstore = & tcx. sess . cstore ;
212
213
let cdata = cstore. get_crate_data ( def. krate ) ;
213
214
decoder:: get_trait_def ( & * cdata, def. node , tcx)
214
215
}
215
216
216
- pub fn get_adt_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId ) -> ty:: AdtDefMaster < ' tcx > {
217
+ pub fn get_adt_def < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId ) -> ty:: AdtDefMaster < ' tcx > {
217
218
let cstore = & tcx. sess . cstore ;
218
219
let cdata = cstore. get_crate_data ( def. krate ) ;
219
220
decoder:: get_adt_def ( & cstore. intr , & * cdata, def. node , tcx)
220
221
}
221
222
222
- pub fn get_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
223
+ pub fn get_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
223
224
-> ty:: GenericPredicates < ' tcx >
224
225
{
225
226
let cstore = & tcx. sess . cstore ;
226
227
let cdata = cstore. get_crate_data ( def. krate ) ;
227
228
decoder:: get_predicates ( & * cdata, def. node , tcx)
228
229
}
229
230
230
- pub fn get_super_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : ast :: DefId )
231
+ pub fn get_super_predicates < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , def : DefId )
231
232
-> ty:: GenericPredicates < ' tcx >
232
233
{
233
234
let cstore = & tcx. sess . cstore ;
234
235
let cdata = cstore. get_crate_data ( def. krate ) ;
235
236
decoder:: get_super_predicates ( & * cdata, def. node , tcx)
236
237
}
237
238
238
- pub fn get_field_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , class_id : ast :: DefId ,
239
- def : ast :: DefId ) -> ty:: TypeScheme < ' tcx > {
239
+ pub fn get_field_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > , class_id : DefId ,
240
+ def : DefId ) -> ty:: TypeScheme < ' tcx > {
240
241
let cstore = & tcx. sess . cstore ;
241
242
let cdata = cstore. get_crate_data ( class_id. krate ) ;
242
243
let all_items = reader:: get_doc ( rbml:: Doc :: new ( cdata. data ( ) ) , tag_items) ;
@@ -261,7 +262,7 @@ pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
261
262
}
262
263
263
264
pub fn get_impl_polarity < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
264
- def : ast :: DefId )
265
+ def : DefId )
265
266
-> Option < ast:: ImplPolarity >
266
267
{
267
268
let cstore = & tcx. sess . cstore ;
@@ -270,7 +271,7 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
270
271
}
271
272
272
273
pub fn get_custom_coerce_unsized_kind < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
273
- def : ast :: DefId )
274
+ def : DefId )
274
275
-> Option < ty:: CustomCoerceUnsized > {
275
276
let cstore = & tcx. sess . cstore ;
276
277
let cdata = cstore. get_crate_data ( def. krate ) ;
@@ -280,7 +281,7 @@ pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
280
281
// Given a def_id for an impl, return the trait it implements,
281
282
// if there is one.
282
283
pub fn get_impl_trait < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
283
- def : ast :: DefId )
284
+ def : DefId )
284
285
-> Option < ty:: TraitRef < ' tcx > > {
285
286
let cstore = & tcx. sess . cstore ;
286
287
let cdata = cstore. get_crate_data ( def. krate ) ;
@@ -294,18 +295,18 @@ pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
294
295
}
295
296
296
297
pub fn each_inherent_implementation_for_type < F > ( cstore : & cstore:: CStore ,
297
- def_id : ast :: DefId ,
298
+ def_id : DefId ,
298
299
callback : F ) where
299
- F : FnMut ( ast :: DefId ) ,
300
+ F : FnMut ( DefId ) ,
300
301
{
301
302
let cdata = cstore. get_crate_data ( def_id. krate ) ;
302
303
decoder:: each_inherent_implementation_for_type ( & * cdata, def_id. node , callback)
303
304
}
304
305
305
306
pub fn each_implementation_for_trait < F > ( cstore : & cstore:: CStore ,
306
- def_id : ast :: DefId ,
307
+ def_id : DefId ,
307
308
mut callback : F ) where
308
- F : FnMut ( ast :: DefId ) ,
309
+ F : FnMut ( DefId ) ,
309
310
{
310
311
cstore. iter_crate_data ( |_, cdata| {
311
312
decoder:: each_implementation_for_trait ( cdata, def_id, & mut callback)
@@ -316,16 +317,16 @@ pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
316
317
/// default method or an implementation of a trait method), returns the ID of
317
318
/// the trait that the method belongs to. Otherwise, returns `None`.
318
319
pub fn get_trait_of_item ( cstore : & cstore:: CStore ,
319
- def_id : ast :: DefId ,
320
+ def_id : DefId ,
320
321
tcx : & ty:: ctxt )
321
- -> Option < ast :: DefId > {
322
+ -> Option < DefId > {
322
323
let cdata = cstore. get_crate_data ( def_id. krate ) ;
323
324
decoder:: get_trait_of_item ( & * cdata, def_id. node , tcx)
324
325
}
325
326
326
327
pub fn get_tuple_struct_definition_if_ctor ( cstore : & cstore:: CStore ,
327
- def_id : ast :: DefId )
328
- -> Option < ast :: DefId >
328
+ def_id : DefId )
329
+ -> Option < DefId >
329
330
{
330
331
let cdata = cstore. get_crate_data ( def_id. krate ) ;
331
332
decoder:: get_tuple_struct_definition_if_ctor ( & * cdata, def_id. node )
@@ -346,37 +347,37 @@ pub fn get_missing_lang_items(cstore: &cstore::CStore, cnum: ast::CrateNum)
346
347
decoder:: get_missing_lang_items ( & * cdata)
347
348
}
348
349
349
- pub fn get_method_arg_names ( cstore : & cstore:: CStore , did : ast :: DefId )
350
+ pub fn get_method_arg_names ( cstore : & cstore:: CStore , did : DefId )
350
351
-> Vec < String >
351
352
{
352
353
let cdata = cstore. get_crate_data ( did. krate ) ;
353
354
decoder:: get_method_arg_names ( & * cdata, did. node )
354
355
}
355
356
356
357
pub fn get_reachable_ids ( cstore : & cstore:: CStore , cnum : ast:: CrateNum )
357
- -> Vec < ast :: DefId >
358
+ -> Vec < DefId >
358
359
{
359
360
let cdata = cstore. get_crate_data ( cnum) ;
360
361
decoder:: get_reachable_ids ( & * cdata)
361
362
}
362
363
363
- pub fn is_typedef ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
364
+ pub fn is_typedef ( cstore : & cstore:: CStore , did : DefId ) -> bool {
364
365
let cdata = cstore. get_crate_data ( did. krate ) ;
365
366
decoder:: is_typedef ( & * cdata, did. node )
366
367
}
367
368
368
- pub fn is_const_fn ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
369
+ pub fn is_const_fn ( cstore : & cstore:: CStore , did : DefId ) -> bool {
369
370
let cdata = cstore. get_crate_data ( did. krate ) ;
370
371
decoder:: is_const_fn ( & * cdata, did. node )
371
372
}
372
373
373
- pub fn is_impl ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
374
+ pub fn is_impl ( cstore : & cstore:: CStore , did : DefId ) -> bool {
374
375
let cdata = cstore. get_crate_data ( did. krate ) ;
375
376
decoder:: is_impl ( & * cdata, did. node )
376
377
}
377
378
378
379
pub fn get_stability ( cstore : & cstore:: CStore ,
379
- def : ast :: DefId )
380
+ def : DefId )
380
381
-> Option < attr:: Stability > {
381
382
let cdata = cstore. get_crate_data ( def. krate ) ;
382
383
decoder:: get_stability ( & * cdata, def. node )
@@ -386,23 +387,23 @@ pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
386
387
cstore. get_crate_data ( krate) . staged_api
387
388
}
388
389
389
- pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : ast :: DefId )
390
+ pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : DefId )
390
391
-> Vec < attr:: ReprAttr > {
391
392
let cdata = cstore. get_crate_data ( def. krate ) ;
392
393
decoder:: get_repr_attrs ( & * cdata, def. node )
393
394
}
394
395
395
- pub fn is_defaulted_trait ( cstore : & cstore:: CStore , trait_def_id : ast :: DefId ) -> bool {
396
+ pub fn is_defaulted_trait ( cstore : & cstore:: CStore , trait_def_id : DefId ) -> bool {
396
397
let cdata = cstore. get_crate_data ( trait_def_id. krate ) ;
397
398
decoder:: is_defaulted_trait ( & * cdata, trait_def_id. node )
398
399
}
399
400
400
- pub fn is_default_impl ( cstore : & cstore:: CStore , impl_did : ast :: DefId ) -> bool {
401
+ pub fn is_default_impl ( cstore : & cstore:: CStore , impl_did : DefId ) -> bool {
401
402
let cdata = cstore. get_crate_data ( impl_did. krate ) ;
402
403
decoder:: is_default_impl ( & * cdata, impl_did. node )
403
404
}
404
405
405
- pub fn is_extern_fn ( cstore : & cstore:: CStore , did : ast :: DefId ,
406
+ pub fn is_extern_fn ( cstore : & cstore:: CStore , did : DefId ,
406
407
tcx : & ty:: ctxt ) -> bool {
407
408
let cdata = cstore. get_crate_data ( did. krate ) ;
408
409
decoder:: is_extern_fn ( & * cdata, did. node , tcx)
0 commit comments