@@ -210,7 +210,7 @@ use syntax::{attr, errors};
210
210
use syntax:: parse:: token;
211
211
212
212
use base:: { custom_coerce_unsize_info, llvm_linkage_by_name} ;
213
- use context:: CrateContext ;
213
+ use context:: SharedCrateContext ;
214
214
use common:: { fulfill_obligation, normalize_and_test_predicates, type_is_sized} ;
215
215
use glue:: { self , DropGlueKind } ;
216
216
use llvm;
@@ -319,7 +319,7 @@ impl<'tcx> ReferenceMap<'tcx> {
319
319
}
320
320
}
321
321
322
- pub fn collect_crate_translation_items < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
322
+ pub fn collect_crate_translation_items < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
323
323
mode : TransItemCollectionMode )
324
324
-> ( FnvHashSet < TransItem < ' tcx > > ,
325
325
ReferenceMap < ' tcx > ) {
@@ -347,7 +347,7 @@ pub fn collect_crate_translation_items<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
347
347
348
348
// Find all non-generic items by walking the HIR. These items serve as roots to
349
349
// start monomorphizing from.
350
- fn collect_roots < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
350
+ fn collect_roots < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
351
351
mode : TransItemCollectionMode )
352
352
-> Vec < TransItem < ' tcx > > {
353
353
debug ! ( "Collecting roots" ) ;
@@ -368,7 +368,7 @@ fn collect_roots<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
368
368
}
369
369
370
370
// Collect all monomorphized translation items reachable from `starting_point`
371
- fn collect_items_rec < ' a , ' tcx : ' a > ( ccx : & CrateContext < ' a , ' tcx > ,
371
+ fn collect_items_rec < ' a , ' tcx : ' a > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
372
372
starting_point : TransItem < ' tcx > ,
373
373
visited : & mut FnvHashSet < TransItem < ' tcx > > ,
374
374
recursion_depths : & mut DefIdMap < usize > ,
@@ -473,7 +473,7 @@ fn check_recursion_limit<'tcx>(tcx: &TyCtxt<'tcx>,
473
473
}
474
474
475
475
struct MirNeighborCollector < ' a , ' tcx : ' a > {
476
- ccx : & ' a CrateContext < ' a , ' tcx > ,
476
+ ccx : & ' a SharedCrateContext < ' a , ' tcx > ,
477
477
mir : & ' a mir:: Mir < ' tcx > ,
478
478
output : & ' a mut Vec < TransItem < ' tcx > > ,
479
479
param_substs : & ' tcx Substs < ' tcx >
@@ -593,7 +593,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
593
593
// object shim or a closure that is handled differently),
594
594
// we check if the callee is something that will actually
595
595
// result in a translation item ...
596
- if can_result_in_trans_item ( self . ccx , callee_def_id) {
596
+ if can_result_in_trans_item ( self . ccx . tcx ( ) , callee_def_id) {
597
597
// ... and create one if it does.
598
598
let trans_item = create_fn_trans_item ( self . ccx . tcx ( ) ,
599
599
callee_def_id,
@@ -606,21 +606,21 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
606
606
607
607
self . super_operand ( operand) ;
608
608
609
- fn can_result_in_trans_item < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
610
- def_id : DefId )
611
- -> bool {
612
- if !match ccx . tcx ( ) . lookup_item_type ( def_id) . ty . sty {
609
+ fn can_result_in_trans_item < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
610
+ def_id : DefId )
611
+ -> bool {
612
+ if !match tcx. lookup_item_type ( def_id) . ty . sty {
613
613
ty:: TyFnDef ( def_id, _, _) => {
614
614
// Some constructors also have type TyFnDef but they are
615
615
// always instantiated inline and don't result in
616
616
// translation item. Same for FFI functions.
617
- match ccx . tcx ( ) . map . get_if_local ( def_id) {
617
+ match tcx. map . get_if_local ( def_id) {
618
618
Some ( hir_map:: NodeVariant ( _) ) |
619
619
Some ( hir_map:: NodeStructCtor ( _) ) |
620
620
Some ( hir_map:: NodeForeignItem ( _) ) => false ,
621
621
Some ( _) => true ,
622
622
None => {
623
- ccx . sess ( ) . cstore . variant_kind ( def_id) . is_none ( )
623
+ tcx . sess . cstore . variant_kind ( def_id) . is_none ( )
624
624
}
625
625
}
626
626
}
@@ -630,7 +630,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
630
630
return false ;
631
631
}
632
632
633
- can_have_local_instance ( ccx . tcx ( ) , def_id)
633
+ can_have_local_instance ( tcx, def_id)
634
634
}
635
635
}
636
636
}
@@ -644,7 +644,7 @@ fn can_have_local_instance<'tcx>(tcx: &TyCtxt<'tcx>,
644
644
def_id. is_local ( ) || tcx. sess . cstore . is_item_mir_available ( def_id)
645
645
}
646
646
647
- fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
647
+ fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
648
648
dg : DropGlueKind < ' tcx > ,
649
649
output : & mut Vec < TransItem < ' tcx > > ) {
650
650
let ty = match dg {
@@ -700,7 +700,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
700
700
substs : self_type_substs,
701
701
} . to_poly_trait_ref ( ) ;
702
702
703
- let substs = match fulfill_obligation ( ccx. shared ( ) , DUMMY_SP , trait_ref) {
703
+ let substs = match fulfill_obligation ( ccx, DUMMY_SP , trait_ref) {
704
704
traits:: VtableImpl ( data) => data. substs ,
705
705
_ => bug ! ( )
706
706
} ;
@@ -779,7 +779,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
779
779
}
780
780
}
781
781
782
- fn do_static_dispatch < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
782
+ fn do_static_dispatch < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
783
783
fn_def_id : DefId ,
784
784
fn_substs : & ' tcx Substs < ' tcx > ,
785
785
param_substs : & ' tcx Substs < ' tcx > )
@@ -822,7 +822,7 @@ fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
822
822
823
823
// Given a trait-method and substitution information, find out the actual
824
824
// implementation of the trait method.
825
- fn do_static_trait_method_dispatch < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
825
+ fn do_static_trait_method_dispatch < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
826
826
trait_method : & ty:: Method ,
827
827
trait_id : DefId ,
828
828
callee_substs : & ' tcx Substs < ' tcx > ,
@@ -843,7 +843,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
843
843
callee_substs) ;
844
844
845
845
let trait_ref = ty:: Binder ( rcvr_substs. to_trait_ref ( tcx, trait_id) ) ;
846
- let vtbl = fulfill_obligation ( ccx. shared ( ) , DUMMY_SP , trait_ref) ;
846
+ let vtbl = fulfill_obligation ( ccx, DUMMY_SP , trait_ref) ;
847
847
848
848
// Now that we know which impl is being used, we can dispatch to
849
849
// the actual function:
@@ -911,7 +911,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
911
911
///
912
912
/// Finally, there is also the case of custom unsizing coercions, e.g. for
913
913
/// smart pointers such as `Rc` and `Arc`.
914
- fn find_vtable_types_for_unsizing < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
914
+ fn find_vtable_types_for_unsizing < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
915
915
source_ty : ty:: Ty < ' tcx > ,
916
916
target_ty : ty:: Ty < ' tcx > )
917
917
-> ( ty:: Ty < ' tcx > , ty:: Ty < ' tcx > ) {
@@ -936,7 +936,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
936
936
& ty:: TyStruct ( target_adt_def, target_substs) ) => {
937
937
assert_eq ! ( source_adt_def, target_adt_def) ;
938
938
939
- let kind = custom_coerce_unsize_info ( ccx. shared ( ) , source_ty, target_ty) ;
939
+ let kind = custom_coerce_unsize_info ( ccx, source_ty, target_ty) ;
940
940
941
941
let coerce_index = match kind {
942
942
CustomCoerceUnsized :: Struct ( i) => i
@@ -986,7 +986,7 @@ fn create_fn_trans_item<'tcx>(tcx: &TyCtxt<'tcx>,
986
986
987
987
/// Creates a `TransItem` for each method that is referenced by the vtable for
988
988
/// the given trait/impl pair.
989
- fn create_trans_items_for_vtable_methods < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
989
+ fn create_trans_items_for_vtable_methods < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
990
990
trait_ty : ty:: Ty < ' tcx > ,
991
991
impl_ty : ty:: Ty < ' tcx > ,
992
992
output : & mut Vec < TransItem < ' tcx > > ) {
@@ -998,7 +998,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
998
998
999
999
// Walk all methods of the trait, including those of its supertraits
1000
1000
for trait_ref in traits:: supertraits ( ccx. tcx ( ) , poly_trait_ref) {
1001
- let vtable = fulfill_obligation ( ccx. shared ( ) , DUMMY_SP , trait_ref) ;
1001
+ let vtable = fulfill_obligation ( ccx, DUMMY_SP , trait_ref) ;
1002
1002
match vtable {
1003
1003
traits:: VtableImpl (
1004
1004
traits:: VtableImplData {
@@ -1035,7 +1035,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1035
1035
//=-----------------------------------------------------------------------------
1036
1036
1037
1037
struct RootCollector < ' b , ' a : ' b , ' tcx : ' a + ' b > {
1038
- ccx : & ' b CrateContext < ' a , ' tcx > ,
1038
+ ccx : & ' b SharedCrateContext < ' a , ' tcx > ,
1039
1039
mode : TransItemCollectionMode ,
1040
1040
output : & ' b mut Vec < TransItem < ' tcx > > ,
1041
1041
enclosing_item : Option < & ' tcx hir:: Item > ,
@@ -1546,12 +1546,12 @@ pub enum TransItemState {
1546
1546
NotPredictedButGenerated ,
1547
1547
}
1548
1548
1549
- pub fn collecting_debug_information ( ccx : & CrateContext ) -> bool {
1549
+ pub fn collecting_debug_information ( ccx : & SharedCrateContext ) -> bool {
1550
1550
return cfg ! ( debug_assertions) &&
1551
1551
ccx. sess ( ) . opts . debugging_opts . print_trans_items . is_some ( ) ;
1552
1552
}
1553
1553
1554
- pub fn print_collection_results < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ) {
1554
+ pub fn print_collection_results < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ) {
1555
1555
use std:: hash:: { Hash , SipHasher , Hasher } ;
1556
1556
1557
1557
if !collecting_debug_information ( ccx) {
0 commit comments