@@ -28,12 +28,12 @@ use hir::map as hir_map;
28
28
use hir:: map:: definitions:: { Definitions , DefKey , DisambiguatedDefPathData } ;
29
29
use hir:: svh:: Svh ;
30
30
use middle:: lang_items;
31
- use ty:: { self , Ty , TyCtxt } ;
32
- use mir:: Mir ;
31
+ use ty:: { self , TyCtxt } ;
33
32
use session:: Session ;
34
33
use session:: search_paths:: PathKind ;
35
34
use util:: nodemap:: { NodeSet , DefIdMap } ;
36
35
36
+ use std:: any:: Any ;
37
37
use std:: collections:: BTreeMap ;
38
38
use std:: path:: PathBuf ;
39
39
use std:: rc:: Rc ;
@@ -163,46 +163,31 @@ pub struct ExternCrate {
163
163
164
164
/// A store of Rust crates, through with their metadata
165
165
/// can be accessed.
166
- pub trait CrateStore < ' tcx > {
166
+ pub trait CrateStore {
167
+ fn crate_data_as_rc_any ( & self , krate : CrateNum ) -> Rc < Any > ;
168
+
167
169
// item info
168
170
fn describe_def ( & self , def : DefId ) -> Option < Def > ;
169
171
fn def_span ( & self , sess : & Session , def : DefId ) -> Span ;
170
172
fn stability ( & self , def : DefId ) -> Option < attr:: Stability > ;
171
173
fn deprecation ( & self , def : DefId ) -> Option < attr:: Deprecation > ;
172
174
fn visibility ( & self , def : DefId ) -> ty:: Visibility ;
173
- fn closure_kind ( & self , def_id : DefId ) -> ty:: ClosureKind ;
174
- fn closure_ty < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId )
175
- -> ty:: ClosureTy < ' tcx > ;
176
- fn item_variances ( & self , def : DefId ) -> Vec < ty:: Variance > ;
177
- fn item_type < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
178
- -> Ty < ' tcx > ;
179
175
fn visible_parent_map < ' a > ( & ' a self ) -> :: std:: cell:: RefMut < ' a , DefIdMap < DefId > > ;
180
- fn item_predicates < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
181
- -> ty:: GenericPredicates < ' tcx > ;
182
- fn item_super_predicates < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
183
- -> ty:: GenericPredicates < ' tcx > ;
184
- fn item_generics ( & self , def : DefId ) -> ty:: Generics ;
176
+ fn item_generics_cloned ( & self , def : DefId ) -> ty:: Generics ;
185
177
fn item_attrs ( & self , def_id : DefId ) -> Vec < ast:: Attribute > ;
186
- fn trait_def < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId ) -> ty:: TraitDef ;
187
- fn adt_def < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId ) -> & ' tcx ty:: AdtDef ;
188
178
fn fn_arg_names ( & self , did : DefId ) -> Vec < ast:: Name > ;
189
179
fn inherent_implementations_for_type ( & self , def_id : DefId ) -> Vec < DefId > ;
190
180
191
181
// trait info
192
182
fn implementations_of_trait ( & self , filter : Option < DefId > ) -> Vec < DefId > ;
193
183
194
184
// impl info
195
- fn associated_item_def_ids ( & self , def_id : DefId ) -> Vec < DefId > ;
196
- fn impl_trait_ref < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
197
- -> Option < ty:: TraitRef < ' tcx > > ;
198
185
fn impl_polarity ( & self , def : DefId ) -> hir:: ImplPolarity ;
199
- fn custom_coerce_unsized_kind ( & self , def : DefId )
200
- -> Option < ty:: adjustment:: CustomCoerceUnsized > ;
201
186
fn impl_parent ( & self , impl_def_id : DefId ) -> Option < DefId > ;
202
187
203
188
// trait/impl-item info
204
189
fn trait_of_item ( & self , def_id : DefId ) -> Option < DefId > ;
205
- fn associated_item ( & self , def : DefId ) -> Option < ty:: AssociatedItem > ;
190
+ fn associated_item_cloned ( & self , def : DefId ) -> ty:: AssociatedItem ;
206
191
207
192
// flags
208
193
fn is_const_fn ( & self , did : DefId ) -> bool ;
@@ -252,12 +237,11 @@ pub trait CrateStore<'tcx> {
252
237
fn load_macro ( & self , did : DefId , sess : & Session ) -> LoadedMacro ;
253
238
254
239
// misc. metadata
255
- fn maybe_get_item_body < ' a > ( & ' tcx self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
256
- -> Option < & ' tcx hir:: Body > ;
240
+ fn maybe_get_item_body < ' a , ' tcx > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
241
+ -> Option < & ' tcx hir:: Body > ;
257
242
fn item_body_nested_bodies ( & self , def : DefId ) -> BTreeMap < hir:: BodyId , hir:: Body > ;
258
243
fn const_is_rvalue_promotable_to_static ( & self , def : DefId ) -> bool ;
259
244
260
- fn get_item_mir < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId ) -> Mir < ' tcx > ;
261
245
fn is_item_mir_available ( & self , def : DefId ) -> bool ;
262
246
263
247
// This is basically a 1-based range of ints, which is a little
@@ -272,10 +256,10 @@ pub trait CrateStore<'tcx> {
272
256
fn used_crates ( & self , prefer : LinkagePreference ) -> Vec < ( CrateNum , LibSource ) > ;
273
257
fn used_crate_source ( & self , cnum : CrateNum ) -> CrateSource ;
274
258
fn extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > ;
275
- fn encode_metadata < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
276
- reexports : & def:: ExportMap ,
277
- link_meta : & LinkMeta ,
278
- reachable : & NodeSet ) -> Vec < u8 > ;
259
+ fn encode_metadata < ' a , ' tcx > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
260
+ reexports : & def:: ExportMap ,
261
+ link_meta : & LinkMeta ,
262
+ reachable : & NodeSet ) -> Vec < u8 > ;
279
263
fn metadata_encoding_version ( & self ) -> & [ u8 ] ;
280
264
}
281
265
@@ -309,53 +293,37 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
309
293
/// A dummy crate store that does not support any non-local crates,
310
294
/// for test purposes.
311
295
pub struct DummyCrateStore ;
296
+
312
297
#[ allow( unused_variables) ]
313
- impl < ' tcx > CrateStore < ' tcx > for DummyCrateStore {
298
+ impl CrateStore for DummyCrateStore {
299
+ fn crate_data_as_rc_any ( & self , krate : CrateNum ) -> Rc < Any >
300
+ { bug ! ( "crate_data_as_rc_any" ) }
314
301
// item info
315
302
fn describe_def ( & self , def : DefId ) -> Option < Def > { bug ! ( "describe_def" ) }
316
303
fn def_span ( & self , sess : & Session , def : DefId ) -> Span { bug ! ( "def_span" ) }
317
304
fn stability ( & self , def : DefId ) -> Option < attr:: Stability > { bug ! ( "stability" ) }
318
305
fn deprecation ( & self , def : DefId ) -> Option < attr:: Deprecation > { bug ! ( "deprecation" ) }
319
306
fn visibility ( & self , def : DefId ) -> ty:: Visibility { bug ! ( "visibility" ) }
320
- fn closure_kind ( & self , def_id : DefId ) -> ty:: ClosureKind { bug ! ( "closure_kind" ) }
321
- fn closure_ty < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId )
322
- -> ty:: ClosureTy < ' tcx > { bug ! ( "closure_ty" ) }
323
- fn item_variances ( & self , def : DefId ) -> Vec < ty:: Variance > { bug ! ( "item_variances" ) }
324
- fn item_type < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
325
- -> Ty < ' tcx > { bug ! ( "item_type" ) }
326
307
fn visible_parent_map < ' a > ( & ' a self ) -> :: std:: cell:: RefMut < ' a , DefIdMap < DefId > > {
327
308
bug ! ( "visible_parent_map" )
328
309
}
329
- fn item_predicates < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
330
- -> ty:: GenericPredicates < ' tcx > { bug ! ( "item_predicates" ) }
331
- fn item_super_predicates < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
332
- -> ty:: GenericPredicates < ' tcx > { bug ! ( "item_super_predicates" ) }
333
- fn item_generics ( & self , def : DefId ) -> ty:: Generics { bug ! ( "item_generics" ) }
310
+ fn item_generics_cloned ( & self , def : DefId ) -> ty:: Generics
311
+ { bug ! ( "item_generics_cloned" ) }
334
312
fn item_attrs ( & self , def_id : DefId ) -> Vec < ast:: Attribute > { bug ! ( "item_attrs" ) }
335
- fn trait_def < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId ) -> ty:: TraitDef
336
- { bug ! ( "trait_def" ) }
337
- fn adt_def < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId ) -> & ' tcx ty:: AdtDef
338
- { bug ! ( "adt_def" ) }
339
313
fn fn_arg_names ( & self , did : DefId ) -> Vec < ast:: Name > { bug ! ( "fn_arg_names" ) }
340
314
fn inherent_implementations_for_type ( & self , def_id : DefId ) -> Vec < DefId > { vec ! [ ] }
341
315
342
316
// trait info
343
317
fn implementations_of_trait ( & self , filter : Option < DefId > ) -> Vec < DefId > { vec ! [ ] }
344
318
345
319
// impl info
346
- fn associated_item_def_ids ( & self , def_id : DefId ) -> Vec < DefId >
347
- { bug ! ( "associated_items" ) }
348
- fn impl_trait_ref < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
349
- -> Option < ty:: TraitRef < ' tcx > > { bug ! ( "impl_trait_ref" ) }
350
320
fn impl_polarity ( & self , def : DefId ) -> hir:: ImplPolarity { bug ! ( "impl_polarity" ) }
351
- fn custom_coerce_unsized_kind ( & self , def : DefId )
352
- -> Option < ty:: adjustment:: CustomCoerceUnsized >
353
- { bug ! ( "custom_coerce_unsized_kind" ) }
354
321
fn impl_parent ( & self , def : DefId ) -> Option < DefId > { bug ! ( "impl_parent" ) }
355
322
356
323
// trait/impl-item info
357
324
fn trait_of_item ( & self , def_id : DefId ) -> Option < DefId > { bug ! ( "trait_of_item" ) }
358
- fn associated_item ( & self , def : DefId ) -> Option < ty:: AssociatedItem > { bug ! ( "associated_item" ) }
325
+ fn associated_item_cloned ( & self , def : DefId ) -> ty:: AssociatedItem
326
+ { bug ! ( "associated_item_cloned" ) }
359
327
360
328
// flags
361
329
fn is_const_fn ( & self , did : DefId ) -> bool { bug ! ( "is_const_fn" ) }
@@ -418,8 +386,8 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
418
386
fn load_macro ( & self , did : DefId , sess : & Session ) -> LoadedMacro { bug ! ( "load_macro" ) }
419
387
420
388
// misc. metadata
421
- fn maybe_get_item_body < ' a > ( & ' tcx self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
422
- -> Option < & ' tcx hir:: Body > {
389
+ fn maybe_get_item_body < ' a , ' tcx > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
390
+ -> Option < & ' tcx hir:: Body > {
423
391
bug ! ( "maybe_get_item_body" )
424
392
}
425
393
fn item_body_nested_bodies ( & self , def : DefId ) -> BTreeMap < hir:: BodyId , hir:: Body > {
@@ -429,8 +397,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
429
397
bug ! ( "const_is_rvalue_promotable_to_static" )
430
398
}
431
399
432
- fn get_item_mir < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > , def : DefId )
433
- -> Mir < ' tcx > { bug ! ( "get_item_mir" ) }
434
400
fn is_item_mir_available ( & self , def : DefId ) -> bool {
435
401
bug ! ( "is_item_mir_available" )
436
402
}
@@ -448,7 +414,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
448
414
{ vec ! [ ] }
449
415
fn used_crate_source ( & self , cnum : CrateNum ) -> CrateSource { bug ! ( "used_crate_source" ) }
450
416
fn extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > { None }
451
- fn encode_metadata < ' a > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
417
+ fn encode_metadata < ' a , ' tcx > ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
452
418
reexports : & def:: ExportMap ,
453
419
link_meta : & LinkMeta ,
454
420
reachable : & NodeSet ) -> Vec < u8 > { vec ! [ ] }
0 commit comments