@@ -155,6 +155,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
155
155
}
156
156
157
157
/// Intern a type
158
+ #[ inline( never) ]
158
159
fn intern_ty (
159
160
local : & CtxtInterners < ' tcx > ,
160
161
global : & CtxtInterners < ' gcx > ,
@@ -216,6 +217,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
216
217
}
217
218
218
219
pub struct CommonTypes < ' tcx > {
220
+ pub unit : Ty < ' tcx > ,
219
221
pub bool : Ty < ' tcx > ,
220
222
pub char : Ty < ' tcx > ,
221
223
pub isize : Ty < ' tcx > ,
@@ -832,7 +834,9 @@ impl<'tcx> CommonTypes<'tcx> {
832
834
interners. region . borrow_mut ( ) . insert ( Interned ( r) ) ;
833
835
& * r
834
836
} ;
837
+
835
838
CommonTypes {
839
+ unit : mk ( Tuple ( List :: empty ( ) ) ) ,
836
840
bool : mk ( Bool ) ,
837
841
char : mk ( Char ) ,
838
842
never : mk ( Never ) ,
@@ -885,6 +889,7 @@ pub struct TyCtxt<'a, 'gcx: 'tcx, 'tcx: 'a> {
885
889
886
890
impl < ' a , ' gcx , ' tcx > Deref for TyCtxt < ' a , ' gcx , ' tcx > {
887
891
type Target = & ' a GlobalCtxt < ' gcx > ;
892
+ #[ inline( always) ]
888
893
fn deref ( & self ) -> & Self :: Target {
889
894
& self . gcx
890
895
}
@@ -2515,6 +2520,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2515
2520
self . mk_fn_ptr ( converted_sig)
2516
2521
}
2517
2522
2523
+ #[ inline]
2518
2524
pub fn mk_ty ( & self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
2519
2525
CtxtInterners :: intern_ty ( & self . interners , & self . global_interners , st)
2520
2526
}
@@ -2548,19 +2554,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2548
2554
}
2549
2555
}
2550
2556
2557
+ #[ inline]
2551
2558
pub fn mk_str ( self ) -> Ty < ' tcx > {
2552
2559
self . mk_ty ( Str )
2553
2560
}
2554
2561
2562
+ #[ inline]
2555
2563
pub fn mk_static_str ( self ) -> Ty < ' tcx > {
2556
2564
self . mk_imm_ref ( self . types . re_static , self . mk_str ( ) )
2557
2565
}
2558
2566
2567
+ #[ inline]
2559
2568
pub fn mk_adt ( self , def : & ' tcx AdtDef , substs : & ' tcx Substs < ' tcx > ) -> Ty < ' tcx > {
2560
2569
// take a copy of substs so that we own the vectors inside
2561
2570
self . mk_ty ( Adt ( def, substs) )
2562
2571
}
2563
2572
2573
+ #[ inline]
2564
2574
pub fn mk_foreign ( self , def_id : DefId ) -> Ty < ' tcx > {
2565
2575
self . mk_ty ( Foreign ( def_id) )
2566
2576
}
@@ -2584,42 +2594,52 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2584
2594
self . mk_ty ( Adt ( adt_def, substs) )
2585
2595
}
2586
2596
2597
+ #[ inline]
2587
2598
pub fn mk_ptr ( self , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
2588
2599
self . mk_ty ( RawPtr ( tm) )
2589
2600
}
2590
2601
2602
+ #[ inline]
2591
2603
pub fn mk_ref ( self , r : Region < ' tcx > , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
2592
2604
self . mk_ty ( Ref ( r, tm. ty , tm. mutbl ) )
2593
2605
}
2594
2606
2607
+ #[ inline]
2595
2608
pub fn mk_mut_ref ( self , r : Region < ' tcx > , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
2596
2609
self . mk_ref ( r, TypeAndMut { ty : ty, mutbl : hir:: MutMutable } )
2597
2610
}
2598
2611
2612
+ #[ inline]
2599
2613
pub fn mk_imm_ref ( self , r : Region < ' tcx > , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
2600
2614
self . mk_ref ( r, TypeAndMut { ty : ty, mutbl : hir:: MutImmutable } )
2601
2615
}
2602
2616
2617
+ #[ inline]
2603
2618
pub fn mk_mut_ptr ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
2604
2619
self . mk_ptr ( TypeAndMut { ty : ty, mutbl : hir:: MutMutable } )
2605
2620
}
2606
2621
2622
+ #[ inline]
2607
2623
pub fn mk_imm_ptr ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
2608
2624
self . mk_ptr ( TypeAndMut { ty : ty, mutbl : hir:: MutImmutable } )
2609
2625
}
2610
2626
2627
+ #[ inline]
2611
2628
pub fn mk_nil_ptr ( self ) -> Ty < ' tcx > {
2612
2629
self . mk_imm_ptr ( self . mk_unit ( ) )
2613
2630
}
2614
2631
2632
+ #[ inline]
2615
2633
pub fn mk_array ( self , ty : Ty < ' tcx > , n : u64 ) -> Ty < ' tcx > {
2616
2634
self . mk_ty ( Array ( ty, ty:: Const :: from_usize ( self , n) ) )
2617
2635
}
2618
2636
2637
+ #[ inline]
2619
2638
pub fn mk_slice ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
2620
2639
self . mk_ty ( Slice ( ty) )
2621
2640
}
2622
2641
2642
+ #[ inline]
2623
2643
pub fn intern_tup ( self , ts : & [ Ty < ' tcx > ] ) -> Ty < ' tcx > {
2624
2644
self . mk_ty ( Tuple ( self . intern_type_list ( ts) ) )
2625
2645
}
@@ -2628,10 +2648,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2628
2648
iter. intern_with ( |ts| self . mk_ty ( Tuple ( self . intern_type_list ( ts) ) ) )
2629
2649
}
2630
2650
2651
+ #[ inline]
2631
2652
pub fn mk_unit ( self ) -> Ty < ' tcx > {
2632
- self . intern_tup ( & [ ] )
2653
+ self . types . unit
2633
2654
}
2634
2655
2656
+ #[ inline]
2635
2657
pub fn mk_diverging_default ( self ) -> Ty < ' tcx > {
2636
2658
if self . features ( ) . never_type {
2637
2659
self . types . never
@@ -2640,19 +2662,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2640
2662
}
2641
2663
}
2642
2664
2665
+ #[ inline]
2643
2666
pub fn mk_bool ( self ) -> Ty < ' tcx > {
2644
2667
self . mk_ty ( Bool )
2645
2668
}
2646
2669
2670
+ #[ inline]
2647
2671
pub fn mk_fn_def ( self , def_id : DefId ,
2648
2672
substs : & ' tcx Substs < ' tcx > ) -> Ty < ' tcx > {
2649
2673
self . mk_ty ( FnDef ( def_id, substs) )
2650
2674
}
2651
2675
2676
+ #[ inline]
2652
2677
pub fn mk_fn_ptr ( self , fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
2653
2678
self . mk_ty ( FnPtr ( fty) )
2654
2679
}
2655
2680
2681
+ #[ inline]
2656
2682
pub fn mk_dynamic (
2657
2683
self ,
2658
2684
obj : ty:: Binder < & ' tcx List < ExistentialPredicate < ' tcx > > > ,
@@ -2661,6 +2687,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2661
2687
self . mk_ty ( Dynamic ( obj, reg) )
2662
2688
}
2663
2689
2690
+ #[ inline]
2664
2691
pub fn mk_projection ( self ,
2665
2692
item_def_id : DefId ,
2666
2693
substs : & ' tcx Substs < ' tcx > )
@@ -2671,11 +2698,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2671
2698
} ) )
2672
2699
}
2673
2700
2701
+ #[ inline]
2674
2702
pub fn mk_closure ( self , closure_id : DefId , closure_substs : ClosureSubsts < ' tcx > )
2675
2703
-> Ty < ' tcx > {
2676
2704
self . mk_ty ( Closure ( closure_id, closure_substs) )
2677
2705
}
2678
2706
2707
+ #[ inline]
2679
2708
pub fn mk_generator ( self ,
2680
2709
id : DefId ,
2681
2710
generator_substs : GeneratorSubsts < ' tcx > ,
@@ -2684,32 +2713,39 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2684
2713
self . mk_ty ( Generator ( id, generator_substs, movability) )
2685
2714
}
2686
2715
2716
+ #[ inline]
2687
2717
pub fn mk_generator_witness ( self , types : ty:: Binder < & ' tcx List < Ty < ' tcx > > > ) -> Ty < ' tcx > {
2688
2718
self . mk_ty ( GeneratorWitness ( types) )
2689
2719
}
2690
2720
2721
+ #[ inline]
2691
2722
pub fn mk_var ( self , v : TyVid ) -> Ty < ' tcx > {
2692
2723
self . mk_infer ( TyVar ( v) )
2693
2724
}
2694
2725
2726
+ #[ inline]
2695
2727
pub fn mk_int_var ( self , v : IntVid ) -> Ty < ' tcx > {
2696
2728
self . mk_infer ( IntVar ( v) )
2697
2729
}
2698
2730
2731
+ #[ inline]
2699
2732
pub fn mk_float_var ( self , v : FloatVid ) -> Ty < ' tcx > {
2700
2733
self . mk_infer ( FloatVar ( v) )
2701
2734
}
2702
2735
2736
+ #[ inline]
2703
2737
pub fn mk_infer ( self , it : InferTy ) -> Ty < ' tcx > {
2704
2738
self . mk_ty ( Infer ( it) )
2705
2739
}
2706
2740
2741
+ #[ inline]
2707
2742
pub fn mk_ty_param ( self ,
2708
2743
index : u32 ,
2709
2744
name : InternedString ) -> Ty < ' tcx > {
2710
2745
self . mk_ty ( Param ( ParamTy { idx : index, name : name } ) )
2711
2746
}
2712
2747
2748
+ #[ inline]
2713
2749
pub fn mk_self_type ( self ) -> Ty < ' tcx > {
2714
2750
self . mk_ty_param ( 0 , keywords:: SelfType . name ( ) . as_interned_str ( ) )
2715
2751
}
@@ -2723,6 +2759,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2723
2759
}
2724
2760
}
2725
2761
2762
+ #[ inline]
2726
2763
pub fn mk_opaque ( self , def_id : DefId , substs : & ' tcx Substs < ' tcx > ) -> Ty < ' tcx > {
2727
2764
self . mk_ty ( Opaque ( def_id, substs) )
2728
2765
}
0 commit comments