@@ -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 > ,
@@ -470,7 +470,7 @@ fn check_recursion_limit<'tcx>(tcx: &TyCtxt<'tcx>,
470
470
}
471
471
472
472
struct MirNeighborCollector < ' a , ' tcx : ' a > {
473
- ccx : & ' a CrateContext < ' a , ' tcx > ,
473
+ ccx : & ' a SharedCrateContext < ' a , ' tcx > ,
474
474
mir : & ' a mir:: Mir < ' tcx > ,
475
475
output : & ' a mut Vec < TransItem < ' tcx > > ,
476
476
param_substs : & ' tcx Substs < ' tcx >
@@ -590,7 +590,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
590
590
// object shim or a closure that is handled differently),
591
591
// we check if the callee is something that will actually
592
592
// result in a translation item ...
593
- if can_result_in_trans_item ( self . ccx , callee_def_id) {
593
+ if can_result_in_trans_item ( self . ccx . tcx ( ) , callee_def_id) {
594
594
// ... and create one if it does.
595
595
let trans_item = create_fn_trans_item ( self . ccx . tcx ( ) ,
596
596
callee_def_id,
@@ -603,21 +603,21 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
603
603
604
604
self . super_operand ( operand) ;
605
605
606
- fn can_result_in_trans_item < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
607
- def_id : DefId )
608
- -> bool {
609
- if !match ccx . tcx ( ) . lookup_item_type ( def_id) . ty . sty {
606
+ fn can_result_in_trans_item < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
607
+ def_id : DefId )
608
+ -> bool {
609
+ if !match tcx. lookup_item_type ( def_id) . ty . sty {
610
610
ty:: TyFnDef ( def_id, _, _) => {
611
611
// Some constructors also have type TyFnDef but they are
612
612
// always instantiated inline and don't result in
613
613
// translation item. Same for FFI functions.
614
- match ccx . tcx ( ) . map . get_if_local ( def_id) {
614
+ match tcx. map . get_if_local ( def_id) {
615
615
Some ( hir_map:: NodeVariant ( _) ) |
616
616
Some ( hir_map:: NodeStructCtor ( _) ) |
617
617
Some ( hir_map:: NodeForeignItem ( _) ) => false ,
618
618
Some ( _) => true ,
619
619
None => {
620
- ccx . sess ( ) . cstore . variant_kind ( def_id) . is_none ( )
620
+ tcx . sess . cstore . variant_kind ( def_id) . is_none ( )
621
621
}
622
622
}
623
623
}
@@ -627,7 +627,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
627
627
return false ;
628
628
}
629
629
630
- can_have_local_instance ( ccx . tcx ( ) , def_id)
630
+ can_have_local_instance ( tcx, def_id)
631
631
}
632
632
}
633
633
}
@@ -641,7 +641,7 @@ fn can_have_local_instance<'tcx>(tcx: &TyCtxt<'tcx>,
641
641
def_id. is_local ( ) || tcx. sess . cstore . is_item_mir_available ( def_id)
642
642
}
643
643
644
- fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
644
+ fn find_drop_glue_neighbors < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
645
645
dg : DropGlueKind < ' tcx > ,
646
646
output : & mut Vec < TransItem < ' tcx > > ) {
647
647
let ty = match dg {
@@ -697,7 +697,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
697
697
substs : self_type_substs,
698
698
} . to_poly_trait_ref ( ) ;
699
699
700
- let substs = match fulfill_obligation ( ccx. shared ( ) , DUMMY_SP , trait_ref) {
700
+ let substs = match fulfill_obligation ( ccx, DUMMY_SP , trait_ref) {
701
701
traits:: VtableImpl ( data) => data. substs ,
702
702
_ => bug ! ( )
703
703
} ;
@@ -776,7 +776,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
776
776
}
777
777
}
778
778
779
- fn do_static_dispatch < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
779
+ fn do_static_dispatch < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
780
780
fn_def_id : DefId ,
781
781
fn_substs : & ' tcx Substs < ' tcx > ,
782
782
param_substs : & ' tcx Substs < ' tcx > )
@@ -819,7 +819,7 @@ fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
819
819
820
820
// Given a trait-method and substitution information, find out the actual
821
821
// implementation of the trait method.
822
- fn do_static_trait_method_dispatch < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
822
+ fn do_static_trait_method_dispatch < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
823
823
trait_method : & ty:: Method ,
824
824
trait_id : DefId ,
825
825
callee_substs : & ' tcx Substs < ' tcx > ,
@@ -840,7 +840,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
840
840
callee_substs) ;
841
841
842
842
let trait_ref = ty:: Binder ( rcvr_substs. to_trait_ref ( tcx, trait_id) ) ;
843
- let vtbl = fulfill_obligation ( ccx. shared ( ) , DUMMY_SP , trait_ref) ;
843
+ let vtbl = fulfill_obligation ( ccx, DUMMY_SP , trait_ref) ;
844
844
845
845
// Now that we know which impl is being used, we can dispatch to
846
846
// the actual function:
@@ -908,7 +908,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
908
908
///
909
909
/// Finally, there is also the case of custom unsizing coercions, e.g. for
910
910
/// smart pointers such as `Rc` and `Arc`.
911
- fn find_vtable_types_for_unsizing < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
911
+ fn find_vtable_types_for_unsizing < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
912
912
source_ty : ty:: Ty < ' tcx > ,
913
913
target_ty : ty:: Ty < ' tcx > )
914
914
-> ( ty:: Ty < ' tcx > , ty:: Ty < ' tcx > ) {
@@ -933,7 +933,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
933
933
& ty:: TyStruct ( target_adt_def, target_substs) ) => {
934
934
assert_eq ! ( source_adt_def, target_adt_def) ;
935
935
936
- let kind = custom_coerce_unsize_info ( ccx. shared ( ) , source_ty, target_ty) ;
936
+ let kind = custom_coerce_unsize_info ( ccx, source_ty, target_ty) ;
937
937
938
938
let coerce_index = match kind {
939
939
CustomCoerceUnsized :: Struct ( i) => i
@@ -983,7 +983,7 @@ fn create_fn_trans_item<'tcx>(tcx: &TyCtxt<'tcx>,
983
983
984
984
/// Creates a `TransItem` for each method that is referenced by the vtable for
985
985
/// the given trait/impl pair.
986
- fn create_trans_items_for_vtable_methods < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
986
+ fn create_trans_items_for_vtable_methods < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ,
987
987
trait_ty : ty:: Ty < ' tcx > ,
988
988
impl_ty : ty:: Ty < ' tcx > ,
989
989
output : & mut Vec < TransItem < ' tcx > > ) {
@@ -995,7 +995,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
995
995
996
996
// Walk all methods of the trait, including those of its supertraits
997
997
for trait_ref in traits:: supertraits ( ccx. tcx ( ) , poly_trait_ref) {
998
- let vtable = fulfill_obligation ( ccx. shared ( ) , DUMMY_SP , trait_ref) ;
998
+ let vtable = fulfill_obligation ( ccx, DUMMY_SP , trait_ref) ;
999
999
match vtable {
1000
1000
traits:: VtableImpl (
1001
1001
traits:: VtableImplData {
@@ -1032,7 +1032,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1032
1032
//=-----------------------------------------------------------------------------
1033
1033
1034
1034
struct RootCollector < ' b , ' a : ' b , ' tcx : ' a + ' b > {
1035
- ccx : & ' b CrateContext < ' a , ' tcx > ,
1035
+ ccx : & ' b SharedCrateContext < ' a , ' tcx > ,
1036
1036
mode : TransItemCollectionMode ,
1037
1037
output : & ' b mut Vec < TransItem < ' tcx > > ,
1038
1038
enclosing_item : Option < & ' tcx hir:: Item > ,
@@ -1543,12 +1543,12 @@ pub enum TransItemState {
1543
1543
NotPredictedButGenerated ,
1544
1544
}
1545
1545
1546
- pub fn collecting_debug_information ( ccx : & CrateContext ) -> bool {
1546
+ pub fn collecting_debug_information ( ccx : & SharedCrateContext ) -> bool {
1547
1547
return cfg ! ( debug_assertions) &&
1548
1548
ccx. sess ( ) . opts . debugging_opts . print_trans_items . is_some ( ) ;
1549
1549
}
1550
1550
1551
- pub fn print_collection_results < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ) {
1551
+ pub fn print_collection_results < ' a , ' tcx > ( ccx : & SharedCrateContext < ' a , ' tcx > ) {
1552
1552
use std:: hash:: { Hash , SipHasher , Hasher } ;
1553
1553
1554
1554
if !collecting_debug_information ( ccx) {
0 commit comments