@@ -15,6 +15,7 @@ use metadata::common::*;
1515use metadata:: cstore;
1616use metadata:: decoder;
1717use metadata:: inline:: InlinedItem ;
18+ use middle:: def_id:: DefId ;
1819use middle:: lang_items;
1920use middle:: ty;
2021
@@ -30,11 +31,11 @@ use std::collections::hash_map::HashMap;
3031#[ derive( Copy , Clone ) ]
3132pub struct MethodInfo {
3233 pub name : ast:: Name ,
33- pub def_id : ast :: DefId ,
34+ pub def_id : DefId ,
3435 pub vis : ast:: Visibility ,
3536}
3637
37- pub fn get_symbol ( cstore : & cstore:: CStore , def : ast :: DefId ) -> String {
38+ pub fn get_symbol ( cstore : & cstore:: CStore , def : DefId ) -> String {
3839 let cdata = cstore. get_crate_data ( def. krate ) ;
3940 decoder:: get_symbol ( cdata. data ( ) , def. node )
4041}
@@ -52,7 +53,7 @@ pub fn each_lang_item<F>(cstore: &cstore::CStore,
5253
5354/// Iterates over each child of the given item.
5455pub fn each_child_of_item < F > ( cstore : & cstore:: CStore ,
55- def_id : ast :: DefId ,
56+ def_id : DefId ,
5657 callback : F ) where
5758 F : FnMut ( decoder:: DefLike , ast:: Name , ast:: Visibility ) ,
5859{
@@ -83,7 +84,7 @@ pub fn each_top_level_item_of_crate<F>(cstore: &cstore::CStore,
8384 callback)
8485}
8586
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 > {
8788 let cstore = & tcx. sess . cstore ;
8889 let cdata = cstore. get_crate_data ( def. krate ) ;
8990 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>
9697 } )
9798}
9899
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 {
100101 let cstore = & tcx. sess . cstore ;
101102 let cdata = cstore. get_crate_data ( def. krate ) ;
102103 decoder:: get_item_name ( & cstore. intr , & cdata, def. node )
103104}
104105
105106pub enum FoundAst < ' ast > {
106107 Found ( & ' ast InlinedItem ) ,
107- FoundParent ( ast :: DefId , & ' ast InlinedItem ) ,
108+ FoundParent ( DefId , & ' ast InlinedItem ) ,
108109 NotFound ,
109110}
110111
111112// Finds the AST for this item in the crate metadata, if any. If the item was
112113// not marked for inlining, then the AST will not be present and hence none
113114// 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 ,
115116 decode_inlined_item : decoder:: DecodeInlinedItem )
116117 -> FoundAst < ' tcx > {
117118 let cstore = & tcx. sess . cstore ;
@@ -120,13 +121,13 @@ pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId,
120121}
121122
122123/// 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 )
124125 -> Vec < ty:: ImplOrTraitItemId > {
125126 let cdata = cstore. get_crate_data ( impl_def_id. krate ) ;
126127 decoder:: get_impl_items ( & * cdata, impl_def_id. node )
127128}
128129
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 )
130131 -> ty:: ImplOrTraitItem < ' tcx > {
131132 let cdata = tcx. sess . cstore . get_crate_data ( def. krate ) ;
132133 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)
135136 tcx)
136137}
137138
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 {
139140 let cdata = cstore. get_crate_data ( def. krate ) ;
140141 decoder:: get_trait_name ( cstore. intr . clone ( ) ,
141142 & * cdata,
142143 def. node )
143144}
144145
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 {
146147 let cdata = cstore. get_crate_data ( def. krate ) ;
147148 decoder:: is_static_method ( & * cdata, def. node )
148149}
149150
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 )
151152 -> Vec < ty:: ImplOrTraitItemId > {
152153 let cdata = cstore. get_crate_data ( def. krate ) ;
153154 decoder:: get_trait_item_def_ids ( & * cdata, def. node )
154155}
155156
156157pub fn get_item_variances ( cstore : & cstore:: CStore ,
157- def : ast :: DefId ) -> ty:: ItemVariances {
158+ def : DefId ) -> ty:: ItemVariances {
158159 let cdata = cstore. get_crate_data ( def. krate ) ;
159160 decoder:: get_item_variances ( & * cdata, def. node )
160161}
161162
162163pub fn get_provided_trait_methods < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
163- def : ast :: DefId )
164+ def : DefId )
164165 -> Vec < Rc < ty:: Method < ' tcx > > > {
165166 let cstore = & tcx. sess . cstore ;
166167 let cdata = cstore. get_crate_data ( def. krate ) ;
167168 decoder:: get_provided_trait_methods ( cstore. intr . clone ( ) , & * cdata, def. node , tcx)
168169}
169170
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 )
171172 -> Vec < Rc < ty:: AssociatedConst < ' tcx > > > {
172173 let cstore = & tcx. sess . cstore ;
173174 let cdata = cstore. get_crate_data ( def. krate ) ;
174175 decoder:: get_associated_consts ( cstore. intr . clone ( ) , & * cdata, def. node , tcx)
175176}
176177
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 )
178179 -> Option < ast:: Name > {
179180 let cdata = cstore. get_crate_data ( def. krate ) ;
180181 decoder:: get_type_name_if_impl ( & * cdata, def. node )
181182}
182183
183184pub fn get_methods_if_impl ( cstore : & cstore:: CStore ,
184- def : ast :: DefId )
185+ def : DefId )
185186 -> Option < Vec < MethodInfo > > {
186187 let cdata = cstore. get_crate_data ( def. krate ) ;
187188 decoder:: get_methods_if_impl ( cstore. intr . clone ( ) , & * cdata, def. node )
188189}
189190
190191pub fn get_item_attrs ( cstore : & cstore:: CStore ,
191- def_id : ast :: DefId )
192+ def_id : DefId )
192193 -> Vec < ast:: Attribute > {
193194 let cdata = cstore. get_crate_data ( def_id. krate ) ;
194195 decoder:: get_item_attrs ( & * cdata, def_id. node )
195196}
196197
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 > {
198199 let cdata = cstore. get_crate_data ( def. krate ) ;
199200 decoder:: get_struct_field_names ( & cstore. intr , & * cdata, def. node )
200201}
201202
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 ,
203204 Vec < ast:: Attribute > > {
204205 let cdata = cstore. get_crate_data ( def. krate ) ;
205206 decoder:: get_struct_field_attrs ( & * cdata)
206207}
207208
208209pub fn get_type < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
209- def : ast :: DefId )
210+ def : DefId )
210211 -> ty:: TypeScheme < ' tcx > {
211212 let cstore = & tcx. sess . cstore ;
212213 let cdata = cstore. get_crate_data ( def. krate ) ;
213214 decoder:: get_type ( & * cdata, def. node , tcx)
214215}
215216
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 > {
217218 let cstore = & tcx. sess . cstore ;
218219 let cdata = cstore. get_crate_data ( def. krate ) ;
219220 decoder:: get_trait_def ( & * cdata, def. node , tcx)
220221}
221222
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 > {
223224 let cstore = & tcx. sess . cstore ;
224225 let cdata = cstore. get_crate_data ( def. krate ) ;
225226 decoder:: get_adt_def ( & cstore. intr , & * cdata, def. node , tcx)
226227}
227228
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 )
229230 -> ty:: GenericPredicates < ' tcx >
230231{
231232 let cstore = & tcx. sess . cstore ;
232233 let cdata = cstore. get_crate_data ( def. krate ) ;
233234 decoder:: get_predicates ( & * cdata, def. node , tcx)
234235}
235236
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 )
237238 -> ty:: GenericPredicates < ' tcx >
238239{
239240 let cstore = & tcx. sess . cstore ;
240241 let cdata = cstore. get_crate_data ( def. krate ) ;
241242 decoder:: get_super_predicates ( & * cdata, def. node , tcx)
242243}
243244
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 > {
246247 let cstore = & tcx. sess . cstore ;
247248 let cdata = cstore. get_crate_data ( class_id. krate ) ;
248249 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,
267268}
268269
269270pub fn get_impl_polarity < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
270- def : ast :: DefId )
271+ def : DefId )
271272 -> Option < ast:: ImplPolarity >
272273{
273274 let cstore = & tcx. sess . cstore ;
@@ -276,7 +277,7 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
276277}
277278
278279pub fn get_custom_coerce_unsized_kind < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
279- def : ast :: DefId )
280+ def : DefId )
280281 -> Option < ty:: CustomCoerceUnsized > {
281282 let cstore = & tcx. sess . cstore ;
282283 let cdata = cstore. get_crate_data ( def. krate ) ;
@@ -286,7 +287,7 @@ pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
286287// Given a def_id for an impl, return the trait it implements,
287288// if there is one.
288289pub fn get_impl_trait < ' tcx > ( tcx : & ty:: ctxt < ' tcx > ,
289- def : ast :: DefId )
290+ def : DefId )
290291 -> Option < ty:: TraitRef < ' tcx > > {
291292 let cstore = & tcx. sess . cstore ;
292293 let cdata = cstore. get_crate_data ( def. krate ) ;
@@ -300,18 +301,18 @@ pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
300301}
301302
302303pub fn each_inherent_implementation_for_type < F > ( cstore : & cstore:: CStore ,
303- def_id : ast :: DefId ,
304+ def_id : DefId ,
304305 callback : F ) where
305- F : FnMut ( ast :: DefId ) ,
306+ F : FnMut ( DefId ) ,
306307{
307308 let cdata = cstore. get_crate_data ( def_id. krate ) ;
308309 decoder:: each_inherent_implementation_for_type ( & * cdata, def_id. node , callback)
309310}
310311
311312pub fn each_implementation_for_trait < F > ( cstore : & cstore:: CStore ,
312- def_id : ast :: DefId ,
313+ def_id : DefId ,
313314 mut callback : F ) where
314- F : FnMut ( ast :: DefId ) ,
315+ F : FnMut ( DefId ) ,
315316{
316317 cstore. iter_crate_data ( |_, cdata| {
317318 decoder:: each_implementation_for_trait ( cdata, def_id, & mut callback)
@@ -322,16 +323,16 @@ pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
322323/// default method or an implementation of a trait method), returns the ID of
323324/// the trait that the method belongs to. Otherwise, returns `None`.
324325pub fn get_trait_of_item ( cstore : & cstore:: CStore ,
325- def_id : ast :: DefId ,
326+ def_id : DefId ,
326327 tcx : & ty:: ctxt )
327- -> Option < ast :: DefId > {
328+ -> Option < DefId > {
328329 let cdata = cstore. get_crate_data ( def_id. krate ) ;
329330 decoder:: get_trait_of_item ( & * cdata, def_id. node , tcx)
330331}
331332
332333pub 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 >
335336{
336337 let cdata = cstore. get_crate_data ( def_id. krate ) ;
337338 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)
352353 decoder:: get_missing_lang_items ( & * cdata)
353354}
354355
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 )
356357 -> Vec < String >
357358{
358359 let cdata = cstore. get_crate_data ( did. krate ) ;
359360 decoder:: get_method_arg_names ( & * cdata, did. node )
360361}
361362
362363pub fn get_reachable_ids ( cstore : & cstore:: CStore , cnum : ast:: CrateNum )
363- -> Vec < ast :: DefId >
364+ -> Vec < DefId >
364365{
365366 let cdata = cstore. get_crate_data ( cnum) ;
366367 decoder:: get_reachable_ids ( & * cdata)
367368}
368369
369- pub fn is_typedef ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
370+ pub fn is_typedef ( cstore : & cstore:: CStore , did : DefId ) -> bool {
370371 let cdata = cstore. get_crate_data ( did. krate ) ;
371372 decoder:: is_typedef ( & * cdata, did. node )
372373}
373374
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 {
375376 let cdata = cstore. get_crate_data ( did. krate ) ;
376377 decoder:: is_const_fn ( & * cdata, did. node )
377378}
378379
379- pub fn is_impl ( cstore : & cstore:: CStore , did : ast :: DefId ) -> bool {
380+ pub fn is_impl ( cstore : & cstore:: CStore , did : DefId ) -> bool {
380381 let cdata = cstore. get_crate_data ( did. krate ) ;
381382 decoder:: is_impl ( & * cdata, did. node )
382383}
383384
384385pub fn get_stability ( cstore : & cstore:: CStore ,
385- def : ast :: DefId )
386+ def : DefId )
386387 -> Option < attr:: Stability > {
387388 let cdata = cstore. get_crate_data ( def. krate ) ;
388389 decoder:: get_stability ( & * cdata, def. node )
@@ -392,23 +393,23 @@ pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
392393 cstore. get_crate_data ( krate) . staged_api
393394}
394395
395- pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : ast :: DefId )
396+ pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : DefId )
396397 -> Vec < attr:: ReprAttr > {
397398 let cdata = cstore. get_crate_data ( def. krate ) ;
398399 decoder:: get_repr_attrs ( & * cdata, def. node )
399400}
400401
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 {
402403 let cdata = cstore. get_crate_data ( trait_def_id. krate ) ;
403404 decoder:: is_defaulted_trait ( & * cdata, trait_def_id. node )
404405}
405406
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 {
407408 let cdata = cstore. get_crate_data ( impl_did. krate ) ;
408409 decoder:: is_default_impl ( & * cdata, impl_did. node )
409410}
410411
411- pub fn is_extern_fn ( cstore : & cstore:: CStore , did : ast :: DefId ,
412+ pub fn is_extern_fn ( cstore : & cstore:: CStore , did : DefId ,
412413 tcx : & ty:: ctxt ) -> bool {
413414 let cdata = cstore. get_crate_data ( did. krate ) ;
414415 decoder:: is_extern_fn ( & * cdata, did. node , tcx)
0 commit comments